share/hedgewars/Data/Scripts/OfficialChallenges.lua
author nemo
Tue, 18 Sep 2018 19:38:58 -0400
changeset 13790 552f0d5ab3e7
parent 13789 a623657da787
child 13794 ced1e6ecaaad
permissions -rw-r--r--
use locale rules for the challenge hashes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13790
552f0d5ab3e7 use locale rules for the challenge hashes
nemo
parents: 13789
diff changeset
     1
HedgewarsScriptLoad("/Scripts/OfficialChallengeHashes.lua")
11542
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
     2
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
     3
-- modified Adler hash
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
     4
local hashA = 0
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
     5
local hashB = 0
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
     6
local hashModule = 299993
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
     7
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
     8
function resetHash()
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
     9
    hashA = 0
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    10
    hashB = 0
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    11
end
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    12
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    13
function addHashData(i)
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    14
    hashA = (hashA + i + 65536) % hashModule
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    15
    hashB = (hashB + hashA) % hashModule
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    16
end
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    17
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    18
function hashDigest()
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    19
    return(hashB * hashModule + hashA)
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    20
end
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    21
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    22
function detectMapWithDigest()
11545
86528b0cd491 detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents: 11542
diff changeset
    23
    if RopePercent == 100 and MinesNum == 0 then
86528b0cd491 detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents: 11542
diff changeset
    24
        mapString = hashDigest() .. "," .. LandDigest
86528b0cd491 detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents: 11542
diff changeset
    25
86528b0cd491 detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents: 11542
diff changeset
    26
        if band(GameFlags, gfBorder) ~= 0 then
86528b0cd491 detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents: 11542
diff changeset
    27
            mapString = "Border," .. mapString
86528b0cd491 detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents: 11542
diff changeset
    28
        end
86528b0cd491 detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents: 11542
diff changeset
    29
86528b0cd491 detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents: 11542
diff changeset
    30
        --WriteLnToConsole(mapString)
86528b0cd491 detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents: 11542
diff changeset
    31
        return(maps[mapString])
86528b0cd491 detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents: 11542
diff changeset
    32
    end
11542
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    33
end