Skip to content

Commit

Permalink
give seed exact value
Browse files Browse the repository at this point in the history
  • Loading branch information
dtlnor committed Sep 20, 2024
1 parent 630ba1b commit 9b45a46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/REMSG.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def readMSG(self, filestream: io.BufferedReader):
# set entry name
entry.setName(helper.seekString((entry.entryNameOffset - dataOffset), stringDict))
if isVersionEntryByHash(version):
nameHash = mmh3.hash(key=entry.name.encode("utf-16-le"), seed=-1, signed=False)
nameHash = mmh3.hash(key=entry.name.encode("utf-16-le"), seed=0xFFFFFFFF, signed=False)
assert nameHash == entry.hash, f"expected {entry.hash} for {entry.name} but get {nameHash}"
else:
assert entryIndex == entry.index, f"expected {entryIndex} for {entry.name} but get {entry.index}"
Expand Down
8 changes: 4 additions & 4 deletions src/REMSGUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def importCSV(msgObj: REMSG.MSG, filename: str, version: int = None, langCount:
name=fEntry[nameidx],
attributeValues=attributes,
langs=[helper.forceWindowsLineBreak(content) for content in contents],
hash=mmh3.hash(key=fEntry[nameidx].encode("utf-16-le"), seed=-1, signed=False) if REMSG.isVersionEntryByHash(version) else None,
hash=mmh3.hash(key=fEntry[nameidx].encode("utf-16-le"), seed=0xFFFFFFFF, signed=False) if REMSG.isVersionEntryByHash(version) else None,
index=i if not (REMSG.isVersionEntryByHash(version)) else None,
)

Expand All @@ -233,9 +233,9 @@ def importCSV(msgObj: REMSG.MSG, filename: str, version: int = None, langCount:
# assert entry.index == entry.index
# else:
# if isVersionEntryByHash(version):
# if entry.hash != mmh3.hash(key = entry.name.encode('utf-16-le'), seed = -1, signed = False):
# if entry.hash != mmh3.hash(key = entry.name.encode('utf-16-le'), seed = 0xFFFFFFFF, signed = False):
# print(f"Incorrect hash value for {entry.name}, filling a correct one")
# entry.hash = mmh3.hash(key = entry.name.encode('utf-16-le'), seed = -1, signed = False)
# entry.hash = mmh3.hash(key = entry.name.encode('utf-16-le'), seed = 0xFFFFFFFF, signed = False)
# else:
# assert entry.index >= len(oldEntrys)

Expand Down Expand Up @@ -371,7 +371,7 @@ def importJson(msgObj: REMSG.MSG, filename: str):
name=jEntry["name"],
attributeValues=list([readAttributeFromStr(next(iter(attr.values())), msg.attributeHeaders[i]["valueType"]) for i, attr in enumerate(jEntry["attributes"])]),
langs=list([helper.forceWindowsLineBreak(content) for content in jEntry["content"]]),
hash=mmh3.hash(key=jEntry["name"].encode("utf-16-le"), seed=-1, signed=False) if REMSG.isVersionEntryByHash(msg.version) else None,
hash=mmh3.hash(key=jEntry["name"].encode("utf-16-le"), seed=0xFFFFFFFF, signed=False) if REMSG.isVersionEntryByHash(msg.version) else None,
index=jIndex if not (REMSG.isVersionEntryByHash(msg.version)) else None,
)

Expand Down

0 comments on commit 9b45a46

Please sign in to comment.