Manager record size and table size checks use the named constants
Prepare verified release / draft (push) Waiting to run
Prepare verified release / draft (push) Waiting to run
108 products of the form size_t(x) * 0xb0c read kManagerRecordSize (the type of the product is unchanged). The career start and the pairings check their table sizes against the world layout instead of 168, 138 and 9. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
9daf649563
commit
7031f4ff02
44 files changed
+116
-115
No files matched your search
@@ -180,7 +180,7 @@ auto App::wait_season_ack() -> void {
|
||||
// player answered Yes. A button counts only when pressed and released on the same button.
|
||||
auto App::show_tax(const GameState& state, const SeasonTaxEvent& event) -> bool {
|
||||
if (!running) return false;
|
||||
const size_t base = size_t(event.manager_slot) * 0xb0c;
|
||||
const size_t base = size_t(event.manager_slot) * kManagerRecordSize;
|
||||
ui::TaxDialogProjection view;
|
||||
view.kind = event.kind == SeasonTaxEventKind::question
|
||||
? ui::TaxDialogKind::question : ui::TaxDialogKind::acknowledgement;
|
||||
|
||||
@@ -1318,7 +1318,7 @@ bool CareerSession::dispatch_menu_layout(const ui::SaveLoadRequest& request, uin
|
||||
std::transform(extension.begin(), extension.end(), extension.begin(),
|
||||
[](unsigned char c) { return char(std::tolower(c)); });
|
||||
if (extension != ".men") { error = "invalid_menu_layout_extension"; return false; }
|
||||
const size_t active_base = size_t(request.manager_slot) * 0xb0c;
|
||||
const size_t active_base = size_t(request.manager_slot) * kManagerRecordSize;
|
||||
if (active_base + 0xb0c > g_.manager_records.size() ||
|
||||
size_t(request.manager_slot) >= g_.manager_teams.size() ||
|
||||
(int(g_.manager_records[active_base + 0x290]) |
|
||||
|
||||
@@ -855,7 +855,7 @@ std::optional<AdvertisingRenewal> CareerSession::dispatch_advertising_renewal(
|
||||
error = "Diese Werbeaktion ist nicht mehr aktuell.";
|
||||
return std::nullopt;
|
||||
}
|
||||
const size_t record = size_t(request.manager_slot) * 0xb0c + 0xa34 +
|
||||
const size_t record = size_t(request.manager_slot) * kManagerRecordSize + 0xa34 +
|
||||
size_t(request.renewal_contract_slot) * 0x0c;
|
||||
if (record + 12 > g_.manager_records.size() ||
|
||||
!std::equal(request.renewal_expected_contract.begin(), request.renewal_expected_contract.end(),
|
||||
@@ -1231,7 +1231,7 @@ bool CareerSession::validate_desk_setting_owner(const DeskSettingIdentity& ident
|
||||
error = "stale_manager_or_revision"; return false;
|
||||
}
|
||||
const int club = g_.manager_teams[size_t(active)];
|
||||
const size_t rec = size_t(active) * 0xb0c;
|
||||
const size_t rec = size_t(active) * kManagerRecordSize;
|
||||
if (identity.runtime_club != club || club < 0 || club > kNoTeam || size_t(club) >= g_.club_ids.size() ||
|
||||
identity.stable_club_identity != std::optional<int>(int(g_.club_ids[size_t(club)])) ||
|
||||
rec + 0xb0c > g_.manager_records.size() || size_t(active + 1) * 5 > g_.manager_options.size() ||
|
||||
@@ -1246,7 +1246,7 @@ bool CareerSession::validate_desk_setting_owner(const DeskSettingIdentity& ident
|
||||
// mask, 1-3 flags, 4 training automation not for the national team). Sets 'error' on a rejected
|
||||
// value; does not bump the revision (the caller does).
|
||||
bool CareerSession::apply_desk_setting(int manager, bool price, int index, int value, std::string& error) {
|
||||
const size_t rec = size_t(manager) * 0xb0c;
|
||||
const size_t rec = size_t(manager) * kManagerRecordSize;
|
||||
const bool national = g_.manager_teams[size_t(manager)] == kNoTeam;
|
||||
if (price) {
|
||||
// Uint8T4: local offsets35..86 map to admission values8..25.
|
||||
@@ -1376,7 +1376,7 @@ bool CareerSession::dispatch_desk_widget(const ui::DeskRequest& request, uint64_
|
||||
if (request.value == 0) {
|
||||
if (g_.manager_options[at] > 8) { error = "invalid_saved_formation_automation"; return false; }
|
||||
value = g_.manager_options[at];
|
||||
const uint8_t mask = g_.manager_records[size_t(active) * 0xb0c + 0x218 + size_t(g_.indoor)];
|
||||
const uint8_t mask = g_.manager_records[size_t(active) * kManagerRecordSize + 0x218 + size_t(g_.indoor)];
|
||||
do { value = (value + 1) % 9; } while (value != 0 && !(mask & (1u << (value - 1))));
|
||||
} else value = (g_.manager_options[at] ^ 1) & 1;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ bool source_table_identity_is_live(const GameState& game,const ui::StrengthsIden
|
||||
game.date!=id.day_counter||id.runtime_club<0||size_t(id.runtime_club)>=game.club_ids.size()||
|
||||
int(game.club_ids[size_t(id.runtime_club)])!=id.club_identity||
|
||||
id.league_group>1) return false;
|
||||
const size_t record=size_t(id.manager)*0xb0c;
|
||||
const size_t record=size_t(id.manager)*kManagerRecordSize;
|
||||
if(record+0x212>game.manager_records.size()||
|
||||
id.manager_default_league!=int(game.manager_records[record+0x210])) return false;
|
||||
const uint32_t settings=::bmh::layout::ManagerSettings+uint32_t(id.manager)*2;
|
||||
@@ -103,7 +103,7 @@ std::optional<ui::StrengthsRequest> CareerSession::strengths_open_request(uint64
|
||||
request.identity={manager,club,int(g_.club_ids[size_t(club)]),club>356?0:team_league(club),g_.date,
|
||||
revision,0,0,g_.memory.u16(setting),g_.memory.u16(family)};
|
||||
request.identity.league_group=uint8_t(request.identity.league>=5);
|
||||
const size_t record=size_t(manager)*0xb0c;
|
||||
const size_t record=size_t(manager)*kManagerRecordSize;
|
||||
if(record+0x212<=g_.manager_records.size())
|
||||
request.identity.manager_default_league=int(g_.manager_records[record+0x210]);
|
||||
else return {};
|
||||
@@ -492,7 +492,7 @@ bool CareerSession::prepare_league_family_child(const ui::StrengthsIdentity& id,
|
||||
league_family_owner_->identity.family_sequence+1!=id.family_sequence))) {
|
||||
error="league family: missing owner binding for child entry";return false;
|
||||
}
|
||||
const size_t record=size_t(id.manager)*0xb0c;
|
||||
const size_t record=size_t(id.manager)*kManagerRecordSize;
|
||||
if(record+0x212>g_.manager_records.size()||id.manager_default_league!=int(g_.manager_records[record+0x210])) {
|
||||
error="league family: stale manager default league";return false;
|
||||
}
|
||||
@@ -1093,7 +1093,7 @@ bool CareerSession::select_league_family_page(const ui::LeagueFamilyRequest& req
|
||||
}
|
||||
const uint8_t old_group=id.league_group;
|
||||
const uint8_t next_group=toggle?uint8_t(old_group^1):old_group;
|
||||
const size_t record=size_t(id.manager)*0xb0c;
|
||||
const size_t record=size_t(id.manager)*kManagerRecordSize;
|
||||
const auto checkpoint=league_family_checkpoint();
|
||||
try {
|
||||
if(toggle) {
|
||||
@@ -1230,7 +1230,7 @@ std::optional<ui::StrengthsIdentity> CareerSession::dispatch_family_table_team_i
|
||||
// Nein/Radio/Video setting made in it.
|
||||
if(!live_unchanged||!accepted||entry_calls<1)
|
||||
throw FormatError("league family: TeamInfo presenter changed owner or did not enter the selected club");
|
||||
const size_t record=size_t(id.manager)*0xb0c;
|
||||
const size_t record=size_t(id.manager)*kManagerRecordSize;
|
||||
if(next.date!=g_.date||next.manager_teams!=g_.manager_teams||
|
||||
!next.memory.has(::bmh::layout::ActiveManager)||next.memory.u8(::bmh::layout::ActiveManager)!=id.manager||record+0x292>next.manager_records.size()||
|
||||
(int(next.manager_records[record+0x290])|int(next.manager_records[record+0x291])<<8)!=id.runtime_club||
|
||||
|
||||
@@ -215,7 +215,7 @@ bool CareerSession::dispatch_training_camp(const ui::TrainingCampRequest& reques
|
||||
error = "stale_manager_or_revision";
|
||||
return false;
|
||||
}
|
||||
const size_t rec = size_t(request.manager_slot) * 0xb0c;
|
||||
const size_t rec = size_t(request.manager_slot) * kManagerRecordSize;
|
||||
if (request.kind == ui::TrainingCampRequestKind::set_focus) {
|
||||
const std::array<uint8_t, 4> current{
|
||||
g_.manager_records.at(rec + 0xc1), g_.manager_records.at(rec + 0xc2),
|
||||
@@ -278,7 +278,7 @@ bool CareerSession::dispatch_bank(const ui::BankRequest& request, uint64_t& revi
|
||||
request.runtime_club != g_.manager_teams[size_t(request.manager_slot)] || request.revision != revision) {
|
||||
error = "stale_manager_or_revision"; return false;
|
||||
}
|
||||
const size_t rec = size_t(request.manager_slot) * 0xb0c;
|
||||
const size_t rec = size_t(request.manager_slot) * kManagerRecordSize;
|
||||
std::optional<ui::BankState::PropertyNotice> property_notice;
|
||||
std::optional<ui::BankState::CreditNotice> credit_notice;
|
||||
const auto read_signed = [&](size_t offset) {
|
||||
@@ -380,7 +380,7 @@ bool CareerSession::dispatch_bank(const ui::BankRequest& request, uint64_t& revi
|
||||
if (lender >= 0) {
|
||||
who.clear();
|
||||
for (size_t i = 0; i < 26; ++i) {
|
||||
const uint8_t ch = g_.manager_records.at(size_t(lender) * 0xb0c + 0xa8 + i);
|
||||
const uint8_t ch = g_.manager_records.at(size_t(lender) * kManagerRecordSize + 0xa8 + i);
|
||||
if (!ch) break;
|
||||
who += char(ch);
|
||||
}
|
||||
@@ -457,7 +457,7 @@ bool CareerSession::dispatch_stadium(const ui::StadiumRequest& supplied_request,
|
||||
request.revision != revision || revision == UINT64_MAX || !g_.memory.has(::bmh::layout::GameMode)) {
|
||||
error = "stale_manager_or_revision"; return false;
|
||||
}
|
||||
const size_t record = size_t(active) * 0xb0c;
|
||||
const size_t record = size_t(active) * kManagerRecordSize;
|
||||
if (record + 0xb0c > g_.manager_records.size() ||
|
||||
(int(g_.manager_records[record + 0x290]) | int(g_.manager_records[record + 0x291]) << 8) != request.runtime_club) {
|
||||
error = "invalid_stadium_owner"; return false;
|
||||
|
||||
@@ -33,7 +33,7 @@ bool CareerSession::dispatch_tactics(const ui::TacticsRequest& request, uint64_t
|
||||
}
|
||||
// RerateTeam: only +d2..+d9 and (index 0) option byte +2.
|
||||
// The tactic board, player order and both RNG streams stay untouched.
|
||||
const size_t rec = size_t(request.manager_slot) * 0xb0c;
|
||||
const size_t rec = size_t(request.manager_slot) * kManagerRecordSize;
|
||||
const size_t option = size_t(request.manager_slot) * 5 + 2;
|
||||
if (g_.manager_records.size() < rec + 0xb0c || g_.manager_options.size() <= option) {
|
||||
error = "Die Taktikdaten sind unvollständig."; return false;
|
||||
@@ -905,7 +905,7 @@ bool CareerSession::dispatch_live_tactic(const ui::TacticsRequest& request, int
|
||||
error = "Ungültige Assistenteneinstellung.";
|
||||
return false;
|
||||
}
|
||||
const size_t record = size_t(manager) * 0xb0c;
|
||||
const size_t record = size_t(manager) * kManagerRecordSize;
|
||||
const size_t option = size_t(manager) * 5 + 2;
|
||||
if (g_.manager_records.size() < record + 0xb0c || g_.manager_options.size() <= option) {
|
||||
error = "Die Taktikdaten sind unvollständig.";
|
||||
@@ -994,7 +994,7 @@ bool CareerSession::dispatch_pitch(const ui::PitchRequest& request, uint64_t& re
|
||||
if (live_context) {
|
||||
const int manager = live_intervention_->manager;
|
||||
const int team = live_intervention_->team;
|
||||
const size_t rec = size_t(manager) * 0xb0c;
|
||||
const size_t rec = size_t(manager) * kManagerRecordSize;
|
||||
if (request.indoor != g_.indoor || manager < 0 || manager >= int(g_.manager_teams.size()) ||
|
||||
g_.manager_teams[size_t(manager)] != team || g_.manager_of(team) != manager ||
|
||||
size_t(team) >= g_.club_ids.size() || rec + 0xb0c > g_.manager_records.size() ||
|
||||
@@ -1052,7 +1052,7 @@ bool CareerSession::dispatch_pitch(const ui::PitchRequest& request, uint64_t& re
|
||||
try {
|
||||
GameState staged = g_;
|
||||
bool accepted = false;
|
||||
const size_t manager_rec = size_t(request.manager_slot) * 0xb0c;
|
||||
const size_t manager_rec = size_t(request.manager_slot) * kManagerRecordSize;
|
||||
static constexpr size_t set_piece_offsets[] = {0xafc,0xafe,0xb08};
|
||||
std::array<uint16_t,3> current_set_piece{};
|
||||
for(size_t i=0;i<3;++i){const size_t at=manager_rec+set_piece_offsets[i];
|
||||
@@ -1444,10 +1444,10 @@ ui::PreparationState CareerSession::preparation_projection(const GameState& stat
|
||||
stadium.gradient_text = source_runtime_byte(state, club_modal_runtime_, exe_, ::bmh::layout::TextGradientDisabled) == 0 &&
|
||||
source_runtime_byte(state, club_modal_runtime_, exe_, ::bmh::layout::TextGradientMode) == 2;
|
||||
stadium.source_level = state.level;
|
||||
stadium.season_tickets = uint16_t(state.manager_records.at(size_t(stadium.manager_slot) * 0xb0c + 0x2ac)) |
|
||||
uint16_t(state.manager_records.at(size_t(stadium.manager_slot) * 0xb0c + 0x2ad)) << 8;
|
||||
const int source_team = int16_t(uint16_t(state.manager_records.at(size_t(stadium.manager_slot) * 0xb0c + 0x290)) |
|
||||
uint16_t(state.manager_records.at(size_t(stadium.manager_slot) * 0xb0c + 0x291)) << 8);
|
||||
stadium.season_tickets = uint16_t(state.manager_records.at(size_t(stadium.manager_slot) * kManagerRecordSize + 0x2ac)) |
|
||||
uint16_t(state.manager_records.at(size_t(stadium.manager_slot) * kManagerRecordSize + 0x2ad)) << 8;
|
||||
const int source_team = int16_t(uint16_t(state.manager_records.at(size_t(stadium.manager_slot) * kManagerRecordSize + 0x290)) |
|
||||
uint16_t(state.manager_records.at(size_t(stadium.manager_slot) * kManagerRecordSize + 0x291)) << 8);
|
||||
const int source_league = source_team > 0x164 ? 0 : team_league(source_team);
|
||||
if (source_league < 0 || size_t(source_league) >= state.league_rounds.size())
|
||||
throw FormatError("stadium source league is outside the live league table");
|
||||
|
||||
@@ -136,7 +136,7 @@ std::optional<CareerSession::StrengthsDispatch> CareerSession::dispatch_strength
|
||||
stadium_.investment||stadium_.tip||stadium_.periphery_quote||top_scorers_owner_||top_scorers_dispatch_active_ || stadium_.block_expansion||other_games_owner_||other_games_dispatch_active_) {
|
||||
error="strengths: stale or unavailable owner";return {};
|
||||
}
|
||||
const size_t rec=size_t(id.manager)*0xb0c;
|
||||
const size_t rec=size_t(id.manager)*kManagerRecordSize;
|
||||
const uint32_t setting=::bmh::layout::ManagerSettings+uint32_t(id.manager)*2,family=::bmh::layout::LeagueTableDisplayModes+uint32_t(id.manager)*2;
|
||||
if(rec+0xb0c>g_.manager_records.size()||
|
||||
(int(g_.manager_records[rec+0x290])|int(g_.manager_records[rec+0x291])<<8)!=id.runtime_club||
|
||||
@@ -359,7 +359,7 @@ std::optional<ui::TopScorersState> CareerSession::open_top_scorers(
|
||||
try {
|
||||
const int manager = request.manager_slot;
|
||||
const int team = g_.manager_teams[size_t(manager)];
|
||||
const size_t manager_record = size_t(manager) * 0xb0c;
|
||||
const size_t manager_record = size_t(manager) * kManagerRecordSize;
|
||||
if (manager_record + 0x292 > g_.manager_records.size() ||
|
||||
uint16_t(g_.manager_records[manager_record + 0x290] |
|
||||
uint16_t(g_.manager_records[manager_record + 0x291]) << 8) != uint16_t(team))
|
||||
@@ -433,7 +433,7 @@ std::optional<CareerSession::TopScorersDispatch> CareerSession::dispatch_top_sco
|
||||
!g_.memory.has(::bmh::layout::ActiveManager) || g_.memory.u8(::bmh::layout::ActiveManager) != identity.manager_slot ||
|
||||
uint32_t(g_.date) != identity.day_counter || identity.league != current.projection.league)
|
||||
throw FormatError("top scorers: desk owner changed");
|
||||
const size_t manager_record = size_t(identity.manager_slot) * 0xb0c;
|
||||
const size_t manager_record = size_t(identity.manager_slot) * kManagerRecordSize;
|
||||
if (manager_record + 0x292 > g_.manager_records.size() ||
|
||||
uint16_t(g_.manager_records[manager_record + 0x290] |
|
||||
uint16_t(g_.manager_records[manager_record + 0x291]) << 8) !=
|
||||
@@ -672,7 +672,7 @@ std::optional<ui::OtherGamesState> CareerSession::open_other_games(
|
||||
if (size_t(manager) >= next.manager_teams.size())
|
||||
throw FormatError("other games: active manager slot is outside typed manager list");
|
||||
const int team = next.manager_teams[size_t(manager)];
|
||||
const size_t record = size_t(manager) * 0xb0c;
|
||||
const size_t record = size_t(manager) * kManagerRecordSize;
|
||||
if (record + 0x292 > next.manager_records.size() || team < 0 || team >= 0x190 ||
|
||||
uint16_t(next.manager_records[record + 0x290] |
|
||||
uint16_t(next.manager_records[record + 0x291]) << 8) != uint16_t(team))
|
||||
@@ -772,7 +772,7 @@ std::optional<CareerSession::OtherGamesDispatch> CareerSession::dispatch_other_g
|
||||
g_.memory.u8(::bmh::layout::ActiveManager) != id.manager_slot || uint32_t(g_.date) != id.day_counter ||
|
||||
g_.memory.u8(::bmh::layout::CareerSession_DispatchOtherGames_RuntimeField + uint32_t(id.manager_slot)) != id.expected_view_byte)
|
||||
throw FormatError("other games: desk owner or view byte changed");
|
||||
const size_t rec = size_t(id.manager_slot) * 0xb0c;
|
||||
const size_t rec = size_t(id.manager_slot) * kManagerRecordSize;
|
||||
if (rec + 0x292 > g_.manager_records.size() ||
|
||||
uint16_t(g_.manager_records[rec + 0x290] | uint16_t(g_.manager_records[rec + 0x291]) << 8) !=
|
||||
uint16_t(id.runtime_team))
|
||||
@@ -831,7 +831,7 @@ std::optional<CareerSession::OtherGamesDispatch> CareerSession::dispatch_other_g
|
||||
next.memory.u8(::bmh::layout::ActiveManager)!=id.manager_slot||
|
||||
next.memory.u8(::bmh::layout::CareerSession_DispatchOtherGames_RuntimeField+uint32_t(id.manager_slot))!=id.expected_view_byte)
|
||||
throw FormatError("other games: TeamInfo changed its outer desk or saved page owner");
|
||||
const size_t active_record=size_t(id.manager_slot)*0xb0c;
|
||||
const size_t active_record=size_t(id.manager_slot)*kManagerRecordSize;
|
||||
if(active_record+0x292>next.manager_records.size()||
|
||||
uint16_t(next.manager_records[active_record+0x290]|
|
||||
uint16_t(next.manager_records[active_record+0x291])<<8)!=uint16_t(id.runtime_team))
|
||||
@@ -1158,7 +1158,7 @@ std::optional<CareerSession::BalanceDispatch> CareerSession::dispatch_balance_pl
|
||||
notice.source_manager_flags=uint8_t(manager)|0x40;
|
||||
notice.compact_dialog_frame=next.notice_gate.compact_dialog_frame!=0;
|
||||
notice.body=message_text(next.state,::bmh::layout::BalancePlan_BalanceFromGame_TextPointer2);
|
||||
const size_t record=size_t(manager)*0xb0c;
|
||||
const size_t record=size_t(manager)*kManagerRecordSize;
|
||||
if(record+0x223>next.state.manager_records.size())throw FormatError("balance: missing manager display identity");
|
||||
const size_t name_at=record+0xa8;size_t name_end=name_at;
|
||||
while(name_end<name_at+30&&next.state.manager_records[name_end])++name_end;
|
||||
|
||||
@@ -234,7 +234,7 @@ bool CareerSession::dispatch_poach_ui(const ui::TransferMarketRequest& request,
|
||||
const auto checkpoint=advertising_session_checkpoint(revision);
|
||||
try {
|
||||
const int manager=request.manager_slot;
|
||||
const size_t record=size_t(manager)*0xb0c;
|
||||
const size_t record=size_t(manager)*kManagerRecordSize;
|
||||
PoachDispatch result;
|
||||
result.start.manager=manager;
|
||||
// These three notices precede the Table modal in Reset.
|
||||
|
||||
@@ -71,9 +71,9 @@ std::string friendly_status_message(FriendlyBookingStatus status) {
|
||||
// from the manager record and club table of the game state. Throws FormatError when the
|
||||
// manager slot or its record is missing.
|
||||
ui::NationalFriendlyIdentity national_friendly_identity(const GameState& game,int manager,int team) {
|
||||
if(manager<0||manager>=5||size_t(manager+1)*0xb0c>game.manager_records.size())
|
||||
if(manager<0||manager>=5||size_t(manager+1)*kManagerRecordSize>game.manager_records.size())
|
||||
throw FormatError("national friendly: missing Source manager identity");
|
||||
const size_t record=size_t(manager)*0xb0c;
|
||||
const size_t record=size_t(manager)*kManagerRecordSize;
|
||||
ui::NationalFriendlyIdentity out;
|
||||
for(size_t i=0;i<30&&game.manager_records[record+0xa8+i];++i)
|
||||
out.manager_name.push_back(char(game.manager_records[record+0xa8+i]));
|
||||
@@ -138,7 +138,7 @@ std::string national_friendly_status_message(FriendlyBookingStatus status) {
|
||||
// Throws FormatError for an invalid slot, a missing record or an out-of-range count.
|
||||
int source_transfer_history_count(const GameState& game, int manager_slot) {
|
||||
if (manager_slot < 0 || manager_slot >= 4) throw FormatError("statistics: invalid manager slot");
|
||||
const size_t at=size_t(manager_slot)*0xb0c+0x21d;
|
||||
const size_t at=size_t(manager_slot)*kManagerRecordSize+0x21d;
|
||||
if(at>=game.manager_records.size())throw FormatError("statistics: missing manager transfer-history counter");
|
||||
const int count=game.manager_records[at];
|
||||
if(count>25)throw FormatError("statistics: Original transfer-history count exceeds 25");
|
||||
@@ -1191,7 +1191,7 @@ struct FlowRequestServer {
|
||||
const auto& game=session->state();
|
||||
if(manager<0||size_t(manager)>=game.manager_teams.size()||
|
||||
!game.memory.has(::bmh::layout::ActiveManager)||game.memory.u8(::bmh::layout::ActiveManager)!=manager||
|
||||
size_t(manager+1)*0xb0c>game.manager_records.size())
|
||||
size_t(manager+1)*kManagerRecordSize>game.manager_records.size())
|
||||
throw FormatError("fair play: invalid active manager");
|
||||
const int team=game.manager_teams[size_t(manager)];
|
||||
if(team!=kNoTeam&&(team<0||size_t(team)>=game.team_flags.size()))
|
||||
@@ -1204,12 +1204,12 @@ struct FlowRequestServer {
|
||||
const int manager=result.desk_action.manager_slot;
|
||||
if(manager<0||size_t(manager)>=game.manager_teams.size()||
|
||||
!game.memory.has(::bmh::layout::ActiveManager)||game.memory.u8(::bmh::layout::ActiveManager)!=manager||
|
||||
size_t(manager+1)*0xb0c>game.manager_records.size())
|
||||
size_t(manager+1)*kManagerRecordSize>game.manager_records.size())
|
||||
throw FormatError("highscore: invalid active manager/roster owner");
|
||||
const int team=game.manager_teams[size_t(manager)];
|
||||
if(team!=kNoTeam&&(team<0||size_t(team)>=game.team_flags.size()))
|
||||
throw FormatError("highscore: active manager has no Source roster");
|
||||
const size_t name_at=size_t(manager)*0xb0c+0xa8;
|
||||
const size_t name_at=size_t(manager)*kManagerRecordSize+0xa8;
|
||||
size_t name_length=0;
|
||||
while(name_length<30&&game.manager_records[name_at+name_length])++name_length;
|
||||
if(name_length==30)throw FormatError("highscore: unterminated active manager name");
|
||||
@@ -2599,7 +2599,7 @@ struct FlowRequestServer {
|
||||
const auto& game = session->state();
|
||||
const auto& desk = flow.desktop()->state();
|
||||
const int manager = request.manager_slot;
|
||||
const size_t record = size_t(manager) * 0xb0c;
|
||||
const size_t record = size_t(manager) * kManagerRecordSize;
|
||||
const auto live = session->desktop_projection(revision);
|
||||
// Calendar identity check: the manager's record must point to the manager's current team and a
|
||||
// fresh desk projection must equal the desk on screen (manager, club, day counter, season,
|
||||
|
||||
+8
-7
@@ -207,7 +207,7 @@ void new_career_markets_and_moods(GameState& g, GameRandom& game, WatcomRandom&
|
||||
if (g.texts) {
|
||||
auto name = [&](int record, uint32_t pointer) {
|
||||
const std::string& t = (*g.texts)[(pointer - ::bmh::layout::TextPointerTable) / 4];
|
||||
const size_t at = size_t(record) * 0xb0c + 0xa8;
|
||||
const size_t at = size_t(record) * kManagerRecordSize + 0xa8;
|
||||
for (size_t i = 0; i <= t.size(); i++) g.manager_records.at(at + i) = i < t.size() ? uint8_t(t[i]) : 0;
|
||||
};
|
||||
name(first, ::bmh::layout::Career_NewCareerMarketsAndMoods_ExecutableField);
|
||||
@@ -438,20 +438,21 @@ void career_managers_begin(GameState& g, bool adding) {
|
||||
bool career_add_manager(GameState& g, const LeImage& exe, int m, const CareerManager& choice, bool adding,
|
||||
GameRandom& game, WatcomRandom& rand, MinuteReport& report) {
|
||||
// Reject malformed requests before changing records or consuming either RNG.
|
||||
const size_t clubs = size_t(world_layout().first_foreign_cup()); // clubs with records (Classic: 168)
|
||||
if (!g.memory.has(::bmh::layout::ManagerCount) || m < 0 || m >= 4 ||
|
||||
g.memory.u8(::bmh::layout::ManagerCount) > 4 || m >= g.memory.u8(::bmh::layout::ManagerCount) ||
|
||||
size_t(m) >= g.manager_teams.size() || g.manager_records.size() < 5 * kRecord ||
|
||||
choice.team < 0 || choice.team >= 168 || size_t(choice.team) >= g.club_ids.size() ||
|
||||
choice.team < 0 || choice.team >= world_layout().first_foreign_cup() || size_t(choice.team) >= g.club_ids.size() ||
|
||||
choice.league < 0 || choice.league > 4 || choice.strength < 0 || choice.strength > 2 ||
|
||||
choice.portrait < 0 || choice.portrait > 11 || choice.name.size() > 24 ||
|
||||
g.tactics.size() < size_t(m + 1) * 0x840 ||
|
||||
g.manager_ratings.size() < size_t(m + 1) * 0x3c ||
|
||||
g.manager_results.size() < g.manager_teams.size() * 0x690 ||
|
||||
g.squad_slots.size() < kSquadSlots || g.club_ids.size() < 168 ||
|
||||
g.team_morale.size() < 168 || g.team_flags.size() < 168 ||
|
||||
g.club_heap_bc.size() < 168 * 2 || g.club_heap_78.size() < 168 * 2 ||
|
||||
g.club_heap_b8.size() < 168 || g.position_history.size() < 138 * 0x1a ||
|
||||
(!g.club_table.empty() && g.club_table.size() < 168 * 0x4a) ||
|
||||
g.squad_slots.size() < kSquadSlots || g.club_ids.size() < clubs ||
|
||||
g.team_morale.size() < clubs || g.team_flags.size() < clubs ||
|
||||
g.club_heap_bc.size() < clubs * 2 || g.club_heap_78.size() < clubs * 2 ||
|
||||
g.club_heap_b8.size() < clubs || g.position_history.size() < size_t(world_layout().league_teams) * 0x1a ||
|
||||
(!g.club_table.empty() && g.club_table.size() < clubs * kClubRecordSize) ||
|
||||
g.player_bonus.size() < g.players.size() || g.player_cards.size() < g.players.size() ||
|
||||
!exe.contains(::bmh::layout::Career_CareerAddManager_ExecutableField) || !exe.contains(::bmh::layout::Career_BuildStadium_RuntimeField3 + 0x15 * 5) ||
|
||||
!exe.contains(::bmh::layout::Career_BuildStadium_RuntimeField + 4 * 0x17 + 0x15)) {
|
||||
|
||||
+2
-2
@@ -596,7 +596,7 @@ void advance_cup(GameState& g, int id, WatcomRandom& rand, MinuteReport& report,
|
||||
for (uint16_t t : winners) {
|
||||
const int manager = g.manager_of(t);
|
||||
if (manager < 0) continue;
|
||||
const size_t at = size_t(manager) * 0xB0C + 0xda + size_t(std::min(g.season, 0x31)) * 3 + (type > 0 ? 2 : 1);
|
||||
const size_t at = size_t(manager) * kManagerRecordSize + 0xda + size_t(std::min(g.season, 0x31)) * 3 + (type > 0 ? 2 : 1);
|
||||
g.manager_records.at(at) = uint8_t(g.manager_records.at(at) + 1);
|
||||
}
|
||||
if (cup_round(mem, entry) == mem.u8(e + 0x1b)) {
|
||||
@@ -622,7 +622,7 @@ void advance_cup(GameState& g, int id, WatcomRandom& rand, MinuteReport& report,
|
||||
if (mem.u8(::bmh::layout::Cup_AdvanceCup_RuntimeField) == 0 && mem.has(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2)) mem.set8(::bmh::layout::CareerSession_BeginFriendlyOpponentTable_ExecutableField2, 0);
|
||||
const int manager = g.manager_of(winners[0]);
|
||||
if (manager >= 0 && type >= 0 && type < 4) {
|
||||
const size_t at = size_t(manager) * 0xB0C + (type == 0 ? 0x8a6 : 0x8a8);
|
||||
const size_t at = size_t(manager) * kManagerRecordSize + (type == 0 ? 0x8a6 : 0x8a8);
|
||||
const uint16_t n = uint16_t(g.manager_records.at(at) | g.manager_records.at(at + 1) << 8);
|
||||
g.manager_records.at(at) = uint8_t(n + 1), g.manager_records.at(at + 1) = uint8_t((n + 1) >> 8);
|
||||
}
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ void enter_desk(GameState& g, int manager, GameRandom& game, WatcomRandom& rand,
|
||||
// (<goal>. Platz) nicht erreicht haben." Reached: (4 - league) * 50000 per place better
|
||||
// than the goal plus one (the third divisions count as the second), booked as income.
|
||||
std::vector<uint8_t>& r = g.manager_records;
|
||||
const size_t rec = size_t(manager) * 0xB0C;
|
||||
const size_t rec = size_t(manager) * kManagerRecordSize;
|
||||
const int goal = r.at(rec + 0x176);
|
||||
if (g.memory.has(::bmh::layout::CareerSession_RuntimeError_RuntimeField4) && g.memory.u8(::bmh::layout::CareerSession_RuntimeError_RuntimeField4) != 0 && goal != 0) {
|
||||
const int place = int16_t(table_position(g, team)) + 1; // TablePosition
|
||||
|
||||
@@ -1815,7 +1815,7 @@ void move_to_deposit(GameState& g, int manager, int32_t amount) {
|
||||
}
|
||||
|
||||
void open_lineup_screen(GameState& g, int manager) {
|
||||
uint8_t* rec = &g.manager_records.at(size_t(manager) * 0xb0c);
|
||||
uint8_t* rec = &g.manager_records.at(size_t(manager) * kManagerRecordSize);
|
||||
if ((rec[0xb0a] | rec[0xb0b] << 8) == 0x3253) return;
|
||||
for (int i = 0; i < 4; i++) rec[0xafc + i] = 0;
|
||||
rec[0xb08] = 0, rec[0xb09] = 0, rec[0xb0a] = 0x53, rec[0xb0b] = 0x32;
|
||||
|
||||
@@ -32,7 +32,7 @@ bool legacy_academy(const GameState& g, int manager) {
|
||||
return value == 1500000 || value == 1000000 || value == 580000 || value == 280000;
|
||||
}
|
||||
uint32_t academy_paid(const GameState& g, int manager) {
|
||||
const auto at = size_t(manager) * 0xb0c + 0x880;
|
||||
const auto at = size_t(manager) * kManagerRecordSize + 0x880;
|
||||
return uint32_t(g.manager_records.at(at)) | uint32_t(g.manager_records.at(at + 1)) << 8 |
|
||||
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ void validate(const GameState& g,const LeaguePairingsOwner& o) {
|
||||
(g.memory.u8(::bmh::layout::CareerSession_CloseLeagueFamily_ExecutableField+uint32_t(o.manager))&0x0f)==8)&&
|
||||
g.memory.has(::bmh::layout::LeagueTableDisplayModes+uint32_t(o.manager)*2+1),
|
||||
"pairings: missing preferences or unsupported saved list mode");
|
||||
require(g.results.size()>=kResultsSize&&g.club_ids.size()>=138&&g.league_rounds.size()>=9&&
|
||||
require(g.results.size()>=kResultsSize&&g.club_ids.size()>=size_t(world_layout().league_teams)&&g.league_rounds.size()>=size_t(kLeagueCount)&&
|
||||
g.memory.has(::bmh::layout::Postponed+0xef)&&g.memory.has(::bmh::layout::CompetitionCalendar+365*2+1),
|
||||
"pairings: incomplete Native schedule");
|
||||
const auto selection_valid=[&](int team,int identity) {
|
||||
@@ -373,9 +373,9 @@ LeaguePairingsOwner edit_league_pairings_source(GameState& g,const LeaguePairing
|
||||
require(g.memory.has(::bmh::layout::CalendarState_FormatError_RuntimeField2)&&g.memory.u8(::bmh::layout::CalendarState_FormatError_RuntimeField2)==0,
|
||||
"pairings: secondary leagues disabled");
|
||||
out.league_group^=1;
|
||||
require(size_t(out.manager)*0xb0c+0x210<g.manager_records.size(),
|
||||
require(size_t(out.manager)*kManagerRecordSize+0x210<g.manager_records.size(),
|
||||
"pairings: missing manager league preference");
|
||||
out.league=out.league_group?5:g.manager_records.at(size_t(out.manager)*0xb0c+0x210);
|
||||
out.league=out.league_group?5:g.manager_records.at(size_t(out.manager)*kManagerRecordSize+0x210);
|
||||
require(out.league>=0&&out.league<9,"pairings: invalid manager league preference");
|
||||
[[fallthrough]];
|
||||
case LeaguePairingsAction::select_league:
|
||||
|
||||
+3
-3
@@ -368,7 +368,7 @@ static void auto_lineup_impl(GameState& g, int team, int mode, int manager) {
|
||||
g.club_heap_78[club_word + 1] = uint8_t(badge_word >> 8);
|
||||
formation = 0;
|
||||
set = manager;
|
||||
const uint8_t style = g.manager_records.at(size_t(manager) * 0xB0C + 0x288);
|
||||
const uint8_t style = g.manager_records.at(size_t(manager) * kManagerRecordSize + 0x288);
|
||||
weight = 1 << ((style & 3) + 4);
|
||||
familiarity = (style >> 4) & 3;
|
||||
if (g.level >= 6) detail = (style >> 2) & 3;
|
||||
@@ -447,7 +447,7 @@ static void auto_lineup_impl(GameState& g, int team, int mode, int manager) {
|
||||
if (option == -1) throw std::invalid_argument("auto_lineup: invalid human formation option");
|
||||
formation = option;
|
||||
set = manager;
|
||||
const uint8_t style = g.manager_records.at(size_t(manager) * 0xB0C + 0x288); // assistant settings
|
||||
const uint8_t style = g.manager_records.at(size_t(manager) * kManagerRecordSize + 0x288); // assistant settings
|
||||
weight = 1 << ((style & 3) + 4);
|
||||
familiarity = (style >> 4) & 3;
|
||||
if (g.level >= 6) detail = (style >> 2) & 3;
|
||||
@@ -788,7 +788,7 @@ bool substitute(GameState& g, int team, int off, int mode, WatcomRandom& rand) {
|
||||
// human teams: the re-sort uses a formation after the attitude (mode / 2 for the
|
||||
// tactical changes, else the manager's setting, record +0xd2): option byte 0 is set
|
||||
// to 4 - attitude for the call and restored afterwards
|
||||
int attitude = mode < 9 ? mode >> 1 : int8_t(g.manager_records.at(size_t(manager) * 0xB0C + 0xd2)); // (mode as clamped above)
|
||||
int attitude = mode < 9 ? mode >> 1 : int8_t(g.manager_records.at(size_t(manager) * kManagerRecordSize + 0xd2)); // (mode as clamped above)
|
||||
if (attitude > 3) attitude = 3;
|
||||
uint8_t& option = g.manager_options.at(size_t(manager) * 5);
|
||||
const uint8_t saved = option;
|
||||
|
||||
@@ -20,7 +20,7 @@ uint32_t key(int team, int player) {
|
||||
}
|
||||
int manager_team(const GameState& g, int manager) {
|
||||
if (manager >= 0 && size_t(manager) < g.manager_teams.size()) return g.manager_teams[size_t(manager)];
|
||||
const size_t at = size_t(manager) * 0xb0c + 0x290;
|
||||
const size_t at = size_t(manager) * kManagerRecordSize + 0x290;
|
||||
if (manager < 0 || manager > 4 || at + 1 >= g.manager_records.size())
|
||||
throw FormatError("long career: invalid manager");
|
||||
return int(g.manager_records[at] | uint16_t(g.manager_records[at + 1]) << 8);
|
||||
|
||||
+3
-3
@@ -112,7 +112,7 @@ void rate_side(GameState& g, const MatchSetup& m, int side, int previous6, Watco
|
||||
int base = kLeagueCrowd[league < 10 ? league : 9] * 1000;
|
||||
if (unsigned(rand.range(base + 3000, base + 6000)) < unsigned(m.spectators)) {
|
||||
// a human manager's side with record +0x289 set suffers more from a full house
|
||||
modifier -= manager >= 0 && g.manager_records.at(size_t(manager) * 0xB0C + 0x289) != 0 ? 9 : 6;
|
||||
modifier -= manager >= 0 && g.manager_records.at(size_t(manager) * kManagerRecordSize + 0x289) != 0 ? 9 : 6;
|
||||
}
|
||||
}
|
||||
modifier = clamp(int8_t(modifier), -10, 10);
|
||||
@@ -141,7 +141,7 @@ void rate_side(GameState& g, const MatchSetup& m, int side, int previous6, Watco
|
||||
} else {
|
||||
// human teams: record +0xd9 (signed) * 5 plus a constant 110, scaled to 0-100. Diamond 3.7: the
|
||||
// condition/technique balance r[6] no longer enters (before: d9 * 5 + r[6]).
|
||||
const int8_t d9 = int8_t(g.manager_records.at(size_t(manager) * 0xB0C + 0xd9));
|
||||
const int8_t d9 = int8_t(g.manager_records.at(size_t(manager) * kManagerRecordSize + 0xd9));
|
||||
r[7] = uint8_t((d9 * 5 + 110) * 100 / 0xFF);
|
||||
}
|
||||
}
|
||||
@@ -162,7 +162,7 @@ std::array<SideRecord, 2> build_side_records(GameState& g, const MatchSetup& m,
|
||||
// state; OpenBMH uses a cleared record (0) as a deterministic stand-in.
|
||||
const int manager = g.manager_of(side ? m.away : m.home);
|
||||
if (manager >= 0 && !g.manager_option(manager, 2))
|
||||
r.b[8] = g.manager_records.at(size_t(manager) * 0xB0C + 0xd2); // the manager's own setting
|
||||
r.b[8] = g.manager_records.at(size_t(manager) * kManagerRecordSize + 0xd2); // the manager's own setting
|
||||
else
|
||||
r.b[8] = uint8_t(initial_attitude(r, rec[1 - side], side, m.match_index, rand));
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ void MatchEngine::set_piece_animation(int kind, int distance, int side, int grou
|
||||
int MatchEngine::designated_slot(int team, int offset, int exclude) const {
|
||||
int manager = state.manager_of(team);
|
||||
if (manager < 0 || state.manager_records.empty()) return -1;
|
||||
const uint8_t* rec = state.manager_records.data() + size_t(manager) * 0xB0C;
|
||||
const uint8_t* rec = state.manager_records.data() + size_t(manager) * kManagerRecordSize;
|
||||
auto u16 = [&](int at) { return int(rec[at] | rec[at + 1] << 8); };
|
||||
if (u16(0xb0a) != 0x3253) return -1;
|
||||
int id = u16(offset);
|
||||
@@ -473,8 +473,8 @@ int injure_player(GameState& g, int slot, int type, bool match, int manager, Wat
|
||||
// duration * (doctor / 100 - 5) / 8; a poor doctor makes it longer. The cut is limited
|
||||
// only for the heavy injuries: types 20-25 by 4 matchdays, types 26-27 by 6, types 28-30
|
||||
// by 8; lighter types have no limit (the duration is cut to 0 at the lowest).
|
||||
const int doctor = int16_t(g.manager_records.at(size_t(manager) * 0xB0C + 0x8ae) |
|
||||
g.manager_records.at(size_t(manager) * 0xB0C + 0x8af) << 8);
|
||||
const int doctor = int16_t(g.manager_records.at(size_t(manager) * kManagerRecordSize + 0x8ae) |
|
||||
g.manager_records.at(size_t(manager) * kManagerRecordSize + 0x8af) << 8);
|
||||
// (the / 8 is Watcom's SAR/SHL/SBB idiom: (x + 7) >> 3 for negative x)
|
||||
const int x = duration * (doctor / 100 - 5);
|
||||
int cut = (x + (x < 0 ? 7 : 0)) >> 3;
|
||||
@@ -703,7 +703,7 @@ ForcedMatchEvent MatchEngine::event_impl(MatchGroup& g, int m, int s, int minute
|
||||
}
|
||||
if (human) {
|
||||
const int bucket = std::min(minute, 0x59) / 5;
|
||||
state.manager_records.at(size_t(manager) * 0xB0C + 0x1ae + size_t(bucket) + size_t((kind == 1) + 2) * 0x12)++;
|
||||
state.manager_records.at(size_t(manager) * kManagerRecordSize + 0x1ae + size_t(bucket) + size_t((kind == 1) + 2) * 0x12)++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,7 +761,7 @@ void MatchEngine::side(MatchGroup& g, int m, int& s, int minute, int& own_att, i
|
||||
report.fail("attitude of a human team needs the manager records (savegame)");
|
||||
return;
|
||||
}
|
||||
own[8] = state.manager_records.at(size_t(manager) * 0xB0C + 0xd2);
|
||||
own[8] = state.manager_records.at(size_t(manager) * kManagerRecordSize + 0xd2);
|
||||
return;
|
||||
}
|
||||
int home = 0, away = 0;
|
||||
@@ -1077,7 +1077,7 @@ void MatchEngine::side(MatchGroup& g, int m, int& s, int minute, int& own_att, i
|
||||
const size_t bucket = size_t(std::min(minute, 0x59) / 5);
|
||||
for (int t : {opp_team, team}) {
|
||||
const int mgr = state.manager_of(t);
|
||||
if (mgr >= 0) state.manager_records.at(size_t(mgr) * 0xB0C + 0x1c0 + bucket)++;
|
||||
if (mgr >= 0) state.manager_records.at(size_t(mgr) * kManagerRecordSize + 0x1c0 + bucket)++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -663,7 +663,7 @@ int attendance(GameState& g, int home, int away, int bits, int temperature, int
|
||||
}
|
||||
}
|
||||
const int home_manager = g.manager_of(home), away_manager = g.manager_of(away); // local_20, local_14
|
||||
const size_t rec = size_t(home_manager) * 0xB0C; // EDI / puVar10: the home manager's record
|
||||
const size_t rec = size_t(home_manager) * kManagerRecordSize; // EDI / puVar10: the home manager's record
|
||||
auto r8 = [&](size_t off) { return int(g.manager_records.at(rec + off)); };
|
||||
auto r16 = [&](size_t off) { return int(g.manager_records.at(rec + off) | g.manager_records.at(rec + off + 1) << 8); };
|
||||
auto r32 = [&](size_t off) { return int32_t(rd32(g.manager_records, rec + off)); };
|
||||
@@ -851,7 +851,7 @@ int attendance(GameState& g, int home, int away, int bits, int temperature, int
|
||||
if (away_manager >= 0 && (bits & 0x180)) {
|
||||
// a shared gate (cups, bits 7/8): the human away club gets the same half and counts
|
||||
// the match in its attendance statistics (no catering, no records)
|
||||
const size_t away_rec = size_t(away_manager) * 0xB0C;
|
||||
const size_t away_rec = size_t(away_manager) * kManagerRecordSize;
|
||||
auto& m = g.manager_records;
|
||||
if ((m.at(away_rec + 0x290) | m.at(away_rec + 0x291) << 8) != kNoTeam) {
|
||||
book_money(g, away_manager, -income, true);
|
||||
@@ -903,7 +903,7 @@ void man_marking(GameState& g, int own_manager, int own, int other_manager, int
|
||||
const size_t at = size_t(own_manager) * 0x840 + s * 0x58 + 0x44;
|
||||
g.tactics.at(at) = 0xFF, g.tactics.at(at + 1) = 0x0F;
|
||||
}
|
||||
const size_t rec = size_t(own_manager) * 0xB0C + 0x8ac;
|
||||
const size_t rec = size_t(own_manager) * kManagerRecordSize + 0x8ac;
|
||||
rate = uint8_t((int16_t(g.manager_records.at(rec) | g.manager_records.at(rec + 1) << 8) >> 4) + 0x28);
|
||||
}
|
||||
bool marking[24] = {}; // local_70: own slots already marking
|
||||
|
||||
+1
-1
@@ -151,7 +151,7 @@ int team_rating(GameState& g, int team, const RatingProfile& profile, RatingCont
|
||||
const int manager = team == kNoTeam ? -1 : g.manager_of(team); // local_5a
|
||||
int rank = 0; // local_5e
|
||||
if (manager >= 0) {
|
||||
const size_t rec = size_t(manager) * 0xB0C;
|
||||
const size_t rec = size_t(manager) * kManagerRecordSize;
|
||||
const int league = g.manager_records.at(rec + 0x210);
|
||||
const int mode = (league < int(g.league_rounds.size()) && g.league_rounds[size_t(league)] > 9) + 1;
|
||||
std::array<uint8_t, 24> buf;
|
||||
|
||||
@@ -54,7 +54,7 @@ void validate(const GameState& state, const std::array<int,2>& teams, int side,
|
||||
if (range.first+range.count > state.squad_slots.size() || range.count < 11)
|
||||
throw FormatError("Reality setup: truncated squad");
|
||||
const int m = manager(state,team);
|
||||
if (m >= 0 && (state.manager_records.size() < size_t(m)*0xb0c+0xd9 ||
|
||||
if (m >= 0 && (state.manager_records.size() < size_t(m)*kManagerRecordSize+0xd9 ||
|
||||
state.tactics.size() < size_t(m+1)*0x840))
|
||||
throw FormatError("Reality setup: truncated manager/board");
|
||||
for (const auto& p : positions[size_t(s)])
|
||||
@@ -110,7 +110,7 @@ void initialize_reality(GameState& state, const std::array<int,2>& teams, int at
|
||||
for (int option = 0; option < 7; ++option)
|
||||
setup.tactics[size_t(side)][size_t(option)] = uint8_t(m < 0 ?
|
||||
rand.range(0,exe.u8(::bmh::layout::RealitySetup_InitializeReality_RuntimeFieldUnsigned+uint32_t(option))) :
|
||||
state.manager_records.at(size_t(m)*0xb0c+0xd2+size_t(option)));
|
||||
state.manager_records.at(size_t(m)*kManagerRecordSize+0xd2+size_t(option)));
|
||||
}
|
||||
setup.grid.reset_occupancy(); // SizeT2 clears only the two occupancy planes.
|
||||
for (int pass = 0; pass < 2; ++pass) {
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ Bytes save_header(const GameState& g) {
|
||||
for (size_t i = 0; i < 11; i++) h.push_back(i < date.size() ? uint8_t(date[i]) : 0);
|
||||
Bytes list(0xa0, 0);
|
||||
for (int m = 0; m < managers && m < 4; m++) {
|
||||
const size_t rec = size_t(m) * 0xb0c;
|
||||
const size_t rec = size_t(m) * kManagerRecordSize;
|
||||
const int team = int16_t(g.manager_records.at(rec + 0x290) | g.manager_records.at(rec + 0x291) << 8);
|
||||
const bool national = team == kNoTeam;
|
||||
const size_t at = size_t(m) * 0x28;
|
||||
|
||||
+9
-9
@@ -427,14 +427,14 @@ void european_fields(GameState& g, GameRandom& game, WatcomRandom& rand) {
|
||||
}
|
||||
|
||||
int32_t rec32(const GameState& g, int m, size_t o) {
|
||||
const size_t at = size_t(m) * 0xB0C + o;
|
||||
const size_t at = size_t(m) * kManagerRecordSize + o;
|
||||
return int32_t(uint32_t(g.manager_records.at(at) | g.manager_records.at(at + 1) << 8 | g.manager_records.at(at + 2) << 16) |
|
||||
uint32_t(g.manager_records.at(at + 3)) << 24);
|
||||
}
|
||||
void set_rec32(GameState& g, int m, size_t o, int32_t v) {
|
||||
for (size_t i = 0; i < 4; i++) g.manager_records.at(size_t(m) * 0xB0C + o + i) = uint8_t(uint32_t(v) >> (8 * i));
|
||||
for (size_t i = 0; i < 4; i++) g.manager_records.at(size_t(m) * kManagerRecordSize + o + i) = uint8_t(uint32_t(v) >> (8 * i));
|
||||
}
|
||||
uint8_t& rec8(GameState& g, int m, size_t o) { return g.manager_records.at(size_t(m) * 0xB0C + o); }
|
||||
uint8_t& rec8(GameState& g, int m, size_t o) { return g.manager_records.at(size_t(m) * kManagerRecordSize + o); }
|
||||
uint16_t mem_u16(const GameState& g, uint32_t a) { return g.memory.u16(a); }
|
||||
|
||||
// HighscoreScore(mask, 0, 0xff): bit 0 the account (+0x314), 1 the deposit (+0x318), 2 the
|
||||
@@ -512,8 +512,8 @@ void season_tickets(GameState& g, int m, WatcomRandom& rand) {
|
||||
const int low = std::max(pop - kBase[league], 0);
|
||||
const int r = rand.range(low, low + 10);
|
||||
const int sold = ((100 - g.level * 5) * (kTickets[league] + r * 300)) / 100;
|
||||
g.manager_records.at(size_t(m) * 0xB0C + 0x2ac) = uint8_t(sold);
|
||||
g.manager_records.at(size_t(m) * 0xB0C + 0x2ad) = uint8_t(sold >> 8);
|
||||
g.manager_records.at(size_t(m) * kManagerRecordSize + 0x2ac) = uint8_t(sold);
|
||||
g.manager_records.at(size_t(m) * kManagerRecordSize + 0x2ad) = uint8_t(sold >> 8);
|
||||
const int32_t income = int32_t(kPrice[league]) * int16_t(sold);
|
||||
book_money(g, m, -income, true);
|
||||
set_rec32(g, m, 0x754, rec32(g, m, 0x754) + income);
|
||||
@@ -999,7 +999,7 @@ void cup_fields_english(GameState& g, GameRandom& game, const uint8_t (&ranks)[4
|
||||
const int team = club_at_rank(l, i, ranks[l]);
|
||||
mem.set16(kEnglishFaField + n++ * 2, uint16_t(team));
|
||||
if (const int m = g.manager_of(team); m >= 0)
|
||||
g.manager_records.at(size_t(m) * 0xB0C + 0xda + 1 + size_t(std::min<int>(g.season, 0x31)) * 3) = 1;
|
||||
g.manager_records.at(size_t(m) * kManagerRecordSize + 0xda + 1 + size_t(std::min<int>(g.season, 0x31)) * 3) = 1;
|
||||
}
|
||||
shuffle(kEnglishFaField, 0x14);
|
||||
shuffle(kEnglishFaQualifyingField, 0x30);
|
||||
@@ -1041,7 +1041,7 @@ void cup_field(GameState& g, GameRandom& game, const std::function<void(const ch
|
||||
const int team = club_at_rank(l, i, ranks[l]);
|
||||
mem.set16(kField + n++ * 2, uint16_t(team));
|
||||
if (const int m = g.manager_of(team); m >= 0)
|
||||
g.manager_records.at(size_t(m) * 0xB0C + 0xda + 1 + size_t(std::min<int>(g.season, 0x31)) * 3) = 1;
|
||||
g.manager_records.at(size_t(m) * kManagerRecordSize + 0xda + 1 + size_t(std::min<int>(g.season, 0x31)) * 3) = 1;
|
||||
}
|
||||
for (uint32_t i = 0; i < 0x40; i++) { // PrepareEvent
|
||||
const uint32_t j = uint32_t(game.range(0, 0x3f));
|
||||
@@ -1202,8 +1202,8 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
|
||||
bool gone = true;
|
||||
if (owner != -1) {
|
||||
std::string text;
|
||||
const int doctor = int16_t(g.manager_records.at(size_t(owner) * 0xB0C + 0x8ae) |
|
||||
g.manager_records.at(size_t(owner) * 0xB0C + 0x8af) << 8);
|
||||
const int doctor = int16_t(g.manager_records.at(size_t(owner) * kManagerRecordSize + 0x8ae) |
|
||||
g.manager_records.at(size_t(owner) * kManagerRecordSize + 0x8af) << 8);
|
||||
if (doctor > rand.range(700, 0x4b0)) {
|
||||
text = message_text(g, ::bmh::layout::Season_SeasonPlayers_TextPointer) + g.player_name(player) + message_text(g, ::bmh::layout::Season_SeasonPlayers_TextPointer2);
|
||||
gone = false;
|
||||
|
||||
@@ -76,7 +76,7 @@ std::optional<SportschauAwardsView> finish_sportschau_awards(GameState& state,
|
||||
for (size_t i = 0; i < 11; ++i) {
|
||||
const int manager = state.manager_of(slot_team(group.desc.at(0x70 + i)));
|
||||
if (manager >= 0) {
|
||||
auto& counter = state.manager_records.at(size_t(manager) * 0xb0c + 0x21e);
|
||||
auto& counter = state.manager_records.at(size_t(manager) * kManagerRecordSize + 0x21e);
|
||||
counter = uint8_t(counter + 1);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ LeagueTable compute_league_table(const GameState& g, int league, int from, int t
|
||||
for (int c = 0; c < t.size; c++) {
|
||||
int manager = g.manager_of(first_team + c);
|
||||
if (manager < 0) continue;
|
||||
uint8_t d = g.manager_records.at(size_t(manager) * 0xB0C + 0x220);
|
||||
uint8_t d = g.manager_records.at(size_t(manager) * kManagerRecordSize + 0x220);
|
||||
if (d >> 5 == 3) t.points[c] = int8_t(t.points[c] - (d & 0x1F));
|
||||
}
|
||||
flags &= ~4;
|
||||
|
||||
+2
-2
@@ -150,7 +150,7 @@ void familiarity_decay(GameState& g, GameRandom& game, WatcomRandom& rand) {
|
||||
}
|
||||
|
||||
void train_squad(GameState& g, int manager, GameRandom& game, WatcomRandom& rand) {
|
||||
const size_t rec = size_t(manager) * 0xB0C;
|
||||
const size_t rec = size_t(manager) * kManagerRecordSize;
|
||||
uint8_t table[4][9];
|
||||
for (int pos = 0; pos < 4; pos++)
|
||||
for (int a = 0; a < 9; a++)
|
||||
@@ -247,7 +247,7 @@ void auto_training(GameState& g, int manager) {
|
||||
uint8_t& option = g.manager_options.at(size_t(manager) * 5 + 4); // CareerSessionRuntimeField3
|
||||
if (!(option & 0x80)) option = 0x9f;
|
||||
const uint8_t flags = (option & 1) ? option : 0; // local_14
|
||||
const size_t rec = size_t(manager) * 0xB0C;
|
||||
const size_t rec = size_t(manager) * kManagerRecordSize;
|
||||
const int team = int16_t(rd16w(g.manager_records, rec + 0x290));
|
||||
uint8_t plan[13];
|
||||
for (int i = 0; i < 13; i++) plan[i] = g.manager_records.at(rec + 0xc5 + size_t(i));
|
||||
|
||||
+1
-1
@@ -1333,7 +1333,7 @@ bool decide_bids(GameState& g, int k, GameRandom& game, WatcomRandom& rand, Minu
|
||||
const int bidder_manager = g.manager_of(bidder);
|
||||
if (bidder_manager >= 0) {
|
||||
const int32_t fee = int32_t(mem.u32(list + 0x1c + uint32_t(bid) * 4));
|
||||
const size_t rec = size_t(bidder_manager) * 0xb0c;
|
||||
const size_t rec = size_t(bidder_manager) * kManagerRecordSize;
|
||||
const int32_t balance = int32_t(uint32_t(g.manager_records.at(rec + 0x314)) |
|
||||
uint32_t(g.manager_records.at(rec + 0x315)) << 8 | uint32_t(g.manager_records.at(rec + 0x316)) << 16 |
|
||||
uint32_t(g.manager_records.at(rec + 0x317)) << 24);
|
||||
|
||||
@@ -56,7 +56,7 @@ AchievementsState achievements_from_game(const GameState& game,const LeImage& ex
|
||||
size_t(owner.manager_slot)>=game.manager_teams.size()||owner.revision==UINT64_MAX||
|
||||
underlay.width!=320||underlay.height!=240||!game.texts)
|
||||
throw FormatError("achievements: invalid Source desk owner");
|
||||
const size_t base=size_t(owner.manager_slot)*0xb0c;
|
||||
const size_t base=size_t(owner.manager_slot)*kManagerRecordSize;
|
||||
if(base+0x556>game.manager_records.size())throw FormatError("achievements: truncated Source manager history");
|
||||
AchievementsState out;out.owner=owner;out.manager_slot=owner.manager_slot;out.underlay=underlay;
|
||||
out.season_count=std::clamp(game.season+1,1,50);out.selected_season=out.season_count-1;
|
||||
|
||||
@@ -42,7 +42,7 @@ BalanceState balance_from_game(const GameState& g,const BalancePlanDraft& d,cons
|
||||
uint32_t first=p.maximum/10,step=p.maximum/5;
|
||||
int64_t first_signed=first;uint32_t advance=step;
|
||||
if(row==20){
|
||||
const size_t rec=size_t(d.manager)*0xb0c;const uint32_t attendance=rec+0x5c<g.manager_records.size()?g.manager_records[rec+0x5c]:0;
|
||||
const size_t rec=size_t(d.manager)*kManagerRecordSize;const uint32_t attendance=rec+0x5c<g.manager_records.size()?g.manager_records[rec+0x5c]:0;
|
||||
if(d.rows[20]==0){first_signed=int64_t(attendance)*400;advance=attendance*100;}
|
||||
else {const uint32_t value=p.initial;if(value<10){
|
||||
// The Original helper divides by zero while deriving its decimal step for 1..9.
|
||||
@@ -53,7 +53,7 @@ BalanceState balance_from_game(const GameState& g,const BalancePlanDraft& d,cons
|
||||
for(size_t i=0;i<6;++i){first_signed=std::max<int64_t>(0,first_signed);if(uint64_t(first_signed)<=p.maximum)p.presets[i]=uint32_t(first_signed);if(uint64_t(first_signed)>p.maximum)p.presets[i].reset();first_signed+=advance;}
|
||||
p.presets[6]=0;p.presets[7]=p.maximum;
|
||||
}
|
||||
const size_t rec=size_t(d.manager)*0xb0c;
|
||||
const size_t rec=size_t(d.manager)*kManagerRecordSize;
|
||||
for(size_t n=0;n<30&&rec+0xa8+n<g.manager_records.size();++n){char c=char(g.manager_records[rec+0xa8+n]);if(!c)break;s.read_only_notice.manager_name.push_back(c);s.close_notice.manager_name.push_back(c);}
|
||||
s.read_only_notice.kind=TaxDialogKind::acknowledgement;s.read_only_notice.source_manager_flags=uint8_t(d.manager)|0x40;s.read_only_notice.body=message_text(g,::bmh::layout::BalancePlan_BalanceFromGame_TextPointer);
|
||||
s.close_notice.kind=TaxDialogKind::acknowledgement;s.close_notice.source_manager_flags=uint8_t(d.manager)|0x40;s.close_notice.body=message_text(g,::bmh::layout::BalancePlan_BalanceFromGame_TextPointer2);
|
||||
|
||||
+2
-2
@@ -69,7 +69,7 @@ void copy_region(Image& target, const Image& source, int sx, int sy, int x, int
|
||||
BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revision) {
|
||||
const int manager = int(g.memory.u8(::bmh::layout::ActiveManager));
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size()) throw FormatError("bank: invalid active manager");
|
||||
const size_t record = size_t(manager) * 0xb0c;
|
||||
const size_t record = size_t(manager) * kManagerRecordSize;
|
||||
if (record + 0x328 > g.manager_records.size()) throw FormatError("bank: truncated manager record");
|
||||
BankState state;
|
||||
state.manager_slot = manager;
|
||||
@@ -92,7 +92,7 @@ BankState bank_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
throw FormatError("bank: unsupported configured manager count");
|
||||
for (int slot = 0; slot < configured_managers && state.credit_lenders.size() < 3; ++slot) {
|
||||
if (slot == manager) continue;
|
||||
const size_t lender_record = size_t(slot) * 0xb0c;
|
||||
const size_t lender_record = size_t(slot) * kManagerRecordSize;
|
||||
if (lender_record + 0x314 > g.manager_records.size())
|
||||
throw FormatError("bank: truncated lender manager record");
|
||||
const auto lender_end = std::find(g.manager_records.begin() + lender_record + 0xa8,
|
||||
|
||||
@@ -67,7 +67,7 @@ ClubPlayerDetailProjection club_player_detail_from_game(const GameState& g,
|
||||
p.gradient_text=(!g.memory.has(::bmh::layout::TextGradientDisabled)||g.memory.u8(::bmh::layout::TextGradientDisabled)==0)&&exe.u8(::bmh::layout::TextGradientMode)==2;
|
||||
p.injury_as_text=g.memory.has(::bmh::layout::ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField4)?g.memory.u8(::bmh::layout::ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField4)!=0:exe.u8(::bmh::layout::ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField4)!=0;
|
||||
if(c.board && !c.human_loan){
|
||||
const size_t month=size_t(c.active_manager)*0xb0c+0x286;
|
||||
const size_t month=size_t(c.active_manager)*kManagerRecordSize+0x286;
|
||||
if(month>=g.manager_records.size())throw FormatError("club player detail: missing active statistics months");
|
||||
p.statistics_months=g.manager_records[month];
|
||||
const uint32_t flags=::bmh::layout::Flags+uint32_t(c.active_manager)*3+2;
|
||||
|
||||
@@ -197,7 +197,7 @@ DeskState project(const StaticMemory& memory, const Tables& t, const LeImage& ex
|
||||
throw FormatError("desk: invalid manager identity");
|
||||
d.managers.push_back(std::move(identity));
|
||||
}
|
||||
const size_t base = size_t(d.manager_slot) * 0xb0c;
|
||||
const size_t base = size_t(d.manager_slot) * kManagerRecordSize;
|
||||
if (t.managers.size() < base + 0xb0c || t.options.size() < size_t(d.manager_slot + 1) * 5)
|
||||
throw FormatError("desk: truncated manager records/options");
|
||||
d.runtime_club = t.teams.at(d.manager_slot);
|
||||
@@ -516,7 +516,7 @@ DeskState desk_from_save(const SaveState& s, const LeImage& exe, uint64_t revisi
|
||||
if (w1.size() != w2.size() || w1.size() != w3.size() || w1.size() % 4) throw FormatError("desk: inconsistent player tables");
|
||||
for (size_t at = 0; at < w1.size(); at += 4) players.push_back({{}, le32(w1, at), le32(w2, at), le32(w3, at)});
|
||||
std::vector<int> teams;
|
||||
for (int i = 0; i < memory.u8(::bmh::layout::ManagerCount); ++i) teams.push_back(word(manager, size_t(i) * 0xb0c + 0x290));
|
||||
for (int i = 0; i < memory.u8(::bmh::layout::ManagerCount); ++i) teams.push_back(word(manager, size_t(i) * kManagerRecordSize + 0x290));
|
||||
auto rounds = block_copy(s, ::bmh::layout::LeagueRoundCounters);
|
||||
auto d = project(memory, {manager, tactics, options, stocks, badges, s.pool(0), offsets, squads, players, morale, teams, rounds},
|
||||
exe, memory.u8(::bmh::layout::Difficulty), memory.u32(::bmh::layout::CalendarDay), memory.u16(::bmh::layout::DaysIntoSeason), int16_t(memory.u16(::bmh::layout::SeasonIndex)), revision);
|
||||
@@ -618,7 +618,7 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
}
|
||||
}
|
||||
if (d.next_opponent && *d.next_opponent >= 0) {
|
||||
const size_t manager_record = size_t(d.manager_slot) * 0xb0c;
|
||||
const size_t manager_record = size_t(d.manager_slot) * kManagerRecordSize;
|
||||
d.next_match_away = manager_record + 0x28a < g.manager_records.size() &&
|
||||
g.manager_records[manager_record + 0x28a] != 0;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ TaxDialogProjection environment_notice_dialog(const bmh::GameState& game, int ma
|
||||
std::string body) {
|
||||
if (manager < 0 || size_t(manager) >= game.manager_teams.size())
|
||||
throw FormatError("environment notice: invalid manager");
|
||||
const size_t record = size_t(manager) * 0xb0c;
|
||||
const size_t record = size_t(manager) * kManagerRecordSize;
|
||||
if (record + 0x222 >= game.manager_records.size())
|
||||
throw FormatError("environment notice: truncated manager record");
|
||||
TaxDialogProjection view;
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ const char* request_name(LineupRequestKind kind) {
|
||||
LineupState lineup_from_save(const SaveState& s,const LeImage& exe,uint64_t revision) {
|
||||
StaticMemory memory(s); auto managers=block(s,::bmh::layout::ManagerRecords);
|
||||
std::vector<int> teams;
|
||||
for(int i=0;i<memory.u8(::bmh::layout::ManagerCount);++i) teams.push_back(le16(managers,size_t(i)*0xb0c+0x290));
|
||||
for(int i=0;i<memory.u8(::bmh::layout::ManagerCount);++i) teams.push_back(le16(managers,size_t(i)*kManagerRecordSize+0x290));
|
||||
auto w1=block(s,::bmh::layout::PlayerConditionTechniqueForm),w2=block(s,::bmh::layout::PlayerSkillWords),w3=block(s,::bmh::layout::PlayerIdentityWords);
|
||||
if(w1.size()!=w2.size()||w1.size()!=w3.size()||w1.size()%4) throw FormatError("lineup: inconsistent player tables");
|
||||
std::vector<Player> players;
|
||||
|
||||
@@ -88,7 +88,7 @@ LiveMatchRow make_row(const MatchGroup& group, int match, int home, int away, co
|
||||
row.spectators = group.spectators[size_t(match)];
|
||||
row.spectators_text = original_to_utf8(format_number(state, int32_t(row.spectators), 0x81));
|
||||
const int manager = state.manager_of(home);
|
||||
const size_t capacity_at = manager >= 0 ? size_t(manager) * 0xb0c + 0x5c : state.manager_records.size();
|
||||
const size_t capacity_at = manager >= 0 ? size_t(manager) * kManagerRecordSize + 0x5c : state.manager_records.size();
|
||||
if (capacity_at < state.manager_records.size())
|
||||
row.attendance_at_capacity = state.manager_records[capacity_at] == row.spectators / 1000;
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ uint8_t source_name_color(const GameState& game, const std::map<uint32_t,uint8_t
|
||||
const int active = source_byte(game,runtime,exe,::bmh::layout::ActiveManager);
|
||||
const int current_manager = source_byte(game,runtime,exe,::bmh::layout::DeskPosition);
|
||||
for (int slot = 0; slot < count && slot < 4; ++slot) {
|
||||
const size_t record = size_t(slot) * 0xb0c;
|
||||
const size_t record = size_t(slot) * kManagerRecordSize;
|
||||
if (record + 0xa8 < game.manager_records.size() && game.manager_records[record + 0xa8] != 0 &&
|
||||
game.manager_teams[size_t(slot)] == team)
|
||||
return slot == active && current_manager < count ? 0x7a : 0x75;
|
||||
|
||||
+4
-4
@@ -69,7 +69,7 @@ PitchExtras extras(const StaticMemory& memory,const Bytes& managers,const Bytes&
|
||||
(memory.has(::bmh::layout::CoachActive)&&memory.u8(::bmh::layout::CoachActive)!=0));
|
||||
if(e.runtime_club<0||(e.runtime_club>=exe.u16(::bmh::layout::LeagueClubCount)&&!national))
|
||||
throw FormatError("pitch: unsupported club");
|
||||
const size_t m=size_t(e.manager_slot)*0xb0c,f=size_t(e.manager_slot)*0x160;
|
||||
const size_t m=size_t(e.manager_slot)*kManagerRecordSize,f=size_t(e.manager_slot)*0x160;
|
||||
if(managers.size()<m+0xb0c||formations.size()<f+0x160||
|
||||
(!national&&badges.size()<size_t(e.runtime_club+1)*2))
|
||||
throw FormatError("pitch: truncated manager/formations/badges");
|
||||
@@ -90,8 +90,8 @@ PitchExtras extras(const StaticMemory& memory,const Bytes& managers,const Bytes&
|
||||
PitchExtras pitch_extras_from_save(const SaveState& save,const LeImage& exe,uint64_t revision){
|
||||
StaticMemory memory(save);const auto managers=block(save,::bmh::layout::ManagerRecords);std::vector<int> teams;
|
||||
const int count=memory.u8(::bmh::layout::ManagerCount);
|
||||
if(count<1||count>4||managers.size()<size_t(count)*0xb0c)throw FormatError("pitch: unsupported save managers");
|
||||
for(int i=0;i<count;++i)teams.push_back(le16(managers,size_t(i)*0xb0c+0x290));
|
||||
if(count<1||count>4||managers.size()<size_t(count)*kManagerRecordSize)throw FormatError("pitch: unsupported save managers");
|
||||
for(int i=0;i<count;++i)teams.push_back(le16(managers,size_t(i)*kManagerRecordSize+0x290));
|
||||
auto e=extras(memory,managers,block(save,::bmh::layout::Formations),block(save,::bmh::layout::ClubBadgeSelectors),teams,exe,revision);
|
||||
e.source="original_save_read_only";return e;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ PitchExtras pitch_extras_from_game(const GameState& game,const LeImage& exe,uint
|
||||
// The independent indoor template set uses the same per-manager stride.
|
||||
if(game.indoor){const size_t at=size_t(e.manager_slot)*0x160+0xb0;
|
||||
std::copy_n(game.formations.begin()+at,8*22,e.formations.begin());
|
||||
e.formation_mask=game.manager_records.at(size_t(e.manager_slot)*0xb0c+0x219);}
|
||||
e.formation_mask=game.manager_records.at(size_t(e.manager_slot)*kManagerRecordSize+0x219);}
|
||||
if(opponent_team>=0){
|
||||
const auto range=squad_range(opponent_team);
|
||||
if(!range.count||range.first+range.count>game.squad_slots.size())
|
||||
|
||||
@@ -118,7 +118,7 @@ PlayerCardState player_card_from_save(const SaveState& s,const LeImage& exe,int
|
||||
for(size_t at=0;at<offsets.size();at+=2)names.push_back(le16(offsets,at));
|
||||
auto out=project(lineup_from_save(s,exe,revision),exe,row,block(s,::bmh::layout::ClubBadgeSelectors),names,s.pool(0),block(s,::bmh::layout::ClubShortNameOffsets));
|
||||
context(out,StaticMemory(s),block(s,::bmh::layout::ClubBadgeSelectors),names,s.pool(0),block(s,::bmh::layout::ClubShortNameOffsets));
|
||||
out.statistics=PlayerStatisticsContext{s.data(::bmh::layout::ManagerRecords)[size_t(out.lineup.manager_slot)*0xb0c+0x286],
|
||||
out.statistics=PlayerStatisticsContext{s.data(::bmh::layout::ManagerRecords)[size_t(out.lineup.manager_slot)*kManagerRecordSize+0x286],
|
||||
s.data(::bmh::layout::Flags)[size_t(out.lineup.manager_slot)*3+2]};
|
||||
validate(out);
|
||||
// layout field checks available heap; the Linux renderer has enough memory and
|
||||
@@ -130,7 +130,7 @@ PlayerCardState player_card_from_game(const GameState& g,const LeImage& exe,int
|
||||
for(int club=0;club<exe.u16(::bmh::layout::CareerSession_DataDirectory_RuntimeField2);++club)short_names.push_back(g.memory.u8(::bmh::layout::ClubShortNameOffsets+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;
|
||||
const size_t months=size_t(out.lineup.manager_slot)*kManagerRecordSize+0x286;
|
||||
const uint32_t flags=::bmh::layout::Flags+uint32_t(out.lineup.manager_slot)*3+2;
|
||||
if(months<g.manager_records.size() && g.memory.has(flags))
|
||||
out.statistics=PlayerStatisticsContext{g.manager_records[months],g.memory.u8(flags)};
|
||||
|
||||
+2
-2
@@ -318,7 +318,7 @@ StadiumState stadium_from_game(const GameState& game, const LeImage& exe, uint64
|
||||
int construction_percent) {
|
||||
const int manager = int(game.memory.u8(::bmh::layout::ActiveManager));
|
||||
// Each manager has a fixed 0xb0c-byte record in manager_records; all record offsets below are relative to it.
|
||||
const size_t record = size_t(manager) * 0xb0c;
|
||||
const size_t record = size_t(manager) * kManagerRecordSize;
|
||||
if (size_t(manager) >= game.manager_teams.size() || record + 0x5d > game.manager_records.size())
|
||||
throw FormatError("stadium: invalid active manager or truncated record");
|
||||
StadiumState state;
|
||||
@@ -413,7 +413,7 @@ StadiumDataProjection stadium_data_from_game(const GameState& game, const LeImag
|
||||
if (manager < 0 || manager > 4) throw FormatError("stadium data: invalid manager");
|
||||
StadiumDataProjection out;
|
||||
out.flags = flags;
|
||||
const size_t at = size_t(manager) * 0xb0c;
|
||||
const size_t at = size_t(manager) * kManagerRecordSize;
|
||||
const auto& r = game.manager_records;
|
||||
out.ticket_price = r.at(at + 0x26e);
|
||||
// Curves: the executable assigns each curve a history selector (0..3) whose record counter gives the
|
||||
|
||||
@@ -61,7 +61,7 @@ StatisticsRankingState statistics_rankings_from_game(const GameState& game, cons
|
||||
if (!game.memory.has(kTitles + kTitleCount * kSeasonCount * 2 - 1))
|
||||
throw FormatError("statistics rankings: save lacks the Original Titles title-holder block");
|
||||
if (manager_slot < 0 || manager_slot >= 4 ||
|
||||
size_t(manager_slot) * 0xb0c + 0x2aa + 1 >= game.manager_records.size())
|
||||
size_t(manager_slot) * kManagerRecordSize + 0x2aa + 1 >= game.manager_records.size())
|
||||
throw FormatError("statistics rankings: missing Source manager season-number field");
|
||||
if (underlay.width != 320 || underlay.height != 240)
|
||||
throw FormatError("statistics rankings: expected accepted 320x240 parent underlay");
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@ TacticsState project(const StaticMemory& memory, const Bytes& managers, const By
|
||||
const int count = memory.u8(::bmh::layout::ManagerCount), slot = memory.u8(::bmh::layout::ActiveManager);
|
||||
if (count < 1 || count > 4 || slot < 0 || slot >= count || teams.size() != size_t(count))
|
||||
throw FormatError("tactics: invalid/unsupported active manager");
|
||||
const size_t manager = size_t(slot) * 0xb0c, first = size_t(slot) * 0x840;
|
||||
const size_t manager = size_t(slot) * kManagerRecordSize, first = size_t(slot) * 0x840;
|
||||
if (managers.size() < manager + 0xb0c || board.size() < first + 0x840 ||
|
||||
options.size() < size_t(slot + 1) * 5)
|
||||
throw FormatError("tactics: truncated manager/board/options");
|
||||
@@ -76,9 +76,9 @@ TacticsState tactics_from_save(const SaveState& save, const LeImage& exe, uint64
|
||||
for (size_t i = 0; i < raw_offsets.size(); i += 2) offsets.push_back(le16(raw_offsets, i));
|
||||
std::vector<int> teams;
|
||||
const int count = memory.u8(::bmh::layout::ManagerCount);
|
||||
if (count < 1 || count > 4 || managers.size() < size_t(count) * 0xb0c)
|
||||
if (count < 1 || count > 4 || managers.size() < size_t(count) * kManagerRecordSize)
|
||||
throw FormatError("tactics: unsupported/truncated managers");
|
||||
for (int i = 0; i < count; ++i) teams.push_back(le16(managers, size_t(i) * 0xb0c + 0x290));
|
||||
for (int i = 0; i < count; ++i) teams.push_back(le16(managers, size_t(i) * kManagerRecordSize + 0x290));
|
||||
auto s = project(memory, managers, board, options, teams, save.pool(0), offsets, exe, revision);
|
||||
s.source = "original_save_read_only"; return s;
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ TotoState toto_from_game(const GameState& g, uint64_t revision) {
|
||||
TotoState s;
|
||||
const int manager = int(g.memory.u8(::bmh::layout::ActiveManager));
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size()) throw FormatError("toto: invalid active manager");
|
||||
const size_t record = size_t(manager) * 0xb0c;
|
||||
const size_t record = size_t(manager) * kManagerRecordSize;
|
||||
if (record + 0x318 > g.manager_records.size() || !g.memory.has(kCoupon + uint32_t(manager) * 0x14 + 0x13))
|
||||
throw FormatError("toto: missing coupon or manager record");
|
||||
s.manager_slot = manager; s.runtime_club = g.manager_teams.at(size_t(manager)); s.revision = revision;
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ TrainingState project(const StaticMemory& memory, const Bytes& records, const By
|
||||
if (s.runtime_club < 0 || s.runtime_club >= max16) throw FormatError("training: national/cup-only squad unsupported");
|
||||
s.squad_capacity = s.runtime_club < max24 ? 24 : 16;
|
||||
const size_t first = size_t(s.runtime_club < max24 ? s.runtime_club * 24 : s.runtime_club * 16 + max24 * 8);
|
||||
const size_t manager = size_t(s.manager_slot) * 0xb0c, board = size_t(s.manager_slot) * 0x840;
|
||||
const size_t manager = size_t(s.manager_slot) * kManagerRecordSize, board = size_t(s.manager_slot) * 0x840;
|
||||
if (records.size() < manager + 0xb0c || tactics.size() < board + size_t(s.squad_capacity) * 0x58 ||
|
||||
options.size() < size_t(s.manager_slot + 1) * 5 || squads.size() < first + size_t(s.squad_capacity))
|
||||
throw FormatError("training: truncated manager/squad tables");
|
||||
@@ -117,7 +117,7 @@ TrainingState training_from_save(const SaveState& save, const LeImage& exe, uint
|
||||
std::vector<Player> players;
|
||||
for (size_t at = 0; at < w1.size(); at += 4) players.push_back({{}, le32(w1, at), le32(w2, at), le32(w3, at)});
|
||||
std::vector<int> teams;
|
||||
for (int slot = 0; slot < memory.u8(::bmh::layout::ManagerCount); ++slot) teams.push_back(le16(records, size_t(slot) * 0xb0c + 0x290));
|
||||
for (int slot = 0; slot < memory.u8(::bmh::layout::ManagerCount); ++slot) teams.push_back(le16(records, size_t(slot) * kManagerRecordSize + 0x290));
|
||||
auto state = project(memory, records, tactics, options, teams, words(block_copy(save, ::bmh::layout::SquadSlots)), players,
|
||||
words(block_copy(save, ::bmh::layout::ClubIdentities)), save.pool(0), words(block_copy(save, ::bmh::layout::PlayerNameOffsets)), save.pool(1), exe, revision);
|
||||
state.source = "original_save_read_only"; return state;
|
||||
|
||||
Reference in new issue
Block a user