Fix cross-platform rendering and optimize frame performance

Correct selection orientation, game-entry lifecycle, mounted NPCs, labels and skill panels. Add the native GPU scene path, resident geometry, bounded texture and Python caches, and collision broad phase.

Pin the independently maintained Metin2 SDK through a submodule and document reproducible setup. Include rendering regressions and macOS packaging improvements.

Validation: client Debug build and 12 targeted client tests passed; SDK build and all 14 SDK tests passed.
This commit is contained in:
shen
2026-10-11 17:55:53 -07:00
parent 08cc8865be
commit 281418f351
101 changed files with 6244 additions and 1877 deletions
+77 -58
View File
@@ -11,7 +11,8 @@ import json
import hashlib
import shutil
import argparse
from pathlib import Path
from pathlib import Path, PurePosixPath
from make_test_rundir import pack_manifests, MANIFEST_ENTRY, archived_root_path
DEFAULT_ASSET_DIRS = [
"mark",
@@ -20,6 +21,14 @@ DEFAULT_ASSET_DIRS = [
"textureset",
"sound",
"runtime",
"icon",
"flag",
"Dialog",
"Itemshop",
"Modulo",
"System",
"battlepass",
"season1",
"upstream/python-root",
]
@@ -36,71 +45,80 @@ def compute_sha256(filepath):
h.update(chunk)
return h.hexdigest()
def package_assets(source_dir, output_dir, manifest_path=None, include_heavy=False):
def package_assets(source_dir, output_dir, manifest_path=None, include_heavy=False, pack_maker=None):
source_path = Path(source_dir).resolve()
dest_path = Path(output_dir).resolve()
dest_path.mkdir(parents=True, exist_ok=True)
if pack_maker is None:
candidate = source_path.parent / "AVA2" / "1. Client DEV" / "pack_maker"
pack_maker = candidate if candidate.is_dir() else None
entries = {}
scan_dirs = list(DEFAULT_ASSET_DIRS)
if include_heavy:
scan_dirs.extend(OPTIONAL_ASSET_DIRS)
manifest = {
"version": "1.0.0",
"source": str(source_path),
"total_files": 0,
"total_bytes": 0,
"files": {}
}
print(f"[*] Packaging assets from {source_path} -> {dest_path}")
packaged_count = 0
total_bytes = 0
def add(rel, source, override=False):
rel = archived_root_path(str(rel))
parts = PurePosixPath(rel).parts
if not parts or rel.startswith("/") or any(part in ("..", ".") or ":" in part for part in parts):
raise ValueError(f"Invalid virtual asset path: {rel}")
if not include_heavy and parts[0].lower() in ("ymir work", "bgm"):
return
if rel.endswith((".pyc", ".tmp")):
return
key = rel.lower()
if override or key not in entries:
if not source.is_file():
raise FileNotFoundError(f"Required asset {rel}: {source}")
# Canonical casing also works on Android/Linux.
# Python imports are case-sensitive on Android/Linux (e.g. uiCommon).
entries[key] = (rel if parts[0] == "root" and len(parts) == 2 and rel.endswith(".py") else key, source)
if pack_maker is not None:
pack_maker = Path(pack_maker).resolve()
for xml in pack_manifests(pack_maker):
for rel, source in MANIFEST_ENTRY.findall(xml.read_text(encoding="latin-1")):
add(rel, pack_maker.parent / source)
# Some custom UI images ship loose beside the Windows executable, outside every pack.
# Copy resource formats only; scripts/configuration continue to come from the port.
resource_extensions = {".png", ".jpg", ".jpeg", ".tga", ".dds", ".sub", ".wav", ".ogg", ".mp3", ".gr2", ".spt", ".mse", ".msa", ".msm"}
excluded = {"pack", "pack_maker", "lib", "miles", "mark", "screenshot", "screenshots", "logs"}
for directory, dirs, files in os.walk(pack_maker.parent):
dirs[:] = [d for d in dirs if not d.startswith(".") and d.lower() not in excluded]
for name in files:
source = Path(directory) / name
if source.suffix.lower() in resource_extensions and source.is_file():
add(source.relative_to(pack_maker.parent).as_posix(), source)
scan_dirs = DEFAULT_ASSET_DIRS + (["map", "property", "rework_inv"] if pack_maker is None else [])
if include_heavy and pack_maker is None:
scan_dirs += OPTIONAL_ASSET_DIRS
for rel_dir in scan_dirs:
src_dir_path = source_path / rel_dir
if not src_dir_path.exists():
base = source_path / rel_dir
if not base.exists():
continue
for directory, dirs, files in os.walk(base):
dirs[:] = [d for d in dirs if not d.startswith(".") and d not in ("__pycache__", "build")]
for name in files:
if not name.startswith("."):
source = Path(directory) / name
if source.is_file():
rel = source.relative_to(source_path).as_posix()
if rel.startswith("upstream/python-root/"):
rel = "root/" + rel[len("upstream/python-root/"):]
add(rel, source, True)
print(f" -> Scanning {rel_dir}...")
for root, dirs, files in os.walk(src_dir_path):
# Exclude build and hidden artifacts
dirs[:] = [d for d in dirs if not d.startswith(".") and d not in ("__pycache__", "build", ".git")]
for file in files:
if file.startswith(".") or file.endswith(".pyc") or file.endswith(".tmp"):
continue
full_path = Path(root) / file
rel_to_source = full_path.relative_to(source_path)
target_file = dest_path / rel_to_source
target_file.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(full_path, target_file)
file_size = full_path.stat().st_size
file_hash = compute_sha256(full_path)
manifest["files"][str(rel_to_source).replace("\\", "/")] = {
"size": file_size,
"sha256": file_hash
}
packaged_count += 1
total_bytes += file_size
manifest["total_files"] = packaged_count
manifest["total_bytes"] = total_bytes
if manifest_path:
out_manifest = Path(manifest_path)
else:
out_manifest = dest_path / "asset_manifest.json"
manifest = {"version": "2.0.0", "source": str(source_path),
"total_files": 0, "total_bytes": 0, "files": {}}
print(f"[*] Packaging {len(entries)} virtual assets into {dest_path}")
for rel, source in entries.values():
target = dest_path / rel
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(source, target)
size = source.stat().st_size
manifest["files"][rel] = {"size": size, "sha256": compute_sha256(source)}
manifest["total_bytes"] += size
manifest["total_files"] = len(entries)
out_manifest = Path(manifest_path) if manifest_path else dest_path / "asset_manifest.json"
out_manifest.parent.mkdir(parents=True, exist_ok=True)
with open(out_manifest, "w", encoding="utf-8") as f:
json.dump(manifest, f, indent=2, sort_keys=True)
print(f"[+] Packaged {packaged_count} files ({total_bytes / (1024*1024):.2f} MB)")
print(f"[+] Manifest written to {out_manifest}")
out_manifest.write_text(json.dumps(manifest, indent=2, sort_keys=True), encoding="utf-8")
print(f"[+] Packaged {len(entries)} files ({manifest['total_bytes'] / (1024*1024):.2f} MB)")
return manifest
def verify_assets(manifest_path, target_dir):
@@ -144,6 +162,7 @@ def main():
parser.add_argument("--source", default=".", help="Source client directory")
parser.add_argument("--output", default="dist/assets", help="Output packaged directory")
parser.add_argument("--manifest", default=None, help="Manifest output path")
parser.add_argument("--pack-maker", default=None, help="Original pack_maker manifests and decoded files")
parser.add_argument("--include-heavy", action="store_true", help="Include large 3D models and BGM")
parser.add_argument("--verify", default=None, help="Verify target directory against specified manifest")
@@ -153,7 +172,7 @@ def main():
success = verify_assets(args.verify, args.output)
sys.exit(0 if success else 1)
else:
package_assets(args.source, args.output, args.manifest, args.include_heavy)
package_assets(args.source, args.output, args.manifest, args.include_heavy, args.pack_maker)
if __name__ == "__main__":
main()