Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion tests/test_btd_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def prepare(self):

def test_original_assets_not_modified_or_decompiled(self):
record = self.prepare()
self.assertEqual(record['maps'], ['mp_crash'])
self.assertEqual(record['maps'], ['mp_crash', 'mp_killhouse'])
self.assertEqual((self.output / 'mods/btd_alpha_001/btd_maprotation.cfg').read_bytes(),
(self.source / 'btd_alpha_001/btd_maprotation.cfg').read_bytes())
self.assertEqual(record['asset_type'], 'btd-alpha-001')
self.assertEqual((self.output / 'mods/btd_alpha_001/mod.ff').read_bytes(), self.fastfile)
self.assertFalse((self.output / 'mods/btd_alpha_001/server.cfg').exists())
Expand Down Expand Up @@ -125,6 +127,15 @@ def test_only_pinned_killhouse_terminal_check_changes(self):
self.assertEqual(record['navigation_source_sha256'], hashlib.sha256(self.navigation_raw).hexdigest())
self.assertEqual(len(record['overlays']), 3)

def test_unpinned_navigation_blocks_map_declaration(self):
lock_path = self.root / 'tools/btd/dependencies.json'
lock = json.loads(lock_path.read_text())
lock['navigation_source_sha256'] = '0' * 64
lock_path.write_text(json.dumps(lock))
with self.assertRaisesRegex(ValueError, 'source hash mismatch'):
self.prepare()
self.assertFalse(self.output.exists())

def test_unpinned_navigation_rejected(self):
with self.assertRaisesRegex(ValueError, 'source hash mismatch'):
btd.navigation_overlay(self.fastfile, '0' * 64)
Expand Down
9 changes: 7 additions & 2 deletions tools/btd/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,13 @@ def prepare(source, headers, binary, output):
shutil.copy2(binary, output / 'cod4x18_dedrun')
(output / 'cod4x18_dedrun').chmod(0o755)
rotation = (source / 'btd_alpha_001/btd_maprotation.cfg').read_text()
# The pinned navigation overlay above repairs Killhouse's terminal marker.
# Advertise it only after verified preparation; retain vendor map order/bytes.
maps = re.findall(r'\bmap (mp_[a-z0-9_]+)', rotation)
if 'mp_killhouse' not in maps:
maps.append('mp_killhouse')
record = {'asset_type': 'btd-alpha-001', 'fs_game': 'mods/btd_alpha_001',
'maps': re.findall(r'\bmap (mp_[a-z0-9_]+)', rotation),
'maps': maps,
'binary_sha256': binary_hash, 'headers': header_lock,
'assets': {Path(k).name: v for k, v in lock['files'].items()
if k.startswith('btd_alpha_001/') and Path(k).name != 'server.cfg'},
Expand All @@ -149,7 +154,7 @@ def prepare(source, headers, binary, output):
'spawn_points_source_sha256': lock['spawn_points_source_sha256'],
'navigation_source_sha256': lock['navigation_source_sha256'],
'dependency_lock_sha256': digest(ROOT / 'tools/btd/dependencies.json'),
'qualification': 'original package map list; gameplay qualification is separate'}
'qualification': 'original package maps plus repaired Killhouse; gameplay qualification is separate'}
(output / 'inputs.json').write_text(json.dumps(record, indent=2) + '\n')
return record

Expand Down
Loading