# HG changeset patch # User unC0Rr # Date 1455285822 -10800 # Node ID 64a5ab2c4f0088009e1e6a506743796c8b8602c4 # Parent 34a0181d5be5c3a609487910d57e8da36d6cbb97 Attempt to implement hash for special points to detect tech racer maps diff -r 34a0181d5be5 -r 64a5ab2c4f00 share/hedgewars/Data/Scripts/Multiplayer/Racer.lua --- a/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua Tue Feb 09 15:27:55 2016 -0500 +++ b/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua Fri Feb 12 17:03:42 2016 +0300 @@ -551,6 +551,9 @@ end function onSpecialPoint(x,y,flag) + addHashData(x) + addHashData(y) + addHashData(flag) specialPointsX[specialPointsCount] = x specialPointsY[specialPointsCount] = y specialPointsCount = specialPointsCount + 1 diff -r 34a0181d5be5 -r 64a5ab2c4f00 share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua --- a/share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua Tue Feb 09 15:27:55 2016 -0500 +++ b/share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua Fri Feb 12 17:03:42 2016 +0300 @@ -724,6 +724,9 @@ end function onSpecialPoint(x,y,flag) + addHashData(x) + addHashData(y) + addHashData(flag) specialPointsX[specialPointsCount] = x specialPointsY[specialPointsCount] = y specialPointsFlag[specialPointsCount] = flag @@ -1270,7 +1273,7 @@ raceType = "mixed race" end - map = detectMap() + map = detectMapWithDigest() for i = 0, (numTeams-1) do if teamScore[i] < 100000 then diff -r 34a0181d5be5 -r 64a5ab2c4f00 share/hedgewars/Data/Scripts/OfficialChallenges.lua --- 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