2026-11-30 22:31:51 +02:00
|
|
|
#include "assets/level.hpp"
|
|
|
|
|
#include "core/clock.hpp"
|
|
|
|
|
#include "core/vfs.hpp"
|
|
|
|
|
#include "game/game_modes.hpp"
|
|
|
|
|
#include "sim/combat.hpp"
|
|
|
|
|
#include "sim/race_sim.hpp"
|
|
|
|
|
|
|
|
|
|
#include <filesystem>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
using namespace top_octane;
|
|
|
|
|
|
|
|
|
|
#define CHECK(cond) \
|
|
|
|
|
do { \
|
|
|
|
|
if (!(cond)) { \
|
|
|
|
|
std::cerr << "FAIL [" << __FILE__ << ":" << __LINE__ << "]: " #cond << "\n"; \
|
|
|
|
|
return 1; \
|
|
|
|
|
} \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
Vfs vfs;
|
|
|
|
|
CHECK(vfs.init(HIOCTANE_DEFAULT_DATA_DIR));
|
|
|
|
|
|
|
|
|
|
assets::LevelData lvl1;
|
|
|
|
|
CHECK(lvl1.load(vfs, 1));
|
|
|
|
|
float dt = static_cast<float>(FixedStepClock::kFixedDt);
|
|
|
|
|
|
|
|
|
|
// 1. Multi-AI Race Simulation (8 racers, 1 lap) + Combat + Pickups
|
|
|
|
|
sim::RaceSetup setup;
|
|
|
|
|
setup.mode = sim::GameMode::SingleRace;
|
|
|
|
|
setup.track_number = 1;
|
|
|
|
|
setup.total_laps = 1;
|
|
|
|
|
setup.difficulty = 2; // Hard AI with weapons & boosting
|
|
|
|
|
setup.num_ai = 7;
|
|
|
|
|
|
|
|
|
|
sim::RaceSim sim;
|
|
|
|
|
CHECK(sim.start_race(lvl1, setup));
|
|
|
|
|
sim.crafts_mut()[0].autopilot = true;
|
|
|
|
|
|
|
|
|
|
int total_shots = 0;
|
|
|
|
|
for (int t = 0; t < 4000 && !sim.race_finished(); ++t) {
|
|
|
|
|
CraftInput in;
|
|
|
|
|
in.fire_minigun = (t % 20 == 0);
|
|
|
|
|
sim.step(in, CraftInput{}, dt);
|
|
|
|
|
}
|
|
|
|
|
for (const auto& c : sim.crafts()) {
|
|
|
|
|
total_shots += c.shots_fired;
|
|
|
|
|
}
|
|
|
|
|
CHECK(sim.crafts()[0].finished);
|
|
|
|
|
CHECK(total_shots > 0);
|
|
|
|
|
std::cout << "[PASS] 8-racer AI & combat race finished in " << sim.crafts()[0].race_time
|
|
|
|
|
<< "s (placement=" << sim.crafts()[0].placement << ", total_shots=" << total_shots << ")\n";
|
|
|
|
|
|
|
|
|
|
// 2. Clone Race Ghost Recording & Playback
|
|
|
|
|
sim::CloneRecording rec = sim.current_recording();
|
|
|
|
|
CHECK(rec.frames.size() > 100);
|
|
|
|
|
{
|
|
|
|
|
sim::RaceSetup csetup;
|
|
|
|
|
csetup.mode = sim::GameMode::CloneRace;
|
|
|
|
|
csetup.track_number = 1;
|
|
|
|
|
csetup.total_laps = 1;
|
|
|
|
|
sim::RaceSim csim;
|
|
|
|
|
CHECK(csim.start_race(lvl1, csetup, &rec));
|
|
|
|
|
CHECK(csim.has_clone_ghost());
|
|
|
|
|
for (int t = 0; t < 240; ++t) {
|
|
|
|
|
csim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
}
|
|
|
|
|
sim::CraftPose gpose = csim.interpolated_clone_pose(0.5f);
|
|
|
|
|
CHECK(gpose.pos.len_sq() > 0.1f);
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] Clone Race ghost recording & playback validated\n";
|
|
|
|
|
|
|
|
|
|
// 3. DeathMatch & Recovery Craft Repair Sequence
|
|
|
|
|
{
|
|
|
|
|
sim::RaceSetup dm;
|
|
|
|
|
dm.mode = sim::GameMode::DeathMatch;
|
|
|
|
|
dm.track_number = 1;
|
|
|
|
|
dm.num_ai = 3;
|
|
|
|
|
dm.deathmatch_kill_limit = 2;
|
|
|
|
|
sim::RaceSim dsim;
|
|
|
|
|
CHECK(dsim.start_race(lvl1, dm));
|
|
|
|
|
// Skip countdown
|
|
|
|
|
for (int t = 0; t < 200; ++t) dsim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
// Place victim directly in front of P1 and fire missile/minigun to test kill & recovery craft
|
|
|
|
|
auto& p1 = dsim.crafts_mut()[0];
|
|
|
|
|
auto& tgt = dsim.crafts_mut()[1];
|
|
|
|
|
Vec3 fwd = p1.forward_dir();
|
|
|
|
|
tgt.curr_pose.pos = p1.curr_pose.pos + fwd * 3.0f;
|
|
|
|
|
tgt.prev_pose = tgt.curr_pose;
|
|
|
|
|
tgt.shield = 5.0f;
|
|
|
|
|
|
|
|
|
|
for (int t = 0; t < 60; ++t) {
|
|
|
|
|
CraftInput fire;
|
|
|
|
|
fire.fire_minigun = true;
|
|
|
|
|
dsim.step(fire, CraftInput{}, dt);
|
|
|
|
|
}
|
|
|
|
|
CHECK(p1.kills >= 1);
|
|
|
|
|
CHECK(tgt.deaths >= 1);
|
|
|
|
|
auto rvis = sim::get_recovery_visuals(dsim.crafts());
|
|
|
|
|
CHECK(!rvis.empty());
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] DeathMatch kill scoring & Recovery Craft dispatch validated\n";
|
|
|
|
|
|
|
|
|
|
// 4. Championship Save / Load & Highscore Persistence in temp directory
|
|
|
|
|
std::filesystem::path tmp_dir = std::filesystem::temp_directory_path() / "top_octane_test_saves";
|
|
|
|
|
std::filesystem::remove_all(tmp_dir);
|
|
|
|
|
{
|
|
|
|
|
game::ChampionshipState ch;
|
|
|
|
|
ch.start_new("ACE", 3, 7, 1);
|
|
|
|
|
ch.record_race_results(sim.crafts());
|
|
|
|
|
CHECK(ch.current_track == 2);
|
|
|
|
|
CHECK(ch.save_slot(tmp_dir, 0));
|
|
|
|
|
|
|
|
|
|
game::ChampionshipState loaded;
|
|
|
|
|
CHECK(loaded.load_slot(tmp_dir, 0));
|
|
|
|
|
CHECK(loaded.current_track == 2);
|
|
|
|
|
CHECK(loaded.player_name == "ACE");
|
|
|
|
|
CHECK(loaded.drivers[0].points == ch.drivers[0].points);
|
|
|
|
|
|
|
|
|
|
game::HighscoreTable hs;
|
|
|
|
|
hs.clear();
|
|
|
|
|
int flags = hs.submit_race(1, sim.crafts());
|
|
|
|
|
CHECK((flags & 3) == 3);
|
|
|
|
|
CHECK(hs.save(tmp_dir / "hiscores.dat"));
|
|
|
|
|
|
|
|
|
|
game::HighscoreTable hs2;
|
|
|
|
|
CHECK(hs2.load(tmp_dir / "hiscores.dat"));
|
|
|
|
|
CHECK(hs2.tracks[0].best_lap == hs.tracks[0].best_lap);
|
|
|
|
|
CHECK(game::save_clone_recording(tmp_dir, rec));
|
|
|
|
|
|
|
|
|
|
sim::CloneRecording rec2;
|
|
|
|
|
CHECK(game::load_clone_recording(tmp_dir, 1, rec2));
|
|
|
|
|
CHECK(rec2.frames.size() == rec.frames.size());
|
|
|
|
|
}
|
|
|
|
|
std::filesystem::remove_all(tmp_dir);
|
|
|
|
|
std::cout << "[PASS] Championship save/load, Highscores & Clone disk round-trip validated\n";
|
|
|
|
|
|
2026-11-30 23:57:29 +02:00
|
|
|
// 5. Gameplay Rule Toggles (fuel, weapons, damage, pickups, track morphing)
|
|
|
|
|
{
|
|
|
|
|
sim::RaceSetup r1;
|
|
|
|
|
r1.mode = sim::GameMode::SingleRace;
|
|
|
|
|
r1.track_number = 1;
|
|
|
|
|
r1.num_ai = 1;
|
|
|
|
|
r1.fuel_enabled = false;
|
|
|
|
|
r1.weapons_enabled = false;
|
|
|
|
|
r1.pickups_enabled = false;
|
|
|
|
|
r1.track_morphing_enabled = false;
|
|
|
|
|
|
|
|
|
|
sim::RaceSim ts1;
|
|
|
|
|
CHECK(ts1.start_race(lvl1, r1));
|
|
|
|
|
CHECK(ts1.pickups().empty());
|
|
|
|
|
float start_fuel = ts1.crafts()[0].fuel;
|
|
|
|
|
// Skip countdown
|
|
|
|
|
for (int t = 0; t < 200; ++t) ts1.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
CraftInput drive;
|
|
|
|
|
drive.throttle = 1.0f;
|
|
|
|
|
drive.boost = true;
|
|
|
|
|
drive.fire_minigun = true;
|
|
|
|
|
drive.fire_missile = true;
|
|
|
|
|
for (int t = 0; t < 120; ++t) {
|
|
|
|
|
ts1.step(drive, CraftInput{}, dt);
|
|
|
|
|
CHECK(ts1.projectiles().empty());
|
|
|
|
|
}
|
|
|
|
|
CHECK(ts1.crafts()[0].fuel == start_fuel);
|
|
|
|
|
if (!lvl1.triggers.empty()) {
|
|
|
|
|
const auto& tr = lvl1.triggers[0];
|
|
|
|
|
ts1.crafts_mut()[0].curr_pose.pos = Vec3(
|
|
|
|
|
tr.tile_x() + 0.5f, lvl1.sample_height_world(tr.tile_x() + 0.5f, tr.tile_z() + 0.5f),
|
|
|
|
|
tr.tile_z() + 0.5f);
|
|
|
|
|
ts1.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
int x0, z0, x1, z1;
|
|
|
|
|
CHECK(!ts1.consume_terrain_dirty(x0, z0, x1, z1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// damage_enabled = false keeps target shields intact on direct hits
|
|
|
|
|
sim::RaceSetup r2;
|
|
|
|
|
r2.mode = sim::GameMode::DeathMatch;
|
|
|
|
|
r2.track_number = 1;
|
|
|
|
|
r2.num_ai = 1;
|
|
|
|
|
r2.damage_enabled = false;
|
|
|
|
|
sim::RaceSim ts2;
|
|
|
|
|
CHECK(ts2.start_race(lvl1, r2));
|
|
|
|
|
for (int t = 0; t < 200; ++t) ts2.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
auto& p1 = ts2.crafts_mut()[0];
|
|
|
|
|
auto& tgt = ts2.crafts_mut()[1];
|
|
|
|
|
Vec3 fwd = p1.forward_dir();
|
|
|
|
|
tgt.curr_pose.pos = p1.curr_pose.pos + fwd * 3.0f;
|
|
|
|
|
tgt.prev_pose = tgt.curr_pose;
|
|
|
|
|
float init_sh = tgt.shield;
|
|
|
|
|
for (int t = 0; t < 60; ++t) {
|
|
|
|
|
CraftInput fire;
|
|
|
|
|
fire.fire_minigun = true;
|
|
|
|
|
ts2.step(fire, CraftInput{}, dt);
|
|
|
|
|
}
|
|
|
|
|
CHECK(tgt.shield == init_sh);
|
|
|
|
|
CHECK(p1.kills == 0);
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] Gameplay rule toggles (fuel, weapons, damage, pickups, morphing) validated\n";
|
|
|
|
|
|
2026-12-01 08:05:04 +02:00
|
|
|
// 6. Authentic Sector Morphing across all 6 levels (Timed, Craft, Rocket triggers + columns/lights/pickups)
|
|
|
|
|
{
|
|
|
|
|
const size_t expected_morph_counts[6] = {1, 2, 5, 2, 7, 6};
|
|
|
|
|
for (int l = 1; l <= 6; ++l) {
|
|
|
|
|
assets::LevelData lvl;
|
|
|
|
|
CHECK(lvl.load(vfs, l));
|
|
|
|
|
CHECK(lvl.morphs.size() == expected_morph_counts[l - 1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 6a. Level 1: Timed morph id=66 lowers (17,32) 1504 -> 1184, then oscillates back to 1504
|
|
|
|
|
{
|
|
|
|
|
sim::RaceSetup ms;
|
|
|
|
|
ms.track_number = 1;
|
|
|
|
|
ms.num_ai = 0;
|
|
|
|
|
sim::RaceSim msim;
|
|
|
|
|
CHECK(msim.start_race(lvl1, ms));
|
|
|
|
|
CHECK(msim.level().cell(17, 32).height == 1504);
|
|
|
|
|
for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
for (int t = 0; t < 290; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
CHECK(msim.level().cell(17, 32).height == 1184);
|
|
|
|
|
for (int t = 0; t < 290; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
CHECK(msim.level().cell(17, 32).height == 1504);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 6b. Level 2: Craft trigger id=80 lowers & re-textures (109,20); Craft trigger id=198 unlocks grp=3 pickups
|
|
|
|
|
{
|
|
|
|
|
assets::LevelData lvl2;
|
|
|
|
|
CHECK(lvl2.load(vfs, 2));
|
|
|
|
|
sim::RaceSetup ms;
|
|
|
|
|
ms.track_number = 2;
|
|
|
|
|
ms.num_ai = 0;
|
|
|
|
|
sim::RaceSim msim;
|
|
|
|
|
CHECK(msim.start_race(lvl2, ms));
|
|
|
|
|
CHECK(msim.level().cell(109, 20).height == 2480);
|
|
|
|
|
CHECK(msim.level().cell(109, 20).tex_or_col == 72);
|
|
|
|
|
bool has_locked_g3 = false;
|
|
|
|
|
for (const auto& pk : msim.pickups()) {
|
|
|
|
|
if (pk.group == 3) {
|
|
|
|
|
has_locked_g3 = true;
|
|
|
|
|
CHECK(!pk.group_unlocked);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CHECK(has_locked_g3);
|
|
|
|
|
|
|
|
|
|
for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
msim.crafts_mut()[0].curr_pose.pos = Vec3(110.5f, msim.level().sample_height_world(110.5f, 19.5f) + 0.30f, 19.5f);
|
|
|
|
|
msim.crafts_mut()[0].prev_pose = msim.crafts_mut()[0].curr_pose;
|
|
|
|
|
for (int t = 0; t < 60; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
CHECK(msim.level().cell(109, 20).height == 1840);
|
|
|
|
|
CHECK(msim.level().cell(109, 20).tex_or_col == 63);
|
|
|
|
|
|
|
|
|
|
msim.crafts_mut()[0].curr_pose.pos = Vec3(127.5f, msim.level().sample_height_world(127.5f, 21.5f) + 0.30f, 21.5f);
|
|
|
|
|
msim.crafts_mut()[0].prev_pose = msim.crafts_mut()[0].curr_pose;
|
|
|
|
|
for (int t = 0; t < 10; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
for (const auto& pk : msim.pickups()) {
|
|
|
|
|
if (pk.group == 3) CHECK(pk.group_unlocked && pk.active);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 6c. Level 3: Rocket trigger id=176 removes solid columns at (67,63) and marks columns_dirty
|
|
|
|
|
{
|
|
|
|
|
assets::LevelData lvl3;
|
|
|
|
|
CHECK(lvl3.load(vfs, 3));
|
|
|
|
|
sim::RaceSetup ms;
|
|
|
|
|
ms.track_number = 3;
|
|
|
|
|
ms.num_ai = 0;
|
|
|
|
|
sim::RaceSim msim;
|
|
|
|
|
CHECK(msim.start_race(lvl3, ms));
|
|
|
|
|
CHECK(msim.level().cell(67, 63).tex_or_col == -87);
|
|
|
|
|
float col_y = msim.level().sample_height_world(67.5f, 63.5f) + 0.30f;
|
|
|
|
|
CHECK(msim.level().is_cell_solid_at_point(67, 63, 67.5f, 63.5f, col_y));
|
|
|
|
|
for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
|
|
|
|
|
auto& p1 = msim.crafts_mut()[0];
|
|
|
|
|
p1.curr_pose.pos = Vec3(67.5f, msim.level().sample_height_world(67.5f, 67.5f) + 0.30f, 67.5f);
|
|
|
|
|
p1.curr_pose.yaw = kPi;
|
|
|
|
|
p1.prev_pose = p1.curr_pose;
|
|
|
|
|
p1.vel = Vec3(0, 0, 0);
|
|
|
|
|
bool saw_cols_dirty = false;
|
|
|
|
|
std::vector<sim::DirtyRect> rects;
|
|
|
|
|
for (int t = 0; t < 40; ++t) {
|
|
|
|
|
CraftInput fire;
|
|
|
|
|
fire.fire_missile = (t == 0);
|
|
|
|
|
msim.step(fire, CraftInput{}, dt);
|
|
|
|
|
bool cdirty = false;
|
|
|
|
|
if (msim.consume_world_dirty(rects, cdirty) && cdirty) saw_cols_dirty = true;
|
|
|
|
|
}
|
|
|
|
|
CHECK(saw_cols_dirty);
|
|
|
|
|
CHECK(msim.level().cell(67, 63).tex_or_col >= 0);
|
|
|
|
|
CHECK(!msim.level().is_cell_solid_at_point(67, 63, 67.5f, 63.5f, col_y));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 6d. Level 4: Rocket id=153 collapses reactor (68,75) & unlocks grp=10 pickups; Craft id=256 + Rocket id=40 open bunker ONCE
|
|
|
|
|
{
|
|
|
|
|
assets::LevelData lvl4;
|
|
|
|
|
CHECK(lvl4.load(vfs, 4));
|
|
|
|
|
sim::RaceSetup ms;
|
|
|
|
|
ms.track_number = 4;
|
|
|
|
|
ms.num_ai = 0;
|
|
|
|
|
sim::RaceSim msim;
|
|
|
|
|
CHECK(msim.start_race(lvl4, ms));
|
|
|
|
|
CHECK(msim.level().cell(68, 75).height == 3360);
|
|
|
|
|
CHECK(msim.level().cell(43, 114).tex_or_col == -172);
|
|
|
|
|
for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
|
|
|
|
|
auto& p1 = msim.crafts_mut()[0];
|
|
|
|
|
p1.curr_pose.pos = Vec3(69.5f, msim.level().sample_height_world(69.5f, 90.0f) + 0.30f, 90.0f);
|
|
|
|
|
p1.curr_pose.yaw = kPi;
|
|
|
|
|
p1.prev_pose = p1.curr_pose;
|
|
|
|
|
p1.vel = Vec3(0, 0, 0);
|
|
|
|
|
for (int t = 0; t < 60; ++t) {
|
|
|
|
|
CraftInput fire;
|
|
|
|
|
fire.fire_missile = (t == 0);
|
|
|
|
|
msim.step(fire, CraftInput{}, dt);
|
|
|
|
|
}
|
|
|
|
|
CHECK(msim.level().cell(68, 75).height == 2048);
|
|
|
|
|
bool g10_unlocked = false;
|
|
|
|
|
for (const auto& pk : msim.pickups()) {
|
|
|
|
|
if (pk.group == 10) {
|
|
|
|
|
g10_unlocked = true;
|
|
|
|
|
CHECK(pk.group_unlocked);
|
|
|
|
|
float expected_y = msim.level().sample_height_world(pk.pos.x, pk.pos.z) + 0.45f;
|
|
|
|
|
CHECK(std::abs(pk.pos.y - expected_y) < 0.05f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CHECK(g10_unlocked);
|
|
|
|
|
|
|
|
|
|
p1.curr_pose.pos = Vec3(44.5f, msim.level().sample_height_world(44.5f, 49.5f) + 0.30f, 49.5f);
|
|
|
|
|
p1.prev_pose = p1.curr_pose;
|
|
|
|
|
for (int t = 0; t < 40; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
CHECK(msim.level().cell(43, 114).tex_or_col == -171);
|
|
|
|
|
|
|
|
|
|
p1.curr_pose.pos = Vec3(44.5f, msim.level().sample_height_world(44.5f, 117.0f) + 0.30f, 117.0f);
|
|
|
|
|
p1.curr_pose.yaw = kPi;
|
|
|
|
|
p1.prev_pose = p1.curr_pose;
|
|
|
|
|
p1.vel = Vec3(0, 0, 0);
|
|
|
|
|
p1.missile_cd = 0.0f;
|
|
|
|
|
for (int t = 0; t < 40; ++t) {
|
|
|
|
|
CraftInput fire;
|
|
|
|
|
fire.fire_missile = (t == 0);
|
|
|
|
|
msim.step(fire, CraftInput{}, dt);
|
|
|
|
|
}
|
|
|
|
|
CHECK(msim.level().cell(43, 114).tex_or_col == -171);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 6e. Level 5: Rocket id=286 blasts pillar (70,81); Craft id=275 starts blinking tunnel lights at (10,25)
|
|
|
|
|
{
|
|
|
|
|
assets::LevelData lvl5;
|
|
|
|
|
CHECK(lvl5.load(vfs, 5));
|
|
|
|
|
sim::RaceSetup ms;
|
|
|
|
|
ms.track_number = 5;
|
|
|
|
|
ms.num_ai = 0;
|
|
|
|
|
sim::RaceSim msim;
|
|
|
|
|
CHECK(msim.start_race(lvl5, ms));
|
|
|
|
|
CHECK(msim.level().cell(70, 81).tex_or_col == -53);
|
|
|
|
|
CHECK(msim.level().cell(10, 25).illumination == 12800);
|
|
|
|
|
for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
|
|
|
|
|
auto& p1 = msim.crafts_mut()[0];
|
|
|
|
|
p1.curr_pose.pos = Vec3(70.5f, msim.level().sample_height_world(70.5f, 84.0f) + 0.30f, 84.0f);
|
|
|
|
|
p1.curr_pose.yaw = kPi;
|
|
|
|
|
p1.prev_pose = p1.curr_pose;
|
|
|
|
|
p1.vel = Vec3(0, 0, 0);
|
|
|
|
|
bool saw_cols_dirty = false;
|
|
|
|
|
std::vector<sim::DirtyRect> rects;
|
|
|
|
|
for (int t = 0; t < 40; ++t) {
|
|
|
|
|
CraftInput fire;
|
|
|
|
|
fire.fire_missile = (t == 0);
|
|
|
|
|
msim.step(fire, CraftInput{}, dt);
|
|
|
|
|
bool cdirty = false;
|
|
|
|
|
if (msim.consume_world_dirty(rects, cdirty) && cdirty) saw_cols_dirty = true;
|
|
|
|
|
}
|
|
|
|
|
CHECK(saw_cols_dirty);
|
|
|
|
|
CHECK(msim.level().cell(70, 81).tex_or_col == 117);
|
|
|
|
|
|
|
|
|
|
p1.curr_pose.pos = Vec3(20.5f, msim.level().sample_height_world(20.5f, 77.5f) + 0.30f, 77.5f);
|
|
|
|
|
p1.prev_pose = p1.curr_pose;
|
|
|
|
|
bool saw_dim = false;
|
|
|
|
|
for (int t = 0; t < 60; ++t) {
|
|
|
|
|
msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
if (msim.level().cell(10, 25).illumination == 8192) saw_dim = true;
|
|
|
|
|
}
|
|
|
|
|
CHECK(saw_dim);
|
|
|
|
|
bool saw_bright = false;
|
|
|
|
|
for (int t = 0; t < 60; ++t) {
|
|
|
|
|
msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
if (msim.level().cell(10, 25).illumination == 12800) saw_bright = true;
|
|
|
|
|
}
|
|
|
|
|
CHECK(saw_bright);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 6f. Level 6: Timed id=3 oscillates ramp (10,75); Craft id=148 collapses (48,52); Rocket id=184 blasts (33,16)
|
|
|
|
|
{
|
|
|
|
|
assets::LevelData lvl6;
|
|
|
|
|
CHECK(lvl6.load(vfs, 6));
|
|
|
|
|
sim::RaceSetup ms;
|
|
|
|
|
ms.track_number = 6;
|
|
|
|
|
ms.num_ai = 0;
|
|
|
|
|
sim::RaceSim msim;
|
|
|
|
|
CHECK(msim.start_race(lvl6, ms));
|
|
|
|
|
CHECK(msim.level().cell(10, 75).height == 2368);
|
|
|
|
|
CHECK(msim.level().cell(48, 52).tex_or_col == -480);
|
|
|
|
|
CHECK(msim.level().cell(33, 16).tex_or_col == -112);
|
|
|
|
|
|
|
|
|
|
for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
CHECK(msim.level().cell(10, 75).height == 2048);
|
|
|
|
|
for (int t = 0; t < 180; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
CHECK(msim.level().cell(10, 75).height == 2368);
|
|
|
|
|
|
|
|
|
|
auto& p1 = msim.crafts_mut()[0];
|
|
|
|
|
p1.curr_pose.pos = Vec3(70.5f, msim.level().sample_height_world(70.5f, 51.5f) + 0.30f, 51.5f);
|
|
|
|
|
p1.prev_pose = p1.curr_pose;
|
|
|
|
|
p1.vel = Vec3(0, 0, 0);
|
|
|
|
|
bool saw_cols_dirty = false;
|
|
|
|
|
std::vector<sim::DirtyRect> rects;
|
|
|
|
|
for (int t = 0; t < 40; ++t) {
|
|
|
|
|
msim.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
bool cdirty = false;
|
|
|
|
|
if (msim.consume_world_dirty(rects, cdirty) && cdirty) saw_cols_dirty = true;
|
|
|
|
|
}
|
|
|
|
|
CHECK(saw_cols_dirty);
|
|
|
|
|
CHECK(msim.level().cell(48, 52).tex_or_col >= 0);
|
|
|
|
|
|
|
|
|
|
p1.curr_pose.pos = Vec3(33.5f, msim.level().sample_height_world(33.5f, 19.5f) + 0.30f, 19.5f);
|
|
|
|
|
p1.curr_pose.yaw = kPi;
|
|
|
|
|
p1.prev_pose = p1.curr_pose;
|
|
|
|
|
p1.vel = Vec3(0, 0, 0);
|
|
|
|
|
p1.missile_cd = 0.0f;
|
|
|
|
|
for (int t = 0; t < 40; ++t) {
|
|
|
|
|
CraftInput fire;
|
|
|
|
|
fire.fire_missile = (t == 0);
|
|
|
|
|
msim.step(fire, CraftInput{}, dt);
|
|
|
|
|
}
|
|
|
|
|
CHECK(msim.level().cell(33, 16).tex_or_col >= 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 6g. track_morphing_enabled = false disables Timed (L1), Craft (L2), and Rocket (L3) morphs
|
|
|
|
|
{
|
|
|
|
|
sim::RaceSetup off1;
|
|
|
|
|
off1.track_number = 1;
|
|
|
|
|
off1.num_ai = 0;
|
|
|
|
|
off1.track_morphing_enabled = false;
|
|
|
|
|
sim::RaceSim s1;
|
|
|
|
|
CHECK(s1.start_race(lvl1, off1));
|
|
|
|
|
for (int t = 0; t < 500; ++t) s1.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
CHECK(s1.level().cell(17, 32).height == 1504);
|
|
|
|
|
|
|
|
|
|
assets::LevelData lvl2;
|
|
|
|
|
CHECK(lvl2.load(vfs, 2));
|
|
|
|
|
sim::RaceSetup off2;
|
|
|
|
|
off2.track_number = 2;
|
|
|
|
|
off2.num_ai = 0;
|
|
|
|
|
off2.track_morphing_enabled = false;
|
|
|
|
|
sim::RaceSim s2;
|
|
|
|
|
CHECK(s2.start_race(lvl2, off2));
|
|
|
|
|
for (int t = 0; t < 200; ++t) s2.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
s2.crafts_mut()[0].curr_pose.pos = Vec3(110.5f, s2.level().sample_height_world(110.5f, 19.5f) + 0.30f, 19.5f);
|
|
|
|
|
s2.crafts_mut()[0].prev_pose = s2.crafts_mut()[0].curr_pose;
|
|
|
|
|
for (int t = 0; t < 60; ++t) s2.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
CHECK(s2.level().cell(109, 20).height == 2480);
|
|
|
|
|
|
|
|
|
|
assets::LevelData lvl3;
|
|
|
|
|
CHECK(lvl3.load(vfs, 3));
|
|
|
|
|
sim::RaceSetup off3;
|
|
|
|
|
off3.track_number = 3;
|
|
|
|
|
off3.num_ai = 0;
|
|
|
|
|
off3.track_morphing_enabled = false;
|
|
|
|
|
sim::RaceSim s3;
|
|
|
|
|
CHECK(s3.start_race(lvl3, off3));
|
|
|
|
|
for (int t = 0; t < 200; ++t) s3.step(CraftInput{}, CraftInput{}, dt);
|
|
|
|
|
s3.crafts_mut()[0].curr_pose.pos = Vec3(67.5f, s3.level().sample_height_world(67.5f, 67.5f) + 0.30f, 67.5f);
|
|
|
|
|
s3.crafts_mut()[0].curr_pose.yaw = kPi;
|
|
|
|
|
s3.crafts_mut()[0].prev_pose = s3.crafts_mut()[0].curr_pose;
|
|
|
|
|
for (int t = 0; t < 40; ++t) {
|
|
|
|
|
CraftInput fire;
|
|
|
|
|
fire.fire_missile = (t == 0);
|
|
|
|
|
s3.step(fire, CraftInput{}, dt);
|
|
|
|
|
}
|
|
|
|
|
CHECK(s3.level().cell(67, 63).tex_or_col == -87);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
std::cout << "[PASS] Authentic sector morphing, Timed/Craft/Rocket triggers & groups verified across all 6 tracks\n";
|
|
|
|
|
|
2026-11-30 22:31:51 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|