- item_tooltip_view.gd: 新增 avoid_rect 属性,tooltip 与装备窗口重叠时自动推到左侧 - inventory_ui.gd: 悬停装备时传入窗口矩形作为避让区域 - 包含其他累积的功能开发和测试文件
67 lines
2.2 KiB
Python
67 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Verify the classic sequence table against the 40250 Windows source.
|
|
|
|
The client-side table is protocol data, not a generated random table. Compare
|
|
the complete byte array and report the digest so a copied prefix or reordered
|
|
tail cannot be mistaken for parity.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
import re
|
|
from pathlib import Path
|
|
|
|
|
|
def read_array(path: Path, symbol: str) -> bytes:
|
|
text = path.read_text(errors="replace")
|
|
match = re.search(
|
|
rf"{re.escape(symbol)}\s*(?:\[[^\]]+\])?\s*=\s*\{{(?P<body>.*?)\}}\s*;",
|
|
text,
|
|
re.S,
|
|
)
|
|
if not match:
|
|
raise ValueError(f"cannot find {symbol} in {path}")
|
|
values = [int(token, 0) for token in re.findall(r"0x[0-9a-fA-F]+|\b\d+\b", match.group("body"))]
|
|
if any(value < 0 or value > 255 for value in values):
|
|
raise ValueError(f"out-of-range byte in {path}")
|
|
return bytes(values)
|
|
|
|
|
|
def digest(data: bytes) -> str:
|
|
return hashlib.sha256(data).hexdigest()
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser()
|
|
default_root = Path(__file__).resolve().parents[4]
|
|
parser.add_argument("--repo-root", type=Path, default=default_root)
|
|
args = parser.parse_args()
|
|
|
|
root = args.repo_root.resolve()
|
|
reference = root.parent / "40250/Server Client TMP4/ClientVS22/source/EterLib/NetStream.cpp"
|
|
current = root / "extension/src/net/classic/sequence_table.h"
|
|
try:
|
|
ref = read_array(reference, "s_bSequenceTable")
|
|
cur = read_array(current, "SEQUENCE_TABLE")
|
|
except (OSError, ValueError) as exc:
|
|
print(json.dumps({"status": "ERROR", "error": str(exc)}, indent=2, sort_keys=True))
|
|
return 2
|
|
|
|
first_difference = next((i for i, pair in enumerate(zip(ref, cur)) if pair[0] != pair[1]), None)
|
|
equal = len(ref) == len(cur) and first_difference is None
|
|
result = {
|
|
"status": "PASS" if equal else "FAIL",
|
|
"reference": {"length": len(ref), "sha256": digest(ref)},
|
|
"current": {"length": len(cur), "sha256": digest(cur)},
|
|
"first_difference": first_difference,
|
|
}
|
|
print(json.dumps(result, indent=2, sort_keys=True))
|
|
return 0 if equal else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|