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:
1 parent
5c2ac8e70f
commit
db788a2739
50 files changed
+3522
-1100
No files matched your search
@@ -10,6 +10,7 @@
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
using namespace top_octane;
|
||||
|
||||
@@ -1082,5 +1083,232 @@ int main() {
|
||||
}
|
||||
std::cout << "[PASS] All 9 tracks 8-racer AI anti-stuck & progression validated\n";
|
||||
|
||||
// 12. Manual Track Recovery from pit, HUD stuck hint, anti-exploit, and SplitScreen P2
|
||||
{
|
||||
sim::RaceSetup rs;
|
||||
rs.mode = sim::GameMode::SingleRace;
|
||||
rs.track_number = 1;
|
||||
rs.num_ai = 0;
|
||||
rs.fuel_enabled = true;
|
||||
|
||||
sim::RaceSim rsim;
|
||||
CHECK(rsim.start_race(lvl1, rs));
|
||||
// Still in countdown -> cannot trigger manual recovery
|
||||
CHECK(!rsim.request_track_recovery(0));
|
||||
for (int t = 0; t < 200; ++t) rsim.step(CraftInput{}, CraftInput{}, dt);
|
||||
|
||||
auto& p1 = rsim.crafts_mut()[0];
|
||||
p1.curr_pose.pos = Vec3(32.5f, lvl1.sample_height_world(32.5f, 57.5f) + 0.28f, 57.5f);
|
||||
p1.curr_pose.yaw = kHalfPi;
|
||||
p1.prev_pose = p1.curr_pose;
|
||||
p1.vel = Vec3(0.0f, 0.0f, 0.0f);
|
||||
p1.next_checkpoint = 1;
|
||||
p1.shield = p1.max_shield * 0.50f;
|
||||
p1.ammo = p1.max_ammo * 0.40f;
|
||||
p1.fuel = 42.0f;
|
||||
|
||||
// Driving trapped inside pit triggers HUD stuck hint after ~2.0s
|
||||
CraftInput drive_fwd;
|
||||
drive_fwd.throttle = 1.0f;
|
||||
for (int t = 0; t < 135; ++t) rsim.step(drive_fwd, CraftInput{}, dt);
|
||||
CHECK(p1.curr_pose.pos.y < 0.0f);
|
||||
CHECK(p1.stuck_in_pit_hint);
|
||||
|
||||
const float pre_shield = p1.shield;
|
||||
const float pre_ammo = p1.ammo;
|
||||
const float pre_fuel = p1.fuel;
|
||||
|
||||
// Press manual recover key
|
||||
rsim.clear_events();
|
||||
CraftInput rec_in;
|
||||
rec_in.recover_pressed = true;
|
||||
rsim.step(rec_in, CraftInput{}, dt);
|
||||
CHECK(p1.recovery_state == sim::RecoveryState::CallingRepair);
|
||||
CHECK(!p1.recovery_refill);
|
||||
CHECK(!p1.stuck_in_pit_hint);
|
||||
CHECK(!sim::get_recovery_visuals(rsim.crafts()).empty());
|
||||
|
||||
bool saw_recovery_banner = false;
|
||||
for (const auto& ev : rsim.events()) {
|
||||
if (ev.banner_text == "CALLING RECOVERY") saw_recovery_banner = true;
|
||||
}
|
||||
CHECK(saw_recovery_banner);
|
||||
|
||||
// Wait ~1.75s for manual recovery sequence (1.6s) to complete
|
||||
for (int t = 0; t < 105; ++t) rsim.step(CraftInput{}, CraftInput{}, dt);
|
||||
CHECK(p1.recovery_state == sim::RecoveryState::Active);
|
||||
CHECK(p1.deaths == 0);
|
||||
CHECK(p1.curr_pose.pos.y > 0.0f);
|
||||
CHECK(p1.curr_pose.pos.x < 25.0f);
|
||||
CHECK(p1.next_checkpoint == 1);
|
||||
CHECK(!p1.stuck_in_pit_hint);
|
||||
int px = static_cast<int>(std::floor(p1.curr_pose.pos.x));
|
||||
int pz = static_cast<int>(std::floor(p1.curr_pose.pos.z));
|
||||
CHECK(!lvl1.is_cell_solid_at_point(px, pz, p1.curr_pose.pos.x,
|
||||
p1.curr_pose.pos.z, p1.curr_pose.pos.y));
|
||||
CHECK(!lvl1.is_cliff_blocking_at_y(px, pz, p1.curr_pose.pos.y));
|
||||
|
||||
// Resources were not freely topped off (anti-exploit)
|
||||
CHECK(std::abs(p1.shield - pre_shield) < 0.01f);
|
||||
CHECK(std::abs(p1.ammo - pre_ammo) < 0.01f);
|
||||
CHECK(p1.fuel <= pre_fuel + 0.01f);
|
||||
CHECK(p1.fuel < p1.max_fuel * 0.6f);
|
||||
|
||||
// Cooldown prevents instant spam right after recovery completes
|
||||
CHECK(p1.recovery_cooldown > 0.5f);
|
||||
rsim.step(rec_in, CraftInput{}, dt);
|
||||
CHECK(p1.recovery_state == sim::RecoveryState::Active);
|
||||
|
||||
// Finished craft cannot recover
|
||||
p1.finished = true;
|
||||
CHECK(!rsim.request_track_recovery(0));
|
||||
|
||||
// SplitScreen P2 manual recovery & emergency minimal fuel floor (<5 -> 8)
|
||||
sim::RaceSetup ss;
|
||||
ss.mode = sim::GameMode::SplitScreen;
|
||||
ss.track_number = 1;
|
||||
ss.num_ai = 0;
|
||||
ss.fuel_enabled = true;
|
||||
sim::RaceSim ssim;
|
||||
CHECK(ssim.start_race(lvl1, ss));
|
||||
for (int t = 0; t < 200; ++t) ssim.step(CraftInput{}, CraftInput{}, dt);
|
||||
|
||||
auto& s_p2 = ssim.crafts_mut()[1];
|
||||
s_p2.curr_pose.pos = Vec3(32.5f, lvl1.sample_height_world(32.5f, 57.5f) + 0.28f, 57.5f);
|
||||
s_p2.prev_pose = s_p2.curr_pose;
|
||||
s_p2.next_checkpoint = 1;
|
||||
s_p2.fuel = 1.0f;
|
||||
|
||||
ssim.step(CraftInput{}, rec_in, dt);
|
||||
CHECK(s_p2.recovery_state == sim::RecoveryState::CallingRepair);
|
||||
for (int t = 0; t < 110; ++t) ssim.step(CraftInput{}, CraftInput{}, dt);
|
||||
CHECK(s_p2.recovery_state == sim::RecoveryState::Active);
|
||||
CHECK(s_p2.curr_pose.pos.y > 0.0f);
|
||||
CHECK(s_p2.curr_pose.pos.x < 25.0f);
|
||||
CHECK(s_p2.fuel >= 5.0f && s_p2.fuel < 15.0f);
|
||||
CHECK(ssim.request_track_recovery(0));
|
||||
}
|
||||
std::cout << "[PASS] Manual Track Recovery from pit, stuck prompt, anti-exploit & SplitScreen P2 validated\n";
|
||||
|
||||
// 13. Step dt safety, Track 6 off-track AI recovery, DamageCraft & Level 9 morph & save fuzzing
|
||||
{
|
||||
// 13a. RaceSim::step ignores dt <= 0 and NaN cleanly
|
||||
sim::RaceSetup rs;
|
||||
rs.mode = sim::GameMode::SingleRace;
|
||||
rs.track_number = 1;
|
||||
rs.num_ai = 1;
|
||||
sim::RaceSim sim0;
|
||||
CHECK(sim0.start_race(lvl1, rs));
|
||||
for (int t = 0; t < 200; ++t) sim0.step(CraftInput{}, CraftInput{}, dt);
|
||||
const Vec3 p_before = sim0.crafts()[0].curr_pose.pos;
|
||||
sim0.step(CraftInput{0.5f, 1.0f}, CraftInput{}, 0.0f);
|
||||
sim0.step(CraftInput{0.5f, 1.0f}, CraftInput{}, -0.1f);
|
||||
sim0.step(CraftInput{0.5f, 1.0f}, CraftInput{}, std::numeric_limits<float>::quiet_NaN());
|
||||
CHECK((sim0.crafts()[0].curr_pose.pos - p_before).len_sq() < 1e-8f);
|
||||
|
||||
// 13b. AI circling behind Track 6 perimeter berm recovers via ai_wp_stall_timer in < 10s
|
||||
assets::LevelData lvl6;
|
||||
CHECK(lvl6.load(vfs, 6));
|
||||
sim::RaceSetup rs6;
|
||||
rs6.mode = sim::GameMode::SingleRace;
|
||||
rs6.track_number = 6;
|
||||
rs6.num_ai = 1;
|
||||
sim::RaceSim sim6;
|
||||
CHECK(sim6.start_race(lvl6, rs6));
|
||||
sim6.crafts_mut()[0].autopilot = true;
|
||||
for (int t = 0; t < 200; ++t) sim6.step(CraftInput{}, CraftInput{}, dt);
|
||||
auto& ai6 = sim6.crafts_mut()[1];
|
||||
ai6.curr_pose.pos = Vec3(78.0f, lvl6.sample_height_world(78.0f, 15.0f) + 0.25f, 15.0f);
|
||||
ai6.prev_pose = ai6.curr_pose;
|
||||
ai6.vel = Vec3(5.0f, 0.0f, 0.0f);
|
||||
ai6.current_wp = 0;
|
||||
ai6.ai_target_wp = 1;
|
||||
ai6.next_checkpoint = 1;
|
||||
ai6.ai_stuck_timer = 0.0f;
|
||||
ai6.ai_progress_timer = 0.0f;
|
||||
ai6.ai_wp_stall_timer = 0.0f;
|
||||
ai6.ai_wp_best_dist = 1e9f;
|
||||
bool recovered = false;
|
||||
for (int t = 0; t < 600; ++t) {
|
||||
sim6.step(CraftInput{}, CraftInput{}, dt);
|
||||
if (ai6.checkpoints_passed >= 1 || ai6.curr_pose.pos.x > 84.0f || ai6.curr_pose.pos.z < 10.0f) {
|
||||
recovered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CHECK(recovered);
|
||||
|
||||
// 13c. Invincible craft takes zero weapon/barrel damage & never heals from negative damage
|
||||
{
|
||||
std::vector<sim::CraftState> cvec(2);
|
||||
cvec[0].id = 0; cvec[0].recovery_state = sim::RecoveryState::Active;
|
||||
cvec[0].curr_pose.pos = Vec3(10.0f, lvl1.sample_height_world(10.0f, 10.0f) + 0.25f, 10.0f);
|
||||
cvec[0].prev_pose = cvec[0].curr_pose;
|
||||
cvec[0].shield = 25.0f; cvec[0].max_shield = 100.0f;
|
||||
cvec[0].invincible_timer = 3.0f;
|
||||
cvec[1].id = 1; cvec[1].recovery_state = sim::RecoveryState::Active;
|
||||
cvec[1].curr_pose.pos = cvec[0].curr_pose.pos + Vec3(0.0f, 0.0f, -2.0f);
|
||||
cvec[1].prev_pose = cvec[1].curr_pose;
|
||||
std::vector<sim::Projectile> pjs;
|
||||
sim::Projectile prj;
|
||||
prj.active = true; prj.owner_id = 1; prj.damage = 40.0f;
|
||||
prj.pos = cvec[0].curr_pose.pos + Vec3(0.0f, 0.0f, -0.5f);
|
||||
prj.vel = Vec3(0.0f, 0.0f, 60.0f);
|
||||
pjs.push_back(prj);
|
||||
std::vector<sim::PickupItem> pks;
|
||||
std::vector<sim::PropObject> prs;
|
||||
std::vector<sim::ParticleBurst> pts;
|
||||
std::vector<sim::SimEvent> evs;
|
||||
std::vector<CraftInput> ins(2);
|
||||
bool ro = false;
|
||||
int wid = -1;
|
||||
sim::step_combat_and_world(rs, lvl1, cvec, ins, pjs, pks, prs, pts, evs, ro, wid, dt);
|
||||
CHECK(std::abs(cvec[0].shield - 25.0f) < 1e-4f);
|
||||
}
|
||||
|
||||
// 13d. Level 9 st=23 grp=1 permanent morph does not auto-activate and blank arena cells
|
||||
assets::LevelData lvl9;
|
||||
CHECK(lvl9.load(vfs, 9));
|
||||
sim::RaceSetup rs9;
|
||||
rs9.mode = sim::GameMode::DeathMatch;
|
||||
rs9.track_number = 9;
|
||||
rs9.num_ai = 3;
|
||||
sim::RaceSim sim9;
|
||||
CHECK(sim9.start_race(lvl9, rs9));
|
||||
for (int t = 0; t < 600; ++t) sim9.step(CraftInput{}, CraftInput{}, dt);
|
||||
int nontriv_arena_cells = 0;
|
||||
for (const auto& pad : sim9.level().pads) {
|
||||
int cx = static_cast<int>(std::floor(pad.cx));
|
||||
int cz = static_cast<int>(std::floor(pad.cz));
|
||||
const auto& cell = sim9.level().cell(cx, cz);
|
||||
if (cell.tex_or_col != 0) ++nontriv_arena_cells;
|
||||
}
|
||||
CHECK(nontriv_arena_cells == static_cast<int>(sim9.level().pads.size()));
|
||||
|
||||
// 13e. Corrupt/malformed save files safely rejected without mutating valid state
|
||||
std::filesystem::path bad_dir = std::filesystem::temp_directory_path() / "top_octane_bad_saves";
|
||||
std::filesystem::create_directories(bad_dir);
|
||||
{
|
||||
std::ofstream ofs(bad_dir / "hiscores.dat");
|
||||
ofs << "HIOCTANE_HISCORES_V2\n"
|
||||
<< "TRACK 1 nan 1 DEADFISH 999\n";
|
||||
}
|
||||
game::HighscoreTable ht;
|
||||
ht.load(bad_dir / "hiscores.dat");
|
||||
for (const auto& rec : ht.tracks) {
|
||||
CHECK(std::isfinite(rec.best_lap));
|
||||
CHECK(std::isfinite(rec.best_race));
|
||||
}
|
||||
{
|
||||
std::ofstream ofs(bad_dir / "clone_t1.dat");
|
||||
ofs << "INVALID_MAGIC 1 -9 99 nan 9999999\n";
|
||||
}
|
||||
sim::CloneRecording cre;
|
||||
CHECK(!game::load_clone_recording(bad_dir, 1, cre));
|
||||
std::filesystem::remove_all(bad_dir);
|
||||
|
||||
std::cout << "[PASS] Gameplay dt/AI-basin/invincible/Level9-morph & save hardening validated\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user