Files
metin2-client/tools/server/ava2-items/install_items.py
T
shenleiandClaude Opus 5.5 1412806ee9 AVA2 unlock P5: mount costume / skin (COSTUME_MOUNT 2, COSTUME_MOUNT_SKIN 4, slots 25/26, mt_mount, npc_mount races)
Keeps 71502/71505/71508/71511 and skins 71234/71254 as costumes, stages the
npc_mount models of races 32012/32028, writes mobs-server.tsv and lets
install_items.py install mob rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 13:58:16 +09:00

28 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""Install items-server.tsv (from make_items.py) into share/conf/item_proto.txt + item_names.txt.
Rows with the same vnum are replaced, so a rerun is idempotent. The db reads the tables only at boot:
restart db and every core afterwards. mobs-server.tsv (optional 4th arg) goes into mob_proto.txt + mob_names.txt
the same way. Usage: install_items.py <server root> <items-server.tsv> <fresh backup dir> [<mobs-server.tsv>]
"""
import shutil,sys
from pathlib import Path
server,rows,backup=map(Path,sys.argv[1:4])
mobrows=Path(sys.argv[4]) if len(sys.argv)>4 else None
if backup.exists():raise SystemExit('use a fresh backup directory')
load=lambda p:{int(l.split(b'\t',1)[0]):l for l in p.read_bytes().splitlines() if l}
backup.mkdir(parents=True)
conf=server/'share/conf'
def install(proto,names,rows):
for filename,row in ((proto,lambda v:rows[v]),(names,lambda v:str(v).encode()+b'\t'+rows[v].split(b'\t')[1])):
path=conf/filename;raw=path.read_bytes();shutil.copy2(path,backup/filename)
newline=b'\r\n' if b'\r\n' in raw else b'\n'
kept=[l for l in raw.replace(b'\r\n',b'\n').split(b'\n') if l and not (l.split(b'\t',1)[0].isdigit() and int(l.split(b'\t',1)[0]) in rows)]
tmp=path.with_name(filename+'.tmp');tmp.write_bytes(newline.join(kept+[row(v) for v in sorted(rows)])+newline);tmp.replace(path)
items=load(rows);install('item_proto.txt','item_names.txt',items)
print('AVA2 items installed:',len(items),'backup:',backup)
if mobrows:
mobs=load(mobrows);install('mob_proto.txt','mob_names.txt',mobs)
print('AVA2 mobs installed:',len(mobs))