author | alfadur |
Sun, 14 Oct 2018 21:25:59 +0300 | |
changeset 13914 | a44e4c057f57 |
parent 13799 | ced1e6ecaaad |
child 14075 | a5be3ef4bbbe |
permissions | -rw-r--r-- |
13795 | 1 |
HedgewarsScriptLoad("/Scripts/OfficialChallengeHashes.lua") |
11547
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
2 |
|
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
3 |
-- modified Adler hash |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
4 |
local hashA = 0 |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
5 |
local hashB = 0 |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
6 |
local hashModule = 299993 |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
7 |
|
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
8 |
function resetHash() |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
9 |
hashA = 0 |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
10 |
hashB = 0 |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
11 |
end |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
12 |
|
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
13 |
function addHashData(i) |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
14 |
hashA = (hashA + i + 65536) % hashModule |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
15 |
hashB = (hashB + hashA) % hashModule |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
16 |
end |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
17 |
|
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
18 |
function hashDigest() |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
19 |
return(hashB * hashModule + hashA) |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
20 |
end |
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
21 |
|
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
22 |
function detectMapWithDigest() |
11550
86528b0cd491
detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents:
11547
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:
11547
diff
changeset
|
24 |
mapString = hashDigest() .. "," .. LandDigest |
86528b0cd491
detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents:
11547
diff
changeset
|
25 |
|
86528b0cd491
detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents:
11547
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:
11547
diff
changeset
|
27 |
mapString = "Border," .. mapString |
86528b0cd491
detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents:
11547
diff
changeset
|
28 |
end |
86528b0cd491
detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents:
11547
diff
changeset
|
29 |
|
86528b0cd491
detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents:
11547
diff
changeset
|
30 |
--WriteLnToConsole(mapString) |
13799
ced1e6ecaaad
Fix maps variable in OfficialChallengeHashes not being global (caused error in normal Racer)
Wuzzy <Wuzzy2@mail.ru>
parents:
13795
diff
changeset
|
31 |
return(official_racer_maps[mapString]) |
11550
86528b0cd491
detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents:
11547
diff
changeset
|
32 |
end |
11547
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
33 |
end |