Honor Original visible league counts for fresh Classic managers (by Codex)

This commit is contained in:
Codex committed 2026-11-02 23:28:05 +01:00
1 parent 048f617395
commit d661ec5eb0
9 files changed
+86 -5

No files matched your search

+10
View File
@@ -4,6 +4,7 @@
#include "game/calendar.hpp"
#include "formats/executable_layout.hpp"
#include "app/career_session.hpp"
#include "formats/league_visibility.hpp"
#include <stdexcept>
#include <system_error>
@@ -728,6 +729,9 @@ bool CareerSession::confirm_manager_join(const ui::ManagerChoice& choice, std::s
selected.name = choice.name; selected.team = runtime_club(draft.state, choice.master_club);
selected.league = choice.start_league; selected.strength = choice.strength; selected.portrait = choice.portrait;
if (selected.team < 0) throw FormatError("join: club not found");
const auto visible=player_league_count(exe_);
const auto club_league=team_league(selected.team);
if(selected.league>=visible||(club_league>=visible&&club_league<5))throw FormatError("join: league is not available for human management");
MinuteReport report;
if (!career_add_manager(draft.state, exe_, choice.slot, selected, true, draft.game, draft.rand, report))
throw FormatError(report.reason);
@@ -807,6 +811,12 @@ void CareerSession::apply_options(const ui::SetupOptions& o) {
bool CareerSession::confirm_manager(const ui::SetupOptions& options, const ui::ManagerChoice& choice, std::string& error) {
if (balance_draft_ || balance_dispatch_active_ || strengths_owner_ || strengths_dispatch_active_ ||
top_scorers_owner_ || top_scorers_dispatch_active_ || stadium_.block_expansion || other_games_owner_ || other_games_dispatch_active_) { error = "strengths_active"; return false; }
const auto visible=player_league_count(exe_);
const auto selected_team=runtime_club(choice.master_club);
const auto selected_league=selected_team>=0?team_league(selected_team):-1;
if(choice.start_league<0||choice.start_league>=visible||(selected_league>=visible&&selected_league<5)) {
error="league is not available for human management";return false;
}
if (!options_applied_) apply_options(options);
const int m = int(managers_.size());
if (m >= options.managers) {
+14
View File
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "formats/executable_layout.hpp"
#include "formats/le.hpp"
#include <stdexcept>
namespace bmh {
// Original data separates internal domestic slots from player-visible levels.
inline int player_league_count(const LeImage& image) {
const auto address=layout::LeaguePairings_LeaguePairingsConstants_RuntimeField;
if(!image.contains(address+1)||image.u8(address)!=5||image.u8(address+1)<1||image.u8(address+1)>5)
throw std::invalid_argument("invalid player-facing league count");
return image.u8(address+1);
}
}
+7 -2
View File
@@ -2,6 +2,7 @@
#include "formats/badge_policy.hpp"
#include "formats/executable_layout.hpp"
#include "ui/manager.hpp"
#include "formats/league_visibility.hpp"
#include <algorithm>
#include <iomanip>
@@ -151,6 +152,7 @@ ManagerScreen::ManagerScreen(const std::filesystem::path& data, int slot, const
if (exe_.u8(::bmh::layout::Manager_FormatError_RuntimeField + i * 2) < 'B') ++text_id;
if (last_[i] - first_[i] >= 20) throw FormatError("manager: league exceeds picker grid");
}
for(int i=player_league_count(exe_);i<5;++i){last_[i]=first_[i]-1;leagues_[i].clear();}
first_[5] = exe_.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField); last_[5] = first_[5] + 19;
first_[6] = first_[5] + 20; last_[6] = first_[5] + exe_.u16(::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField6) - 1;
leagues_[5] = texts_[(::bmh::layout::Manager_FormatError_TextPointer - ::bmh::layout::TextPointerTable) / 4]; leagues_[6] = leagues_[5];
@@ -160,6 +162,8 @@ ManagerScreen::ManagerScreen(const std::filesystem::path& data, int slot, const
throw FormatError("manager: unsupported extra-team table");
}
int ManagerScreen::visible_league_count() const {return player_league_count(exe_);}
int ManagerScreen::master_id(int selection_id) const {
return context_.club_order.at(size_t(selection_id));
}
@@ -206,6 +210,7 @@ bool ManagerScreen::click(int x, int y, bool right) {
for (int i = 0; i < 7; ++i) {
int bx = i < 4 ? 64 : 161, by = 175 + (i < 4 ? i : i - 4) * 11;
if (x >= bx && x <= bx + 94 && y >= by && y <= by + 10) {
if(i<5&&i>=visible_league_count())return false;
bool changed = group_ != i; group_ = i; hover_ = hovered_club(x, y); return changed;
}
}
@@ -227,7 +232,7 @@ bool ManagerScreen::click(int x, int y, bool right) {
for (int i = 0; i < 4; ++i) {
if (x < field_x_[i] || x > field_x_[i] + field_width_[i] || y < baseline_[i] - 26 || y > baseline_[i] + 3) continue;
if (i == 0) { choice_.name.clear(); view_ = ManagerView::name_edit; return true; }
if (i == 1) { choice_.start_league = (choice_.start_league + 1) % 5; return true; }
if (i == 1) { choice_.start_league = (choice_.start_league + 1) % visible_league_count(); return true; }
if (i == 2) open_clubs = true;
if (i == 3) { choice_.strength = (choice_.strength + 1) % 3; return true; }
}
@@ -369,7 +374,7 @@ Image ManagerScreen::render() const {
if (choice_.selection_club == id) copy(out, faces_, 228, 0, x + 24, y + 23, 11, 13, true);
}
}
for (int i = 0; i < 7; ++i)
for (int i = 0; i < 7; ++i)if(i>=5||i<visible_league_count())
button(out, i < 4 ? 64 : 161, 175 + (i < 4 ? i : i - 4) * 11, 94, leagues_[i], group_ == i);
// Hover clear uses a new local pattern origin, even when no club is hovered.
pattern(out, 81, 222, 151, 8);
+1
View File
@@ -56,6 +56,7 @@ public:
// builds them from the executable's tables: label (original encoding) and the inclusive
// range of selection indices. Used by the console (openbmh_cli) for ListTeams.
static constexpr int group_count = 7;
int visible_league_count() const;
const std::string& group_label(int group) const { return leagues_.at(size_t(group)); }
int group_first(int group) const { return first_.at(size_t(group)); }
int group_last(int group) const { return last_.at(size_t(group)); }
+6 -1
View File
@@ -18,7 +18,12 @@ int main(int argc, char** argv) {
check(s.choice().master_club == 0 && s.choice().portrait == 0, "default available identity");
check(s.render().pixels.size() == 320 * 240, "original manager framebuffer");
check(!s.click(320, 10, true) && !s.text("ignored"), "invalid point and inactive text input");
for (int i = 0; i < 5; ++i) s.click(30, 140);
for (int i = 0; i < s.visible_league_count(); ++i) s.click(30, 140);
if(s.visible_league_count()==4) {
check(s.group_label(4).empty()&&s.group_last(4)<s.group_first(4),"hidden English domestic group remains selectable");
check(s.click(200,95),"English club picker opens");const auto unchanged=s.choice();
check(!s.click(180,180)&&s.choice()==unchanged,"hidden English group accepted a click");s.click(5,225,true);
}
for (int i = 0; i < 3; ++i) s.click(220, 140);
check(s.choice().start_league == 0 && s.choice().strength == 1, "league and strength wrap");
check(s.click(30, 65) && s.choice().name.empty(), "starting edit clears name like original");