Add track recovery, fix Arctic Land bridge & 9-map sim/render, harden security & optimize runtime

- Add manual track recovery (R / Backspace / Gamepad Back), document controls in README.md, fix Track 8 (Arctic Land) bridge jump/clearance physics, and fix Track 5 respawn invincibility & Track 6 off-track AI recovery across all 9 maps
- Verify 9-map sector morphing, combat (swept projectiles/LOS), pitstop chargers, and overpass/bridge surface sampling
- Fix Overpass Bottom (-Y) diagonal split and AO, add TerrainChunk frustum culling, O(1) 3D Classic uPaletteLut, atlas gutter/bleed UVs, cached uniform locations, and reusable render scratch buffers
- Harden VFS path traversal, RNC decompression bombs/truncated headers, asset/WAV parsers, GameConfig, save loaders, CLI args, and FLIC lifecycle
- Optimize 48 kHz OPL3/SoundFont synthesis (trig LUTs, cached envelopes/filters), 64-bit XMI ticks, and audio parameter/thread safety
- Add security, rendering, physics, and gameplay regression tests across all test suites
This commit is contained in:
Luxferre committed 2026-12-01 18:50:29 +02:00
1 parent 5c2ac8e70f
commit db788a2739
50 files changed
+3522 -1100

No files matched your search

+98
View File
@@ -15,7 +15,9 @@
#include <cstdio>
#include <cstdlib>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <limits>
#include <optional>
using namespace top_octane;
@@ -386,5 +388,101 @@ int main() {
std::cout << "[PASS] Vfs relocatable & XDG data directory lookup validated\n";
}
// 9. GameConfig recovery keybindings defaults & persistence round-trip
{
GameConfig def_cfg;
CHECK(def_cfg.keys.recover == 21);
CHECK(def_cfg.keys.p2_recover == 42);
std::filesystem::path tmp_ini = std::filesystem::temp_directory_path() / "top_octane_test_config.ini";
std::filesystem::remove(tmp_ini);
GameConfig saved_cfg;
saved_cfg.keys.recover = 29; // Z
saved_cfg.keys.p2_recover = 76; // Delete
CHECK(saved_cfg.save(tmp_ini));
GameConfig loaded_cfg;
CHECK(loaded_cfg.load(tmp_ini));
CHECK(loaded_cfg.keys.recover == 29);
CHECK(loaded_cfg.keys.p2_recover == 76);
std::filesystem::remove(tmp_ini);
std::cout << "[PASS] GameConfig keybinding persistence validated\n";
}
// 10. Security hardening (VFS traversal, RNC1/RNC2 bombs & truncation, WAV, corrupt config)
{
std::vector<uint8_t> tmp_buf;
CHECK(!vfs.exists("../Makefile"));
CHECK(!vfs.exists("/etc/passwd"));
CHECK(!vfs.read_file("../Makefile", tmp_buf));
CHECK(!vfs.read_file("/etc/passwd", tmp_buf));
// RNC1 bomb (> 32 MiB) & truncated RNC1/RNC2 headers
const std::vector<uint8_t> rnc1_bomb = {
'R', 'N', 'C', 1, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10, 0, 0, 0, 0, 0, 0
};
const std::vector<uint8_t> rnc1_trunc = {
'R', 'N', 'C', 1, 0x00, 0x00, 0x00, 0x20,
0x00, 0x00, 0x00, 0x10, 0, 0
};
const std::vector<uint8_t> rnc2_bomb = {
'R', 'N', 'C', 2, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10, 0, 0, 0, 0, 0, 0
};
const std::vector<uint8_t> rnc2_trunc = {
'R', 'N', 'C', 2, 0x00, 0x00, 0x00, 0x10,
0x00, 0x00, 0x00, 0x04, 0, 0, 0, 0, 0, 0
};
CHECK(!rnc_unpack(rnc1_bomb, tmp_buf));
CHECK(!rnc_unpack(rnc1_trunc, tmp_buf));
CHECK(!rnc_unpack(rnc2_bomb, tmp_buf));
CHECK(!rnc_unpack(rnc2_trunc, tmp_buf));
// Invalid WAV / empty buffers
SoundSample bad_wav_out;
const std::vector<uint8_t> garbage_wav = {'R', 'I', 'F', 'F', 12, 0, 0, 0, 'W', 'A', 'V', 'E'};
CHECK(!decode_wav_bytes(nullptr, 0, bad_wav_out));
CHECK(!decode_wav_bytes(garbage_wav.data(), garbage_wav.size(), bad_wav_out));
// Corrupt GameConfig (NaN/Inf/out-of-range/path-traversal) rejected/sanitized cleanly
std::filesystem::path bad_ini = std::filesystem::temp_directory_path() / "top_octane_bad_cfg.ini";
{
std::ofstream ofs(bad_ini);
ofs << "fov_deg = nan\n"
<< "draw_distance = inf\n"
<< "master_volume = -inf\n"
<< "key_recover = -9\n"
<< "key_p2_recover = 99999\n"
<< "custom_soundfont_path = ../evil.sf2\n";
}
GameConfig bad_cfg;
CHECK(bad_cfg.load(bad_ini));
CHECK(std::isfinite(bad_cfg.fov_deg) && bad_cfg.fov_deg >= 50.0f && bad_cfg.fov_deg <= 105.0f);
CHECK(std::isfinite(bad_cfg.draw_distance) && bad_cfg.draw_distance >= 30.0f);
CHECK(std::isfinite(bad_cfg.master_volume) && bad_cfg.master_volume >= 0.0f && bad_cfg.master_volume <= 1.0f);
CHECK(bad_cfg.keys.recover == 21);
CHECK(bad_cfg.keys.p2_recover == 42);
CHECK(bad_cfg.custom_soundfont_path.empty());
std::filesystem::remove(bad_ini);
std::cout << "[PASS] VFS traversal, RNC bombs, invalid WAV & corrupt GameConfig hardening validated\n";
}
// 11. LevelData::sample_entity_surface_y on L6 skybridge, L8 bridge/archway, L9 alcove
{
LevelData lvl6, lvl8, lvl9;
CHECK(lvl6.load(vfs, 6));
CHECK(lvl8.load(vfs, 8));
CHECK(lvl9.load(vfs, 9));
CHECK(lvl6.sample_entity_surface_y(90.5f, 39.5f) >= 2.9f);
CHECK(lvl6.sample_entity_surface_y(87.5f, 39.5f) >= 2.9f);
CHECK(lvl8.sample_entity_surface_y(75.5f, 70.5f) >= 1.9f);
CHECK(lvl8.sample_entity_surface_y(46.5f, 19.5f) < 0.5f);
CHECK(lvl9.sample_entity_surface_y(10.0f, 88.0f) < 0.8f);
std::cout << "[PASS] LevelData::sample_entity_surface_y bridge/archway/alcove heights validated\n";
}
return 0;
}