Load Modern worlds and add Modern training camps (M3, M4)

M3 - Modern world loader:
- modern/content/world: typed view of the world tables (leagues, clubs,
  players, nations, league dates, training camp catalogue).
- modern/content/world_package: opens a Modern world (runtime:modern-v1, or
  editor:world-v1 until data revision 1.4), reads only the engine entries and
  decodes the Classic payload (import: load_classic_payload).
- modern/content/world_expand: turns the Classic start into the world: club
  ids in the order of the world's leagues, per-club tables remapped (added
  clubs copy an original club of their league), added players from their
  attributes, 24 squad slots per league club, pools kept, layout, league
  sizes and league dates installed; UTF-8 names and OBW ids in ModernState.
- Fixes found by playing the Modern data set: referee pool exhausted on days
  with German and larger international leagues (Modern deviation), card
  table per league club grown, slot-to-team lookup via WorldLayout, form
  history stride from the layout, remaining slot literals.
- Classic UI projections used by the session read the layout instead of
  executable constants (Classic values unchanged).
- modern_season_sim opens .obw worlds; MODERN_DEBUG / MODERN_WATCH tracing.

M4 - training camps:
- Catalogue in ModernState (built-in 18 fictional camps on three maps, or the
  world's extended catalogue); price, booking and effect use it.
- Six-star grades: step index capped, limit +1 from pitch 5 and +1 with pitch
  and fitness 6, catering 6 one more point of condition, lodging 6 one week
  less injury. Classic data behaves as before. modern_camp_tests.

Verified: 190 tests pass; Classic replay regression identical to the M0
baseline; season_sim and modern_season_sim identical with Classic data; the
Modern data set plays full seasons (leagues 34/38/34 rounds).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-23 22:43:25 +02:00
1 parent 13bdc56f04
commit 6f55622307
53 files changed
+1392 -87

No files matched your search

+12
View File
@@ -2,6 +2,8 @@
#include "formats/executable_layout.hpp"
#include "modern/game/modern_state.hpp"
#include "modern/app/modern_session.hpp"
#include "modern/content/world_expand.hpp"
#include "modern/content/world_package.hpp"
#include "modern/game/balance_plan.hpp"
#include "modern/game/bank_credit.hpp"
#include "modern/game/career.hpp"
@@ -590,6 +592,10 @@ ModernSession::ModernSession(const std::filesystem::path& data, uint32_t watcom_
session_id_ = next_session_id.fetch_add(1, std::memory_order_relaxed);
initialize_club_modal_runtime();
g_ = modern::startup_state(exe_, db_, read_file(data / "M3.MEN"), read_file(data / "M3.DAT"));
// A Modern world: give the Classic start the dimensions and data of the world (M3).
if (std::getenv("MODERN_DEBUG")) std::fprintf(stderr, "session: classic start built\n");
if (const World* world = current_world()) world_report_ = expand_to_world(g_, *world);
if (std::getenv("MODERN_DEBUG")) std::fprintf(stderr, "session: world expanded\n");
if (const auto resource = content::find(data)) {
g_.display_start_year = resource->content->start_year;
content::set_display_start_year(data, g_.display_start_year);
@@ -598,6 +604,7 @@ ModernSession::ModernSession(const std::filesystem::path& data, uint32_t watcom_
g_.texts = &texts_;
g_.currency_suffix = exe_.cstring(::bmh::layout::CurrencySuffixText); // CurrencySuffixText
modern::configure_training_camp_data(g_, exe_);
if (const World* world = current_world()) install_training_camps(g_, *world);
for (size_t i = 0; i < g_.credit_rate_table.size(); ++i) g_.credit_rate_table[i] = exe_.u8(::bmh::layout::BankCredit_BankCreditContext_RuntimeField3 + uint32_t(i));
g_.credit_divisor = std::bit_cast<double>(uint64_t(exe_.u32(::bmh::layout::BankCredit_BankCreditContext_RuntimeField)) | uint64_t(exe_.u32(::bmh::layout::BankCredit_BankCreditContext_RuntimeField2)) << 32);
g_.credit_rate_table_available = true;
@@ -606,10 +613,14 @@ ModernSession::ModernSession(const std::filesystem::path& data, uint32_t watcom_
turn_driver_.desk_autosave = [this](const ModernState &state, WatcomRandom &random) {
write_desk_autosave(state, random);
};
const bool trace = std::getenv("MODERN_DEBUG") != nullptr;
if (trace) std::fprintf(stderr, "session: startup players\n");
modern::startup_players(g_, game_, rand_); // CareerFirstSteps2
MinuteReport report;
if (trace) std::fprintf(stderr, "session: new career before dialog\n");
if (!modern::new_career_before_dialog(g_, game_, rand_, report)) // InitializeCareer up to the dialog
throw std::runtime_error("career start: " + report.reason);
if (trace) std::fprintf(stderr, "session: career prepared\n");
}
ModernSession::ModernSession(const std::filesystem::path &data, uint32_t watcom_seed,
@@ -686,6 +697,7 @@ ModernSession::ModernSession(const std::filesystem::path &data, uint32_t watcom_
g_.texts = &texts_;
g_.currency_suffix = exe_.cstring(::bmh::layout::CurrencySuffixText); // CurrencySuffixText
modern::configure_training_camp_data(g_, exe_);
if (const World* world = current_world()) install_training_camps(g_, *world);
for (size_t i = 0; i < g_.credit_rate_table.size(); ++i) g_.credit_rate_table[i] = exe_.u8(::bmh::layout::BankCredit_BankCreditContext_RuntimeField3 + uint32_t(i));
g_.credit_divisor = std::bit_cast<double>(uint64_t(exe_.u32(::bmh::layout::BankCredit_BankCreditContext_RuntimeField)) | uint64_t(exe_.u32(::bmh::layout::BankCredit_BankCreditContext_RuntimeField2)) << 32);
g_.credit_rate_table_available = true;
+5
View File
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "formats/executable_layout.hpp"
#pragma once
#include "modern/content/world_expand.hpp"
// The engine side of the UI's career handoff (src/ui/flow.hpp, ENGINE_BINDING.md).
//
// The original starts a career at program start (game/career.hpp): the data files are
@@ -879,7 +880,11 @@ public:
ui::SettingsState settings_projection(int manager, uint64_t revision) const {
return ui::settings_from_game(state(), manager, revision, exe_, sound_capabilities_);
}
// What expanding the Classic start into the Modern world did (empty for Classic data).
const ExpandReport& world_report() const { return world_report_; }
private:
ExpandReport world_report_;
std::optional<ui::SettingsSoundCapabilities> sound_capabilities_;
std::optional<std::filesystem::path> autosave_directory_;
std::string autosave_error_;