AVA2 new_switchbot ported as port_switchbot.{h,cpp}: SWITCHBOT item window (7),
CG/GC 171 and GG 31 with AVA2 subheaders and field order, pack(1) structs pinned
by static_assert, 0.1 s roll, P2P hand-over on warp, boot ALTER of
player.item.window. Switchers come from the inventory; current checks and
ItemLog are kept. Clients sending "mt20261016" or newer as the version
timestamp get the switchbot; older clients are left alone.
The v1 /mt_switchbot chat command, its lock verb and query capability bit 64
are removed (cap mask 1023 -> 959).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.7 KiB
Python
38 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Port commands must not take over abbreviations of the original commands.
|
|
|
|
interpret_command (cmd.cpp) picks the first table entry whose name starts with the typed command
|
|
(strncmp over the typed length; do_cmd entries need an exact match). A port command placed before an
|
|
original one would steal its abbreviations, as mt_features once did with /m (mob) and /mt (mto).
|
|
"""
|
|
from pathlib import Path
|
|
import re
|
|
ROOT=Path(__file__).resolve().parents[2]
|
|
text=(ROOT/'src/server/game/src/cmd.cpp').read_bytes().decode('latin1')
|
|
table=text.split('struct command_info cmd_info[] =',1)[1]
|
|
entries=re.findall(r'\{\s*"((?:[^"\\]|\\.)*)",\s*([A-Za-z_0-9]+|NULL)',table)
|
|
assert entries[0][0]=='!RESERVED!'
|
|
end=[i for i,(name,_) in enumerate(entries) if name=='\\n']
|
|
assert end,'table sentinel not found'
|
|
entries=entries[1:end[0]]
|
|
PORT=lambda name:name.startswith('mt_')
|
|
port=[name for name,_ in entries if PORT(name)]
|
|
assert {'mt_features','mt_pickup','mt_chest'}<=set(port),port
|
|
|
|
def resolve(rows,cmd):
|
|
for name,fn in rows:
|
|
if fn=='do_cmd':
|
|
if name==cmd:return name
|
|
elif name.startswith(cmd):return name
|
|
return None
|
|
|
|
original=[(name,fn) for name,fn in entries if not PORT(name)]
|
|
for name in port:assert resolve(entries,name)==name,name
|
|
for name,_ in original:
|
|
for k in range(1,len(name)+1):
|
|
typed=name[:k]
|
|
assert resolve(entries,typed)==resolve(original,typed),'/%s now runs %s instead of %s'%(typed,resolve(entries,typed),resolve(original,typed))
|
|
for typed in ('m','mt','mo'):assert not PORT(resolve(entries,typed) or ''),typed
|
|
assert resolve(entries,'m')=='mob' and resolve(entries,'mt')=='mto'
|
|
print('cmd prefix ok: %d commands, %d port'%(len(entries),len(port)))
|