Enable expanded international careers and private Classic-format preparation (by Codex)
This commit is contained in:
1 parent
aae6556708
commit
b5d60ef8a7
78 files changed
+816
-269
No files matched your search
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "alltime_table.hpp"
|
||||
#include <algorithm>
|
||||
@@ -25,11 +26,11 @@ void button(Image&out,const Image&a,const SpriteFont&spr,const LeImage&exe,int x
|
||||
}
|
||||
AllTimeTableState alltime_table_from_game(const GameState&g,const LeImage&exe,DeskRequest owner,const Image&underlay,int nation,bool relative){
|
||||
if(nation<0||nation>4)throw FormatError("alltime: nation outside 0..4");if(underlay.width!=320||underlay.height!=240)throw FormatError("alltime: parent underlay must be 320x240");AllTimeTableState s;s.owner=owner;s.underlay=underlay;s.nation=nation;s.relative=relative;s.mask=uint8_t((1U<<nation)|(relative?0x20:0));
|
||||
if(g.club_table.size()<168*0x4a)return s;s.has_data=true;s.records.resize(168);
|
||||
for(int t=0;t<168;++t){size_t b=size_t(t)*0x4a+0x1e;auto u=[&](int o){return uint16_t(g.club_table[b+size_t(o)]|uint16_t(g.club_table[b+size_t(o+1)])<<8);};auto&r=s.records[size_t(t)];r.points=u(0);r.goals_for=u(2);r.goals_against=u(4);r.wins=u(6);r.draws=u(8);r.losses=u(10);if(t<int(g.club_ids.size()))s.club_names[size_t(t)]=g.club_name(t);s.club_name_colors[size_t(t)]=team_color(g,t);}
|
||||
for(int n=0;n<5;++n)if(0x165+n<int(g.club_ids.size()))s.nation_names[size_t(n)]=g.club_name(0x165+n);
|
||||
if(g.club_table.size()<runtime_dimensions.record_teams*0x4a)return s;s.has_data=true;s.records.resize(runtime_dimensions.record_teams);
|
||||
for(int t=0;t<runtime_dimensions.record_teams;++t){size_t b=size_t(t)*0x4a+0x1e;auto u=[&](int o){return uint16_t(g.club_table[b+size_t(o)]|uint16_t(g.club_table[b+size_t(o+1)])<<8);};auto&r=s.records[size_t(t)];r.points=u(0);r.goals_for=u(2);r.goals_against=u(4);r.wins=u(6);r.draws=u(8);r.losses=u(10);if(t<int(g.club_ids.size()))s.club_names[size_t(t)]=g.club_name(t);s.club_name_colors[size_t(t)]=team_color(g,t);}
|
||||
for(int n=0;n<5;++n)if(kNoTeam+n<int(g.club_ids.size()))s.nation_names[size_t(n)]=g.club_name(kNoTeam+n);
|
||||
const uint32_t start=kFirst+uint32_t(nation)*8;const int league=exe.u8(kLeague+uint32_t(nation));const uint32_t full=uint32_t(league_matchdays(league));
|
||||
for(int part=0;part<2;++part){int first=exe.u16(start+uint32_t(part)*4),end=exe.u16(::bmh::layout::AlltimeTable_AlltimeTableFromGame_RuntimeField+uint32_t(nation)*8+uint32_t(part)*4);for(int team=first;team<end;++team){if(team<0||team>=168)continue;const auto&r=s.records[size_t(team)];int played=int(r.wins)+r.draws+r.losses;if(!played)continue;uint32_t p=r.points,gf=r.goals_for,ga=r.goals_against;if(relative){p=p*full*10U/uint32_t(played);gf=gf*full*10U/uint32_t(played);ga=ga*full*10U/uint32_t(played);}AllTimeRow row;row.team=team;row.played=played;row.points=p;row.goals_for=gf;row.goals_against=ga;row.points_key=p*0x10001U+0x7d000000U;row.goal_key=gf*0x10001U-ga*0x10000U+0x7d000000U;s.rows.push_back(row);}}
|
||||
for(int part=0;part<2;++part){int first=exe.u16(start+uint32_t(part)*4),end=exe.u16(::bmh::layout::AlltimeTable_AlltimeTableFromGame_RuntimeField+uint32_t(nation)*8+uint32_t(part)*4);for(int team=first;team<end;++team){if(team<0||team>=runtime_dimensions.record_teams)continue;const auto&r=s.records[size_t(team)];int played=int(r.wins)+r.draws+r.losses;if(!played)continue;uint32_t p=r.points,gf=r.goals_for,ga=r.goals_against;if(relative){p=p*full*10U/uint32_t(played);gf=gf*full*10U/uint32_t(played);ga=ga*full*10U/uint32_t(played);}AllTimeRow row;row.team=team;row.played=played;row.points=p;row.goals_for=gf;row.goals_against=ga;row.points_key=p*0x10001U+0x7d000000U;row.goal_key=gf*0x10001U-ga*0x10000U+0x7d000000U;s.rows.push_back(row);}}
|
||||
std::stable_sort(s.rows.begin(),s.rows.end(),[](const auto&a,const auto&b){if(a.points_key!=b.points_key)return a.points_key>b.points_key;return a.goal_key>b.goal_key;});if(s.rows.size()>24)s.rows.resize(24);return s;
|
||||
}
|
||||
AllTimeTableScreen::AllTimeTableScreen(const std::filesystem::path&data,AllTimeTableState s):state_(std::move(s)),data_(data),exe_(load_le(asset_path(data,"BMH.exe"))),font_(load_font(asset_path(data/"F","BMH3.FNT"))),header_(load_font(asset_path(data/"F","BMH2.FNT"))),sprite_(data),window_(load_vga(asset_path(data/"KB","56.VGA"))),buttons_(load_vga(asset_path(data/"KB","0.VGA"))),texts_(load_textd(asset_path(data,"TEXTD.BLK"))){if(state_.underlay.width!=320||state_.underlay.height!=240)throw FormatError("alltime: invalid parent frame");}
|
||||
|
||||
@@ -22,8 +22,8 @@ struct AllTimeTableState {
|
||||
Image underlay;
|
||||
std::vector<AllTimeRecord> records;
|
||||
std::array<std::string,5> nation_names{};
|
||||
std::array<std::string,168> club_names{};
|
||||
std::array<uint8_t,168> club_name_colors{};
|
||||
std::vector<std::string> club_names = std::vector<std::string>(size_t(runtime_dimensions.record_teams));
|
||||
std::vector<uint8_t> club_name_colors = std::vector<uint8_t>(size_t(runtime_dimensions.record_teams));
|
||||
std::vector<AllTimeRow> rows;
|
||||
int nation=0;
|
||||
uint8_t mask=1;
|
||||
|
||||
@@ -47,7 +47,7 @@ int32_t source_asset_mask_1e(const GameState& game, int manager) {
|
||||
}
|
||||
int source_manager_league(const GameState& game, const LeImage& exe, int manager) {
|
||||
const int team = game.manager_teams.at(size_t(manager));
|
||||
if (team > 0x164) return 0; // TeamLeague2 special-team early return.
|
||||
if (team > (kNoTeam - 1)) return 0; // TeamLeague2 special-team early return.
|
||||
int cumulative = 0;
|
||||
for (int league = 0; league < 9; ++league) {
|
||||
cumulative += exe.u8(::bmh::layout::LeagueSizes + uint32_t(league));
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ CalendarScreen::CalendarScreen(const std::filesystem::path& data, CalendarState
|
||||
if (runtime_club >= 0) {
|
||||
// TeamLeague2 returns zero for team handles above0x164 (national included).
|
||||
int league = 0, boundary = 0;
|
||||
if (runtime_club <= 0x164) {
|
||||
if (runtime_club <= (kNoTeam - 1)) {
|
||||
for (; league < 9; ++league) {
|
||||
boundary += exe_.u8(::bmh::layout::LeagueSizes + uint32_t(league));
|
||||
if (runtime_club < boundary) break;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/club_player_detail.hpp"
|
||||
@@ -46,8 +47,8 @@ ClubPlayerDetailProjection club_player_detail_from_game(const GameState& g,
|
||||
for(int i=0;i<2;++i){
|
||||
const int id=i?c.secondary_club:c.primary_club;if(id<0||id==0xffff)continue;
|
||||
ClubPlayerDetailClub club;club.runtime_team=id;club.original_full_name=g.club_name(id);club.original_short_name=club.original_full_name;
|
||||
if(id<168){
|
||||
const uint8_t raw=g.memory.u8(::bmh::layout::ClubShortNameOffsets+uint32_t(id));
|
||||
if(id<runtime_dimensions.record_teams){
|
||||
const uint8_t raw=g.club_short_offset(id);
|
||||
club.original_short_name=club.original_short_name.substr(raw>>4,(raw&15)+1);
|
||||
}
|
||||
// SourceBadgeFallback consults the selector only for real atlas clubs.
|
||||
@@ -98,7 +99,7 @@ ClubPlayerDetailScreen::ClubPlayerDetailScreen(const std::filesystem::path& data
|
||||
}
|
||||
// TextWidth national/foreign names: longest word, then remove two
|
||||
// trailing characters until FNT3 fits57 pixels.
|
||||
if(id>=168 && small_.text_width(club.original_short_name)>57){
|
||||
if(id>=runtime_dimensions.record_teams && small_.text_width(club.original_short_name)>57){
|
||||
std::string longest;size_t at=0;
|
||||
while(at<club.original_short_name.size()){
|
||||
const size_t end=club.original_short_name.find(' ',at);
|
||||
|
||||
+7
-6
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/cup_draw.hpp"
|
||||
@@ -58,7 +59,7 @@ int region_for_team(int id) {
|
||||
if(t-kCupOnlyTeams>=0)return (t-kCupOnlyTeams)/7-5+10;
|
||||
return 0;
|
||||
}
|
||||
int league_for_team(int id) { return id>0x164?0:team_league(id); }
|
||||
int league_for_team(int id) { return id>(kNoTeam - 1)?0:team_league(id); }
|
||||
uint8_t manager_color(const GameState& game,int id,uint8_t base) {
|
||||
const int active=game.memory.has(::bmh::layout::ActiveManager)?game.memory.u8(::bmh::layout::ActiveManager):-1;
|
||||
const int count=game.memory.has(::bmh::layout::ManagerCount)?game.memory.u8(::bmh::layout::ManagerCount):int(game.manager_teams.size());
|
||||
@@ -142,10 +143,10 @@ CupDrawProjection cup_draw_from_game(const GameState& game,const SeasonCupDrawEv
|
||||
std::string context;
|
||||
if(event.group_stage&&event.phase==SeasonCupDrawPhase::overview) {
|
||||
const bool human_national=game.manager_of(id)>=0||
|
||||
(game.memory.has(::bmh::layout::CupDraw_FormatError_RuntimeField2)&&game.memory.has(::bmh::layout::CupDraw_FormatError_RuntimeField3)&&game.memory.u16(::bmh::layout::CupDraw_FormatError_RuntimeField2)==0x165&&game.memory.u16(::bmh::layout::CupDraw_FormatError_RuntimeField3)==id);
|
||||
if(id>=168&&!human_national) {
|
||||
if(size_t(id-168)>=game.foreign_strength.size())throw FormatError("cup draw: missing Source foreign-strength byte");
|
||||
const uint8_t strength=game.foreign_strength[size_t(id-168)];
|
||||
(game.memory.has(::bmh::layout::CupDraw_FormatError_RuntimeField2)&&game.memory.has(::bmh::layout::CupDraw_FormatError_RuntimeField3)&&game.memory.u16(::bmh::layout::CupDraw_FormatError_RuntimeField2)==kNoTeam&&game.memory.u16(::bmh::layout::CupDraw_FormatError_RuntimeField3)==id);
|
||||
if(id>=runtime_dimensions.record_teams&&!human_national) {
|
||||
if(size_t(id-runtime_dimensions.record_teams)>=game.foreign_strength.size())throw FormatError("cup draw: missing Source foreign-strength byte");
|
||||
const uint8_t strength=game.foreign_strength[size_t(id-runtime_dimensions.record_teams)];
|
||||
const unsigned band=strength>>5;
|
||||
context=text_at(texts,size_t((::bmh::layout::CupDraw_FormatError_TextPointer4-::bmh::layout::TextPointerTable)/4)+band)+original_to_utf8(exe.cstring(::bmh::layout::CupDraw_FormatError_TextPointer));
|
||||
for(unsigned bit=0;bit<3;++bit)
|
||||
@@ -153,7 +154,7 @@ CupDrawProjection cup_draw_from_game(const GameState& game,const SeasonCupDrawEv
|
||||
context+=original_to_utf8(exe.cstring(::bmh::layout::CupDraw_FormatError_ExecutableField));
|
||||
} else {
|
||||
std::array<int,5> values{};
|
||||
if(id>=168&&id!=kNoTeam) {
|
||||
if(id>=runtime_dimensions.record_teams&&id!=kNoTeam) {
|
||||
const auto snapshot=std::find_if(event.group_average_snapshots.begin(),event.group_average_snapshots.end(),
|
||||
[&](const auto& v){return v.runtime_id==id;});
|
||||
if(snapshot==event.group_average_snapshots.end())
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/desk_drawers.hpp"
|
||||
|
||||
@@ -54,7 +55,7 @@ std::optional<int> source_drawer_team(const DeskState& state, int local_kind) {
|
||||
// away-side swap. The drawer cases use those retained values: when
|
||||
// both are open, uVar21 is local48; otherwise it is local44.
|
||||
const int local44 = state.next_opponent.value_or(-1);
|
||||
const int local48 = state.national_team ? 0x165 : state.runtime_club;
|
||||
const int local48 = state.national_team ? kNoTeam : state.runtime_club;
|
||||
const int uVar21 = (open_count == 2) ? local48 : local44;
|
||||
const bool first_case = local_kind == pair[0];
|
||||
const int side = first_case ? (uVar21 != local48 ? local48 : local44) : uVar21;
|
||||
@@ -182,7 +183,7 @@ void DeskDrawerRenderer::recent(Image& target, const DeskState& state, const Des
|
||||
}
|
||||
|
||||
void DeskDrawerRenderer::head_to_head(Image& target, const DeskState& state, const DeskItem& item) const {
|
||||
if (!state.next_opponent || *state.next_opponent < 0 || *state.next_opponent > 0xa7) {
|
||||
if (!state.next_opponent || *state.next_opponent < 0 || *state.next_opponent >= runtime_dimensions.record_teams) {
|
||||
text(target, state, item.x + 1, item.y + 13, texts_[1207], 0x6a, item.x + 115); // DeskDrawersRuntimeField
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/desk_records.hpp"
|
||||
|
||||
@@ -43,7 +44,7 @@ uint8_t source_team_color(const GameState& g,int team) {
|
||||
DeskRecordsState fair_play_state_from_game(const GameState& g, int league, const Image& underlay,int manager_slot) {
|
||||
if(league<0||league>=9) throw FormatError("fair play: invalid Source league");
|
||||
const int first=league_first_team(league), count=kLeagueSizes[league];
|
||||
if(first<0||count<=0||first+count>138||g.club_ids.size()<size_t(first+count))
|
||||
if(first<0||count<=0||first+count>runtime_dimensions.league_teams||g.club_ids.size()<size_t(first+count))
|
||||
throw FormatError("fair play: incomplete Source league");
|
||||
std::vector<int16_t> teams(static_cast<size_t>(count)); std::vector<uint32_t> keys(static_cast<size_t>(count));
|
||||
for(int i=0;i<count;++i) {
|
||||
|
||||
+10
-9
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/desk_state.hpp"
|
||||
@@ -40,7 +41,7 @@ std::string pool_name(const Bytes& names, const std::vector<uint16_t>& offsets,
|
||||
}
|
||||
|
||||
int executable_league(const LeImage& exe, int team) {
|
||||
if (team < 0 || team >= 138 || !exe.contains(::bmh::layout::LeagueSizes + 8)) return -1;
|
||||
if (team < 0 || team >= runtime_dimensions.league_teams || !exe.contains(::bmh::layout::LeagueSizes + 8)) return -1;
|
||||
int first = 0;
|
||||
for (int league = 0; league < 9; ++league) {
|
||||
if (!exe.contains(::bmh::layout::LeagueSizes + uint32_t(league))) return -1;
|
||||
@@ -80,7 +81,7 @@ void project_drawer_rows(DeskState& d, const LeImage& exe, const Bytes& managers
|
||||
auto rank_curve = [&](int team, DeskRankCurve& curve) {
|
||||
curve.runtime_team = team;
|
||||
curve.team_name = pool_name(club_names, club_ids, team);
|
||||
if (team == 0x165) {
|
||||
if (team == kNoTeam) {
|
||||
// TablePosition returns rank 2 for this special national row;
|
||||
// QuoteNationalFriendlyMatch uses its native no-team squad (no random rating).
|
||||
curve.current_position = 2;
|
||||
@@ -100,16 +101,16 @@ void project_drawer_rows(DeskState& d, const LeImage& exe, const Bytes& managers
|
||||
curve.samples.push_back({round + 1, int((packed >> ((round % 3) * 5)) & 0x1f)});
|
||||
}
|
||||
if (!curve.samples.empty()) curve.current_position = curve.samples.back().source_rank;
|
||||
if (game && team < 138) curve.strength = team_average(*game, team, 0x1ff).value;
|
||||
if (game && team < runtime_dimensions.league_teams) curve.strength = team_average(*game, team, 0x1ff).value;
|
||||
};
|
||||
rank_curve(d.runtime_club < 0 ? 0x165 : d.runtime_club, d.rank_curves[0]);
|
||||
rank_curve(d.runtime_club < 0 ? kNoTeam : d.runtime_club, d.rank_curves[0]);
|
||||
if (authenticated_rival && *authenticated_rival >= 0 && *authenticated_rival != d.runtime_club)
|
||||
rank_curve(*authenticated_rival, d.rank_curves[1]);
|
||||
|
||||
// SourceDrawerTeam reads only the prepared opponent's venue history. Other
|
||||
// teams' names need not be available to render this manager's current Desk.
|
||||
if (!authenticated_rival || *authenticated_rival < 0 || *authenticated_rival >= 168) return;
|
||||
const size_t at = manager * 0x690 + size_t(*authenticated_rival) * 10;
|
||||
if (!authenticated_rival || *authenticated_rival < 0 || *authenticated_rival >= runtime_dimensions.record_teams) return;
|
||||
const size_t at = manager * (runtime_dimensions.record_teams * 10) + size_t(*authenticated_rival) * 10;
|
||||
if (at + 10 > manager_results.size()) return;
|
||||
const bool present = std::any_of(manager_results.begin() + at,
|
||||
manager_results.begin() + at + 10, [](uint8_t value) { return value != 0xff; });
|
||||
@@ -307,7 +308,7 @@ DeskState project(const StaticMemory& memory, const Tables& t, const LeImage& ex
|
||||
d.warnings[3] = remaining < 4;
|
||||
const int max24 = exe.u16(::bmh::layout::TeamsWithSquads), league_teams = exe.u16(::bmh::layout::CareerSession_DispatchLineup_RuntimeField);
|
||||
if (!d.national_team && d.runtime_club >= league_teams) throw FormatError("desk: cup-only squad projection not supported");
|
||||
const size_t first = d.national_team ? 3072 : size_t(d.runtime_club < max24 ? d.runtime_club * 24 : d.runtime_club * 16 + max24 * 8);
|
||||
const size_t first = d.national_team ? runtime_dimensions.national_slots_first : size_t(d.runtime_club < max24 ? d.runtime_club * 24 : d.runtime_club * 16 + max24 * 8);
|
||||
const size_t count = d.national_team ? 24 : (d.runtime_club < max24 ? 24 : 16);
|
||||
if (t.squads.size() < first + count || t.tactics.size() < size_t(d.manager_slot) * 0x840 + count * 0x58)
|
||||
throw FormatError("desk: truncated squad/tactics");
|
||||
@@ -691,8 +692,8 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
DeskState load_reference_desk(const std::filesystem::path& path, const LeImage& exe) {
|
||||
auto fbm = load_savegame(path);
|
||||
if (!fbm.checksum_ok) throw FormatError("desk: FBM checksum mismatch");
|
||||
if (fbm.version != "V2.24") throw FormatError("desk: unsupported FBM version");
|
||||
DbCounts counts{exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4)};
|
||||
if (fbm.version != (exe.expanded_profile() ? "O1.1" : "V2.24")) throw FormatError("desk: unsupported FBM version");
|
||||
DbCounts counts{exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4), uint32_t(exe.u16(layout::CareerSession_DispatchLineup_RuntimeField)), 30};
|
||||
SaveState save(fbm.stream, counts);
|
||||
auto d = desk_from_save(save, exe);
|
||||
validate_desk_state(d);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "ui/friendly_match.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -80,7 +81,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 >= runtime_dimensions.record_teams && !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");
|
||||
@@ -344,7 +345,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_ >= runtime_dimensions.record_teams) {
|
||||
selected_opponent_ = -1;
|
||||
feedback_ = "Bitte einen anderen Ligaverein waehlen.";
|
||||
return std::nullopt;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/incoming_transfer.hpp"
|
||||
@@ -62,7 +63,7 @@ std::string source_money(uint32_t value, int width, uint32_t numerator, uint32_t
|
||||
}
|
||||
|
||||
int team_badge(const GameState& game, int team) {
|
||||
if (team < 0 || team >= 168 || size_t(team) * 2 + 2 > game.club_heap_78.size()) return -1;
|
||||
if (team < 0 || team >= runtime_dimensions.record_teams || size_t(team) * 2 + 2 > game.club_heap_78.size()) return -1;
|
||||
return (int(game.club_heap_78[size_t(team) * 2]) |
|
||||
int(game.club_heap_78[size_t(team) * 2 + 1]) << 8) & 0x1ff;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/league_pairings.hpp"
|
||||
|
||||
@@ -82,7 +83,7 @@ LeaguePairingsState league_pairings_from_game(const GameState& g,const LeaguePai
|
||||
//51329 ->LeagueName uses the league names prepared by6b98e, including
|
||||
//the shared Regionalliga A/B text and foreign country's Native name.
|
||||
//TeamStatistics_SourceLeagueName_RuntimeField's temporary prefix is only set around other callers, not this Desk.
|
||||
const auto league_title=owner.league<5?league_name(g,owner.league):g.club_name(0x165+owner.league-4);
|
||||
const auto league_title=owner.league<5?league_name(g,owner.league):g.club_name(kNoTeam+owner.league-4);
|
||||
if(owner.postponed_active) {
|
||||
out.title=message_text(g,::bmh::layout::LeaguePairings_FormatError_TextPointer12)+league_title;
|
||||
out.subtitle.clear();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/league_table.hpp"
|
||||
|
||||
@@ -145,7 +146,7 @@ LeagueTableState project_league_table(const bmh::GameState& game, int manager_sl
|
||||
// not a TEXTD entry at the domestic league-title address.
|
||||
state.league_name = league_id < 5
|
||||
? original_to_utf8(bmh::league_name(game, league_id))
|
||||
: original_to_utf8(game.club_name(0x165 + league_id - 4));
|
||||
: original_to_utf8(game.club_name(kNoTeam + league_id - 4));
|
||||
state.header_text = original_to_utf8(bmh::message_text(game, ::bmh::layout::LeagueTable_OriginalToUtf8_TextPointer2));
|
||||
// SelectsOriginalPanelWhenClear selects the original panel when SolidPanelBackground is clear.
|
||||
// Older/minimal saves may not serialize this presentation option.
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/lineup.hpp"
|
||||
|
||||
@@ -44,7 +45,7 @@ LineupState project(const StaticMemory& memory, const LeImage& exe, const std::v
|
||||
if (out.runtime_club < 0 || (out.runtime_club >= limit && !national))
|
||||
throw FormatError("lineup: only domestic league squads are supported");
|
||||
const size_t count = national || out.runtime_club < split ? 24 : 16;
|
||||
const size_t first = national ? 3072 : out.runtime_club < split ? size_t(out.runtime_club) * 24 : size_t(out.runtime_club) * 16 + split * 8;
|
||||
const size_t first = national ? runtime_dimensions.national_slots_first : out.runtime_club < split ? size_t(out.runtime_club) * 24 : size_t(out.runtime_club) * 16 + split * 8;
|
||||
const size_t board_base = size_t(out.manager_slot) * 0x840;
|
||||
if (first + count > squad.size() || board_base + count * 0x58 > tactics.size() || size_t(out.manager_slot) * 5 >= options.size())
|
||||
throw FormatError("lineup: truncated squad/tactics/options");
|
||||
|
||||
@@ -452,9 +452,9 @@ Palette LiveMatchdayScreen::shot_palette(const Palette& base, const LiveShotEven
|
||||
for (int side = 0; side < 2; ++side) {
|
||||
const int team = group.fixtures.at(size_t(shot.match * 2 + side));
|
||||
if (team == -1) continue;
|
||||
if (team < 0 || !state.memory.has(::bmh::layout::ClubKitSelectorsUnsigned + uint32_t(team)))
|
||||
if (team < 0 || size_t(team) >= state.club_ids.size())
|
||||
throw FormatError("live shot: original club colours missing");
|
||||
const int kit = state.memory.u8(::bmh::layout::ClubKitSelectorsUnsigned + uint32_t(team));
|
||||
const int kit = state.club_kit(team);
|
||||
int shirt = kit >> 4, shorts = kit & 15;
|
||||
if (side == 0) { home_shirt = shirt; home_shorts = shorts; }
|
||||
else if (shorts == home_shorts || (shirt == home_shorts && shorts == home_shirt)) {
|
||||
|
||||
+1
-1
@@ -263,7 +263,7 @@ void ManagerScreen::portrait(Image& out, int x, int y, int id) const {
|
||||
}
|
||||
void ManagerScreen::badge(Image& out, int x, int y, int id) const {
|
||||
border(out, x, y);
|
||||
if (id>=90 && id<original_badge_gate(exe_)) { copy(out, widgets_, 8, 0, x, y, 38, 38); return; }
|
||||
if (original_badge_fallback(id, &exe_)) { copy(out, widgets_, 8, 0, x, y, 38, 38); return; }
|
||||
int sprite = le16(db_.raw_club_badge_selectors, size_t(id) * 2) & 0x1ff;
|
||||
auto atlas = load_vga(asset_path(data_ / "W", std::to_string(sprite >> 3) + ".VGA"));
|
||||
copy(out, atlas, (sprite & 7) * 38, 0, x, y, 38, 38);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/matchday_results.hpp"
|
||||
|
||||
@@ -57,7 +58,7 @@ std::string competition_name(const MatchdayResultGroup& group,
|
||||
std::string name;
|
||||
if (group.league_id) {
|
||||
const int league = *group.league_id;
|
||||
name = league < 5 ? league_name(game, league) : game.club_name(0x165 + league - 4);
|
||||
name = league < 5 ? league_name(game, league) : game.club_name(kNoTeam + league - 4);
|
||||
} else if (*group.cup_id == 0xb && !bmh::kEnglishCompetitions) { // (English: the League Cup, named below)
|
||||
// FinishEvent/BuildSideRecords: descriptor type 0x0c reads the runtime
|
||||
// TEXTD slot TournamentName, then appends edition TEXTD suffix MatchdayResults_CompetitionName_TextPointer.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "national_friendly_ui.hpp"
|
||||
|
||||
@@ -6,9 +7,9 @@
|
||||
|
||||
namespace bmh::ui {
|
||||
namespace {
|
||||
constexpr int kNationalTeam = 0x165;
|
||||
constexpr int kFirstNationTeam = 0x166; // Nation zero is intentionally not selectable.
|
||||
constexpr int kLastNationTeam = 0x165 + 61;
|
||||
const int& kNationalTeam = kNoTeam;
|
||||
int first_nation_team() { return kNoTeam + 1; } // Nation zero is intentionally not selectable.
|
||||
int last_nation_team() { return kNoTeam + 61; }
|
||||
|
||||
TaxDialogProjection question(const NationalFriendlyIdentity& identity, uint16_t flags,
|
||||
int manager, const GameState& game, std::string body) {
|
||||
@@ -70,14 +71,14 @@ NationalFriendlyUiAction NationalFriendlyUi::show(TaxDialogProjection p) const {
|
||||
|
||||
NationalFriendlyUiAction NationalFriendlyUi::select_opponent(const GameState& g, int team) {
|
||||
if (stage_ != NationalFriendlyUiStage::picker) return {};
|
||||
if (team < kFirstNationTeam || team > kLastNationTeam) return cancel();
|
||||
if (team < first_nation_team() || team > last_nation_team()) return cancel();
|
||||
opponent_ = team;
|
||||
stage_ = NationalFriendlyUiStage::venue_question;
|
||||
return show(question(identity_, 0x606, caller_.manager, g, bmh::message_text(g, ::bmh::layout::Controller_ClubFriendlyState_TextPointer)));
|
||||
}
|
||||
|
||||
NationalFriendlyUiAction NationalFriendlyUi::answer_venue(bool yes) {
|
||||
if (stage_ != NationalFriendlyUiStage::venue_question || opponent_ < kFirstNationTeam) return {};
|
||||
if (stage_ != NationalFriendlyUiStage::venue_question || opponent_ < first_nation_team()) return {};
|
||||
manager_home_ = yes;
|
||||
stage_ = NationalFriendlyUiStage::quote_pending;
|
||||
NationalFriendlyUiAction a;
|
||||
|
||||
@@ -153,7 +153,7 @@ std::string original_literal(const LeImage& exe, uint32_t address) {
|
||||
}
|
||||
|
||||
int source_league(const LeImage& exe, int team) {
|
||||
if (team > 0x164) return 0;
|
||||
if (team > (kNoTeam - 1)) return 0;
|
||||
if (team < 0) invalid("negative team for Source league lookup");
|
||||
int cumulative = 0;
|
||||
for (int league = 0; league < 9; ++league) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/pending_offer.hpp"
|
||||
@@ -35,7 +36,7 @@ int pending_offer_owner_team(const GameState& game, int manager) {
|
||||
throw FormatError("pending offer UI: missing retained Source club");
|
||||
const int team = int(game.manager_records[base + 0x290]) |
|
||||
(int(game.manager_records[base + 0x291]) << 8);
|
||||
if (team >= 138) throw FormatError("pending offer UI: invalid retained Source club");
|
||||
if (team >= runtime_dimensions.league_teams) throw FormatError("pending offer UI: invalid retained Source club");
|
||||
return team;
|
||||
}
|
||||
|
||||
@@ -59,8 +60,8 @@ bool pending_offer_spare_buyer(const GameState& game, int raw_offer_slot, int ex
|
||||
const int buyer = team_at(4);
|
||||
const uint32_t offer = ::bmh::layout::OfferSlots + uint32_t(raw_offer_slot) * 4;
|
||||
const uint32_t list = ::bmh::layout::EditorList + uint32_t(raw_offer_slot + 40) * 0x58;
|
||||
const size_t pool = 0xb70 + size_t(raw_offer_slot + 40);
|
||||
if (team_at(0) != kNoTeam || buyer >= 138 || buyer != expected_team || !game.memory.has(offer + 3) ||
|
||||
const size_t pool = runtime_dimensions.pool_first + size_t(raw_offer_slot + 40);
|
||||
if (team_at(0) != kNoTeam || buyer >= runtime_dimensions.league_teams || buyer != expected_team || !game.memory.has(offer + 3) ||
|
||||
!game.memory.has(list + 0x57) || pool >= game.squad_slots.size())
|
||||
return false;
|
||||
const uint32_t word = game.memory.u32(offer);
|
||||
@@ -69,7 +70,7 @@ bool pending_offer_spare_buyer(const GameState& game, int raw_offer_slot, int ex
|
||||
if (word == 0xffffffffu || int(word & 31) != owner ||
|
||||
player == 0xfff || size_t(player) >= game.players.size() ||
|
||||
(game.squad_slots[pool] & 0xfff) != player || game.memory.u16(list) != buyer ||
|
||||
seller >= 138 || seller == buyer || (owner > 0 && team_at(size_t(owner)) != seller))
|
||||
seller >= runtime_dimensions.league_teams || seller == buyer || (owner > 0 && team_at(size_t(owner)) != seller))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/player_card.hpp"
|
||||
@@ -31,8 +32,8 @@ void validate(const PlayerCardState& s) {
|
||||
const auto& p=s.lineup.players.at(size_t(s.row));
|
||||
if(p.player_id!=(p.slot&0xfff)||p.row!=s.row)throw FormatError("player card: inconsistent player identity");
|
||||
if(s.statistics && s.statistics->months>12)throw FormatError("player statistics: more than twelve monthly samples");
|
||||
if(s.loan&&(s.loan->owner<0||s.loan->owner>=168||s.loan->borrower!=s.lineup.runtime_club||
|
||||
s.loan->borrower>=168||s.loan->months<0||s.loan->months>255||
|
||||
if(s.loan&&(s.loan->owner<0||s.loan->owner>=runtime_dimensions.record_teams||s.loan->borrower!=s.lineup.runtime_club||
|
||||
s.loan->borrower>=runtime_dimensions.record_teams||s.loan->months<0||s.loan->months>255||
|
||||
std::any_of(s.loan->badges.begin(),s.loan->badges.end(),[](int badge){return badge<0||badge>511;})))
|
||||
throw FormatError("player card: inconsistent ordinary loan context");
|
||||
}
|
||||
@@ -67,7 +68,7 @@ void context(PlayerCardState& out,const StaticMemory& memory,const Bytes& club_h
|
||||
// the ordinary borrower row, not the lender's ClubInfo_FormatError_RuntimeField snapshot.
|
||||
PlayerCardLoan detail;
|
||||
detail.owner=int(loan>>12&0x3ff);detail.borrower=int(loan>>22&0x3ff);
|
||||
if(detail.borrower!=out.lineup.runtime_club||detail.owner>=168||detail.borrower>=168||out.loan||!memory.has(::bmh::layout::ClubPlayerDetail_InvalidArgument_RuntimeField+i)){
|
||||
if(detail.borrower!=out.lineup.runtime_club||detail.owner>=runtime_dimensions.record_teams||detail.borrower>=runtime_dimensions.record_teams||out.loan||!memory.has(::bmh::layout::ClubPlayerDetail_InvalidArgument_RuntimeField+i)){
|
||||
out.unsupported_record="loan_record";continue;
|
||||
}
|
||||
detail.months=memory.u8(::bmh::layout::ClubPlayerDetail_InvalidArgument_RuntimeField+i);
|
||||
@@ -125,7 +126,7 @@ PlayerCardState player_card_from_save(const SaveState& s,const LeImage& exe,int
|
||||
}
|
||||
PlayerCardState player_card_from_game(const GameState& g,const LeImage& exe,int row,uint64_t revision) {
|
||||
Bytes short_names;
|
||||
for(int club=0;club<exe.u16(::bmh::layout::CareerSession_DataDirectory_RuntimeField2);++club)short_names.push_back(g.memory.u8(::bmh::layout::ClubShortNameOffsets+club));
|
||||
for(int club=0;club<exe.u16(::bmh::layout::CareerSession_DataDirectory_RuntimeField2);++club)short_names.push_back(g.club_short_offset(club));
|
||||
auto out=project(lineup_from_game(g,exe,revision),exe,row,g.club_heap_78,g.club_ids,g.club_names,short_names);
|
||||
context(out,g.memory,g.club_heap_78,g.club_ids,g.club_names,short_names);
|
||||
const size_t months=size_t(out.lineup.manager_slot)*0xb0c+0x286;
|
||||
|
||||
@@ -93,8 +93,8 @@ PreparationState preparation_from_game(const GameState& game, const LeImage& exe
|
||||
|
||||
PreparationState load_preparation_reference(const std::filesystem::path& path, const LeImage& exe) {
|
||||
const auto fbm = load_savegame(path);
|
||||
if (!fbm.checksum_ok || fbm.version != "V2.24") throw FormatError("preparation: unsupported/damaged FBM");
|
||||
const DbCounts counts{exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4)};
|
||||
if (!fbm.checksum_ok || fbm.version != (exe.expanded_profile() ? "O1.1" : "V2.24")) throw FormatError("preparation: unsupported/damaged FBM");
|
||||
const DbCounts counts{exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField3), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField2), exe.u32(::bmh::layout::CareerSession_DataDirectory_RuntimeField4), uint32_t(exe.u16(layout::CareerSession_DispatchLineup_RuntimeField)), 30};
|
||||
const SaveState save(fbm.stream, counts);
|
||||
PreparationState result;
|
||||
result.desktop = desk_from_save(save, exe);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/flow.hpp"
|
||||
|
||||
@@ -1353,7 +1354,7 @@ void StartupFlow::show_transfer_offer(PreparationState preparation, OutgoingTran
|
||||
editor.manager_slot != request->manager_slot || editor.runtime_club != request->runtime_club ||
|
||||
(!poach && (editor.list_entry != request->bid.list_entry || editor.source_slot != request->bid.source_slot ||
|
||||
editor.player != request->bid.player)) ||
|
||||
(poach && (editor.list_entry<40 || editor.list_entry>43 || editor.source_slot!=2928+editor.list_entry ||
|
||||
(poach && (editor.list_entry<40 || editor.list_entry>43 || editor.source_slot!=runtime_dimensions.pool_first+editor.list_entry ||
|
||||
editor.player<0 || editor.initial_action_loan)) || editor.revision != preparation.desktop.revision ||
|
||||
preparation.desktop.revision != request->revision + 1)
|
||||
throw FormatError("transfer offer: invalid opening acknowledgement");
|
||||
|
||||
@@ -185,7 +185,7 @@ bool SaveLoadScreen::info_press(int x, int y) {
|
||||
try {
|
||||
const auto saved = load_savegame(entries_.at(size_t(selected_)).path);
|
||||
const auto& h = saved.plain_header;
|
||||
if (!saved.checksum_ok || saved.version != "V2.24" || h.size() < 172 || h[0] < 1 || h[0] > 4)
|
||||
if (!saved.checksum_ok || (saved.version != "V2.24" && saved.version != "O1.1") || h.size() < 172 || h[0] < 1 || h[0] > 4)
|
||||
throw FormatError("save/load: invalid native information header");
|
||||
const auto field = [&](size_t at, size_t count) {
|
||||
const auto end = h.begin() + at + count;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "series_records.hpp"
|
||||
|
||||
@@ -50,7 +51,7 @@ SeriesRecordsProjection series_records_from_game(const GameState& game, const Le
|
||||
throw FormatError("series records: manager record missing");
|
||||
const size_t manager_at = size_t(manager_slot) * kManagerRecord;
|
||||
const int team = int(read16(game.manager_records, manager_at + 0x290));
|
||||
if (team < 0 || team > 0x165)
|
||||
if (team < 0 || team > kNoTeam)
|
||||
throw FormatError("series records: invalid Source manager club");
|
||||
|
||||
SeriesRecordsProjection out;
|
||||
@@ -58,7 +59,7 @@ SeriesRecordsProjection series_records_from_game(const GameState& game, const Le
|
||||
out.runtime_team = team;
|
||||
out.gradient_text = (!game.memory.has(::bmh::layout::TextGradientDisabled) || game.memory.u8(::bmh::layout::TextGradientDisabled) == 0) &&
|
||||
exe.u8(::bmh::layout::TextGradientMode) == 2;
|
||||
if (team >= 0x5a || game.club_table.size() < 168 * kClubRecord) {
|
||||
if (team >= 0x5a || game.club_table.size() < runtime_dimensions.record_teams * kClubRecord) {
|
||||
out.source_available = false; // TeamLeague shows SeriesRecordsRuntimeField outside its 0..89 table range.
|
||||
return out;
|
||||
}
|
||||
@@ -106,7 +107,7 @@ SeriesRecordsScreen::SeriesRecordsScreen(const std::filesystem::path& data,
|
||||
texts_(load_textd(asset_path(data, "TEXTD.BLK"))),
|
||||
font_(load_font(asset_path(data / "F", "BMH3.FNT"))) {
|
||||
if (projection_.manager_slot < 0 || projection_.manager_slot >= 4 ||
|
||||
projection_.runtime_team < 0 || projection_.runtime_team > 0x165 ||
|
||||
projection_.runtime_team < 0 || projection_.runtime_team > kNoTeam ||
|
||||
(projection_.source_available &&
|
||||
(projection_.league < 0 || projection_.league >= kLeagueCount ||
|
||||
projection_.league_row < 0 || projection_.league_row >= kLeagueSizes[size_t(projection_.league)])) ||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "game/messages.hpp"
|
||||
#include "game/state.hpp"
|
||||
#include "ui/manager.hpp"
|
||||
#include "ui/setup.hpp"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/sportschau.hpp"
|
||||
@@ -478,8 +479,8 @@ Image SportschauMatchReport::render_report(size_t visible_log_entries,
|
||||
text(out, heading_, 0, 54, home_name, 0x5f, 156);
|
||||
text(out, heading_, 156, 54, away_name, 0x5f, 312);
|
||||
|
||||
const bool home_domestic = fixture_.home_team < 168;
|
||||
const bool away_domestic = fixture_.away_team < 168;
|
||||
const bool home_domestic = fixture_.home_team < runtime_dimensions.record_teams;
|
||||
const bool away_domestic = fixture_.away_team < runtime_dimensions.record_teams;
|
||||
// Some Original club abbreviation bytes are unavailable because the
|
||||
// source-side temporary buffer was never initialized. Keep the known
|
||||
// header, badge, score and report visible, and omit only that abbreviation.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/strengths_state.hpp"
|
||||
|
||||
@@ -176,7 +177,7 @@ StrengthsProjection strengths_from_game(const GameState& game, int manager_slot,
|
||||
|
||||
const int first = league_first_team(league);
|
||||
const int size = kLeagueSizes[league];
|
||||
if (first < 0 || first + size > 138) invalid("league bounds exceed domestic club table");
|
||||
if (first < 0 || first + size > runtime_dimensions.league_teams) invalid("league bounds exceed domestic club table");
|
||||
if (game.club_ids.size() < size_t(first + size)) invalid("club ID table is truncated");
|
||||
if (game.club_names.empty()) invalid("club name pool is empty");
|
||||
for (int team = first; team < first + size; ++team) {
|
||||
@@ -235,7 +236,7 @@ StrengthsProjection strengths_from_game(const GameState& game, int manager_slot,
|
||||
if (league < 5) {
|
||||
out.league_name = iso646de_to_utf8(league_name(game, league).c_str());
|
||||
} else {
|
||||
const int title_team = 0x165 + league - 4;
|
||||
const int title_team = kNoTeam + league - 4;
|
||||
if (size_t(title_team) >= game.club_ids.size() ||
|
||||
game.club_ids[size_t(title_team)] >= game.club_names.size())
|
||||
invalid("foreign league title is missing from the save name pool");
|
||||
|
||||
+13
-12
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/team_statistics.hpp"
|
||||
@@ -78,7 +79,7 @@ std::string source_league_name(const GameState& game, int league, const TextDb&
|
||||
std::string name;
|
||||
if (game.memory.has(::bmh::layout::TeamStatistics_SourceLeagueName_RuntimeField) && game.memory.u8(::bmh::layout::TeamStatistics_SourceLeagueName_RuntimeField) != 0)
|
||||
name = source_text(texts, ::bmh::layout::SportschauAwards_MatchdayIntroView_TextPointer);
|
||||
name += game.club_name((mapped & 0x7f) + 0x165);
|
||||
name += game.club_name((mapped & 0x7f) + kNoTeam);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -86,17 +87,17 @@ std::string source_league_name(const GameState& game, int league, const TextDb&
|
||||
TeamStatisticsProjection team_statistics_from_game(const GameState& game, int team,
|
||||
TeamStatisticsMode mode,
|
||||
const LeImage& exe, const TextDb& texts) {
|
||||
if (team < 0 || team > 0x165) throw FormatError("team statistics: runtime team outside LeagueCalculations range");
|
||||
if (team < 0 || team > kNoTeam) throw FormatError("team statistics: runtime team outside LeagueCalculations range");
|
||||
const int mode_number = int(mode);
|
||||
if (mode_number < 0 || mode_number > 2) throw FormatError("team statistics: invalid mode");
|
||||
if (team >= 138 && team < 168)
|
||||
if (team >= runtime_dimensions.league_teams && team < runtime_dimensions.record_teams)
|
||||
throw FormatError("team statistics: simulated teams require Source draw-state ratings and are not exposed here");
|
||||
TeamStatisticsProjection out;
|
||||
out.runtime_team = team;
|
||||
out.mode = mode;
|
||||
out.source_badge_fallback = original_badge_fallback(team,&exe);
|
||||
out.badge_heap = game.club_heap_78;
|
||||
if (team != 0x165) {
|
||||
if (team != kNoTeam) {
|
||||
int region_team = team;
|
||||
const int league_gate = exe.u8(::bmh::layout::LeaguePairings_LeaguePairingsConstants_RuntimeField);
|
||||
for (int league = 0; league < 9; ++league) {
|
||||
@@ -109,8 +110,8 @@ TeamStatisticsProjection team_statistics_from_game(const GameState& game, int te
|
||||
out.flag_index = uint8_t((region_team - int(exe.u16(::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField6))) / 7 - league_gate + 10);
|
||||
}
|
||||
}
|
||||
out.source_has_league_panel = team < 0xa8;
|
||||
out.league = team > 0x164 ? 0 : team_league(team);
|
||||
out.source_has_league_panel = team < runtime_dimensions.record_teams;
|
||||
out.league = team > (kNoTeam - 1) ? 0 : team_league(team);
|
||||
if (size_t(team) < game.club_ids.size()) out.original_team_name = game.club_name(team);
|
||||
if (out.source_has_league_panel) {
|
||||
if (out.league < 0 || out.league >= kLeagueCount)
|
||||
@@ -135,7 +136,7 @@ TeamStatisticsProjection team_statistics_from_game(const GameState& game, int te
|
||||
out.position_history.size(), out.position_history.begin());
|
||||
out.source_has_position_history = true;
|
||||
}
|
||||
} else if (team == 0x165) {
|
||||
} else if (team == kNoTeam) {
|
||||
// Source 357 maps to league 0 for common labels, but the save does not
|
||||
// contain a position-history row for this national-team pseudo-club.
|
||||
out.source_has_position_history = false;
|
||||
@@ -143,7 +144,7 @@ TeamStatisticsProjection team_statistics_from_game(const GameState& game, int te
|
||||
out.gradient_text = (!game.memory.has(::bmh::layout::TextGradientDisabled) || game.memory.u8(::bmh::layout::TextGradientDisabled) == 0) && exe.u8(::bmh::layout::TextGradientMode) == 2;
|
||||
out.decorated_background = !game.memory.has(::bmh::layout::PlainBackground) || game.memory.u8(::bmh::layout::PlainBackground) == 0;
|
||||
|
||||
if (team < 138) {
|
||||
if (team < runtime_dimensions.league_teams) {
|
||||
constexpr std::array<uint16_t, 5> average_flags{0x1f1, 0x1f2, 0x1f4, 0x1f8, 0x1ff};
|
||||
for (size_t i = 0; i < average_flags.size(); ++i)
|
||||
out.source_averages[i] = uint16_t(team_average(game, team, average_flags[i]).value);
|
||||
@@ -167,7 +168,7 @@ TeamStatisticsProjection team_statistics_from_game(const GameState& game, int te
|
||||
}
|
||||
if (game.memory.has(::bmh::layout::ActiveManager)) {
|
||||
const int manager = game.memory.u8(::bmh::layout::ActiveManager);
|
||||
const size_t start = size_t(manager) * 0x690;
|
||||
const size_t start = size_t(manager) * (runtime_dimensions.record_teams * 10);
|
||||
if (manager < 4 && start + out.active_manager_results.size() <= game.manager_results.size()) {
|
||||
out.active_manager_slot = manager;
|
||||
std::copy_n(game.manager_results.begin() + static_cast<std::ptrdiff_t>(start),
|
||||
@@ -178,7 +179,7 @@ TeamStatisticsProjection team_statistics_from_game(const GameState& game, int te
|
||||
out.active_manager_team = owned;
|
||||
if (owned >= 0 && size_t(owned) < game.club_ids.size())
|
||||
out.active_manager_team_name = game.club_name(owned);
|
||||
out.source_has_head_to_head = team != owned && team < 0xa8 && owned != 0x165;
|
||||
out.source_has_head_to_head = team != owned && team < runtime_dimensions.record_teams && owned != kNoTeam;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,7 +195,7 @@ TeamStatisticsScreen::TeamStatisticsScreen(const std::filesystem::path& data,
|
||||
flags_(load_vga(asset_path(data / "KB", "24.VGA"))), faces_(load_vga(asset_path(data / "KB", "27.VGA"))),
|
||||
ratings_(load_vga(asset_path(data / "KB", "30.VGA"))) {
|
||||
if (backdrop_.width != 320 || backdrop_.height != 240 || projection_.runtime_team < 0 ||
|
||||
projection_.runtime_team > 0x165 ||
|
||||
projection_.runtime_team > kNoTeam ||
|
||||
(projection_.source_has_league_panel && (projection_.league < 0 || projection_.league >= kLeagueCount ||
|
||||
projection_.table.league != projection_.league || projection_.league_row < 0 ||
|
||||
projection_.league_row >= projection_.table.size)))
|
||||
@@ -431,7 +432,7 @@ Image TeamStatisticsScreen::render() const {
|
||||
uint16_t(projection_.badge_heap[size_t(projection_.runtime_team) * 2 + 1]) << 8) & 0x1ff;
|
||||
copy(out, crest_, (selector & 7) * 38, 0, 271, 55, 38, 38);
|
||||
}
|
||||
if (projection_.source_has_league_panel || projection_.runtime_team == 0x165) {
|
||||
if (projection_.source_has_league_panel || projection_.runtime_team == kNoTeam) {
|
||||
const int league = projection_.league;
|
||||
rect(out, 225, 150, 1, 43, 0x6a); rect(out, 225, 192, 81, 1, 0x6a);
|
||||
if (projection_.source_has_position_history && projection_.source_has_league_panel) {
|
||||
|
||||
@@ -45,7 +45,7 @@ struct TeamStatisticsProjection {
|
||||
int active_manager_slot = -1;
|
||||
int active_manager_team = -1;
|
||||
std::string active_manager_team_name;
|
||||
std::array<uint8_t, 0x690> active_manager_results{};
|
||||
std::vector<uint8_t> active_manager_results = std::vector<uint8_t>(size_t(runtime_dimensions.record_teams) * 10);
|
||||
bool has_active_head_to_head = false;
|
||||
bool source_has_league_panel = true;
|
||||
bool source_has_head_to_head = false;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
namespace bmh::ui {
|
||||
namespace {
|
||||
constexpr size_t kPoolFirst = 0xb70;
|
||||
const int& kPoolFirst = runtime_dimensions.pool_first;
|
||||
constexpr int kMarketEntries = 40;
|
||||
constexpr uint32_t kTransferTable = ::bmh::layout::EditorList;
|
||||
constexpr uint32_t kTransferEntrySize = 0x58;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/state.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "world_cup_statistics.hpp"
|
||||
|
||||
@@ -97,7 +98,7 @@ WorldCupStatisticsProjection world_cup_statistics_from_game(const GameState& gam
|
||||
throw FormatError("World Cup statistics: placement names a nation outside 0..61");
|
||||
out.badge_heap = game.club_heap_78;
|
||||
for (int nation = 0; nation < kNationCount; ++nation) {
|
||||
const int team = 0x165 + nation;
|
||||
const int team = kNoTeam + nation;
|
||||
if (size_t(team) >= game.club_ids.size())
|
||||
throw FormatError("World Cup statistics: national-team identity is unavailable");
|
||||
out.country_names[size_t(nation)] = game.club_name(team);
|
||||
@@ -145,7 +146,7 @@ std::optional<uint8_t> world_cup_nation_at(const WorldCupStatisticsProjection& p
|
||||
WorldCupStatisticsRequest world_cup_selection_request(const WorldCupStatisticsProjection& p,
|
||||
std::optional<uint8_t> nation) {
|
||||
if (!p.can_select_opponent || !nation || *nation == 0 || *nation >= kNationCount) return {};
|
||||
return {WorldCupStatisticsRequestKind::select_opponent, 0x165 + *nation};
|
||||
return {WorldCupStatisticsRequestKind::select_opponent, kNoTeam + *nation};
|
||||
}
|
||||
|
||||
WorldCupStatisticsScreen::WorldCupStatisticsScreen(const std::filesystem::path& data,
|
||||
@@ -169,7 +170,7 @@ void WorldCupStatisticsScreen::draw_flag(Image& out, uint8_t nation, int x, int
|
||||
}
|
||||
|
||||
void WorldCupStatisticsScreen::draw_badge(Image& out, uint8_t nation, int x, int y) const {
|
||||
const int team = 0x165 + nation;
|
||||
const int team = kNoTeam + nation;
|
||||
if (size_t(team) * 2 + 1 >= projection_.badge_heap.size()) return;
|
||||
const uint16_t selector = uint16_t(projection_.badge_heap[size_t(team) * 2] |
|
||||
uint16_t(projection_.badge_heap[size_t(team) * 2 + 1]) << 8) & 0x1ff;
|
||||
|
||||
Reference in new issue
Block a user