author | alfadur |
Mon, 15 Apr 2019 21:22:51 +0300 | |
changeset 14808 | 92225a708bda |
parent 14236 | 74bf2d906097 |
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 |
14236
74bf2d906097
Turn accidental globals to locals in Lua libraries
Wuzzy <Wuzzy2@mail.ru>
parents:
14075
diff
changeset
|
24 |
local mapString = hashDigest() .. "," .. LandDigest |
11550
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 |
|
14075
a5be3ef4bbbe
Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents:
13799
diff
changeset
|
30 |
WriteLnToConsole("OfficialChallenges: Hash: "..mapString) |
a5be3ef4bbbe
Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents:
13799
diff
changeset
|
31 |
local map = official_racer_maps[mapString] |
a5be3ef4bbbe
Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents:
13799
diff
changeset
|
32 |
if map ~= nil then |
a5be3ef4bbbe
Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents:
13799
diff
changeset
|
33 |
WriteLnToConsole("OfficialChallenges: Detected official challenge: "..map) |
a5be3ef4bbbe
Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents:
13799
diff
changeset
|
34 |
end |
a5be3ef4bbbe
Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents:
13799
diff
changeset
|
35 |
return map |
11550
86528b0cd491
detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents:
11547
diff
changeset
|
36 |
end |
11547
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11540
diff
changeset
|
37 |
end |