Reduce the career's game options to the ones that matter; keep leagues in a running game

The game page of a Dreierpack career offers five options (winter
postponements and their cap, indoor tournaments, the two transfer-news
switches). The cells of the original's presentation, the multi-player and
autosave cells and the switches that take leagues out of a running game are
no longer shown, and settings.commit refuses them. The sound page and the
marking automation are hidden in a career. A mailbox text cut inside a
multi-byte character no longer breaks the news read. modern_live_dump can
commit options and reports their effect.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-14 09:32:01 +01:00
1 parent 6d70a48be8
commit 1de09ba8a6
7 files changed
+135 -12

No files matched your search

+20
View File
@@ -8658,6 +8658,21 @@ std::vector<std::pair<std::string, ui::MailboxMessage>> ui_mailbox(const ModernS
std::snprintf(key, sizeof key, "message:%u-%08x", unsigned(m.date_counter), hash);
std::string id = key;
if (const int n = seen[id]++; n > 0) id += "-" + std::to_string(n + 1);
// A mailbox entry has a fixed size: a long text can end inside a multi-byte character of
// a world name. Such a tail (and any other ill-formed byte) is dropped, so the read
// always carries valid UTF-8; the id above stays the one of the stored bytes.
std::string clean;
clean.reserve(m.text.size());
for (size_t i = 0; i < m.text.size();) {
const unsigned char c = static_cast<unsigned char>(m.text[i]);
const size_t length = c < 0x80 ? 1 : (c >> 5) == 0x6 ? 2 : (c >> 4) == 0xe ? 3 : (c >> 3) == 0x1e ? 4 : 0;
bool whole = length != 0 && i + length <= m.text.size();
for (size_t k = 1; whole && k < length; ++k)
whole = (static_cast<unsigned char>(m.text[i + k]) & 0xc0) == 0x80;
if (whole) clean.append(m.text, i, length), i += length;
else ++i;
}
m.text = std::move(clean);
out.emplace_back(std::move(id), std::move(m));
}
return out;
@@ -10630,6 +10645,11 @@ cli::Json ModernSession::ui_command(const cli::Json& request, uint64_t& revision
const auto code = ui_text(edit, "code");
const auto *value = ui_field(edit, "value");
const int index = ui_setting_index(code);
// The interface offers only the options of the season itself; the original's
// presentation cells and the switches that take leagues out of a running game
// are not changed through this command.
static const std::set<std::string> offered{"P5", "Q5", "J8", "H6", "I6"};
if (!offered.contains(code)) throw FormatError("Diese Einstellung wird nicht angeboten.");
if (index < 0 || !seen.insert(index).second || !value || !value->integer() || *value->integer() < 0 || *value->integer() > 255)
throw FormatError("invalid_setting_edit");
const auto address = ::bmh::layout::LeaguePresentationOptions + uint32_t(index);
+1 -1
View File
@@ -39,7 +39,7 @@ Json engine_settings_projection(const Json &bundle) {
"Ungültige Wettbewerbszuordnung.");
titles[row] = name.is_null() ? "Wettbewerb " + row : name.get<std::string>();
}
Json catalogue = live_settings_catalogue();
Json catalogue = career_settings_catalogue();
for (auto &group : catalogue.at("groups"))
if (group.contains("competitions"))
for (auto &competition : group["competitions"]) {
+3 -3
View File
@@ -18,7 +18,7 @@ void App::settings_after_render() {
if (auto *label = element("settings-search-count"))
label->SetInnerRML(std::to_string(count) + (settings_query_.empty()
? " Optionen"
: " von "+std::to_string(live_settings_option_count())+" Optionen"));
: " von "+std::to_string(engine_mode_ ? career_settings_option_count() : live_settings_option_count())+" Optionen"));
}
if (settings_restore_scroll_) {
context_->Update();
@@ -113,12 +113,12 @@ void App::settings_filter() {
if (auto *label = element("settings-search-count"))
label->SetInnerRML(std::to_string(count) + (settings_query_.empty()
? " Optionen"
: " von "+std::to_string(live_settings_option_count())+" Optionen"));
: " von "+std::to_string(engine_mode_ ? career_settings_option_count() : live_settings_option_count())+" Optionen"));
if (auto *select = dynamic_cast<Rml::ElementFormControlSelect *>(
element("settings-jump"))) {
std::string choices;
std::string first;
for (const auto &g : live_settings_catalogue().at("groups")) {
for (const auto &g : settings_catalogue_view().at("groups")) {
const auto id = g.at("id").get<std::string>();
const bool shown = element("settings-group-" + id) != nullptr;
if (shown && first.empty())
+43
View File
@@ -51,7 +51,50 @@ inline const Json &live_settings_catalogue() {
}();
return view;
}
// The game options of a Dreierpack career: only switches that change how the season is
// played or what the manager is told. The stored cells of the original's presentation
// (broadcast panels, animation timings, result boards per competition) have no effect in
// this interface and are not offered; neither is switching leagues off in a running game.
inline const Json &career_settings_catalogue() {
static const Json view = [] {
const auto &all = settings_catalogue();
const auto find = [&](const std::string &code) -> Json {
for (const auto &group : all.at("groups"))
if (group.contains("options"))
for (const auto &row : group.at("options"))
if (row.value("code", "") == code) return row;
throw editor::Error("Unbekannte Spieloption.");
};
const auto option = [&](const char *code, const char *label, const char *help) {
Json row = find(code);
row["label"] = label; row["help"] = help;
return row;
};
Json out = Json::object();
out["groups"] = Json::array(
{{{"id", "rules"}, {"title", "Spielablauf"},
{"options", Json::array({option("P5", "Spielausfälle im Winter", "Bei schlechtem Wetter fallen Spiele aus und werden nachgeholt."),
option("J8", "Höchstens ausgefallene Spiele je Liga und Spieltag", "0 bis 9."),
option("Q5", "Hallenturniere in der Winterpause", "Kann während der Hallensaison nicht umgestellt werden.")})}},
{{"id", "transfers"}, {"title", "Nachrichten"},
{"options", Json::array({option("H6", "Alle Transfers melden", "Jeder Vereinswechsel erscheint in den Nachrichten."),
option("I6", "Nur Transfers der Tabellennachbarn melden", "")})}}});
out["sound"] = Json::array();
Json automation = Json::array();
for (const auto &row : all.at("automation"))
if (row[0] != "marking") automation.push_back(row);
out["automation"] = std::move(automation);
return out;
}();
return view;
}
inline int career_settings_option_count() {
int total = 0;
for (const auto &group : career_settings_catalogue().at("groups")) total += int(group.at("options").size());
return total;
}
inline int live_settings_option_count() {
int total = 0;
for (const auto &group : live_settings_catalogue().at("groups")) {
if (group.contains("options"))
+9 -8
View File
@@ -196,8 +196,9 @@ std::string App::render_settings() {
{"game", "Spiel"},
{"automation", "Automatik"}}};
for (const auto &[id, label] : categories)
if (!settings_global_only() || std::string(id) == "display" ||
std::string(id) == "sound")
if ((!settings_global_only() || std::string(id) == "display" ||
std::string(id) == "sound") &&
!(engine_mode_ && std::string(id) == "sound")) // a career has no sound options yet
nav += btn("settings-category", "<span>" + std::string(label) + "</span>",
settings_category_ == id ? "active" : "",
"id=\"settings-tab-" + std::string(id) +
@@ -207,10 +208,10 @@ std::string App::render_settings() {
const std::map<std::string, std::pair<std::string, std::string>> captions = {
{"display", {"Anzeige", "Bildschirm und Sprache"}},
{"sound", {"Sound", "Lautstärke, Effekte und Spielton"}},
{"game", {"Spiel", "Spielablauf und Live-Ticker"}},
{"game", {"Spiel", engine_mode_ ? "Spielablauf und Nachrichten" : "Spielablauf und Live-Ticker"}},
{"automation",
{"Automatik",
"Aufstellung, Wechsel, Taktik, Manndeckung und Training"}}};
engine_mode_ ? "Aufstellung, Wechsel, Taktik und Training" : "Aufstellung, Wechsel, Taktik, Manndeckung und Training"}}};
std::string head = "<div><h2>" + captions.at(settings_category_).first +
"</h2><p>" + captions.at(settings_category_).second +
"</p></div>";
@@ -324,10 +325,10 @@ std::string App::render_settings() {
settings_switch("automation-all", "automation", "all",
total > 0 && on == total, on > 0 && on < total)) +
"</div><div class=\"settings-group\"><h3>Aufgaben an den Co-Trainer "
"abgeben</h3><p class=\"settings-group-help\">Die fünf "
"Automatikfunktionen des Originals. Änderungen werden erst mit "
"„Anwenden“ übernommen.</p>";
for (const auto &o : live_settings_catalogue().at("automation")) {
"abgeben</h3><p class=\"settings-group-help\">" +
std::string(engine_mode_ ? "" : "Die fünf Automatikfunktionen des Originals. ") +
"Änderungen werden erst mit „Anwenden“ übernommen.</p>";
for (const auto &o : settings_catalogue_view().at("automation")) {
const auto key = o[0].get<std::string>();
pane += settings_row("automation-" + key, o[1].get<std::string>(),
o[2].get<std::string>(),