share/hedgewars/Data/Scripts/OfficialChallenges.lua
author nemo
Tue, 18 Sep 2018 19:38:58 -0400
changeset 13824 552f0d5ab3e7
parent 13823 a623657da787
child 13828 ced1e6ecaaad
permissions -rw-r--r--
use locale rules for the challenge hashes

HedgewarsScriptLoad("/Scripts/OfficialChallengeHashes.lua")

-- 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()
    if RopePercent == 100 and MinesNum == 0 then
        mapString = hashDigest() .. "," .. LandDigest

        if band(GameFlags, gfBorder) ~= 0 then
            mapString = "Border," .. mapString
        end

        --WriteLnToConsole(mapString)
        return(maps[mapString])
    end
end