Fix checkpoint normals, morph pickup deduplication, and final championship standings screen
This commit is contained in:
1 parent
bbd701b716
commit
9f276a432b
8 files changed
+460
-63
No files matched your search
@@ -69,10 +69,34 @@ int main() {
|
||||
CHECK(lvl.checkpoints[0].index == 0);
|
||||
for (const auto& cp : lvl.checkpoints) {
|
||||
CHECK(cp.x0 != cp.x1 || cp.z0 != cp.z1);
|
||||
Vec2 seg(cp.x1 - cp.x0, cp.z1 - cp.z0);
|
||||
float slen = seg.len();
|
||||
CHECK(slen > 0.5f);
|
||||
CHECK(std::abs(cp.dir.len() - 1.0f) < 1e-3f);
|
||||
CHECK(std::abs(cp.dir.dot(seg) / slen) < 1e-3f);
|
||||
}
|
||||
if (l == 3) {
|
||||
CHECK(lvl.checkpoints[1].dir.y < -0.99f && !lvl.checkpoints[1].bidirectional);
|
||||
}
|
||||
if (l == 4) {
|
||||
CHECK(lvl.checkpoints[6].dir.x > 0.99f && !lvl.checkpoints[6].bidirectional);
|
||||
CHECK(lvl.checkpoints[9].dir.x < -0.99f && !lvl.checkpoints[9].bidirectional);
|
||||
}
|
||||
if (l == 6) {
|
||||
CHECK(lvl.checkpoints[9].dir.x > 0.99f && !lvl.checkpoints[9].bidirectional);
|
||||
}
|
||||
if (l == 7) {
|
||||
CHECK(lvl.checkpoints.size() == 6);
|
||||
}
|
||||
if (l == 8) {
|
||||
CHECK(lvl.checkpoints[1].bidirectional);
|
||||
CHECK(lvl.checkpoints[4].bidirectional);
|
||||
}
|
||||
if (l == 9) {
|
||||
for (const auto& cp : lvl.checkpoints) {
|
||||
CHECK(cp.bidirectional);
|
||||
}
|
||||
}
|
||||
|
||||
// Verify all referenced columns & floor tiles are within valid bounds
|
||||
int col_cells = 0;
|
||||
|
||||
@@ -1434,5 +1434,247 @@ int main() {
|
||||
std::cout << "[PASS] DeathMatch Final Lap & Wrong Way suppression validated\n";
|
||||
}
|
||||
|
||||
// 15. Perpendicular Checkpoint Normals, Bidirectional Gates, Morphed Shortcuts & Pickup Deduplication
|
||||
{
|
||||
auto test_gate_crossing = [&](int track_num, int cp_idx, Vec2 start_xz, Vec2 dir_xz,
|
||||
int expected_after, int steps = 8) -> bool {
|
||||
assets::LevelData lvl;
|
||||
if (!lvl.load(vfs, track_num)) return false;
|
||||
sim::RaceSetup setup;
|
||||
setup.mode = sim::GameMode::SingleRace;
|
||||
setup.track_number = track_num;
|
||||
setup.num_ai = 0;
|
||||
setup.total_laps = 2;
|
||||
setup.weapons_enabled = false;
|
||||
setup.fuel_enabled = false;
|
||||
setup.damage_enabled = false;
|
||||
sim::RaceSim sim_obj;
|
||||
if (!sim_obj.start_race(lvl, setup)) return false;
|
||||
for (int t = 0; t < 200; ++t) sim_obj.step(CraftInput{}, CraftInput{}, dt);
|
||||
auto& p1 = sim_obj.crafts_mut()[0];
|
||||
p1.autopilot = false;
|
||||
p1.next_checkpoint = cp_idx;
|
||||
p1.checkpoints_passed = cp_idx;
|
||||
Vec2 d = dir_xz.normalized();
|
||||
p1.curr_pose.pos = Vec3(start_xz.x, sim_obj.level().sample_height_world(start_xz.x, start_xz.y) + 0.30f,
|
||||
start_xz.y);
|
||||
p1.curr_pose.yaw = std::atan2(d.x, d.y);
|
||||
p1.prev_pose = p1.curr_pose;
|
||||
for (int t = 0; t < steps; ++t) {
|
||||
p1.vel.x = d.x * 18.0f;
|
||||
p1.vel.z = d.y * 18.0f;
|
||||
sim_obj.step(CraftInput{}, CraftInput{}, dt);
|
||||
}
|
||||
return sim_obj.crafts()[0].next_checkpoint == expected_after;
|
||||
};
|
||||
|
||||
// 15a. Previously failing forward crossings & reverse-crossing rejection on fixed gates
|
||||
CHECK(test_gate_crossing(6, 9, Vec2(9.2f, 89.6f), Vec2(0.8f, 0.5f), 10)); // L6 cp[9] ESE waypoint crossing
|
||||
CHECK(test_gate_crossing(6, 9, Vec2(10.8f, 90.0f), Vec2(-1.0f, 0.0f), 9)); // L6 cp[9] reverse West rejected
|
||||
CHECK(test_gate_crossing(3, 1, Vec2(18.5f, 57.6f), Vec2(-0.7f, -0.7f), 2)); // L3 cp[1] NW diagonal exit
|
||||
CHECK(test_gate_crossing(4, 6, Vec2(44.4f, 123.8f), Vec2(0.5f, 0.85f), 7)); // L4 cp[6] angled SE crossing
|
||||
CHECK(test_gate_crossing(4, 9, Vec2(24.6f, 79.5f), Vec2(-0.5f, 0.85f), 0)); // L4 cp[9] angled SW crossing
|
||||
CHECK(test_gate_crossing(8, 1, Vec2(97.5f, 87.2f), Vec2(0.0f, 1.0f), 2)); // L8 cp[1] Southbound hairpin entry
|
||||
CHECK(test_gate_crossing(8, 4, Vec2(17.4f, 88.6f), Vec2(0.7f, -0.7f), 5)); // L8 cp[4] NE hairpin exit
|
||||
CHECK(test_gate_crossing(8, 4, Vec2(19.3f, 85.0f), Vec2(-1.0f, 0.0f), 5, 3)); // L8 cp[4] apex tile strip graze
|
||||
CHECK(test_gate_crossing(8, 4, Vec2(22.0f, 85.0f), Vec2(0.0f, 1.0f), 4, 4)); // L8 cp[4] East of apex strip does not fire
|
||||
|
||||
// 15b. Level 7 chained mine shortcut (trig#278 -> trig#279 -> trig#282) hits cp[2] and cp[3]
|
||||
{
|
||||
assets::LevelData lvl7;
|
||||
CHECK(lvl7.load(vfs, 7));
|
||||
sim::RaceSetup ms;
|
||||
ms.track_number = 7;
|
||||
ms.num_ai = 0;
|
||||
ms.total_laps = 2;
|
||||
ms.fuel_enabled = false;
|
||||
ms.damage_enabled = false;
|
||||
sim::RaceSim msim;
|
||||
CHECK(msim.start_race(lvl7, ms));
|
||||
for (int t = 0; t < 200; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
||||
|
||||
const uint16_t ramp_before = msim.level().cell(33, 42).height;
|
||||
const uint16_t ramp_src = msim.level().cell(39, 49).height;
|
||||
const uint16_t ridge_before = msim.level().cell(45, 40).height;
|
||||
const uint16_t ridge_src = msim.level().cell(45, 49).height;
|
||||
CHECK(ramp_before > ramp_src);
|
||||
CHECK(ridge_before > 2048u && ridge_src < 2048u);
|
||||
|
||||
auto& p1 = msim.crafts_mut()[0];
|
||||
p1.autopilot = false;
|
||||
// Visiting trig#279 before trig#278 arms group 5 must NOT morph M[3]
|
||||
p1.curr_pose.pos = Vec3(32.0f, msim.level().sample_height_world(32.0f, 42.5f) + 0.30f, 42.5f);
|
||||
p1.prev_pose = p1.curr_pose;
|
||||
for (int t = 0; t < 40; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
||||
CHECK(msim.level().cell(33, 42).height == ramp_before);
|
||||
|
||||
// Crossing trig#278 (94..99, 56..57) arms trig#279
|
||||
p1.curr_pose.pos = Vec3(95.5f, msim.level().sample_height_world(95.5f, 56.5f) + 0.30f, 56.5f);
|
||||
p1.prev_pose = p1.curr_pose;
|
||||
for (int t = 0; t < 10; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
||||
|
||||
// Now trig#279 fires on Lap 2 and flattens M[3] step at (33, 42)
|
||||
p1.curr_pose.pos = Vec3(32.0f, msim.level().sample_height_world(32.0f, 42.5f) + 0.30f, 42.5f);
|
||||
p1.prev_pose = p1.curr_pose;
|
||||
for (int t = 0; t < 45; ++t) msim.step(CraftInput{}, CraftInput{}, dt);
|
||||
CHECK(msim.level().cell(33, 42).height == ramp_src);
|
||||
|
||||
// Missile hit on trig#282 blasts ridge M[4] (44..47, 39..42)
|
||||
p1.curr_pose.pos = Vec3(45.5f, msim.level().sample_height_world(45.5f, 43.0f) + 0.30f, 43.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 < 45; ++t) {
|
||||
CraftInput fire;
|
||||
fire.fire_missile = (t == 0);
|
||||
msim.step(fire, CraftInput{}, dt);
|
||||
}
|
||||
CHECK(msim.level().cell(45, 40).height == ridge_src);
|
||||
|
||||
// Driving into mine entry crosses cp[2] (z=46) and exiting north rejoins before cp[3] (x=52)
|
||||
p1.next_checkpoint = 2;
|
||||
p1.checkpoints_passed = 2;
|
||||
p1.curr_pose.pos = Vec3(22.0f, msim.level().sample_height_world(22.0f, 46.8f) + 0.30f, 46.8f);
|
||||
p1.curr_pose.yaw = kPi;
|
||||
p1.prev_pose = p1.curr_pose;
|
||||
for (int t = 0; t < 10; ++t) {
|
||||
p1.vel = Vec3(0.0f, 0.0f, -18.0f);
|
||||
msim.step(CraftInput{}, CraftInput{}, dt);
|
||||
}
|
||||
CHECK(msim.crafts()[0].next_checkpoint == 3);
|
||||
|
||||
p1.curr_pose.pos = Vec3(51.2f, msim.level().sample_height_world(51.2f, 24.5f) + 0.30f, 24.5f);
|
||||
p1.curr_pose.yaw = kPi * 0.5f;
|
||||
p1.prev_pose = p1.curr_pose;
|
||||
for (int t = 0; t < 10; ++t) {
|
||||
p1.vel = Vec3(18.0f, 0.0f, 0.0f);
|
||||
msim.step(CraftInput{}, CraftInput{}, dt);
|
||||
}
|
||||
CHECK(msim.crafts()[0].next_checkpoint == 4);
|
||||
}
|
||||
|
||||
// 15c. Morph pickup relocation deduplicates overlapping pickups (L4 M[1] & L5 M[2])
|
||||
auto check_no_stacked_pickups = [&](const sim::RaceSim& s) -> bool {
|
||||
for (size_t i = 0; i < s.pickups().size(); ++i) {
|
||||
const auto& a = s.pickups()[i];
|
||||
if (!a.group_unlocked) continue;
|
||||
for (size_t j = i + 1; j < s.pickups().size(); ++j) {
|
||||
const auto& b = s.pickups()[j];
|
||||
if (!b.group_unlocked) continue;
|
||||
float dx = a.pos.x - b.pos.x;
|
||||
float dz = a.pos.z - b.pos.z;
|
||||
if (dx * dx + dz * dz < 0.25f) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
{
|
||||
assets::LevelData lvl4;
|
||||
CHECK(lvl4.load(vfs, 4));
|
||||
sim::RaceSetup ms4;
|
||||
ms4.track_number = 4;
|
||||
ms4.num_ai = 0;
|
||||
sim::RaceSim sim4;
|
||||
CHECK(sim4.start_race(lvl4, ms4));
|
||||
for (int t = 0; t < 200; ++t) sim4.step(CraftInput{}, CraftInput{}, dt);
|
||||
auto& p1 = sim4.crafts_mut()[0];
|
||||
p1.curr_pose.pos = Vec3(69.5f, sim4.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);
|
||||
sim4.step(fire, CraftInput{}, dt);
|
||||
}
|
||||
CHECK(check_no_stacked_pickups(sim4));
|
||||
int vault_unlocked = 0;
|
||||
for (const auto& pk : sim4.pickups()) {
|
||||
if (pk.group_unlocked && pk.pos.x >= 64.0f && pk.pos.x <= 77.0f &&
|
||||
pk.pos.z >= 71.0f && pk.pos.z <= 89.0f) {
|
||||
++vault_unlocked;
|
||||
}
|
||||
}
|
||||
CHECK(vault_unlocked == 8);
|
||||
}
|
||||
|
||||
{
|
||||
assets::LevelData lvl5;
|
||||
CHECK(lvl5.load(vfs, 5));
|
||||
sim::RaceSetup ms5;
|
||||
ms5.track_number = 5;
|
||||
ms5.num_ai = 0;
|
||||
sim::RaceSim sim5;
|
||||
CHECK(sim5.start_race(lvl5, ms5));
|
||||
for (int t = 0; t < 200; ++t) sim5.step(CraftInput{}, CraftInput{}, dt);
|
||||
auto& p1 = sim5.crafts_mut()[0];
|
||||
p1.curr_pose.pos = Vec3(17.0f, sim5.level().sample_height_world(17.0f, 134.0f) + 0.30f, 134.0f);
|
||||
p1.prev_pose = p1.curr_pose;
|
||||
for (int t = 0; t < 45; ++t) sim5.step(CraftInput{}, CraftInput{}, dt);
|
||||
CHECK(check_no_stacked_pickups(sim5));
|
||||
int alcove_unlocked = 0;
|
||||
for (const auto& pk : sim5.pickups()) {
|
||||
if (pk.group_unlocked && pk.pos.x >= 15.0f && pk.pos.x <= 20.0f &&
|
||||
pk.pos.z >= 133.0f && pk.pos.z <= 137.0f) {
|
||||
++alcove_unlocked;
|
||||
}
|
||||
}
|
||||
CHECK(alcove_unlocked == 4);
|
||||
}
|
||||
|
||||
std::cout << "[PASS] Perpendicular checkpoints, bidirectional hairpins, L7 mine morph & pickup deduplication validated\n";
|
||||
}
|
||||
|
||||
// 16. Championship completion opens PostRace directly on overall championship leaderboard with exact tie-breakers
|
||||
{
|
||||
CHECK(game::initial_post_race_page(sim::GameMode::Championship, false) == 0);
|
||||
CHECK(game::initial_post_race_page(sim::GameMode::Championship, true) == 2);
|
||||
CHECK(game::initial_post_race_page(sim::GameMode::SingleRace, true) == 0);
|
||||
CHECK(game::initial_post_race_page(sim::GameMode::DeathMatch, true) == 0);
|
||||
|
||||
game::ChampionshipState ch;
|
||||
ch.start_new("ACE", 0, 0, 1, 2);
|
||||
CHECK(!ch.is_complete());
|
||||
CHECK(game::initial_post_race_page(sim::GameMode::Championship, ch.is_complete()) == 0);
|
||||
|
||||
auto make_results = [&](const std::array<int, 8>& places, const std::array<int, 8>& kills) {
|
||||
std::vector<sim::CraftState> out(8);
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
out[static_cast<size_t>(i)].id = i;
|
||||
out[static_cast<size_t>(i)].is_human = (i == 0);
|
||||
out[static_cast<size_t>(i)].player_index = (i == 0) ? 0 : -1;
|
||||
out[static_cast<size_t>(i)].placement = places[static_cast<size_t>(i)];
|
||||
out[static_cast<size_t>(i)].kills = kills[static_cast<size_t>(i)];
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
// Race 1 (places for slots 0..7): slot 1=1st(10,1W), slot 2=2nd(6), slot 0=3rd(4), slot 3=4th(3), slot 4=5th(2), slot 5=6th(1), 6=7th, 7=8th
|
||||
ch.record_race_results(make_results({3, 1, 2, 4, 5, 6, 7, 8}, {1, 2, 6, 2, 0, 0, 3, 1}));
|
||||
CHECK(ch.current_track == 2);
|
||||
CHECK(!ch.is_complete());
|
||||
CHECK(game::initial_post_race_page(sim::GameMode::Championship, ch.is_complete()) == 0);
|
||||
|
||||
// Race 2 creates controlled ties:
|
||||
// - Slot 1: 12 pts, 1 win, 2 kills
|
||||
// - Slot 4: 12 pts, 1 win, 0 kills (loses to Slot 1 on kills, beats Slot 2 on wins)
|
||||
// - Slot 2: 12 pts, 0 wins, 6 kills
|
||||
// - Slot 3: 7 pts, 0 wins, 6 kills
|
||||
// - Slot 0: 7 pts, 0 wins, 2 kills (loses to Slot 3 on kills)
|
||||
ch.record_race_results(make_results({4, 5, 2, 3, 1, 6, 7, 8}, {1, 0, 0, 4, 0, 0, 0, 0}));
|
||||
CHECK(ch.is_complete());
|
||||
CHECK(game::initial_post_race_page(sim::GameMode::Championship, ch.is_complete()) == 2);
|
||||
|
||||
const std::array<size_t, 8> expected_order{1, 4, 2, 3, 0, 5, 6, 7};
|
||||
const auto order = ch.sorted_driver_indices();
|
||||
for (size_t i = 0; i < order.size(); ++i) {
|
||||
CHECK(order[i] == expected_order[i]);
|
||||
}
|
||||
|
||||
std::cout << "[PASS] Championship completion leaderboard default page & tie-break ranking validated\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user