Team id comparisons ask the world layout

92 comparisons against the raw numbers 138, 168 and 357 in engine, UI and app
read world_layout().league_teams, first_foreign_cup() and no_team(); a team id
written as 0x165 is kNoTeam. Same values, same arithmetic.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude committed 2026-11-10 23:16:53 +01:00
1 parent cb6d3b6035
commit d552c59a77
29 files changed
+94 -93

No files matched your search

+2 -2
View File
@@ -83,7 +83,7 @@ FriendlyMatchScreen::FriendlyMatchScreen(const std::filesystem::path& data, Frie
data_(data), next_request_id_(state_.first_request_id) {
const bool valid_national_slot = state_.national_team && state_.runtime_team == bmh::kNoTeam;
if (state_.manager_slot < 0 || state_.manager_slot > 3 || state_.runtime_team < 0 ||
(state_.runtime_team >= 168 && !valid_national_slot) ||
(state_.runtime_team >= world_layout().first_foreign_cup() && !valid_national_slot) ||
state_.revision == UINT64_MAX || !state_.first_request_id || state_.planner_count < 0 ||
state_.planner_count > std::numeric_limits<int>::max() - 2)
throw FormatError("friendly screen: invalid manager/request identity");
@@ -347,7 +347,7 @@ std::optional<FriendlyMatchRequest> FriendlyMatchScreen::click(int x, int y, boo
const int row = (y-0x1d)/7;
if (row < 0 || size_t(row) >= rows.size()) return std::nullopt;
selected_opponent_ = rows[size_t(row)].runtime_team_id;
if (selected_opponent_ == state_.runtime_team || selected_opponent_ < 0 || selected_opponent_ >= 168) {
if (selected_opponent_ == state_.runtime_team || selected_opponent_ < 0 || selected_opponent_ >= world_layout().first_foreign_cup()) {
selected_opponent_ = -1;
feedback_ = "Bitte einen anderen Ligaverein waehlen.";
return std::nullopt;