tools/client/summarize_game_smoke.py (3066B)
1 """Collect native FPS crops, menu evidence, and comparable binary sizes.""" 2 3 import json 4 import pathlib 5 6 import PIL.Image 7 import PIL.ImageDraw 8 9 10 root = pathlib.Path(__file__).resolve().parents[2] 11 work = root / "local/client/game-14.9.1" 12 reports = sorted(work.glob("smoke-*.json"), key=lambda path: path.stat().st_mtime) 13 fps_reports = [path for path in reports if (work / f"{path.stem}-fps-5.png").exists()] 14 sheet = PIL.Image.new("RGB", (900, len(fps_reports) * 110), "#202020") 15 draw = PIL.ImageDraw.Draw(sheet) 16 17 # Keep the exact native pixels available alongside enlarged, readable FPS crops. 18 for row, filename in enumerate(fps_reports): 19 report = json.loads(filename.read_text()) 20 pid = report["run"]["pid"] 21 draw.text((8, row * 110), f"PID {pid}: {pathlib.PureWindowsPath(report['run']['executable']).name}", fill="white") 22 for sample in range(1, 6): 23 image = work / f"smoke-{pid}-fps-{sample}.png" 24 if image.exists(): 25 crop = PIL.Image.open(image).crop((16, 27, 84, 42)) 26 sheet.paste(crop.resize((170, 38), PIL.Image.Resampling.NEAREST), 27 ((sample - 1) * 180, row * 110 + 22)) 28 frames = [event for event in report["events"] if "capture" in event and "-fps-" in event["capture"]] 29 draw.text((8, row * 110 + 68), 30 "Capture seconds: " + ", ".join(f"{event['elapsed_seconds']:.1f}" for event in frames), 31 fill="white") 32 33 # Review visible menu state and movement, not merely successful key injection. 34 for filename in reports: 35 report = json.loads(filename.read_text()) 36 pid = report["run"]["pid"] 37 smoke_sheet = PIL.Image.new("RGB", (1536, 812), "#202020") 38 smoke_draw = PIL.ImageDraw.Draw(smoke_sheet) 39 labels = ["fps-5", "inventory-open", "inventory-closed", "map-open", "map-closed", "moved"] 40 for index, label in enumerate(labels): 41 image = work / f"smoke-{pid}-{label}.png" 42 if image.exists(): 43 x, y = index % 3 * 512, index // 3 * 406 44 smoke_draw.text((x + 8, y), f"PID {pid}: {label}", fill="white") 45 smoke_sheet.paste(PIL.Image.open(image).resize((512, 384)), (x, y + 22)) 46 smoke_sheet.save(work / f"smoke-review-{pid}.png") 47 sheet.save(work / "fps-comparison.png") 48 49 # Compare all reconstructed modules, not the tiny original bootstrap EXE alone. 50 scope = json.loads((root / "client/scope.json").read_text()) 51 original = sum((root / "anarchy-vanilla-14.9.1" / module["name"]).stat().st_size 52 for module in scope["game"]) 53 rebuilt = (root / "client/build/windows/game.exe").stat().st_size 54 images = 0 55 sizes = {"original_game_module_count": len(scope["game"]), "original_game_bytes": original, 56 "rebuilt_exe_bytes": rebuilt, "required_image_bytes": images, 57 "rebuilt_with_images_bytes": rebuilt + images, 58 "executable_size_ratio": rebuilt / original, 59 "with_images_size_ratio": (rebuilt + images) / original} 60 (work / "size-comparison.json").write_text(json.dumps(sizes, indent=2)) 61 print(json.dumps(sizes, indent=2)) 62 print(work / "fps-comparison.png")