share/hedgewars/Data/Scripts/OfficialChallenges.lua
changeset 11542 64a5ab2c4f00
parent 11535 135094ab3146
child 11545 86528b0cd491
--- a/share/hedgewars/Data/Scripts/OfficialChallenges.lua	Tue Feb 09 15:27:55 2016 -0500
+++ b/share/hedgewars/Data/Scripts/OfficialChallenges.lua	Fri Feb 12 17:03:42 2016 +0300
@@ -45,3 +45,26 @@
         end
     end
 end
+
+-- modified Adler hash
+local hashA = 0
+local hashB = 0
+local hashModule = 299993
+
+function resetHash()
+    hashA = 0
+    hashB = 0
+end
+
+function addHashData(i)
+    hashA = (hashA + i + 65536) % hashModule
+    hashB = (hashB + hashA) % hashModule
+end
+
+function hashDigest()
+    return(hashB * hashModule + hashA)
+end
+
+function detectMapWithDigest()
+    return("map " .. hashDigest())
+end