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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10022
eb981a03de90 - Make Racer report achievements
unc0rr
parents:
diff changeset
     1
function detectMap()
10091
213c38232b3d Official racer challenge #2
unc0rr
parents: 10022
diff changeset
     2
    if RopePercent == 100 and MinesNum == 0 then
10211
f4c51ab8f46d Better detection
unc0rr
parents: 10180
diff changeset
     3
-- challenges with border
10214
426aafe1f3ed Fix script
unc0rr
parents: 10213
diff changeset
     4
        if band(GameFlags, gfBorder) ~= 0 then
10211
f4c51ab8f46d Better detection
unc0rr
parents: 10180
diff changeset
     5
            if LandDigest == "M838018718Scripts/Multiplayer/Racer.lua" then
f4c51ab8f46d Better detection
unc0rr
parents: 10180
diff changeset
     6
                return("Racer Challenge #1")
f4c51ab8f46d Better detection
unc0rr
parents: 10180
diff changeset
     7
            elseif LandDigest == "M-490229244Scripts/Multiplayer/Racer.lua" then
f4c51ab8f46d Better detection
unc0rr
parents: 10180
diff changeset
     8
                return("Racer Challenge #2")
f4c51ab8f46d Better detection
unc0rr
parents: 10180
diff changeset
     9
            elseif LandDigest == "M806689586Scripts/Multiplayer/Racer.lua" then
f4c51ab8f46d Better detection
unc0rr
parents: 10180
diff changeset
    10
                return("Racer Challenge #3")
10222
084a1a925da9 Racer challenge map #7
unc0rr
parents: 10221
diff changeset
    11
            elseif LandDigest == "M1770509913Scripts/Multiplayer/Racer.lua" then
084a1a925da9 Racer challenge map #7
unc0rr
parents: 10221
diff changeset
    12
                return("Racer Challenge #7")
10247
7c6b265b89d1 Official racer challenge map #8
unc0rr
parents: 10222
diff changeset
    13
            elseif LandDigest == "M1902370941Scripts/Multiplayer/Racer.lua" then
7c6b265b89d1 Official racer challenge map #8
unc0rr
parents: 10222
diff changeset
    14
                return("Racer Challenge #8")
10335
d56b4c109abb Racer challenge map #9
unc0rr
parents: 10247
diff changeset
    15
            elseif LandDigest == "M185940363Scripts/Multiplayer/Racer.lua" then
d56b4c109abb Racer challenge map #9
unc0rr
parents: 10247
diff changeset
    16
                return("Racer Challenge #9")
10365
d5786d4230fd Racer challenge map #10
unc0rr
parents: 10335
diff changeset
    17
            elseif LandDigest == "M751885839Scripts/Multiplayer/Racer.lua" then
d5786d4230fd Racer challenge map #10
unc0rr
parents: 10335
diff changeset
    18
                return("Racer Challenge #10")
10366
b451b8f69f44 Official racer map #11
unc0rr
parents: 10365
diff changeset
    19
            elseif LandDigest == "M178845011Scripts/Multiplayer/Racer.lua" then
10367
unc0rr
parents: 10366
diff changeset
    20
                return("Racer Challenge #11")
10377
c6d8e7cd6e54 Challenge map #12
unc0rr
parents: 10367
diff changeset
    21
            elseif LandDigest == "M706743197Scripts/Multiplayer/Racer.lua" then
c6d8e7cd6e54 Challenge map #12
unc0rr
parents: 10367
diff changeset
    22
                return("Racer Challenge #12")
10832
ad257b8b2816 Racer challenge #13
unC0Rr
parents: 10377
diff changeset
    23
            elseif LandDigest == "M157242054Scripts/Multiplayer/Racer.lua" then
ad257b8b2816 Racer challenge #13
unC0Rr
parents: 10377
diff changeset
    24
                return("Racer Challenge #13")
10833
655bab155a58 Racer challenge map #14
unC0Rr
parents: 10832
diff changeset
    25
            elseif LandDigest == "M-1585582638Scripts/Multiplayer/Racer.lua" then
655bab155a58 Racer challenge map #14
unC0Rr
parents: 10832
diff changeset
    26
                return("Racer Challenge #14")
10885
3ea36d8d4636 racer challenge map #16
unc0rr
parents: 10854
diff changeset
    27
            elseif LandDigest == "M-528106034Scripts/Multiplayer/Racer.lua" then
3ea36d8d4636 racer challenge map #16
unc0rr
parents: 10854
diff changeset
    28
                return("Racer Challenge #16")
11535
135094ab3146 Racer maps #18 and #19
unC0Rr
parents: 11346
diff changeset
    29
            elseif LandDigest == "M-534640804Scripts/Multiplayer/Racer.lua" then
135094ab3146 Racer maps #18 and #19
unC0Rr
parents: 11346
diff changeset
    30
                return("Racer Challenge #18")
135094ab3146 Racer maps #18 and #19
unC0Rr
parents: 11346
diff changeset
    31
            elseif LandDigest == "M-1839546856Scripts/Multiplayer/Racer.lua" then
135094ab3146 Racer maps #18 and #19
unC0Rr
parents: 11346
diff changeset
    32
                return("Racer Challenge #19")
10214
426aafe1f3ed Fix script
unc0rr
parents: 10213
diff changeset
    33
            end
10211
f4c51ab8f46d Better detection
unc0rr
parents: 10180
diff changeset
    34
-- challenges without border
10214
426aafe1f3ed Fix script
unc0rr
parents: 10213
diff changeset
    35
        elseif LandDigest == "M-134869715Scripts/Multiplayer/Racer.lua" then
426aafe1f3ed Fix script
unc0rr
parents: 10213
diff changeset
    36
            return("Racer Challenge #4")
426aafe1f3ed Fix script
unc0rr
parents: 10213
diff changeset
    37
        elseif LandDigest == "M-661895109Scripts/Multiplayer/Racer.lua" then
426aafe1f3ed Fix script
unc0rr
parents: 10213
diff changeset
    38
            return("Racer Challenge #5")
10221
847a51bded01 Official racer challenge map #6
unc0rr
parents: 10214
diff changeset
    39
        elseif LandDigest == "M479034891Scripts/Multiplayer/Racer.lua" then
847a51bded01 Official racer challenge map #6
unc0rr
parents: 10214
diff changeset
    40
            return("Racer Challenge #6")
10854
4925438f5ab7 Racer challenge map #15
unC0Rr
parents: 10833
diff changeset
    41
        elseif LandDigest == "M256715557Scripts/Multiplayer/Racer.lua" then
4925438f5ab7 Racer challenge map #15
unC0Rr
parents: 10833
diff changeset
    42
            return("Racer Challenge #15")
11346
9fc4dc5f8446 map #17 digest
unC0Rr
parents: 10885
diff changeset
    43
        elseif LandDigest == "M-1389184823Scripts/Multiplayer/Racer.lua" then
9fc4dc5f8446 map #17 digest
unC0Rr
parents: 10885
diff changeset
    44
            return("Racer Challenge #17")
10091
213c38232b3d Official racer challenge #2
unc0rr
parents: 10022
diff changeset
    45
        end
10022
eb981a03de90 - Make Racer report achievements
unc0rr
parents:
diff changeset
    46
    end
eb981a03de90 - Make Racer report achievements
unc0rr
parents:
diff changeset
    47
end
11542
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    48
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    49
-- modified Adler hash
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    50
local hashA = 0
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    51
local hashB = 0
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    52
local hashModule = 299993
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    53
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    54
function resetHash()
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    55
    hashA = 0
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    56
    hashB = 0
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    57
end
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    58
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    59
function addHashData(i)
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    60
    hashA = (hashA + i + 65536) % hashModule
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    61
    hashB = (hashB + hashA) % hashModule
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    62
end
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    63
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    64
function hashDigest()
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    65
    return(hashB * hashModule + hashA)
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    66
end
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    67
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    68
function detectMapWithDigest()
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    69
    return("map " .. hashDigest())
64a5ab2c4f00 Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents: 11535
diff changeset
    70
end