- Port server core and libraries to Linux and 32-bit ARM (armhf): * Replace FreeBSD kqueue with Linux epoll in libthecore fdwatch * Fix unaligned float and 64-bit int memory stores in utils.h str_to_number to avoid ARM VFP alignment fault (SIGBUS) * Fix getopt loop variable type in main.cpp (char -> int) to eliminate infinite loop caused by default unsigned char on ARM * Add -fsigned-char and multi-architecture flags to Makefiles (x86_64 -m32, i386, and ARM armhf) * Update libsql for modern MariaDB client library (removed reconnect field) and C++20 concept/syntax compatibility * Replace Win32 xdirent with standard POSIX dirent on Unix/Linux * Include xmd5 in libthecore on non-FreeBSD platforms - AVA2 unlock features and tools: * Material stacking up to 2000 count, refine material resolution and test suites * AVA2 ticket shop and point drop configuration updates
40 lines
2.9 KiB
Python
40 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Create a fresh, isolated QA character. Does not edit any existing account or item."""
|
|
import argparse,json,re,subprocess
|
|
from pathlib import Path
|
|
|
|
def sql(q):
|
|
r=subprocess.run(['mysql','-N','-e',q],check=True,capture_output=True,text=True)
|
|
return [row.split('\t') for row in r.stdout.splitlines()]
|
|
def ident(s):
|
|
if not re.fullmatch(r'[a-zA-Z0-9_]+',s):raise ValueError('identifier')
|
|
return '`'+s+'`'
|
|
def value(s):return '0x'+s.encode().hex()
|
|
def clone(table,overrides,where):
|
|
cols=[x[0] for x in sql('SHOW COLUMNS FROM '+table) if x[0]!='id']
|
|
fields=','.join(ident(c) for c in cols)
|
|
expressions=','.join(overrides.get(c,ident(c)) for c in cols)
|
|
sql('INSERT INTO '+table+' ('+fields+') SELECT '+expressions+' FROM '+table+' WHERE '+where+' LIMIT 1')
|
|
|
|
if __name__=='__main__':
|
|
p=argparse.ArgumentParser();p.add_argument('--player-schema',required=True);p.add_argument('--account-schema',required=True);p.add_argument('--private-file',required=True);a=p.parse_args()
|
|
private=Path(a.private_file);secrets=json.loads(private.read_text());login=secrets['login'];name=secrets['name']
|
|
if len(secrets['password'])>16:raise ValueError('login UI password limit is 16')
|
|
acc=ident(a.account_schema)+'.account';player=ident(a.player_schema)+'.player';index=ident(a.player_schema)+'.player_index'
|
|
if sql('SELECT id FROM '+acc+' WHERE login='+value(login)):raise RuntimeError('fixture account already exists')
|
|
if sql('SELECT id FROM '+player+' WHERE name='+value(name)):raise RuntimeError('fixture character already exists')
|
|
clone(acc,{'login':value(login),'password':'PASSWORD('+value(secrets['password'])+')','status':"'OK'",'create_time':'NOW()'},'1 ORDER BY id')
|
|
aid=int(sql('SELECT id FROM '+acc+' WHERE login='+value(login))[0][0])
|
|
replacements={'account_id':str(aid),'name':value(name),'job':'0','level':'10','gold':'1000000','exp':'0','map_index':'1','x':'477100','y':'956700','z':'0','exit_map_index':'1','exit_x':'477100','exit_y':'956700','hp':'10000','sp':'10000'}
|
|
clone(player,replacements,'job=0 ORDER BY id')
|
|
pid=int(sql('SELECT id FROM '+player+' WHERE name='+value(name))[0][0])
|
|
sql('INSERT INTO '+index+' (id,pid1,pid2,pid3,pid4,pid5,empire) VALUES (%d,%d,0,0,0,0,1)'%(aid,pid))
|
|
item=ident(a.player_schema)+'.item'
|
|
for i,count in enumerate([199,200,201,255,256,1999,2000]):
|
|
sql("INSERT INTO "+item+" (owner_id,window,pos,count,vnum,port_extra) VALUES (%d,'INVENTORY',%d,%d,30006,%s)"%(pid,180+i,count,'0x'+'00'*69))
|
|
for cell,vnum,count in [(192,71085,2000),(193,71084,2000),(194,19,1)]:
|
|
sql("INSERT INTO "+item+" (owner_id,window,pos,count,vnum,port_extra) VALUES (%d,'INVENTORY',%d,%d,%d,%s)"%(pid,cell,count,vnum,'0x'+'00'*69))
|
|
secrets.update(account_id=aid,player_id=pid,player_schema=a.player_schema,account_schema=a.account_schema)
|
|
private.write_text(json.dumps(secrets));private.chmod(0o600)
|
|
print(json.dumps({'account_id':aid,'player_id':pid,'schema':a.player_schema,'seeded_count':sql('SELECT SUM(count) FROM '+item+' WHERE owner_id='+str(pid))[0][0]}))
|