share/hedgewars/Data/Scripts/OfficialChallenges.lua
author unC0Rr
Fri, 12 Feb 2016 17:03:42 +0300
changeset 11542 64a5ab2c4f00
parent 11535 135094ab3146
child 11545 86528b0cd491
permissions -rw-r--r--
Attempt to implement hash for special points to detect tech racer maps

function detectMap()
    if RopePercent == 100 and MinesNum == 0 then
-- challenges with border
        if band(GameFlags, gfBorder) ~= 0 then
            if LandDigest == "M838018718Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #1")
            elseif LandDigest == "M-490229244Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #2")
            elseif LandDigest == "M806689586Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #3")
            elseif LandDigest == "M1770509913Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #7")
            elseif LandDigest == "M1902370941Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #8")
            elseif LandDigest == "M185940363Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #9")
            elseif LandDigest == "M751885839Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #10")
            elseif LandDigest == "M178845011Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #11")
            elseif LandDigest == "M706743197Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #12")
            elseif LandDigest == "M157242054Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #13")
            elseif LandDigest == "M-1585582638Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #14")
            elseif LandDigest == "M-528106034Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #16")
            elseif LandDigest == "M-534640804Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #18")
            elseif LandDigest == "M-1839546856Scripts/Multiplayer/Racer.lua" then
                return("Racer Challenge #19")
            end
-- challenges without border
        elseif LandDigest == "M-134869715Scripts/Multiplayer/Racer.lua" then
            return("Racer Challenge #4")
        elseif LandDigest == "M-661895109Scripts/Multiplayer/Racer.lua" then
            return("Racer Challenge #5")
        elseif LandDigest == "M479034891Scripts/Multiplayer/Racer.lua" then
            return("Racer Challenge #6")
        elseif LandDigest == "M256715557Scripts/Multiplayer/Racer.lua" then
            return("Racer Challenge #15")
        elseif LandDigest == "M-1389184823Scripts/Multiplayer/Racer.lua" then
            return("Racer Challenge #17")
        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