Files
metin2-client/scripts/migrate_to_xxf_models.py
T
shenandshen 846a993183 feat: complete xxf-ch5 35 features migration, protocol bindings, and gate validation
- S1: Chinese locale pack, target HP/drop preview, elemental icons, exchange level display, item highlight, FOV settings, advanced skybox, GM warp.
- S2: 5-page 225-slot inventory, seamless channel switch, wiki/drop query/chest preview.
- S3: Auto-refine/attribute locks, sash combine/absorb, talisman/elemental stats, costume/mount/shining slots, changelook, soulbind, glove, quiver, magic reduction.
- S4: Modern cube renewal, mythic dragon soul (6 grades/1152 slots), DS attr change, global rankings, dice system.
- S5: Multi-token shop, offline private shop search, offline shop state machine, 64-bit gold alignment, Won dual currency exchange.
- S6: Single account 5-character slot adaptive wire protocol, Wolfman profession & claw weapon/applies, Conqueror level & Sungma attributes, pets & 6th/7th attrs, battle pass & boss tracking.
- Pass 42/42 platform gate test suites in scripts/port_gate.sh macos.
2026-10-22 01:29:14 -07:00

228 lines
8.6 KiB
Python

#!/usr/bin/env python3
"""
Migrate metin2-client/Client/pack to 喜相逢五区 full model & asset pack architecture (Solution B).
1. Removes old 40250 model, map, and patch packs from Client/pack (already backed up).
2. Clones all 喜相逢 packs (yw_*, item*, maps, updata*, special_patch*, Skybox, etc.) into Client/pack.
3. Generates the updated Client/pack/Index.
4. Verifies pack loading.
"""
import os
import sys
import shutil
import subprocess
from pathlib import Path
REPO = Path(__file__).resolve().parents[1]
CLIENT_PACK = REPO / "Client/pack"
XXF_PACK = Path("/Users/shen/Work/Code/Metin2/喜相逢五区客户端/pack")
# Old 40250 packs that are completely replaced by 喜相逢's yw_* and maps packs
OLD_PACKS_TO_REMOVE = [
# PC models
"PC.eix", "PC.epk", "pc2.eix", "pc2.epk",
# Monster models
"Monster.eix", "Monster.epk", "monster2.eix", "monster2.epk",
# NPC models
"NPC.eix", "NPC.epk", "npc2.eix", "npc2.epk",
# Zone models & old maps
"Zone.eix", "Zone.epk",
"Outdoor.eix", "Outdoor.epk",
"OutdoorA1.eix", "OutdoorA1.epk",
"OutdoorA2.eix", "OutdoorA2.epk",
"OutdoorA3.eix", "OutdoorA3.epk",
"OutdoorB1.eix", "OutdoorB1.epk",
"OutdoorB3.eix", "OutdoorB3.epk",
"OutdoorC1.eix", "OutdoorC1.epk",
"OutdoorC3.eix", "OutdoorC3.epk",
"OutdoorSnow1.eix", "OutdoorSnow1.epk",
"outdoordesert1.eix", "outdoordesert1.epk",
"outdoorduel.eix", "outdoorduel.epk",
"outdoorempirebattle1.eix", "outdoorempirebattle1.epk",
"outdoorfielddungeon1.eix", "outdoorfielddungeon1.epk",
"outdoorflame1.eix", "outdoorflame1.epk",
"outdoorgmguildbuild.eix", "outdoorgmguildbuild.epk",
"outdoorguild1.eix", "outdoorguild1.epk",
"outdoorguild2.eix", "outdoorguild2.epk",
"outdoorguild3.eix", "outdoorguild3.epk",
"outdoormilgyo1.eix", "outdoormilgyo1.epk",
"outdoort1.eix", "outdoort1.epk",
"outdoort2.eix", "outdoort2.epk",
"outdoort3.eix", "outdoort3.epk",
"outdoort4.eix", "outdoort4.epk",
"outdoortrent.eix", "outdoortrent.epk",
"outdoortrent02.eix", "outdoortrent02.epk",
"outdoorwedding.eix", "outdoorwedding.epk",
"indoordeviltower1.eix", "indoordeviltower1.epk",
"indoormonkeydungeon1.eix", "indoormonkeydungeon1.epk",
"indoormonkeydungeon2.eix", "indoormonkeydungeon2.epk",
"indoormonkeydungeon3.eix", "indoormonkeydungeon3.epk",
"indoorspiderdungeon1.eix", "indoorspiderdungeon1.epk",
# Old patches (replaced by 喜相逢's special_patch_* & updata*)
"patch1.eix", "patch1.epk",
"patch2.eix", "patch2.epk",
"metin2_patch_5th_armor.eix", "metin2_patch_5th_armor.epk",
"metin2_patch_costume_soccer.eix", "metin2_patch_costume_soccer.epk",
"metin2_patch_dance.eix", "metin2_patch_dance.epk",
"metin2_patch_dragon_rock.eix", "metin2_patch_dragon_rock.epk",
"metin2_patch_dragon_rock_mobs.eix", "metin2_patch_dragon_rock_mobs.epk",
"metin2_patch_dragon_rock_mobs_texcache.eix", "metin2_patch_dragon_rock_mobs_texcache.epk",
"metin2_patch_dragon_rock_texcache.eix", "metin2_patch_dragon_rock_texcache.epk",
"metin2_patch_ds.eix", "metin2_patch_ds.epk",
"metin2_patch_dss_box.eix", "metin2_patch_dss_box.epk",
"metin2_patch_easter1.eix", "metin2_patch_easter1.epk",
"metin2_patch_etc.eix", "metin2_patch_etc.epk",
"metin2_patch_etc_costume1.eix", "metin2_patch_etc_costume1.epk",
"metin2_patch_eu3.eix", "metin2_patch_eu3.epk",
"metin2_patch_eu4.eix", "metin2_patch_eu4.epk",
"metin2_patch_flame.eix", "metin2_patch_flame.epk",
"metin2_patch_flame_dungeon.eix", "metin2_patch_flame_dungeon.epk",
"metin2_patch_halloween.eix", "metin2_patch_halloween.epk",
"metin2_patch_mineral.eix", "metin2_patch_mineral.epk",
"metin2_patch_mundi.eix", "metin2_patch_mundi.epk",
"metin2_patch_party.eix", "metin2_patch_party.epk",
"metin2_patch_pet1.eix", "metin2_patch_pet1.epk",
"metin2_patch_pet2.eix", "metin2_patch_pet2.epk",
"metin2_patch_ramadan_costume.eix", "metin2_patch_ramadan_costume.epk",
"metin2_patch_sd.eix", "metin2_patch_sd.epk",
"metin2_patch_snow.eix", "metin2_patch_snow.epk",
"metin2_patch_snow_dungeon.eix", "metin2_patch_snow_dungeon.epk",
"metin2_patch_w20_etc.eix", "metin2_patch_w20_etc.epk",
"metin2_patch_w20_sound.eix", "metin2_patch_w20_sound.epk",
"metin2_patch_w21_etc.eix", "metin2_patch_w21_etc.epk",
"metin2_patch_w21_mobs.eix", "metin2_patch_w21_mobs.epk",
"metin2_patch_w21_mobs_m.eix", "metin2_patch_w21_mobs_m.epk",
"metin2_patch_xmas.eix", "metin2_patch_xmas.epk",
# Old seasons (replaced by 喜相逢 season)
"season1.eix", "season1.epk",
"season2.eix", "season2.epk",
"season3_eu.eix", "season3_eu.epk",
# Old sounds (replaced by 喜相逢 sound)
"sound2.eix", "sound2.epk",
"sound_m.eix", "sound_m.epk",
# Unused / dummy
"Psyco.eix", "Psyco.epk",
]
def main():
print(f"Target pack dir: {CLIENT_PACK}")
print(f"XXF source pack dir: {XXF_PACK}")
# 1. Remove old packs
removed_count = 0
for name in OLD_PACKS_TO_REMOVE:
p = CLIENT_PACK / name
if p.exists() or p.is_symlink():
p.unlink()
removed_count += 1
print(f"Removed {removed_count} old pack files.")
# 2. Copy/Clone 喜相逢 packs
# We clone all packs from 喜相逢 EXCEPT root (metin2-client keeps its own ported root)
cloned_count = 0
for src in sorted(XXF_PACK.iterdir()):
if src.name == "Index" or src.name.startswith("root."):
continue
dst = CLIENT_PACK / src.name
if dst.exists() or dst.is_symlink():
dst.unlink()
# Use cp -c on macOS APFS for instant copy-on-write clone
res = subprocess.run(["cp", "-c", str(src), str(dst)], capture_output=True)
if res.returncode != 0:
shutil.copy2(src, dst)
cloned_count += 1
print(f"Cloned {cloned_count} pack files from 喜相逢五区.")
# 3. Create updated Index
# Order:
# 1. Platform & Port UI extensions (highest priority)
# 2. 喜相逢 updates & special patches
# 3. 喜相逢 3D Models (Plechito, high-poly character models, new monsters, mounts)
# 4. Base fallback packs
# 5. Multi-language fallback mappings
index_entries = [
"PACK",
"*", "patch_ava2_ui",
"*", "item2",
"*", "new-ui",
"*", "Skybox",
"*", "updata",
"*", "updata2",
"*", "updata3",
"*", "special_patch_animation",
"*", "special_patch_common",
"*", "special_patch_ex",
"*", "special_patch_hair",
"*", "icon",
"*", "locale",
"*", "maps",
"*", "property",
"*", "season",
"*", "sound",
"*", "textureset",
"*", "uiscript",
"*", "yw_etc",
"*", "yw_monster",
"*", "yw_monster2",
"*", "yw_npc",
"*", "yw_npc_mount",
"*", "yw_npc_mount2",
"*", "yw_npc_pet",
"*", "yw_npc2",
"*", "yw_pc",
"*", "yw_pc2",
"*", "yw_pc3",
"*", "yw_pc4",
"*", "yw_item",
"*", "yw_zone",
"*", "item",
"*", "guild",
"*", "Terrain",
"*", "Tree",
"*", "Effect",
"*", "ETC",
"*", "BGM",
"*", "uiloading",
# Locale mappings for non-Chinese fallbacks if locale.cfg switches
"locale/de/", "locale_de",
"locale/dk/", "locale_dk",
"locale/en/", "locale_en",
"locale/es/", "locale_es",
"locale/fr/", "locale_fr",
"locale/gr/", "locale_gr",
"locale/hu/", "locale_hu",
"locale/it/", "locale_it",
"locale/nl/", "locale_nl",
"locale/pl/", "locale_pl",
"locale/pt/", "locale_pt",
"locale/ro/", "locale_ro",
"locale/ru/", "locale_ru",
"locale/tr/", "locale_tr",
"locale/cz/", "locale_cz",
]
index_path = CLIENT_PACK / "Index"
index_path.write_text("\n".join(index_entries) + "\n", encoding="latin-1")
print(f"Updated {index_path} successfully ({len(index_entries)//2} registered packs).")
# 4. Verify on-disk packs
registered_names = set()
for i in range(1, len(index_entries), 2):
registered_names.add(index_entries[i + 1])
missing = []
for name in registered_names:
# Check case-insensitively
found = any(f.name.lower() == (name.lower() + ".eix") for f in CLIENT_PACK.iterdir())
if not found:
missing.append(name)
if missing:
print(f"Warning: {len(missing)} packs registered in Index not found on disk: {missing}")
else:
print(f"All {len(registered_names)} registered packs verified on disk!")
if __name__ == "__main__":
main()