51 lines
2.5 KiB
Python
51 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate include/gateway/wmo_game_object_displays.hpp: every GameObjectDisplayInfo row whose model is a WMO.
|
|
|
|
70334 loads a game object's model as WMO only when the server sets GO_FLAG_MAP_OBJECT (0x00100000; TrinityCore:
|
|
"pre-7.0 model loading used to be controlled by file extension"). Turtle's 1.12 server never sends it, so without this
|
|
list the client parses the WMO root as an M2 and crashes (ACCESS_VIOLATION reading MD21 flags, ships/zeppelins
|
|
2026-11-24). Rerun after any GameObjectDisplayInfo import.
|
|
|
|
gen_wmo_displays.py <GameObjectDisplayInfo.csv (DBCD dump of the live client table)> <out.hpp>
|
|
A display counts when its FileDataID's file in the client store starts with the WMO root magic ('REVM').
|
|
"""
|
|
import csv, sys
|
|
sys.path.insert(0, '/mnt/Games/@project/gateway/runtime/continuation-20261113/claude-lane/parity/recipes-20261122')
|
|
import client_read # reads the live client CASC store by FileDataID
|
|
|
|
def main():
|
|
names = {} # community listfile: only .wmo-named or unnamed files need a read (M2/other names cannot be WMO roots)
|
|
for l in open('/mnt/Games/@project/listfiles/community-listfile.csv', encoding='utf-8', errors='replace'):
|
|
a, _, b = l.strip().partition(';')
|
|
if a.isdigit(): names[int(a)] = b.lower()
|
|
rows = list(csv.DictReader(open(sys.argv[1]))); seen = {}; ids = []
|
|
for r in rows:
|
|
f = int(r['FileDataID'])
|
|
if not f: continue
|
|
if f not in seen and names.get(f, '.wmo').rsplit('.', 1)[-1] != 'wmo': seen[f] = False
|
|
if f not in seen:
|
|
try: seen[f] = client_read.read_fdid(f)[:4] == b'REVM'
|
|
except Exception: seen[f] = False
|
|
if seen[f]: ids.append(int(r['ID']))
|
|
ids = sorted(set(ids))
|
|
body = ',\n '.join(', '.join(map(str, ids[i:i + 12])) for i in range(0, len(ids), 12))
|
|
open(sys.argv[2], 'w').write(f'''// Generated by ops/wmo-displays/gen_wmo_displays.py from the live 70334 GameObjectDisplayInfo ({len(rows)} rows).
|
|
// Displays whose model file is a WMO root: the create must carry GO_FLAG_MAP_OBJECT or 70334 loads it as an M2.
|
|
#pragma once
|
|
#include <algorithm>
|
|
#include <cstdint>
|
|
#include <iterator>
|
|
namespace gateway {{
|
|
inline constexpr uint32_t GO_FLAG_MAP_OBJECT=0x00100000u;
|
|
inline constexpr uint32_t WmoGameObjectDisplays[]={{
|
|
{body}
|
|
}};
|
|
constexpr bool turtle_wmo_game_object_display(uint32_t display){{
|
|
return std::binary_search(std::begin(WmoGameObjectDisplays),std::end(WmoGameObjectDisplays),display);
|
|
}}
|
|
}}
|
|
''')
|
|
print(len(ids), 'WMO displays ->', sys.argv[2])
|
|
|
|
if __name__ == '__main__': main()
|