aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


tools/client/prepare_portable_assets.py (1581B)


      1 """Copy the game's data and configuration without Windows executable files."""
      2 import pathlib
      3 import shutil
      4 
      5 
      6 root = pathlib.Path(__file__).resolve().parents[2]
      7 source = root / 'anarchy-runtime-14.9.1'
      8 destination = root / 'anarchy-assets-14.9.1'
      9 assert not destination.exists(), '%s already exists' % destination
     10 
     11 # Keep world data for every playfield, but no launcher, patcher or audio plug-ins.
     12 directories = [
     13     'cd_image/data/db', 'cd_image/data/Statels', 'cd_image/data/Shadows',
     14     'cd_image/OCC', 'cd_image/text', 'cd_image/textures',
     15     'cd_image/sound/music', 'cd_image/sound/sfx', 'cd_image/sound/voice',
     16     'cd_image/sound/SourceFiles', 'Setupf', 'fonts',
     17 ]
     18 files = [source / name for name in ['Prefs/Main.cfg', 'Prefs/localtest/Login.cfg', 'version.id',
     19                                   'CharCreateCamera.dat']]
     20 for name in directories:
     21     files.extend(path for path in (source / name).rglob('*') if path.is_file())
     22 
     23 # Check contents too: Miles plug-ins use .flt, .asi and .m3d rather than .dll.
     24 for path in files:
     25     assert path.suffix.lower() not in ['.exe', '.dll', '.com', '.asi', '.flt', '.m3d'], path
     26     with path.open('rb') as file:
     27         magic = file.read(4)
     28     assert magic[:2] != b'MZ' and magic != b'\x7fELF', path
     29 for path in files:
     30     target = destination / path.relative_to(source)
     31     target.parent.mkdir(parents=True, exist_ok=True)
     32     shutil.copy2(path, target)
     33 (destination / 'Screenshots').mkdir()
     34 print('Prepared %s: %d data/configuration files, %d bytes' % (
     35     destination, len(files), sum(path.stat().st_size for path in files)))