Create real careers from the native wizard and preserve manager presentation (by Codex)

This commit is contained in:
Codex committed 2026-10-29 01:11:41 +01:00
1 parent 738ecc7a09
commit ce1535fe2d
38 files changed
+466 -75

No files matched your search

+31 -1
View File
@@ -54,6 +54,7 @@
#include "formats/fbm.hpp"
#include "formats/savestate.hpp"
#include "modern/game/career.hpp"
#include "ui/season_entrants.hpp"
#include "modern/game/cup.hpp"
#include "modern/game/driver.hpp"
#include "modern/game/desk.hpp"
@@ -8947,12 +8948,41 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
const std::string kind = ui_text(request, "kind"), request_id = ui_text(request, "requestId");
const int manager = context.manager;
if (manager < 0 || size_t(manager) >= g_.manager_teams.size() ||
(kind != "lineup" && kind != "tactics" && kind != "training" && kind != "bank" && kind != "contracts" &&
(kind != "opening" && kind != "lineup" && kind != "tactics" && kind != "training" && kind != "bank" && kind != "contracts" &&
kind != "advertising" && kind != "stadium" && kind != "transfer" && kind != "postmatch" && kind != "credit" &&
!(kind == "friendly" && g_.manager_teams[size_t(manager)] == no_team())))
return modern::ui_read(g_, context, request);
if (const std::string wanted = ui_text(request, "managerId"); !wanted.empty() && wanted != modern::ui_manager_id(g_, manager))
return modern::ui_error(request_id, "manager_not_active", "Dieser Manager sitzt nicht am Schreibtisch.", revision, false);
if (kind == "opening") {
try {
O entrants{{"uefa", A{}}, {"champions", A{}}, {"winners", A{}}}; A order, fixtures;
const bool enabled = g_.memory.has(::bmh::layout::CompetitionSelection) && (g_.memory.u32(::bmh::layout::CompetitionSelection) & 1) != 0;
const auto team = [&](int runtime) {
if (runtime < 0 || size_t(runtime) >= g_.world_club_id.size()) throw FormatError("opening participant outside world");
const auto name = size_t(runtime) < g_.world_club_name.size() && !g_.world_club_name[size_t(runtime)].empty() ? g_.world_club_name[size_t(runtime)] : ui::original_to_utf8(g_.club_name(runtime));
return cli::Json(O{{"id", modern::ui_team_id(g_, runtime)}, {"name", name}});
};
// Read the same active prefixes as EuropeanClub/SeasonEntrants, without
// depending on Classic's executable pixel-placement and badge tables.
constexpr uint32_t pools[]{::bmh::layout::Career_CompetitionPointersEnglish_ExecutableField25,::bmh::layout::Career_CompetitionPointersEnglish_RuntimeField14,::bmh::layout::Career_CompetitionPointersEnglish_ExecutableField19};
constexpr uint32_t counts[]{::bmh::layout::Career_EuropeanClub_ExecutableField,::bmh::layout::Career_EuropeanClub_ExecutableField2,::bmh::layout::Career_EuropeanClub_ExecutableField3};
constexpr const char* keys[]{"uefa", "champions", "winners"};
if(enabled)for(size_t competition=0;competition<3;++competition) {
std::set<int> seen;const int count=g_.memory.u8(counts[competition]);
for(int i=0;i<count;++i){const int runtime=g_.memory.u16(pools[competition]+uint32_t(i)*2);if(runtime<modern::german_clubs()&&seen.insert(runtime).second)std::get<A>(entrants.at(keys[competition]).value).push_back(team(runtime));}
}
if (enabled) {
const auto pairs = modern::query_projection(g_, manager, O{{"kind", "other-fixtures"}, {"viewId", "cup-view:0:0"}, {"round", 1}});
const auto* p = pairs.object();
if (!p || !p->count("matches")) throw FormatError("opening cup pairings unavailable");
for (const auto& match : *p->at("matches").array()) {
const auto& m = *match.object(); order.push_back(m.at("home")); order.push_back(m.at("away")); fixtures.push_back(m.at("id"));
}
}
return modern::ui_snapshot(g_, context, request_id, O{{"kind", "opening"}, {"enabled", enabled}, {"showEntrants", enabled}, {"entrants", std::move(entrants)}, {"order", std::move(order)}, {"fixtureIds", std::move(fixtures)}});
} catch (const std::exception&) { return modern::ui_error(request_id, "opening_unavailable", "Die Saisonvorbereitung ist derzeit nicht verfügbar.", revision, false); }
}
if (kind == "friendly") {
// the national coach's friendly (menu 6): the quote rates both teams with a draw of the
// Watcom generator; the read quotes on a copy of it (the session's generator stays as it