1:1 source port of the engine and game code; Windows build and system layer; docs. No game files or SDK headers.
This commit is contained in:
parent
c3b032a45a
commit
0ecb47e9cb
3871 changed files with 91080 additions and 1640063 deletions
29
tools/port/gen_particles.py
Normal file
29
tools/port/gen_particles.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"""Generate port/src/core/particles.h: gparticles, the precompiled Lua 5.0 chunk "particles.lua" (the particle
|
||||
script helpers: CreateValue, CompileParameters, the Lua side of the particle language) that
|
||||
TLuaParticleSystem::NewScript runs with lua_dobuffer(L, gparticles, 0x20d2, "particles.lua") when it creates a
|
||||
script, copied byte for byte from the shipped game binary (__data @0x001d9700, symbol _gparticles, 0x20d2 bytes;
|
||||
the size is the immediate of the lua_dobuffer call at game 0x0009b7e9).
|
||||
usage: python3 tools/port/gen_particles.py"""
|
||||
import os, re, subprocess
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
B = os.path.expanduser("~/Library/Application Support/Steam/steamapps/common/Chocolatier Decadence by Design/chocolatier-decadence-design.app/Contents/MacOS/chocolatier-decadence-design")
|
||||
ADDR, SIZE = 0x1d9700, 0x20d2
|
||||
out = subprocess.run(['otool', '-arch', 'i386', '-l', B], capture_output=True, text=True).stdout
|
||||
data = open(B, 'rb').read()
|
||||
blob = None
|
||||
for m in re.finditer(r'sectname (\S+)\n\s+segname (\S+)\n\s+addr (0x[0-9a-f]+)\n\s+size (0x[0-9a-f]+)\n\s+offset (\d+)', out):
|
||||
s, sz, off = int(m.group(3), 16), int(m.group(4), 16), int(m.group(5))
|
||||
if s <= ADDR < s + sz:
|
||||
blob = data[off + ADDR - s: off + ADDR - s + SIZE]
|
||||
break
|
||||
assert blob is not None and len(blob) == SIZE and blob[:5] == b'\x1bLuaP'
|
||||
lines = ['// Generated by tools/port/gen_particles.py from the game binary (__data @0x001d9700, 0x20d2 bytes). Do not edit.',
|
||||
'// gparticles: the precompiled Lua chunk "particles.lua" (the particle script language helpers) that',
|
||||
'// TLuaParticleSystem::NewScript runs in every script it creates. Included by luaparticlesystem.cpp only.',
|
||||
'#ifndef PARTICLES_H_INCLUDED', '#define PARTICLES_H_INCLUDED', '',
|
||||
'unsigned char gparticles[%d] = {' % SIZE]
|
||||
for i in range(0, SIZE, 24):
|
||||
lines.append(' ' + ','.join('0x%02x' % b for b in blob[i:i + 24]) + ',')
|
||||
lines += ['};', '', '#endif // PARTICLES_H_INCLUDED', '']
|
||||
open(os.path.join(ROOT, 'port/src/core/particles.h'), 'w').write('\n'.join(lines))
|
||||
print('wrote port/src/core/particles.h', SIZE, 'bytes')
|
||||
Loading…
Add table
Add a link
Reference in a new issue