1 import hashlib
, sys
, re
3 alphanum
= "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_".encode()
8 l
= re
.sub("#.*".encode(), "".encode(), l
)
9 l
= re
.sub("//.*".encode(), "".encode(), l
)
11 d
= re
.sub("\/\*.*?\*/".encode(), "".encode(), d
) # remove /* */ comments
12 d
= d
.replace("\t".encode(), " ".encode()) # tab to space
13 d
= re
.sub(" *".encode(), " ".encode(), d
) # remove double spaces
14 d
= re
.sub("".encode(), "".encode(), d
) # remove /* */ comments
18 # this eats up cases like 'n {'
21 if d
[i
:i
+ 1] == " ".encode():
22 if not (d
[i
- 1:i
] in alphanum
and d
[i
+1:i
+ 2] in alphanum
):
28 for filename
in sys
.argv
[1:]:
29 f
+= cstrip([l
.strip() for l
in open(filename
, "rb")])
31 hash = hashlib
.md5(f
).hexdigest().lower()[16:]
32 #TODO 0.7: improve nethash creation
33 if hash == "71de0f4d82688970":
34 hash = "626fce9a778df4d4"
35 print('#define GAME_NETVERSION_HASH "%s"' % hash)