author | alfadur <mail@none> |
Tue, 05 Feb 2019 01:40:16 +0300 | |
changeset 14697 | 9377ee00f1f1 |
parent 14252 | 74bf2d906097 |
permissions | -rw-r--r-- |
13824 | 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 |
14252
74bf2d906097
Turn accidental globals to locals in Lua libraries
Wuzzy <Wuzzy2@mail.ru>
parents:
14091
diff
changeset
|
24 |
local mapString = hashDigest() .. "," .. LandDigest |
11545
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 |
|
14091
a5be3ef4bbbe
Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents:
13828
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:
13828
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:
13828
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:
13828
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:
13828
diff
changeset
|
34 |
end |
a5be3ef4bbbe
Update official challenge hashes, improve console logging (warning: racer #17 is missing!)
Wuzzy <Wuzzy2@mail.ru>
parents:
13828
diff
changeset
|
35 |
return map |
11545
86528b0cd491
detectMap() rewrite with more sane approach, also check waypoints placement to avoid cheating
unc0rr
parents:
11542
diff
changeset
|
36 |
end |
11542
64a5ab2c4f00
Attempt to implement hash for special points to detect tech racer maps
unC0Rr
parents:
11535
diff
changeset
|
37 |
end |