Files
Viano-Core/doc/clientless/checkpoints/2026-10-27-profession/vcore-economy-db.py
T

45 lines
6.8 KiB
Python

from pathlib import Path
import os,re,subprocess,sys
config=Path('/home/wow_admin/wow_cata_server/server/debug/etc/worldserver.conf').read_text()
h,port,u,password,db=re.search(r'^WorldDatabaseInfo\s*=\s*"([^"]+)"',config,re.M).group(1).split(';')
args=['mysql','--protocol=TCP','--host='+h,'--port='+port,'--user='+u,'--database='+db,'--batch','--default-character-set=utf8mb4','--connect-timeout=10']
env=os.environ.copy();env['MYSQL_PWD']=password
op=sys.argv[1] if len(sys.argv)>1 else ''
if op=='state':
h,port,u,password,db=re.search(r'^CharacterDatabaseInfo\s*=\s*"([^"]+)"',config,re.M).group(1).split(';')
args=['mysql','--protocol=TCP','--host='+h,'--port='+port,'--user='+u,'--database='+db,'--batch','--default-character-set=utf8mb4','--connect-timeout=10']
env['MYSQL_PWD']=password
if op=='state':
query="SELECT guid,money FROM characters WHERE guid=26; SELECT item,bag,slot FROM character_inventory WHERE guid=26 ORDER BY bag,slot,item; SELECT guid,itemEntry,count FROM item_instance WHERE owner_guid=26 ORDER BY guid;"
elif op=='workstation_inspect':
query="""SELECT data0 AS focus_id,COUNT(*) AS n,LEFT(GROUP_CONCAT(DISTINCT name ORDER BY name SEPARATOR ', '),600) AS examples FROM gameobject_template WHERE type=8 GROUP BY data0 ORDER BY data0; SELECT entry,name,type,data0 FROM gameobject_template WHERE name REGEXP 'Alchemy|Alchemist|Workbench|Loom|Tanning|Sewing|Enchanter|Runeforge|Cooking Fire|Campfire' AND type IN (5,8,10) ORDER BY entry LIMIT 65; SHOW CREATE TABLE npc_trainer; SHOW CREATE TABLE trainer; SHOW CREATE TABLE creature_trainer;"""
elif op=='profession_inspect':
query="""SELECT t.entry,t.name,t.type,t.data0,t.data1 FROM gameobject_template t WHERE (t.type=8 AND (t.name REGEXP 'Anvil|Forge|Alchemy|Loom|Workbench|Enchant|Tanning|Cooking')) OR (t.type=3 AND t.name IN ('Copper Vein','Silverleaf','Peacebloom')) ORDER BY t.type,t.data0,t.entry LIMIT 90; SELECT w.point_key,a.display_name,w.category,w.map,w.position_x,w.position_y,w.position_z,a.is_area,a.area_id,a.zone_id FROM vcore_clientless_world_point w JOIN vcore_adventure_location a USING(point_key) WHERE w.enabled=1 AND (a.is_area=1 AND a.zone_id=12 OR w.category='workshop' AND a.zone_id=1519) ORDER BY w.point_key LIMIT 25;"""
elif op=='exploration_inspect':
query="""SELECT g.guid,g.id,t.name,t.type,g.position_x,g.position_y,g.position_z FROM gameobject g JOIN gameobject_template t ON t.entry=g.id WHERE g.map=0 AND g.position_x BETWEEN -9000 AND -8750 AND g.position_y BETWEEN 500 AND 750 AND t.type IN (5,9,10) ORDER BY g.id; SELECT w.point_key,a.display_name,w.category,w.map,w.position_x,w.position_y,w.position_z FROM vcore_clientless_world_point w JOIN vcore_adventure_location a USING(point_key) WHERE w.enabled=1 AND w.map=0 AND (a.display_name LIKE '%Northshire%' OR a.display_name LIKE '%Goldshire%' OR a.display_name LIKE '%Stonecairn%') ORDER BY a.display_name;"""
elif op=='exploration_apply':
query='START TRANSACTION;\n'+Path('/home/wow_admin/wow_cata_server/source/TrinityCore/sql/custom/world/2026_10_27_04_adventure_exploration.sql').read_text()+"\nSELECT a.action_key,a.kind,a.requirement,i.weight FROM vcore_adventure_action a JOIN vcore_adventure_action_intent i USING(action_key) WHERE a.action_key LIKE 'adventure_%' OR (a.action_key='explore' AND i.intent='adventure'); COMMIT;"
elif op=='catalog':
query="""SELECT w.point_key,w.category,w.map,w.position_x,w.position_y,w.position_z,w.orientation,w.enabled,COALESCE(w.comment,''),a.display_name,a.source_type,a.source_id,a.area_id,a.zone_id,a.region_key,a.is_area,a.faction FROM vcore_clientless_world_point w JOIN vcore_adventure_location a USING(point_key) ORDER BY w.point_key;"""
elif op=='source_audit':
query="""SELECT id,name,map,position_x,position_y,position_z FROM game_tele WHERE name IN ('Orgrimmar','ThunderBluff','Thunder Bluff','Undercity','SilvermoonCity','Darnassus','TheExodar','Ironforge','Stormwind'); SHOW COLUMNS FROM game_tele; SHOW COLUMNS FROM creature; SELECT c.id,t.name,c.map,c.position_x,c.position_y,c.position_z,COALESCE(NULLIF(c.npcflag,0),t.npcflag) AS flags,t.faction FROM creature c JOIN creature_template t ON t.entry=c.id WHERE t.name IN ('Innkeeper Gryshka','Innkeeper Pala','Innkeeper Allison','Auctioneer Thathung','Auctioneer Chilton') ORDER BY c.map,c.id;"""
elif op=='audit':
query="""SELECT COUNT(*) AS active_locations FROM vcore_clientless_world_point w JOIN vcore_adventure_location a USING(point_key) WHERE w.enabled=1 AND w.category NOT LIKE 'travel%'; SELECT a.source_type,w.category,a.faction,COUNT(*) AS n FROM vcore_adventure_location a JOIN vcore_clientless_world_point w USING(point_key) WHERE w.enabled=1 GROUP BY a.source_type,w.category,a.faction ORDER BY n DESC; SELECT w.point_key,a.display_name,w.category,a.region_key,a.area_id,a.zone_id,a.is_area,a.faction,w.map,w.position_x,w.position_y,w.position_z FROM vcore_adventure_location a JOIN vcore_clientless_world_point w USING(point_key) WHERE w.enabled=1 AND (a.display_name REGEXP 'Orgrimmar|Thunder Bluff|Undercity|Silvermoon|Darnassus|Exodar|Ironforge|Stormwind' OR (a.is_area=1 AND a.zone_id IN (1519,1637,1638,1497,1537,1657,3430,3487,3557))) ORDER BY a.is_area DESC,a.zone_id,w.point_key;"""
elif op=='inspect':
query="""SELECT c.guid,c.id,t.name,t.npcflag,c.position_x,c.position_y,c.position_z,c.orientation FROM creature c JOIN creature_template t ON t.entry=c.id WHERE c.map=0 AND c.position_x BETWEEN -9000 AND -8750 AND c.position_y BETWEEN 450 AND 850 AND (t.npcflag & (128|131072|2097152))<>0 ORDER BY c.id,c.guid; SHOW CREATE TABLE vcore_adventure_location; SHOW CREATE TABLE vcore_clientless_world_point; SELECT category,intent,weight FROM vcore_adventure_location_intent ORDER BY category,intent;"""
elif op=='apply':
query='START TRANSACTION;\n'+Path('/home/wow_admin/wow_cata_server/source/TrinityCore/sql/custom/world/2026_10_27_03_adventure_economy.sql').read_text()+"\nSELECT w.point_key,w.category,w.position_x,w.position_y,w.position_z FROM vcore_clientless_world_point w WHERE w.point_key LIKE 'stormwind_economy_%'; SELECT a.action_key,a.requirement,i.weight FROM vcore_adventure_action a JOIN vcore_adventure_action_intent i USING(action_key) WHERE i.intent='economy'; COMMIT;"
else:raise SystemExit('inspect or apply only')
r=subprocess.run(args,input=query,text=True,capture_output=True,env=env)
if op=='catalog' and not r.returncode:
import hashlib
Path('/tmp/vcore-import-catalog-current.tsv').write_text(r.stdout)
print('Catalog snapshot:',len(r.stdout.splitlines())-1,'records; SHA256',hashlib.sha256(r.stdout.encode()).hexdigest())
elif op=='state' and not r.returncode:
import hashlib
snapshot=Path('/tmp/vcore-economy-state-current.txt');snapshot.write_text(r.stdout)
print('Arthoran persisted money/inventory SHA256:',hashlib.sha256(r.stdout.encode()).hexdigest())
else:print(r.stdout,end='')
if r.stderr:print(r.stderr.replace(password,'[redacted]'),file=sys.stderr,end='')
raise SystemExit(r.returncode)