Enable Tracks 7-9 across menus, loaders, modes, tests, and update README

This commit is contained in:
Luxferre committed 2026-12-01 14:18:37 +02:00
1 parent 5a42ca9968
commit fc76e447fe
15 files changed
+254 -101

No files matched your search

+5 -4
View File
@@ -4,7 +4,8 @@ A modern, cross-platform **SDL2 + OpenGL 3.3 Core** C++20 source port of Bullfro
## Key fixes over the original DOS version ## Key fixes over the original DOS version
- **CPU cycles & timing:** Fixed `60 Hz` deterministic simulation clock with high-refresh render-state interpolation and OS-friendly VSync yielding (eliminates DOSBox hyper-speed and frame hitching). - **CPU cycles & timing:** Fixed `60 Hz` deterministic simulation clock with high-refresh render-state interpolation and OS-friendly VSync yielding (eliminates DOSBox hyper-speed and frame hitching).
- **Graphics:** Native OpenGL 3.3 Core renderer with widescreen Hor+ FOV, HiDPI support, extended draw distance, MSAA, perspective-correct 3D terrain & column geometry (`TEXTU0-0..5`, `SKY0-0..5`, `BULLFROG OBJECT DATA`), plus an authentic **classic mode** (`F2`) featuring 4:3 `320×200`/`640×480` quantization against `PALET0-0.DAT` and optional scanlines. - **Graphics:** Native OpenGL 3.3 Core renderer with widescreen Hor+ FOV, HiDPI support, extended draw distance, MSAA, perspective-correct 3D terrain & column geometry (`TEXTU0-0..8`, `SKY0-0..5`, `BULLFROG OBJECT DATA`), authentic `TMAPS` pickup/weapon-upgrade billboards, modern directional shadows & dynamic lighting, scaled cockpit HUD, explosion/smoke effects, autoscaling menus, plus **classic mode** (`F2`) featuring 4:3 `320×200`/`640×480` quantization against `PALET0-0.DAT` and optional scanlines.
- **Gameplay & Revision content:** Full support for all 9 tracks—including Bullfrog's Revision expansion tracks (*7. Ancient Mine Town*, *8. Arctic Land*, and *9. Death Match Arena*)—across Track Select, 8-track Championships, Highscores, Clone Races, and Track Viewer; stat-matched vehicle top speeds and HUD speedometers; pitstop recharge audio cues; and anti-stuck AI navigation/recovery.
- **Controls:** Scancode-based remappable keyboard, hot-plugged `SDL_GameController` analog steering/triggers with deadzone/curve calibration and rumble haptics, optional mouse steering, and 2-player local split-screen. - **Controls:** Scancode-based remappable keyboard, hot-plugged `SDL_GameController` analog steering/triggers with deadzone/curve calibration and rumble haptics, optional mouse steering, and 2-player local split-screen.
- **Audio & music:** Low-latency SDL2 float32 stereo mixer with 3D spatial panning/attenuation, bank 3 & bank 9 WAV SFX extraction from `SOUND.DAT`, and native Miles XMIDI (`MUSIC.DAT`) playback via **OPL3 FM (`SAMPLE.OPL`)**, **SoundFont (`BULLFROG.SBK` / `.sf2`)**, or custom `.wav` tracks — completely bypassing the DOS `MPU401.MDI` crash. - **Audio & music:** Low-latency SDL2 float32 stereo mixer with 3D spatial panning/attenuation, bank 3 & bank 9 WAV SFX extraction from `SOUND.DAT`, and native Miles XMIDI (`MUSIC.DAT`) playback via **OPL3 FM (`SAMPLE.OPL`)**, **SoundFont (`BULLFROG.SBK` / `.sf2`)**, or custom `.wav` tracks — completely bypassing the DOS `MPU401.MDI` crash.
@@ -40,8 +41,8 @@ make test
## CLI options ## CLI options
- `--data-dir <path>`: Path to the read-only assets directory (default: `./data` or installed/XDG data dirs; also reads `HIOCTANE_DATA` env var). - `--data-dir <path>`: Path to the read-only assets directory (default: `./data` or installed/XDG data dirs; also reads `HIOCTANE_DATA` env var).
- `--track <1..6>`: Jump directly into a race on track 1–6. - `--track <1..9>`: Jump directly into a race on track 1–9.
- `--track-viewer <1..6>`: Open interactive 3D track inspection camera. - `--track-viewer <1..9>`: Open interactive 3D track inspection camera.
- `--classic`: Launch in 4:3 classic palette visual mode. - `--classic`: Launch in 4:3 classic palette visual mode.
- `--fullscreen`: Launch in borderless fullscreen. - `--fullscreen`: Launch in borderless fullscreen.
- `--music-backend <opl3|sf|custom>`: Choose OPL3 FM, SoundFont, or custom WAV music. - `--music-backend <opl3|sf|custom>`: Choose OPL3 FM, SoundFont, or custom WAV music.
@@ -52,7 +53,7 @@ make test
- **Player 1 (keyboard):** `W/S` or `Up/Down` (throttle/brake), `A/D` or `Left/Right` (steer), `Left Shift` (boost), `Space` (minigun), `E` (missile), `Q` (auto-pilot), `C` (camera view), `Esc`/`P` (pause). - **Player 1 (keyboard):** `W/S` or `Up/Down` (throttle/brake), `A/D` or `Left/Right` (steer), `Left Shift` (boost), `Space` (minigun), `E` (missile), `Q` (auto-pilot), `C` (camera view), `Esc`/`P` (pause).
- **Player 2 (split-screen):** `Arrow keys` (steer/throttle/brake), `Right Shift` (boost), `Right Ctrl` (minigun), `Enter` (missile). - **Player 2 (split-screen):** `Arrow keys` (steer/throttle/brake), `Right Shift` (boost), `Right Ctrl` (minigun), `Enter` (missile).
- **Gamepad:** Left stick / D-pad (steer), `RT`/`A` (throttle), `LT`/`B` (brake), `LB`/`X` (boost), `RB` (minigun), `Y` (missile), `Start` (pause). - **Gamepad:** Left stick / D-pad (steer), `RT`/`A` (throttle), `LT`/`B` (brake), `LB`/`X` (boost), `RB` (minigun), `Y` (missile), `Start` (pause).
- **Hotkeys:** `F2` (toggle classic mode), `F4` (switch OPL3 / SoundFont music), `F11` or `Alt+Enter` (toggle fullscreen). - **Hotkeys:** `F2` (toggle classic mode), `F4` (switch OPL3 / SoundFont music), `F11` or `Alt+Enter` (toggle fullscreen), `1–9` / `[` `]` (switch tracks in Track Viewer).
User configuration, highscores, clone ghosts, and championship saves are stored in your OS user preferences directory (`SDL_GetPrefPath`). Original files in `data/` are never modified. User configuration, highscores, clone ghosts, and championship saves are stored in your OS user preferences directory (`SDL_GetPrefPath`). Original files in `data/` are never modified.
+41 -2
View File
@@ -20,13 +20,28 @@ inline int16_t read_le16s(const uint8_t* p) {
return static_cast<int16_t>(read_le16(p)); return static_cast<int16_t>(read_le16(p));
} }
constexpr const char* kTrackNames[6] = { constexpr const char* kTrackNames[kMaxTracks] = {
"1. AMAZON DELTA TURNPIKE", "1. AMAZON DELTA TURNPIKE",
"2. TRANS-ASIA INTERSTATE", "2. TRANS-ASIA INTERSTATE",
"3. SHANGHAI DRAGON", "3. SHANGHAI DRAGON",
"4. NEW CHERNOBYL CENTRAL", "4. NEW CHERNOBYL CENTRAL",
"5. SLAM CANYON", "5. SLAM CANYON",
"6. THRAK CITY", "6. THRAK CITY",
"7. ANCIENT MINE TOWN",
"8. ARCTIC LAND",
"9. DEATH MATCH ARENA",
};
constexpr const char* kTrackShortNames[kMaxTracks] = {
"AMAZON DELTA",
"TRANS-ASIA",
"SHANGHAI DRAGON",
"NEW CHERNOBYL",
"SLAM CANYON",
"THRAK CITY",
"ANCIENT MINE",
"ARCTIC LAND",
"DEATH MATCH ARENA",
}; };
constexpr size_t kLevelUnpackedSize = 896140; constexpr size_t kLevelUnpackedSize = 896140;
@@ -40,8 +55,31 @@ constexpr size_t kMapOffset = 0x62C8C; // 404620
} // namespace } // namespace
const char* track_name(int track_num) {
int idx = std::clamp(track_num, 1, kMaxTracks) - 1;
return kTrackNames[idx];
}
const char* track_short_name(int track_num) {
int idx = std::clamp(track_num, 1, kMaxTracks) - 1;
return kTrackShortNames[idx];
}
int count_available_tracks(const Vfs& vfs) {
int count = 0;
for (int i = 1; i <= kMaxTracks; ++i) {
char rel[64];
std::snprintf(rel, sizeof(rel), "MAPS/LEVEL0-%d.DAT", i);
if (!vfs.exists(rel)) {
break;
}
count = i;
}
return std::max(1, count);
}
bool LevelData::load(const Vfs& vfs, int level_num) { bool LevelData::load(const Vfs& vfs, int level_num) {
level_number = std::clamp(level_num, 1, 6); level_number = std::clamp(level_num, 1, kMaxTracks);
world_index = level_number - 1; world_index = level_number - 1;
name = kTrackNames[world_index]; name = kTrackNames[world_index];
@@ -162,6 +200,7 @@ bool LevelData::load(const Vfs& vfs, int level_num) {
std::sort(raw_gates.begin(), raw_gates.end(), std::sort(raw_gates.begin(), raw_gates.end(),
[](const LevelEntity& a, const LevelEntity& b) { return a.value < b.value; }); [](const LevelEntity& a, const LevelEntity& b) { return a.value < b.value; });
for (const auto& g : raw_gates) { for (const auto& g : raw_gates) {
if (g.aux1 == 0 && g.aux2 == 0) continue; // skip degenerate orphaned gate markers
CheckpointGate gate; CheckpointGate gate;
gate.index = g.value; gate.index = g.value;
gate.x0 = g.tile_x(); gate.x0 = g.tile_x();
+8 -3
View File
@@ -12,10 +12,15 @@ namespace top_octane::assets {
constexpr int kMapWidth = 256; constexpr int kMapWidth = 256;
constexpr int kMapHeight = 160; constexpr int kMapHeight = 160;
constexpr int kMaxTracks = 9;
constexpr int kMaxEntities = 4000; constexpr int kMaxEntities = 4000;
constexpr int kMaxColumns = 1024; constexpr int kMaxColumns = 1024;
constexpr int kMaxBlocks = 1024; constexpr int kMaxBlocks = 1024;
const char* track_name(int track_num);
const char* track_short_name(int track_num);
int count_available_tracks(const Vfs& vfs);
struct LevelEntity { struct LevelEntity {
uint16_t id = 0; uint16_t id = 0;
uint8_t type = 0; uint8_t type = 0;
@@ -111,8 +116,8 @@ struct ChargerPad {
}; };
struct LevelData { struct LevelData {
int level_number = 1; // 1..6 int level_number = 1; // 1..9
int world_index = 0; // 0..5 (corresponding to TEXTU0-x / SKY0-x / TABLE0-x) int world_index = 0; // 0..8 (corresponding to TEXTU0-x / SKY0-x / TABLE0-x)
std::string name; std::string name;
std::vector<LevelEntity> entities; // active non-empty entities std::vector<LevelEntity> entities; // active non-empty entities
@@ -134,7 +139,7 @@ struct LevelData {
int min_x = 0, max_x = kMapWidth - 1; int min_x = 0, max_x = kMapWidth - 1;
int min_z = 0, max_z = kMapHeight - 1; int min_z = 0, max_z = kMapHeight - 1;
bool load(const Vfs& vfs, int level_num); // level_num in [1..6] bool load(const Vfs& vfs, int level_num); // level_num in [1..9]
const MapEntry& cell(int x, int z) const; const MapEntry& cell(int x, int z) const;
MapEntry& cell_mut(int x, int z); MapEntry& cell_mut(int x, int z);
+5 -1
View File
@@ -48,8 +48,12 @@ uint8_t Palette::find_nearest(uint8_t r, uint8_t g, uint8_t b) const {
} }
bool ColorTables::load(const Vfs& vfs, int world_index, const Palette& pal) { bool ColorTables::load(const Vfs& vfs, int world_index, const Palette& pal) {
int idx = (world_index == 6) ? 0 : std::clamp(world_index, 0, 8);
char rel[64]; char rel[64];
std::snprintf(rel, sizeof(rel), "DATA/TABLE0-%d.DAT", std::clamp(world_index, 0, 5)); std::snprintf(rel, sizeof(rel), "DATA/TABLE0-%d.DAT", idx);
if (!vfs.exists(rel)) {
std::snprintf(rel, sizeof(rel), "DATA/TABLE0-2.DAT");
}
std::vector<uint8_t> raw, data; std::vector<uint8_t> raw, data;
if (!vfs.read_file(rel, raw)) { if (!vfs.read_file(rel, raw)) {
LOG_ERROR("Failed to read color table: %s", rel); LOG_ERROR("Failed to read color table: %s", rel);
+13 -3
View File
@@ -8,10 +8,20 @@
namespace top_octane::assets { namespace top_octane::assets {
bool WorldTextures::load(const Vfs& vfs, int world_index, const Palette& pal) { bool WorldTextures::load(const Vfs& vfs, int world_index, const Palette& pal) {
int idx = std::clamp(world_index, 0, 5); int tex_idx = (world_index == 6) ? 0 : std::clamp(world_index, 0, 8);
int sky_idx = std::clamp(world_index, 0, 8);
if (world_index == 6) {
sky_idx = 4;
}
char tex_path[64], sky_path[64]; char tex_path[64], sky_path[64];
std::snprintf(tex_path, sizeof(tex_path), "DATA/TEXTU0-%d.DAT", idx); std::snprintf(tex_path, sizeof(tex_path), "DATA/TEXTU0-%d.DAT", tex_idx);
std::snprintf(sky_path, sizeof(sky_path), "DATA/SKY0-%d.DAT", idx); if (!vfs.exists(tex_path)) {
std::snprintf(tex_path, sizeof(tex_path), "DATA/TEXTU0-2.DAT");
}
std::snprintf(sky_path, sizeof(sky_path), "DATA/SKY0-%d.DAT", sky_idx);
if (!vfs.exists(sky_path)) {
std::snprintf(sky_path, sizeof(sky_path), "DATA/SKY0-%d.DAT", (world_index == 7) ? 1 : 2);
}
std::vector<uint8_t> raw_tex; std::vector<uint8_t> raw_tex;
if (!vfs.read_file(tex_path, raw_tex) || !rnc_unpack(raw_tex, tile_indices)) { if (!vfs.read_file(tex_path, raw_tex) || !rnc_unpack(raw_tex, tile_indices)) {
+62 -39
View File
@@ -264,6 +264,8 @@ bool GameApp::init(const LaunchOptions& opts) {
} }
input_.init(); input_.init();
audio_.init(vfs_, cfg_, /*open_device=*/true); audio_.init(vfs_, cfg_, /*open_device=*/true);
available_tracks_ = assets::count_available_tracks(vfs_);
championship_tracks_ = (available_tracks_ >= 8) ? 8 : available_tracks_;
// Preload vehicle & prop 3D models cleanly // Preload vehicle & prop 3D models cleanly
for (int v = 0; v < 6; ++v) { for (int v = 0; v < 6; ++v) {
@@ -277,16 +279,18 @@ bool GameApp::init(const LaunchOptions& opts) {
} }
if (!opts.smoke_menu.empty()) { if (!opts.smoke_menu.empty()) {
selected_track_ = 1; selected_track_ = (opts.start_track >= 1 && opts.start_track <= available_tracks_)
? opts.start_track
: 1;
if (opts.smoke_menu == "main") enter_state(ScreenState::MainMenu); if (opts.smoke_menu == "main") enter_state(ScreenState::MainMenu);
else if (opts.smoke_menu == "track") enter_state(ScreenState::TrackSelect); else if (opts.smoke_menu == "track") enter_state(ScreenState::TrackSelect);
else if (opts.smoke_menu == "vehicle") enter_state(ScreenState::VehicleSelect); else if (opts.smoke_menu == "vehicle") enter_state(ScreenState::VehicleSelect);
else if (opts.smoke_menu == "options") enter_state(ScreenState::Options); else if (opts.smoke_menu == "options") enter_state(ScreenState::Options);
else if (opts.smoke_menu == "highscores") enter_state(ScreenState::Highscores); else if (opts.smoke_menu == "highscores") enter_state(ScreenState::Highscores);
else enter_state(ScreenState::MainMenu); else enter_state(ScreenState::MainMenu);
} else if (opts.track_viewer && opts.start_track >= 1 && opts.start_track <= 6) { } else if (opts.track_viewer && opts.start_track >= 1 && opts.start_track <= available_tracks_) {
enter_track_viewer(opts.start_track); enter_track_viewer(opts.start_track);
} else if (opts.start_track >= 1 && opts.start_track <= 6) { } else if (opts.start_track >= 1 && opts.start_track <= available_tracks_) {
selected_track_ = opts.start_track; selected_track_ = opts.start_track;
start_race_session(); start_race_session();
} else if (opts.smoke_test_frames > 0) { } else if (opts.smoke_test_frames > 0) {
@@ -452,7 +456,7 @@ void GameApp::enter_state(ScreenState s) {
void GameApp::enter_track_viewer(int track_num) { void GameApp::enter_track_viewer(int track_num) {
in_race_session_ = false; in_race_session_ = false;
cancel_name_edit(); cancel_name_edit();
selected_track_ = std::clamp(track_num, 1, 6); selected_track_ = std::clamp(track_num, 1, available_tracks_);
if (!viewer_level_.load(vfs_, selected_track_)) return; if (!viewer_level_.load(vfs_, selected_track_)) return;
world_ren_.load_level(vfs_, viewer_level_, palette_); world_ren_.load_level(vfs_, viewer_level_, palette_);
if (!viewer_level_.checkpoints.empty()) { if (!viewer_level_.checkpoints.empty()) {
@@ -761,18 +765,18 @@ void GameApp::update_menu(float dt) {
if (m.confirm) { if (m.confirm) {
audio_.play_sfx("SELECT.WAV", 0.38f); audio_.play_sfx("SELECT.WAV", 0.38f);
if (menu_cursor_ == 0) { if (menu_cursor_ == 0) {
champ_.start_new(cfg_.player_name, p1_veh_, p1_team_, selected_difficulty_); champ_.start_new(cfg_.player_name, p1_veh_, p1_team_, selected_difficulty_, championship_tracks_);
selected_track_ = 1; selected_track_ = 1;
enter_state(ScreenState::VehicleSelect); enter_state(ScreenState::VehicleSelect);
} else if (menu_cursor_ == 2) { } else if (menu_cursor_ == 2) {
if (!champ_.active || champ_.is_complete()) { if (!champ_.active || champ_.is_complete()) {
champ_.start_new(cfg_.player_name, p1_veh_, p1_team_, selected_difficulty_); champ_.start_new(cfg_.player_name, p1_veh_, p1_team_, selected_difficulty_, championship_tracks_);
} }
selected_track_ = std::clamp(champ_.current_track, 1, 6); selected_track_ = std::clamp(champ_.current_track, 1, champ_.total_tracks);
start_race_session(); start_race_session();
} else if (menu_cursor_ == 3) { } else if (menu_cursor_ == 3) {
if (champ_.load_slot(vfs_.pref_dir(), champ_slot_cursor_)) { if (champ_.load_slot(vfs_.pref_dir(), champ_slot_cursor_)) {
selected_track_ = std::clamp(champ_.current_track, 1, 6); selected_track_ = std::clamp(champ_.current_track, 1, champ_.total_tracks);
selected_difficulty_ = std::clamp(champ_.difficulty, 0, 2); selected_difficulty_ = std::clamp(champ_.difficulty, 0, 2);
cfg_.difficulty = selected_difficulty_; cfg_.difficulty = selected_difficulty_;
status_toast_ = "LOADED SLOT " + std::to_string(champ_slot_cursor_ + 1); status_toast_ = "LOADED SLOT " + std::to_string(champ_slot_cursor_ + 1);
@@ -800,7 +804,7 @@ void GameApp::update_menu(float dt) {
if (dir != 0) { if (dir != 0) {
audio_.play_sfx("CHANGE.WAV", 0.32f); audio_.play_sfx("CHANGE.WAV", 0.32f);
if (menu_cursor_ == 0) { if (menu_cursor_ == 0) {
selected_track_ = ((selected_track_ - 1 + dir + 6) % 6) + 1; selected_track_ = ((selected_track_ - 1 + dir + available_tracks_) % available_tracks_) + 1;
} else if (menu_cursor_ == 1) { } else if (menu_cursor_ == 1) {
if (selected_mode_ == sim::GameMode::DeathMatch) { if (selected_mode_ == sim::GameMode::DeathMatch) {
cfg_.deathmatch_kill_limit = std::clamp(cfg_.deathmatch_kill_limit + dir, 3, 20); cfg_.deathmatch_kill_limit = std::clamp(cfg_.deathmatch_kill_limit + dir, 3, 20);
@@ -1126,12 +1130,29 @@ int GameApp::run() {
} }
} else if (ev.type == SDL_KEYDOWN && !ev.key.repeat && } else if (ev.type == SDL_KEYDOWN && !ev.key.repeat &&
!input_.is_rebinding() && !input_.is_text_input_active()) { !input_.is_rebinding() && !input_.is_text_input_active()) {
if (ev.key.keysym.scancode == SDL_SCANCODE_F2) { SDL_Scancode sc = ev.key.keysym.scancode;
if (sc == SDL_SCANCODE_F2) {
cfg_.classic_mode = !cfg_.classic_mode; cfg_.classic_mode = !cfg_.classic_mode;
} else if (ev.key.keysym.scancode == SDL_SCANCODE_F4) { } else if (sc == SDL_SCANCODE_F4) {
int b = (static_cast<int>(cfg_.music_backend) + 1) % 2; int b = (static_cast<int>(cfg_.music_backend) + 1) % 2;
cfg_.music_backend = static_cast<MusicBackend>(b); cfg_.music_backend = static_cast<MusicBackend>(b);
audio_.apply_config(cfg_, window_focused_); audio_.apply_config(cfg_, window_focused_);
} else if (state_ == ScreenState::TrackViewer) {
if (sc >= SDL_SCANCODE_1 && sc <= SDL_SCANCODE_9) {
int t = static_cast<int>(sc - SDL_SCANCODE_1) + 1;
if (t <= available_tracks_) {
audio_.play_sfx("CHANGE.WAV", 0.32f);
enter_track_viewer(t);
}
} else if (sc == SDL_SCANCODE_LEFTBRACKET || sc == SDL_SCANCODE_PAGEUP) {
int prev = ((selected_track_ - 2 + available_tracks_) % available_tracks_) + 1;
audio_.play_sfx("CHANGE.WAV", 0.32f);
enter_track_viewer(prev);
} else if (sc == SDL_SCANCODE_RIGHTBRACKET || sc == SDL_SCANCODE_PAGEDOWN) {
int nxt = (selected_track_ % available_tracks_) + 1;
audio_.play_sfx("CHANGE.WAV", 0.32f);
enter_track_viewer(nxt);
}
} }
} }
input_.handle_event(ev, cfg_, want_quit, want_fs); input_.handle_event(ev, cfg_, want_quit, want_fs);
@@ -1208,9 +1229,11 @@ void GameApp::render_frame(float alpha) {
MenuLayout ml = compute_menu_layout(win_w_, win_h_); MenuLayout ml = compute_menu_layout(win_w_, win_h_);
ui_ren_.begin(win_w_, win_h_, ml.vw, ml.vh); ui_ren_.begin(win_w_, win_h_, ml.vw, ml.vh);
ui_ren_.draw_rect(12, 12, 520, 56, Vec4(0, 0, 0, 0.65f)); const float tv_w = std::min(680.0f, ml.vw - 24.0f);
ui_ren_.draw_text(24, 22, 2.0f, viewer_level_.name, Vec4(1, 0.85f, 0.2f, 1)); ui_ren_.draw_rect(12, 12, tv_w, 56, Vec4(0, 0, 0, 0.65f));
ui_ren_.draw_text(24, 44, 1.5f, "WASD MOVE ARROWS LOOK SPACE/C UP/DOWN F2 CLASSIC ESC BACK", ui_ren_.draw_text_fit(24, 20, tv_w - 24.0f, 2.0f, viewer_level_.name, Vec4(1, 0.85f, 0.2f, 1));
ui_ren_.draw_text_fit(24, 44, tv_w - 24.0f, 1.45f,
"WASD MOVE ARROWS LOOK 1-9/[ ] TRACK SPACE/C UP/DOWN F2 CLASSIC ESC BACK",
Vec4(0.85f, 0.9f, 1.0f, 1)); Vec4(0.85f, 0.9f, 1.0f, 1));
ui_ren_.end(); ui_ren_.end();
return; return;
@@ -1909,7 +1932,7 @@ void GameApp::render_menus() {
"NEW CHAMPIONSHIP", "NEW CHAMPIONSHIP",
std::string(str.difficulty) + ": < " + diff_label(selected_difficulty_) + " >", std::string(str.difficulty) + ": < " + diff_label(selected_difficulty_) + " >",
champ_.active && !champ_.is_complete() champ_.active && !champ_.is_complete()
? ("CONTINUE CHAMPIONSHIP (TRACK " + std::to_string(champ_.current_track) + "/6)") ? ("CONTINUE CHAMPIONSHIP (TRACK " + std::to_string(champ_.current_track) + "/" + std::to_string(champ_.total_tracks) + ")")
: "CONTINUE CHAMPIONSHIP (NONE)", : "CONTINUE CHAMPIONSHIP (NONE)",
"LOAD SLOT " + std::to_string(champ_slot_cursor_ + 1) + "LOAD SLOT " + std::to_string(champ_slot_cursor_ + 1) +
(ChampionshipState::slot_exists(vfs_.pref_dir(), champ_slot_cursor_) ? " [SAVED]" : " [EMPTY]"), (ChampionshipState::slot_exists(vfs_.pref_dir(), champ_slot_cursor_) ? " [SAVED]" : " [EMPTY]"),
@@ -1930,9 +1953,10 @@ void GameApp::render_menus() {
if (state_ == ScreenState::TrackSelect) { if (state_ == ScreenState::TrackSelect) {
ui_ren_.draw_text_centered(cx, oy + 76.0f, 2.55f, str.select_track, Vec4(0.4f, 0.85f, 1, 1)); ui_ren_.draw_text_centered(cx, oy + 76.0f, 2.55f, str.select_track, Vec4(0.4f, 0.85f, 1, 1));
// Track map preview sprite from TRACK0-1 (full track silhouettes sit at indices 1, 3, 6, 7, 9, 11) // Track map preview sprite from TRACK0-1 (1..6 originals + 7..9 revision expansion)
static constexpr int kTrackPreviewSprites[6] = {1, 3, 6, 7, 9, 11}; static constexpr int kTrackPreviewSprites[assets::kMaxTracks] = {1, 3, 6, 7, 9, 11, 12, 14, 15};
int preview_idx = kTrackPreviewSprites[std::clamp(selected_track_ - 1, 0, 5)]; const int track_idx = std::clamp(selected_track_ - 1, 0, assets::kMaxTracks - 1);
int preview_idx = kTrackPreviewSprites[track_idx];
const float box_x = cx + 100.0f; const float box_x = cx + 100.0f;
const float box_y = oy + 148.0f; const float box_y = oy + 148.0f;
const float box_w = std::clamp(vw - box_x - 28.0f, 180.0f, 340.0f); const float box_w = std::clamp(vw - box_x - 28.0f, 180.0f, 340.0f);
@@ -1952,10 +1976,6 @@ void GameApp::render_menus() {
} }
const float left_x = std::max(36.0f, cx - 460.0f); const float left_x = std::max(36.0f, cx - 460.0f);
const float max_w = std::max(220.0f, box_x - left_x - 24.0f); const float max_w = std::max(220.0f, box_x - left_x - 24.0f);
const char* tnames[6] = {
"1. AMAZON DELTA TURNPIKE", "2. TRANS-ASIA INTERSTATE", "3. SHANGHAI DRAGON",
"4. NEW CHERNOBYL CENTRAL", "5. SLAM CANYON", "6. THRAK CITY"
};
std::string row1 = (selected_mode_ == sim::GameMode::DeathMatch) std::string row1 = (selected_mode_ == sim::GameMode::DeathMatch)
? ("KILL LIMIT: < " + std::to_string(cfg_.deathmatch_kill_limit) + " >") ? ("KILL LIMIT: < " + std::to_string(cfg_.deathmatch_kill_limit) + " >")
: (std::string(str.laps) + ": < " + std::to_string(selected_laps_) + " >"); : (std::string(str.laps) + ": < " + std::to_string(selected_laps_) + " >");
@@ -1963,7 +1983,7 @@ void GameApp::render_menus() {
? (std::string(str.opponents) + ": CLONE GHOST") ? (std::string(str.opponents) + ": CLONE GHOST")
: (std::string(str.opponents) + ": < " + std::to_string(selected_opponents_) + " >"); : (std::string(str.opponents) + ": < " + std::to_string(selected_opponents_) + " >");
std::string rows[5] = { std::string rows[5] = {
std::string("TRACK: ") + tnames[selected_track_ - 1], std::string("TRACK: < ") + assets::track_name(selected_track_) + " >",
row1, row1,
std::string(str.difficulty) + ": < " + diff_label(selected_difficulty_) + " >", std::string(str.difficulty) + ": < " + diff_label(selected_difficulty_) + " >",
row3, row3,
@@ -1974,7 +1994,7 @@ void GameApp::render_menus() {
ui_ren_.draw_text_fit(left_x, oy + 166.0f + i * 48.0f, max_w, 2.0f, rows[i], ui_ren_.draw_text_fit(left_x, oy + 166.0f + i * 48.0f, max_w, 2.0f, rows[i],
sel ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1)); sel ? Vec4(1, 0.92f, 0.2f, 1) : Vec4(0.85f, 0.9f, 1, 1));
} }
const auto& rec = hiscores_.tracks[selected_track_ - 1]; const auto& rec = hiscores_.tracks[track_idx];
ui_ren_.draw_text_fit(left_x, oy + 448.0f, vw - left_x - 32.0f, 1.8f, ui_ren_.draw_text_fit(left_x, oy + 448.0f, vw - left_x - 32.0f, 1.8f,
"BEST LAP: " + format_time(rec.best_lap) + " (" + rec.best_lap_driver + ")", "BEST LAP: " + format_time(rec.best_lap) + " (" + rec.best_lap_driver + ")",
Vec4(0.4f, 1, 0.65f, 1)); Vec4(0.4f, 1, 0.65f, 1));
@@ -2063,29 +2083,32 @@ void GameApp::render_menus() {
if (state_ == ScreenState::Highscores) { if (state_ == ScreenState::Highscores) {
ui_ren_.draw_text_centered(cx, oy + 76.0f, 2.55f, str.highscores, Vec4(0.4f, 0.85f, 1, 1)); ui_ren_.draw_text_centered(cx, oy + 76.0f, 2.55f, str.highscores, Vec4(0.4f, 0.85f, 1, 1));
const char* tnames[6] = {"AMAZON DELTA", "TRANS-ASIA", "SHANGHAI DRAGON", "NEW CHERNOBYL", "SLAM CANYON", "THRAK CITY"};
float tbl_w = std::min(900.0f, vw - 48.0f); float tbl_w = std::min(900.0f, vw - 48.0f);
float c_trk = cx - tbl_w * 0.5f; float c_trk = cx - tbl_w * 0.5f;
float c_lap = c_trk + tbl_w * 0.30f; float c_lap = c_trk + tbl_w * 0.32f;
float c_rac = c_trk + tbl_w * 0.65f; float c_rac = c_trk + tbl_w * 0.66f;
float hdr_y = oy + 140.0f; float hdr_y = oy + 132.0f;
ui_ren_.draw_text_fit(c_trk, hdr_y, tbl_w * 0.28f, 1.75f, "TRACK", Vec4(0.4f, 0.85f, 1, 1)); ui_ren_.draw_text_fit(c_trk, hdr_y, tbl_w * 0.30f, 1.7f, "TRACK", Vec4(0.4f, 0.85f, 1, 1));
ui_ren_.draw_text_fit(c_lap, hdr_y, tbl_w * 0.33f, 1.75f, "BEST LAP", Vec4(0.4f, 0.85f, 1, 1)); ui_ren_.draw_text_fit(c_lap, hdr_y, tbl_w * 0.32f, 1.7f, "BEST LAP", Vec4(0.4f, 0.85f, 1, 1));
ui_ren_.draw_text_fit(c_rac, hdr_y, tbl_w * 0.35f, 1.75f, "BEST RACE", Vec4(0.4f, 0.85f, 1, 1)); ui_ren_.draw_text_fit(c_rac, hdr_y, tbl_w * 0.34f, 1.7f, "BEST RACE", Vec4(0.4f, 0.85f, 1, 1));
for (int i = 0; i < 6; ++i) { const bool compact = (available_tracks_ > 6);
const float start_y = compact ? (oy + 162.0f) : (oy + 178.0f);
const float row_step = compact ? 33.0f : 44.0f;
const float text_sc = compact ? 1.50f : 1.70f;
for (int i = 0; i < available_tracks_; ++i) {
const auto& r = hiscores_.tracks[i]; const auto& r = hiscores_.tracks[i];
float ry = oy + 178.0f + i * 44.0f; float ry = start_y + static_cast<float>(i) * row_step;
std::string col0 = std::to_string(i + 1) + ". " + tnames[i]; std::string col0 = std::to_string(i + 1) + ". " + assets::track_short_name(i + 1);
std::string col1 = format_time(r.best_lap) + " (" + r.best_lap_driver + ")"; std::string col1 = format_time(r.best_lap) + " (" + r.best_lap_driver + ")";
std::string col2 = format_time(r.best_race) + " (" + r.best_race_driver + ")"; std::string col2 = format_time(r.best_race) + " (" + r.best_race_driver + ")";
ui_ren_.draw_text_fit(c_trk, ry, tbl_w * 0.28f, 1.7f, col0, Vec4(0.9f, 0.95f, 1, 1)); ui_ren_.draw_text_fit(c_trk, ry, tbl_w * 0.30f, text_sc, col0, Vec4(0.9f, 0.95f, 1, 1));
ui_ren_.draw_text_fit(c_lap, ry, tbl_w * 0.33f, 1.7f, col1, Vec4(0.85f, 0.95f, 0.9f, 1)); ui_ren_.draw_text_fit(c_lap, ry, tbl_w * 0.32f, text_sc, col1, Vec4(0.85f, 0.95f, 0.9f, 1));
ui_ren_.draw_text_fit(c_rac, ry, tbl_w * 0.35f, 1.7f, col2, Vec4(0.85f, 0.95f, 0.9f, 1)); ui_ren_.draw_text_fit(c_rac, ry, tbl_w * 0.34f, text_sc, col2, Vec4(0.85f, 0.95f, 0.9f, 1));
} }
ui_ren_.draw_text_centered_fit(cx, oy + 480.0f, tbl_w, 1.85f, "ENTER CLEAR HISCORES ESC BACK", Vec4(1, 0.85f, 0.2f, 1)); ui_ren_.draw_text_centered_fit(cx, oy + 488.0f, tbl_w, 1.85f, "ENTER CLEAR HISCORES ESC BACK", Vec4(1, 0.85f, 0.2f, 1));
if (status_toast_timer_ > 0.0f) { if (status_toast_timer_ > 0.0f) {
ui_ren_.draw_text_centered(cx, oy + 520.0f, 2.0f, status_toast_, Vec4(0.3f, 1, 0.5f, 1)); ui_ren_.draw_text_centered(cx, oy + 526.0f, 2.0f, status_toast_, Vec4(0.3f, 1, 0.5f, 1));
} }
return; return;
} }
+2
View File
@@ -117,6 +117,8 @@ private:
// Race / Mode selection state // Race / Mode selection state
sim::GameMode selected_mode_ = sim::GameMode::SingleRace; sim::GameMode selected_mode_ = sim::GameMode::SingleRace;
int available_tracks_ = 6;
int championship_tracks_ = 6;
int selected_track_ = 1; int selected_track_ = 1;
int selected_laps_ = 3; int selected_laps_ = 3;
int selected_difficulty_ = 1; int selected_difficulty_ = 1;
+31 -10
View File
@@ -21,15 +21,17 @@ std::filesystem::path slot_path(const std::filesystem::path& pref_dir, int slot)
std::filesystem::path clone_path(const std::filesystem::path& pref_dir, int track_num) { std::filesystem::path clone_path(const std::filesystem::path& pref_dir, int track_num) {
char buf[32]; char buf[32];
std::snprintf(buf, sizeof(buf), "clone_0%d.bin", std::clamp(track_num, 1, 6)); std::snprintf(buf, sizeof(buf), "clone_%02d.bin", std::clamp(track_num, 1, assets::kMaxTracks));
return pref_dir / buf; return pref_dir / buf;
} }
} // namespace } // namespace
void ChampionshipState::start_new(const std::string& p_name, int vehicle_idx, int team_idx, int diff) { void ChampionshipState::start_new(const std::string& p_name, int vehicle_idx, int team_idx, int diff,
int num_tracks) {
active = true; active = true;
current_track = 1; current_track = 1;
total_tracks = std::clamp(num_tracks, 1, assets::kMaxTracks);
difficulty = std::clamp(diff, 0, 2); difficulty = std::clamp(diff, 0, 2);
player_vehicle = std::clamp(vehicle_idx, 0, 5); player_vehicle = std::clamp(vehicle_idx, 0, 5);
player_team = std::clamp(team_idx, 0, 7); player_team = std::clamp(team_idx, 0, 7);
@@ -77,8 +79,8 @@ bool ChampionshipState::save_slot(const std::filesystem::path& pref_dir, int slo
std::ofstream ofs(slot_path(pref_dir, slot), std::ios::trunc); std::ofstream ofs(slot_path(pref_dir, slot), std::ios::trunc);
if (!ofs) return false; if (!ofs) return false;
ofs << "TOPOCTANE_CHAMP_V1\n" ofs << "TOPOCTANE_CHAMP_V2\n"
<< (active ? 1 : 0) << " " << current_track << " " << difficulty << " " << (active ? 1 : 0) << " " << current_track << " " << total_tracks << " " << difficulty << " "
<< player_vehicle << " " << player_team << " " << overall_rating_pts << "\n" << player_vehicle << " " << player_team << " " << overall_rating_pts << "\n"
<< player_name << "\n"; << player_name << "\n";
for (int i = 0; i < 8; ++i) { for (int i = 0; i < 8; ++i) {
@@ -96,12 +98,22 @@ bool ChampionshipState::load_slot(const std::filesystem::path& pref_dir, int slo
std::ifstream ifs(slot_path(pref_dir, slot)); std::ifstream ifs(slot_path(pref_dir, slot));
if (!ifs) return false; if (!ifs) return false;
std::string magic; std::string magic;
if (!std::getline(ifs, magic) || magic != "TOPOCTANE_CHAMP_V1") return false; if (!std::getline(ifs, magic)) return false;
int act = 0; int act = 0;
if (magic == "TOPOCTANE_CHAMP_V1") {
if (!(ifs >> act >> current_track >> difficulty >> player_vehicle >> player_team >> overall_rating_pts)) { if (!(ifs >> act >> current_track >> difficulty >> player_vehicle >> player_team >> overall_rating_pts)) {
return false; return false;
} }
total_tracks = std::max(6, current_track);
} else if (magic == "TOPOCTANE_CHAMP_V2") {
if (!(ifs >> act >> current_track >> total_tracks >> difficulty >> player_vehicle >> player_team >> overall_rating_pts)) {
return false;
}
total_tracks = std::clamp(total_tracks, 1, assets::kMaxTracks);
} else {
return false;
}
active = (act != 0); active = (act != 0);
ifs.ignore(256, '\n'); ifs.ignore(256, '\n');
if (!std::getline(ifs, player_name)) return false; if (!std::getline(ifs, player_name)) return false;
@@ -134,7 +146,7 @@ void HighscoreTable::clear() {
} }
int HighscoreTable::submit_race(int track_num, const std::vector<sim::CraftState>& crafts) { int HighscoreTable::submit_race(int track_num, const std::vector<sim::CraftState>& crafts) {
int idx = std::clamp(track_num - 1, 0, 5); int idx = std::clamp(track_num - 1, 0, assets::kMaxTracks - 1);
TrackRecord& rec = tracks[idx]; TrackRecord& rec = tracks[idx];
int flags = 0; int flags = 0;
for (const auto& c : crafts) { for (const auto& c : crafts) {
@@ -158,8 +170,17 @@ bool HighscoreTable::load(const std::filesystem::path& path) {
std::ifstream ifs(path); std::ifstream ifs(path);
if (!ifs) return false; if (!ifs) return false;
std::string magic; std::string magic;
if (!std::getline(ifs, magic) || magic != "TOPOCTANE_HISCORE_V1") return false; if (!std::getline(ifs, magic)) return false;
for (int i = 0; i < 6; ++i) { int count = 0;
if (magic == "TOPOCTANE_HISCORE_V1") {
count = 6;
} else if (magic == "TOPOCTANE_HISCORE_V2") {
count = assets::kMaxTracks;
} else {
return false;
}
clear();
for (int i = 0; i < count; ++i) {
if (!(ifs >> tracks[i].best_lap >> tracks[i].best_race)) return false; if (!(ifs >> tracks[i].best_lap >> tracks[i].best_race)) return false;
ifs.ignore(256, '\n'); ifs.ignore(256, '\n');
if (!std::getline(ifs, tracks[i].best_lap_driver)) return false; if (!std::getline(ifs, tracks[i].best_lap_driver)) return false;
@@ -173,8 +194,8 @@ bool HighscoreTable::save(const std::filesystem::path& path) const {
if (path.has_parent_path()) std::filesystem::create_directories(path.parent_path(), ec); if (path.has_parent_path()) std::filesystem::create_directories(path.parent_path(), ec);
std::ofstream ofs(path, std::ios::trunc); std::ofstream ofs(path, std::ios::trunc);
if (!ofs) return false; if (!ofs) return false;
ofs << "TOPOCTANE_HISCORE_V1\n" << std::setprecision(9); ofs << "TOPOCTANE_HISCORE_V2\n" << std::setprecision(9);
for (int i = 0; i < 6; ++i) { for (int i = 0; i < assets::kMaxTracks; ++i) {
ofs << tracks[i].best_lap << " " << tracks[i].best_race << "\n" ofs << tracks[i].best_lap << " " << tracks[i].best_race << "\n"
<< tracks[i].best_lap_driver << "\n" << tracks[i].best_lap_driver << "\n"
<< tracks[i].best_race_driver << "\n"; << tracks[i].best_race_driver << "\n";
+7 -4
View File
@@ -1,5 +1,6 @@
#pragma once #pragma once
#include "assets/level.hpp"
#include "sim/race_sim.hpp" #include "sim/race_sim.hpp"
#include "sim/vehicle_defs.hpp" #include "sim/vehicle_defs.hpp"
@@ -21,7 +22,8 @@ struct DriverStanding {
struct ChampionshipState { struct ChampionshipState {
bool active = false; bool active = false;
int current_track = 1; // 1..6 int current_track = 1; // 1..total_tracks
int total_tracks = 8; // 6 for base data, 8 when expansion racing tracks 7-8 exist
int difficulty = 1; int difficulty = 1;
int player_vehicle = 0; int player_vehicle = 0;
int player_team = 7; int player_team = 7;
@@ -31,9 +33,10 @@ struct ChampionshipState {
std::array<DriverStanding, 8> drivers{}; std::array<DriverStanding, 8> drivers{};
std::array<int, 8> team_points{}; std::array<int, 8> team_points{};
void start_new(const std::string& p_name, int vehicle_idx, int team_idx, int diff); void start_new(const std::string& p_name, int vehicle_idx, int team_idx, int diff,
int num_tracks = 8);
void record_race_results(const std::vector<sim::CraftState>& crafts); void record_race_results(const std::vector<sim::CraftState>& crafts);
bool is_complete() const { return current_track > 6; } bool is_complete() const { return current_track > total_tracks; }
std::string player_rating_title() const; std::string player_rating_title() const;
bool save_slot(const std::filesystem::path& pref_dir, int slot) const; bool save_slot(const std::filesystem::path& pref_dir, int slot) const;
@@ -49,7 +52,7 @@ struct TrackRecord {
}; };
struct HighscoreTable { struct HighscoreTable {
std::array<TrackRecord, 6> tracks{}; std::array<TrackRecord, assets::kMaxTracks> tracks{};
void clear(); void clear();
// Returns bitmask: bit 0 = new fastest lap, bit 1 = new fastest race // Returns bitmask: bit 0 = new fastest lap, bit 1 = new fastest race
+2 -2
View File
@@ -13,8 +13,8 @@ void print_usage(const char* argv0) {
std::cout << "Top-Octane (Modern Cross-Platform SDL2 + OpenGL 3.3 Port of Hi-Octane)\n" std::cout << "Top-Octane (Modern Cross-Platform SDL2 + OpenGL 3.3 Port of Hi-Octane)\n"
<< "Usage: " << argv0 << " [options]\n" << "Usage: " << argv0 << " [options]\n"
<< " --data-dir <path> Path to read-only assets folder (default: ./data)\n" << " --data-dir <path> Path to read-only assets folder (default: ./data)\n"
<< " --track <1..6> Launch straight into race on track 1..6\n" << " --track <1..9> Launch straight into race on track 1..9\n"
<< " --track-viewer <1..6> Open interactive 3D track viewer for track 1..6\n" << " --track-viewer <1..9> Open interactive 3D track viewer for track 1..9\n"
<< " --classic Start in 4:3 Classic palette visual mode\n" << " --classic Start in 4:3 Classic palette visual mode\n"
<< " --modern Start in Modern HDR lighting visual mode\n" << " --modern Start in Modern HDR lighting visual mode\n"
<< " --fullscreen Start in borderless fullscreen\n" << " --fullscreen Start in borderless fullscreen\n"
+13 -3
View File
@@ -678,7 +678,7 @@ WorldRenderer::~WorldRenderer() {
} }
WorldRenderer::WorldLightingTheme WorldRenderer::theme_for_world(int world_idx) { WorldRenderer::WorldLightingTheme WorldRenderer::theme_for_world(int world_idx) {
switch (std::clamp(world_idx, 0, 5)) { switch (std::clamp(world_idx, 0, assets::kMaxTracks - 1)) {
case 0: // Amazon Delta Turnpike case 0: // Amazon Delta Turnpike
return {Vec3(0.46f, 0.78f, 0.42f).normalized(), return {Vec3(0.46f, 0.78f, 0.42f).normalized(),
Vec3(1.06f, 0.99f, 0.87f), Vec3(0.72f, 0.88f, 1.04f), Vec3(0.42f, 0.46f, 0.36f)}; Vec3(1.06f, 0.99f, 0.87f), Vec3(0.72f, 0.88f, 1.04f), Vec3(0.42f, 0.46f, 0.36f)};
@@ -694,9 +694,19 @@ WorldRenderer::WorldLightingTheme WorldRenderer::theme_for_world(int world_idx)
case 4: // Slam Canyon case 4: // Slam Canyon
return {Vec3(0.52f, 0.76f, 0.39f).normalized(), return {Vec3(0.52f, 0.76f, 0.39f).normalized(),
Vec3(1.10f, 0.98f, 0.84f), Vec3(0.72f, 0.86f, 1.02f), Vec3(0.50f, 0.40f, 0.32f)}; Vec3(1.10f, 0.98f, 0.84f), Vec3(0.72f, 0.86f, 1.02f), Vec3(0.50f, 0.40f, 0.32f)};
default: // Thrak City case 5: // Thrak City
return {Vec3(0.44f, 0.79f, 0.43f).normalized(), return {Vec3(0.44f, 0.79f, 0.43f).normalized(),
Vec3(1.02f, 0.97f, 0.95f), Vec3(0.68f, 0.80f, 1.05f), Vec3(0.38f, 0.38f, 0.48f)}; Vec3(1.02f, 0.97f, 0.95f), Vec3(0.68f, 0.80f, 1.05f), Vec3(0.38f, 0.38f, 0.48f)};
case 6: // Ancient Mine Town
return {Vec3(0.48f, 0.77f, 0.41f).normalized(),
Vec3(1.08f, 0.98f, 0.84f), Vec3(0.74f, 0.86f, 1.02f), Vec3(0.46f, 0.42f, 0.34f)};
case 7: // Arctic Land
return {Vec3(0.40f, 0.80f, 0.44f).normalized(),
Vec3(1.05f, 1.06f, 1.10f), Vec3(0.80f, 0.90f, 1.06f), Vec3(0.58f, 0.64f, 0.72f)};
case 8:
default: // Death Match Arena
return {Vec3(0.44f, 0.78f, 0.44f).normalized(),
Vec3(1.04f, 0.99f, 0.95f), Vec3(0.68f, 0.80f, 1.04f), Vec3(0.40f, 0.40f, 0.48f)};
} }
} }
@@ -1060,7 +1070,7 @@ bool WorldRenderer::load_level(const Vfs& vfs, const assets::LevelData& level,
return false; return false;
} }
fog_color_ = color_tables_.fog_color; fog_color_ = color_tables_.fog_color;
current_world_index_ = std::clamp(level.world_index, 0, 5); current_world_index_ = std::clamp(level.world_index, 0, assets::kMaxTracks - 1);
// Upload 256 x 64 x 64 terrain texture array // Upload 256 x 64 x 64 terrain texture array
if (tex_terrain_array_) glDeleteTextures(1, &tex_terrain_array_); if (tex_terrain_array_) glDeleteTextures(1, &tex_terrain_array_);
+14 -6
View File
@@ -32,11 +32,13 @@ int main() {
Vfs vfs; Vfs vfs;
CHECK(vfs.init(HIOCTANE_DEFAULT_DATA_DIR)); CHECK(vfs.init(HIOCTANE_DEFAULT_DATA_DIR));
// 1. Palette & ColorTables (0..5) CHECK(assets::count_available_tracks(vfs) == 9);
// 1. Palette & ColorTables (0..8)
Palette pal; Palette pal;
CHECK(pal.load(vfs)); CHECK(pal.load(vfs));
CHECK(pal.colors[1].a == 255); CHECK(pal.colors[1].a == 255);
for (int w = 0; w < 6; ++w) { for (int w = 0; w < 9; ++w) {
ColorTables tbl; ColorTables tbl;
CHECK(tbl.load(vfs, w, pal)); CHECK(tbl.load(vfs, w, pal));
WorldTextures wtex; WorldTextures wtex;
@@ -44,16 +46,22 @@ int main() {
CHECK(wtex.tile_rgba.size() == 256u * 64u * 64u * 4u); CHECK(wtex.tile_rgba.size() == 256u * 64u * 64u * 4u);
CHECK(wtex.sky_rgba.size() == 256u * 256u * 4u); CHECK(wtex.sky_rgba.size() == 256u * 256u * 4u);
} }
std::cout << "[PASS] Palette, 6 ColorTables, 6 WorldTextures & Skies\n"; std::cout << "[PASS] Palette, 9 ColorTables, 9 WorldTextures & Skies\n";
// 2. All 6 Levels (decompression, CRC16, entities, columns, blocks, waypoints, checkpoints) // 2. All 9 Levels (decompression, CRC16, entities, columns, blocks, waypoints, checkpoints)
for (int l = 1; l <= 6; ++l) { for (int l = 1; l <= 9; ++l) {
LevelData lvl; LevelData lvl;
CHECK(lvl.load(vfs, l)); CHECK(lvl.load(vfs, l));
CHECK(lvl.map.size() == kMapWidth * kMapHeight); CHECK(lvl.map.size() == kMapWidth * kMapHeight);
CHECK(!lvl.main_waypoints.empty()); CHECK(!lvl.main_waypoints.empty());
CHECK(!lvl.checkpoints.empty()); CHECK(!lvl.checkpoints.empty());
CHECK(lvl.checkpoints[0].index == 0); CHECK(lvl.checkpoints[0].index == 0);
for (const auto& cp : lvl.checkpoints) {
CHECK(cp.x0 != cp.x1 || cp.z0 != cp.z1);
}
if (l == 7) {
CHECK(lvl.checkpoints.size() == 6);
}
// Verify all referenced columns & floor tiles are within valid bounds // Verify all referenced columns & floor tiles are within valid bounds
int col_cells = 0; int col_cells = 0;
@@ -80,7 +88,7 @@ int main() {
<< " pickups=" << lvl.pickups.size() << " pickups=" << lvl.pickups.size()
<< " h=[" << min_h << ".." << max_h << "]\n"; << " h=[" << min_h << ".." << max_h << "]\n";
} }
std::cout << "[PASS] All 6 Levels parsed & validated\n"; std::cout << "[PASS] All 9 Levels parsed & validated\n";
// 3. Object texture atlases & all 3D models in OBJECTS/DATA/ // 3. Object texture atlases & all 3D models in OBJECTS/DATA/
ObjectTextureAtlas obj_atlas; ObjectTextureAtlas obj_atlas;
+36 -9
View File
@@ -8,6 +8,7 @@
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <filesystem> #include <filesystem>
#include <fstream>
#include <iostream> #include <iostream>
using namespace top_octane; using namespace top_octane;
@@ -109,14 +110,16 @@ int main() {
std::filesystem::remove_all(tmp_dir); std::filesystem::remove_all(tmp_dir);
{ {
game::ChampionshipState ch; game::ChampionshipState ch;
ch.start_new("ACE", 3, 7, 1); ch.start_new("ACE", 3, 7, 1, 8);
ch.record_race_results(sim.crafts()); ch.record_race_results(sim.crafts());
CHECK(ch.current_track == 2); CHECK(ch.current_track == 2);
CHECK(ch.total_tracks == 8);
CHECK(ch.save_slot(tmp_dir, 0)); CHECK(ch.save_slot(tmp_dir, 0));
game::ChampionshipState loaded; game::ChampionshipState loaded;
CHECK(loaded.load_slot(tmp_dir, 0)); CHECK(loaded.load_slot(tmp_dir, 0));
CHECK(loaded.current_track == 2); CHECK(loaded.current_track == 2);
CHECK(loaded.total_tracks == 8);
CHECK(loaded.player_name == "ACE"); CHECK(loaded.player_name == "ACE");
CHECK(loaded.drivers[0].points == ch.drivers[0].points); CHECK(loaded.drivers[0].points == ch.drivers[0].points);
@@ -124,19 +127,43 @@ int main() {
hs.clear(); hs.clear();
int flags = hs.submit_race(1, sim.crafts()); int flags = hs.submit_race(1, sim.crafts());
CHECK((flags & 3) == 3); CHECK((flags & 3) == 3);
int flags9 = hs.submit_race(9, sim.crafts());
CHECK((flags9 & 3) == 3);
CHECK(hs.save(tmp_dir / "hiscores.dat")); CHECK(hs.save(tmp_dir / "hiscores.dat"));
game::HighscoreTable hs2; game::HighscoreTable hs2;
CHECK(hs2.load(tmp_dir / "hiscores.dat")); CHECK(hs2.load(tmp_dir / "hiscores.dat"));
CHECK(hs2.tracks[0].best_lap == hs.tracks[0].best_lap); CHECK(hs2.tracks[0].best_lap == hs.tracks[0].best_lap);
CHECK(game::save_clone_recording(tmp_dir, rec)); CHECK(std::abs(hs2.tracks[8].best_lap - hs.tracks[8].best_lap) < 1e-6f);
// Legacy V1 highscores backwards-compatibility (6 entries)
{
std::ofstream ofs(tmp_dir / "hiscores_v1.dat", std::ios::trunc);
ofs << "TOPOCTANE_HISCORE_V1\n";
for (int i = 0; i < 6; ++i) {
ofs << (12.5f + i) << " " << (42.0f + i) << "\nLEGACY" << i << "\nLEGACYR" << i << "\n";
}
}
game::HighscoreTable hs_v1;
CHECK(hs_v1.load(tmp_dir / "hiscores_v1.dat"));
CHECK(std::abs(hs_v1.tracks[0].best_lap - 12.5f) < 1e-5f);
CHECK(hs_v1.tracks[0].best_lap_driver == "LEGACY0");
CHECK(hs_v1.tracks[8].best_lap == 0.0f);
CHECK(game::save_clone_recording(tmp_dir, rec));
sim::CloneRecording rec2; sim::CloneRecording rec2;
CHECK(game::load_clone_recording(tmp_dir, 1, rec2)); CHECK(game::load_clone_recording(tmp_dir, 1, rec2));
CHECK(rec2.frames.size() == rec.frames.size()); CHECK(rec2.frames.size() == rec.frames.size());
sim::CloneRecording rec7 = rec;
rec7.track_number = 7;
CHECK(game::save_clone_recording(tmp_dir, rec7));
sim::CloneRecording rec7_out;
CHECK(game::load_clone_recording(tmp_dir, 7, rec7_out));
CHECK(rec7_out.track_number == 7 && rec7_out.frames.size() == rec7.frames.size());
} }
std::filesystem::remove_all(tmp_dir); std::filesystem::remove_all(tmp_dir);
std::cout << "[PASS] Championship save/load, Highscores & Clone disk round-trip validated\n"; std::cout << "[PASS] Championship save/load, 9-track Highscores (V1/V2) & Clone disk round-trip validated\n";
// 5. Gameplay Rule Toggles (fuel, weapons, damage, pickups, track morphing) // 5. Gameplay Rule Toggles (fuel, weapons, damage, pickups, track morphing)
{ {
@@ -636,8 +663,8 @@ int main() {
// 8. Authentic Pitstop Fuel / Shield / Ammo Charger Bays // 8. Authentic Pitstop Fuel / Shield / Ammo Charger Bays
{ {
const size_t expected_pad_counts[6] = {3, 3, 3, 7, 6, 7}; const size_t expected_pad_counts[9] = {3, 3, 3, 7, 6, 7, 4, 4, 3};
for (int l = 1; l <= 6; ++l) { for (int l = 1; l <= 9; ++l) {
assets::LevelData lvl; assets::LevelData lvl;
CHECK(lvl.load(vfs, l)); CHECK(lvl.load(vfs, l));
CHECK(lvl.pads.size() == expected_pad_counts[l - 1]); CHECK(lvl.pads.size() == expected_pad_counts[l - 1]);
@@ -780,7 +807,7 @@ int main() {
CHECK(p1.fuel <= 20.0f); CHECK(p1.fuel <= 20.0f);
} }
} }
std::cout << "[PASS] Authentic pitstop Fuel/Shield/Ammo chargers verified across all 6 tracks\n"; std::cout << "[PASS] Authentic pitstop Fuel/Shield/Ammo chargers verified across all 9 tracks\n";
// 9. Original Explosions, Volumetric Smoke Trails, Wreck Plumes & Steam Vents // 9. Original Explosions, Volumetric Smoke Trails, Wreck Plumes & Steam Vents
{ {
@@ -1003,8 +1030,8 @@ int main() {
} }
std::cout << "[PASS] Authentic pickup subtypes (upgrades, double caps, invincible, invisible) validated\n"; std::cout << "[PASS] Authentic pickup subtypes (upgrades, double caps, invincible, invisible) validated\n";
// 11. Full 8-racer AI anti-stuck & progression check across all 6 tracks // 11. Full 8-racer AI anti-stuck & progression check across all 9 tracks
for (int l = 1; l <= 6; ++l) { for (int l = 1; l <= 9; ++l) {
assets::LevelData lvl; assets::LevelData lvl;
CHECK(lvl.load(vfs, l)); CHECK(lvl.load(vfs, l));
sim::RaceSetup ms; sim::RaceSetup ms;
@@ -1053,7 +1080,7 @@ int main() {
} }
CHECK(progressed >= 6); CHECK(progressed >= 6);
} }
std::cout << "[PASS] All 6 tracks 8-racer AI anti-stuck & progression validated\n"; std::cout << "[PASS] All 9 tracks 8-racer AI anti-stuck & progression validated\n";
return 0; return 0;
} }
+9 -9
View File
@@ -24,8 +24,8 @@ int main() {
Vfs vfs; Vfs vfs;
CHECK(vfs.init(HIOCTANE_DEFAULT_DATA_DIR)); CHECK(vfs.init(HIOCTANE_DEFAULT_DATA_DIR));
// 1. Verify starting grid across all 6 levels is collision-free and finite // 1. Verify starting grid across all 9 levels is collision-free and finite
for (int l = 1; l <= 6; ++l) { for (int l = 1; l <= 9; ++l) {
assets::LevelData lvl; assets::LevelData lvl;
CHECK(lvl.load(vfs, l)); CHECK(lvl.load(vfs, l));
@@ -57,7 +57,7 @@ int main() {
} }
} }
} }
std::cout << "[PASS] Start grid valid & collision-free across all 6 tracks\n"; std::cout << "[PASS] Start grid valid & collision-free across all 9 tracks\n";
// 2. Verify fixed-step determinism (running two identical sims produces bit-identical state) // 2. Verify fixed-step determinism (running two identical sims produces bit-identical state)
assets::LevelData lvl1; assets::LevelData lvl1;
@@ -250,8 +250,8 @@ int main() {
} }
std::cout << "[PASS] Overhead gantry overpass & ceiling clamping verified\n"; std::cout << "[PASS] Overhead gantry overpass & ceiling clamping verified\n";
// 7. All 6 tracks 1-lap autopilot completion // 7. All 9 tracks 1-lap autopilot completion
for (int l = 1; l <= 6; ++l) { for (int l = 1; l <= 9; ++l) {
assets::LevelData lvl; assets::LevelData lvl;
CHECK(lvl.load(vfs, l)); CHECK(lvl.load(vfs, l));
sim::RaceSetup setup; sim::RaceSetup setup;
@@ -272,12 +272,12 @@ int main() {
<< " time=" << p1.race_time << "s\n"; << " time=" << p1.race_time << "s\n";
CHECK(p1.finished); CHECK(p1.finished);
} }
std::cout << "[PASS] 1-lap autopilot completion verified across all 6 tracks\n"; std::cout << "[PASS] 1-lap autopilot completion verified across all 9 tracks\n";
// 8. 8-direction full-boost ramming stress test across all 6 tracks (0 column/cliff traps) // 8. 8-direction full-boost ramming stress test across all 9 tracks (0 column/cliff traps)
{ {
float dt = static_cast<float>(FixedStepClock::kFixedDt); float dt = static_cast<float>(FixedStepClock::kFixedDt);
for (int l = 1; l <= 6; ++l) { for (int l = 1; l <= 9; ++l) {
assets::LevelData lvl; assets::LevelData lvl;
CHECK(lvl.load(vfs, l)); CHECK(lvl.load(vfs, l));
for (const auto& wp : lvl.main_waypoints) { for (const auto& wp : lvl.main_waypoints) {
@@ -322,7 +322,7 @@ int main() {
} }
} }
} }
std::cout << "[PASS] 8-direction boost ramming stress test: 0 texture/cliff traps across all 6 tracks\n"; std::cout << "[PASS] 8-direction boost ramming stress test: 0 texture/cliff traps across all 9 tracks\n";
// 9. Targeted containment, bridge deck, cliff, and escape edge cases // 9. Targeted containment, bridge deck, cliff, and escape edge cases
{ {
+6 -6
View File
@@ -25,8 +25,8 @@ int main() {
assets::Palette pal; assets::Palette pal;
CHECK(pal.load(vfs)); CHECK(pal.load(vfs));
// Verify CPU geometry generation for all 6 tracks // Verify CPU geometry generation for all 9 tracks
for (int l = 1; l <= 6; ++l) { for (int l = 1; l <= 9; ++l) {
assets::LevelData lvl; assets::LevelData lvl;
CHECK(lvl.load(vfs, l)); CHECK(lvl.load(vfs, l));
@@ -129,15 +129,15 @@ int main() {
<< " column_tris=" << geo.column_indices.size() / 3 << "\n"; << " column_tris=" << geo.column_indices.size() / 3 << "\n";
} }
// Verify TRACK0-1 full track silhouette preview sprites for all 6 tracks // Verify TRACK0-1 full track silhouette preview sprites for all 9 tracks
{ {
assets::SpriteBank track_bank; assets::SpriteBank track_bank;
CHECK(track_bank.load(vfs, "DATA/TRACK0-1.DAT", "DATA/TRACK0-1.TAB", pal)); CHECK(track_bank.load(vfs, "DATA/TRACK0-1.DAT", "DATA/TRACK0-1.TAB", pal));
static constexpr int kPreviewIndices[6] = {1, 3, 6, 7, 9, 11}; static constexpr int kPreviewIndices[9] = {1, 3, 6, 7, 9, 11, 12, 14, 15};
for (int idx : kPreviewIndices) { for (int idx : kPreviewIndices) {
CHECK(static_cast<size_t>(idx) < track_bank.sprites.size()); CHECK(static_cast<size_t>(idx) < track_bank.sprites.size());
const auto& sp = track_bank.sprites[idx]; const auto& sp = track_bank.sprites[idx];
CHECK(sp.width >= 50 && sp.height >= 90); CHECK(sp.width >= 24 && sp.height >= 90);
CHECK(!sp.rgba.empty()); CHECK(!sp.rgba.empty());
} }
} }
@@ -176,6 +176,6 @@ int main() {
CHECK(mg.indices.size() == mesh.triangles.size() * 3u); CHECK(mg.indices.size() == mesh.triangles.size() * 3u);
} }
std::cout << "[PASS] All 6 Levels & Vehicle 3D Render Geometry validated\n"; std::cout << "[PASS] All 9 Levels & Vehicle 3D Render Geometry validated\n";
return 0; return 0;
} }