Prepare Classic 1.0 edition rules and Diamond 3.7 foreign crests (by Codex)
This commit is contained in:
1 parent
c293a35f56
commit
8ee062ea46
46 files changed
+296
-147
No files matched your search
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/career_session.hpp"
|
||||
|
||||
@@ -540,6 +541,9 @@ static void install_league_sizes(const LeImage& exe) {
|
||||
kNewcomerCount = exe.u16(::bmh::layout::CareerSession_InstallLeagueSizes_RuntimeField6);
|
||||
// EXE strings the engine posts (messages.hpp)
|
||||
install_message_texts(exe);
|
||||
install_career_rules(exe);
|
||||
install_environment_rules(exe);
|
||||
install_original_badge_policy(exe);
|
||||
}
|
||||
|
||||
CareerSession::CareerSession(const std::filesystem::path& data, uint32_t watcom_seed)
|
||||
@@ -3331,7 +3335,7 @@ std::optional<CareerSession::BalanceDispatch> CareerSession::dispatch_balance_pl
|
||||
notice.manager_name.assign(reinterpret_cast<const char*>(next.state.manager_records.data()+name_at),name_end-name_at);
|
||||
notice.portrait=next.state.manager_records[record+0x221];
|
||||
const int club=next.state.manager_teams[size_t(manager)];
|
||||
notice.badge_fallback=club==0x0fff||(club>89&&club<138)||(club>167&&club<357);
|
||||
notice.badge_fallback=original_badge_fallback(club,&exe_);
|
||||
if(!notice.badge_fallback&&club>=0&&size_t(club)*2+2<=next.state.club_heap_78.size())
|
||||
notice.badge_sprite=(int(next.state.club_heap_78[size_t(club)*2])|
|
||||
int(next.state.club_heap_78[size_t(club)*2+1])<<8)&0x1ff;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "app/controller.hpp"
|
||||
#include "app/window_actions.hpp"
|
||||
@@ -56,7 +57,7 @@ ui::NationalFriendlyIdentity national_friendly_identity(const GameState& game,in
|
||||
out.manager_name.push_back(char(game.manager_records[record+0xa8+i]));
|
||||
out.portrait=game.manager_records[record+0x221];
|
||||
out.manager_slot=manager;
|
||||
out.badge_fallback=team==0x0fff||(team>89&&team<138)||(team>167&&team<357);
|
||||
out.badge_fallback=original_badge_fallback(team);
|
||||
if(!out.badge_fallback&&team>=0&&size_t(team)*2+1<game.club_heap_78.size())
|
||||
out.badge_sprite=int(game.club_heap_78[size_t(team)*2]|
|
||||
uint16_t(game.club_heap_78[size_t(team)*2+1])<<8)&0x1ff;
|
||||
|
||||
+2
-2
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/live_timing.hpp"
|
||||
// openbmh_play - the UI of src/ui connected to the engine: options, manager dialogs, a new
|
||||
@@ -684,8 +685,7 @@ int main(int argc, char** argv) {
|
||||
view.manager_name += char(state.manager_records[base + 0xa8 + i]);
|
||||
view.body = event.text;
|
||||
view.portrait = state.manager_records[base + 0x221];
|
||||
view.badge_fallback = event.team == 0x0fff || (event.team > 89 && event.team < 138) ||
|
||||
(event.team > 167 && event.team < 357);
|
||||
view.badge_fallback = original_badge_fallback(event.team);
|
||||
view.badge_sprite = view.badge_fallback ? 0 : le16(state.club_heap_78, size_t(event.team) * 2) & 0x1ff;
|
||||
ui::GameEndTaxDialog screen(data, std::move(view), game_end_options(state),
|
||||
event.kind == SeasonTaxEventKind::outcome ? season_backdrop : std::optional<Image>{});
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/le.hpp"
|
||||
|
||||
namespace bmh {
|
||||
|
||||
// Installed alongside the loaded edition's other runtime tables. Club selectors
|
||||
// remain database/savegame data; this only reproduces the original drawing gate.
|
||||
inline int original_foreign_badge_end = 138;
|
||||
|
||||
inline int original_badge_gate(const LeImage& exe) {
|
||||
constexpr auto instruction = layout::ForeignBadgeGateInstruction;
|
||||
if (exe.contains(instruction) && exe.contains(instruction + 6) &&
|
||||
exe.u8(instruction) == 0x66 && exe.u8(instruction + 1) == 0x81 &&
|
||||
exe.u8(instruction + 2) == 0xfb && exe.u8(instruction + 5) == 0x7c &&
|
||||
exe.u8(instruction + 6) == 7) {
|
||||
const int end = exe.u16(instruction + 3);
|
||||
if (end == 90 || end == 138) return end;
|
||||
}
|
||||
// Never invent individual foreign crests for an unverified drawing routine.
|
||||
return 138;
|
||||
}
|
||||
|
||||
inline void install_original_badge_policy(const LeImage& exe) {
|
||||
original_foreign_badge_end = original_badge_gate(exe);
|
||||
}
|
||||
|
||||
inline bool original_badge_fallback(int token, const LeImage* exe = nullptr) {
|
||||
const int team = token & 0xfff;
|
||||
const int end = exe ? original_badge_gate(*exe) : original_foreign_badge_end;
|
||||
return team == 0xfff || (team >= 90 && team < end) || (team >= 168 && team < 357);
|
||||
}
|
||||
|
||||
} // namespace bmh
|
||||
@@ -1976,3 +1976,13 @@ inline constexpr auto EnglishDesktopBinSourceX = 0x6e180;
|
||||
inline constexpr auto EnglishDesktopBinSourceY = 0x6e182;
|
||||
inline constexpr auto EnglishDesktopSocketSourceX = 0x6e184;
|
||||
} // namespace bmh::layout
|
||||
|
||||
namespace bmh::layout {
|
||||
inline constexpr auto EnvironmentBudgetSteps = 0xa50ff;
|
||||
inline constexpr auto EnvironmentVerifiedCodeBegin = 0x6c000;
|
||||
inline constexpr auto EnvironmentVerifiedCodeEnd = 0x6cb40;
|
||||
inline constexpr auto EnvironmentVerifiedHookBegin = 0x7af65;
|
||||
inline constexpr auto EnvironmentVerifiedHookEnd = 0x7b020;
|
||||
}
|
||||
|
||||
namespace bmh::layout { inline constexpr auto ForeignBadgeGateInstruction = 0x10070; }
|
||||
@@ -1,6 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/le.hpp"
|
||||
#include "formats/rule_base.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
@@ -43,7 +42,6 @@ LeImage load_le(const std::filesystem::path& path) {
|
||||
const uint32_t base = word(sizeof kImageMagic), size = word(sizeof kImageMagic + 4);
|
||||
if (raw.size() != sizeof kImageMagic + 8 + size_t(size)) throw FormatError("OpenBMH image: wrong size");
|
||||
LeImage img = LeImage::from_bytes(base, Bytes(raw.begin() + sizeof kImageMagic + 8, raw.end()));
|
||||
apply_rule_base(img);
|
||||
return img;
|
||||
}
|
||||
auto u8 = [&](size_t o) -> uint32_t {
|
||||
@@ -133,7 +131,6 @@ LeImage load_le(const std::filesystem::path& path) {
|
||||
}
|
||||
}
|
||||
}
|
||||
apply_rule_base(img);
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -29,7 +29,7 @@ public:
|
||||
// The string a pointer variable at `address` points to (e.g. Weekly_AdvertisingOffers_TextPointer).
|
||||
std::string string_at_pointer(uint32_t address) const { return cstring(u32(address)); }
|
||||
const uint8_t* data(uint32_t address) const { return bytes_.data() + (address - base_); }
|
||||
// Overwrites bytes inside the image (the rule base, formats/rule_base.hpp).
|
||||
// Overwrites bytes inside a prepared image for verified address translation.
|
||||
void patch(uint32_t address, const uint8_t* bytes, size_t count) {
|
||||
for (size_t i = 0; i < count; ++i) bytes_.at(address - base_ + i) = bytes[i];
|
||||
}
|
||||
@@ -51,10 +51,8 @@ private:
|
||||
Bytes bytes_;
|
||||
};
|
||||
|
||||
// OpenBMH deviates from the original: applies a shared supported rule profile when loading editions with different rule-table values.
|
||||
// Loads the original executable image without changing edition-specific rule tables.
|
||||
// Throws FormatError for files that are not LE executables or use external fixups.
|
||||
// A German BMH.EXE is loaded with the OpenBMH rule base applied (formats/rule_base.hpp):
|
||||
// every edition plays by the supported rule profile rule values.
|
||||
LeImage load_le(const std::filesystem::path& path);
|
||||
|
||||
// The OpenBMH image format: "OPENBMH-IMAGE" NUL, u32 base, u32 size, the bytes. load_le()
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "formats/rule_base.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace bmh {
|
||||
|
||||
namespace {
|
||||
|
||||
struct RuleBytes {
|
||||
uint32_t address;
|
||||
std::vector<uint8_t> bytes;
|
||||
};
|
||||
|
||||
// OpenBMH deviates from the original: normalizes live-scene defaults, league strength ranges, option defaults, stadium prices and capacities, betting limits, and the foreign-player limit across supported editions.
|
||||
// Every byte here differs in at least one German edition from supported rule profile 2026-27 and is read by
|
||||
// the engine as a rule (runtime verification exe_diff over the ten editions, minus texts, calendar,
|
||||
// season values and screen positions).
|
||||
const std::vector<RuleBytes> kRuleBase = {
|
||||
{::bmh::layout::LiveSceneOptions, {0x01, 0x01, 0x01, 0x01, 0x01, 0x01}}, // live scene options (CareerSession_DispatchLiveTactic_RuntimeField2, RerateTeam)
|
||||
// (The training camp resorts DeskActions_ConfigureTrainingCampData_RuntimeField.. - qualities and prices - are content, not rules:
|
||||
// every edition, the English one too, keeps its own resorts;
|
||||
{::bmh::layout::LeagueStrengthRanges, {0x47, 0x5d, 0x31, 0x47, 0x1c, 0x31, 0x1c, 0x31, 0x0a, 0x1c}}, // league strength ranges (LeagueStrengthRanges)
|
||||
{::bmh::layout::AdditionalLeagueStrengthRanges, {0x5f, 0x5a, 0x5f, 0x4b, 0x5f}}, // league strength ranges
|
||||
{::bmh::layout::FinalLeagueStrengthMaximum, {0x5f}}, // league strength ranges
|
||||
{::bmh::layout::RuleOptionDefaults, {0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x03, 0x02, 0x02, 0x02, 0x02, 0x03, 0x04, 0x02, 0x03, 0x02, 0x03, 0x06, 0x08, 0x06, 0x08, 0x0a, 0x0c, 0x10, 0x14, 0x18, 0x1c, 0x1e}}, // option defaults (ClubPlayerDetail_ClubPlayerDetailFromGame_RuntimeField4...)
|
||||
{::bmh::layout::StadiumPriceTable, {0xa0, 0x25, 0x26, 0x00, 0xa0, 0xf0, 0x19, 0x00, 0xc0, 0x91, 0x21, 0x00, 0x40, 0x42, 0x0f, 0x00, 0xe0, 0xc8, 0x10, 0x00, 0x60, 0xe3, 0x16, 0x00, 0xc0, 0x45, 0x04, 0x00, 0xc0, 0x45, 0x04, 0x00, 0xc0, 0x45, 0x04, 0x00, 0xc0, 0x45, 0x04, 0x00, 0x30, 0x57, 0x05, 0x00, 0x30, 0x57, 0x05, 0x00, 0x30, 0x57, 0x05, 0x00, 0x30, 0x57, 0x05, 0x00, 0xa0, 0xbb, 0x0d, 0x00, 0xb0, 0x71, 0x0b, 0x00, 0x40, 0x77, 0x1b, 0x00, 0xc0, 0x91, 0x21, 0x00, 0x30, 0x57, 0x05, 0x00, 0xc0, 0x27, 0x09, 0x00, 0x70, 0x64, 0x08, 0x00, 0x40, 0x42, 0x0f, 0x00, 0xe0, 0x93, 0x04, 0x00, 0xd8, 0xb8, 0x05, 0x00, 0xe0, 0x93, 0x04, 0x00, 0x30, 0x57, 0x05, 0x00, 0xe0, 0x93, 0x04, 0x00, 0xd8, 0xb8, 0x05, 0x00, 0xe0, 0x93, 0x04, 0x00, 0x30, 0x57, 0x05, 0x00, 0xd0, 0x07, 0xb8, 0x0b, 0xb8, 0x0b, 0x40, 0x1f, 0xa0, 0x0f, 0xb8, 0x0b}}, // stadium prices (CareerSession_DispatchStadium_RuntimeField)
|
||||
{::bmh::layout::AdditionalStadiumPrices, {0x88, 0x13, 0xc0, 0x12, 0x60, 0x09, 0x40, 0x1f}}, // stadium prices (CareerSession_DispatchStadium_RuntimeField)
|
||||
{::bmh::layout::StadiumBlockCapacities, {0x12, 0x08, 0x0e, 0x08, 0x12, 0x08, 0x0e}}, // stadium block places (CareerSession_Invalid_RuntimeField)
|
||||
{::bmh::layout::ComputerBettingLimits, {0x33, 0x20, 0x50, 0x74}}, // computer tip gaps (CareerSession_DispatchLeagueTableControl_RuntimeField)
|
||||
{::bmh::layout::ForeignPlayerLimitEnabled, {0x00}}, // substitution rule switch (ForeignPlayerLimitEnabled)
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void apply_rule_base(LeImage& exe) {
|
||||
// only the German data object has these addresses
|
||||
if (exe.base() != 0x10000 || !exe.contains(::bmh::layout::GermanDataSegmentBegin) || !exe.contains(::bmh::layout::GermanDataCompatibilityEnd)) return;
|
||||
for (const RuleBytes& r : kRuleBase) exe.patch(r.address, r.bytes.data(), r.bytes.size());
|
||||
}
|
||||
|
||||
} // namespace bmh
|
||||
@@ -1,17 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#pragma once
|
||||
// One engine uses a shared rule profile across supported editions.
|
||||
// OpenBMH deviates from the original: normalizes live-scene options, league
|
||||
// strength ranges, option defaults, stadium prices and capacities, betting limits,
|
||||
// and the foreign-player limit. Texts, currency, calendar, league structure, screen
|
||||
// positions, season values, and edition-specific resort content stay loaded from data.
|
||||
|
||||
#include "formats/le.hpp"
|
||||
|
||||
namespace bmh {
|
||||
|
||||
// Applies the shared rule profile to compatible German executable images.
|
||||
// Images without the matching data segment are left unchanged.
|
||||
void apply_rule_base(LeImage& exe);
|
||||
|
||||
} // namespace bmh
|
||||
+18
-1
@@ -20,11 +20,28 @@ constexpr int kLeagueTeams = 138; // CareerSession_DispatchLineup_RuntimeFie
|
||||
|
||||
// LeagueSizes: clubs per league; LeagueStrengthRanges: (minimum, maximum) strength per league.
|
||||
// (the clubs per league are kLeagueSizes, schedule.hpp)
|
||||
constexpr int kLeagueStrength[9][2] = {{71, 93}, {49, 71}, {28, 49}, {28, 49}, {10, 28},
|
||||
int kLeagueStrength[9][2] = {{71, 93}, {49, 71}, {28, 49}, {28, 49}, {10, 28},
|
||||
{85, 95}, {90, 95}, {75, 95}, {80, 95}};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::pair<int,int> career_strength_range(int league) {
|
||||
if (league<0 || league>=9) throw FormatError("career: invalid league range");
|
||||
return {kLeagueStrength[league][0],kLeagueStrength[league][1]};
|
||||
}
|
||||
|
||||
void install_career_rules(const LeImage& exe) {
|
||||
int next[9][2]{};
|
||||
for (int league = 0; league < 9; ++league) {
|
||||
for (int bound = 0; bound < 2; ++bound)
|
||||
next[league][bound] = exe.u8(layout::LeagueStrengthRanges + uint32_t(league * 2 + bound));
|
||||
if (next[league][0] > next[league][1] || next[league][1] > 99)
|
||||
throw FormatError("career: unsupported original league strength range");
|
||||
}
|
||||
for (int league = 0; league < 9; ++league)
|
||||
for (int bound = 0; bound < 2; ++bound) kLeagueStrength[league][bound] = next[league][bound];
|
||||
}
|
||||
|
||||
void generate_player(GameState& g, int id, int level_flags, GameRandom& game, WatcomRandom& rand) {
|
||||
Player& p = g.players.at(size_t(id));
|
||||
const bool keep_age = (level_flags & 0x1000) != 0, exact = (level_flags & 0x2000) != 0;
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
|
||||
namespace bmh {
|
||||
|
||||
// Install the nine strength ranges from the loaded edition, never a shared replacement.
|
||||
void install_career_rules(const LeImage&);
|
||||
std::pair<int,int> career_strength_range(int league);
|
||||
|
||||
// OpenBMH deviates from the original: uses the supported player-generation ranges and excludes reserved calendar positions when assigning managers.
|
||||
// GeneratePlayer with the supported rule profile patch GeneratePlayer2: new values for player `id` around
|
||||
// `level` (low 12 bits of `level_flags`; 0x1000 = leave the age at 0, 0x2000 = exactly
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
#include "game/environment.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <utility>
|
||||
|
||||
namespace bmh {
|
||||
namespace {
|
||||
bool supported_environment = true; // Synthetic state tests explicitly use the verified monthly model.
|
||||
|
||||
uint32_t youth_at(int manager) { return layout::EnvironmentYouthTeams + uint32_t(manager) * 0x24; }
|
||||
uint32_t spending_at(int manager, int item) {
|
||||
return layout::Spending + uint32_t(manager) * 0x24 + uint32_t(item) * 4;
|
||||
@@ -29,6 +32,21 @@ uint32_t academy_paid(const GameState& g, int manager) {
|
||||
uint32_t(g.manager_records.at(at + 2)) << 16 | uint32_t(g.manager_records.at(at + 3)) << 24;
|
||||
}
|
||||
}
|
||||
void install_environment_rules(const LeImage& exe) {
|
||||
for (size_t i=0;i<kEnvironmentStep.size();++i) {
|
||||
const uint32_t at=layout::EnvironmentBudgetSteps+uint32_t(i);
|
||||
if (!exe.contains(at) || exe.u8(at)==0) { supported_environment=false; return; }
|
||||
kEnvironmentStep[i]=int32_t(exe.u8(at))*1000;
|
||||
}
|
||||
uint64_t fingerprint = 14695981039346656037ull;
|
||||
for (const auto [first,last] : {std::pair{layout::EnvironmentVerifiedCodeBegin,layout::EnvironmentVerifiedCodeEnd},std::pair{layout::EnvironmentVerifiedHookBegin,layout::EnvironmentVerifiedHookEnd}}) {
|
||||
if (!exe.contains(first) || !exe.contains(last-1)) { supported_environment=false; return; }
|
||||
for (uint32_t at=first;at<last;++at) fingerprint=(fingerprint ^ exe.u8(at))*1099511628211ull;
|
||||
}
|
||||
// Fingerprints identify verified behaviour, not filenames, dates or artwork.
|
||||
supported_environment = fingerprint==0xc2488a656f340e99ull || fingerprint==0x19adba7ef3eda507ull;
|
||||
}
|
||||
bool environment_rules_supported() { return supported_environment; }
|
||||
int32_t environment_monthly_cost(const GameState& g, int manager, int item) {
|
||||
const auto value = g.memory.u32(spending_at(manager, item));
|
||||
if (item == kYouthAcademy && legacy_academy(g, manager) && academy_paid(g, manager) >= value) return 0;
|
||||
@@ -39,6 +57,7 @@ bool environment_academy_active(const GameState& g, int manager) {
|
||||
return value != 0 && (!legacy_academy(g, manager) || academy_paid(g, manager) >= value);
|
||||
}
|
||||
EnvironmentState environment_state(const GameState& g, int manager) {
|
||||
if (!supported_environment) throw FormatError("environment: this original program variant is not verified");
|
||||
validate_manager(g, manager);
|
||||
EnvironmentState result;
|
||||
for (int i = 0; i < kEnvironmentItems; ++i) {
|
||||
@@ -56,6 +75,7 @@ EnvironmentState environment_state(const GameState& g, int manager) {
|
||||
}
|
||||
EnvironmentResult set_environment(GameState& g, int manager, int item, int level, std::string* message) {
|
||||
if (message) message->clear();
|
||||
if (!supported_environment) return EnvironmentResult::invalid;
|
||||
if (manager < 0 || size_t(manager) >= g.manager_teams.size() || item < 0 || item >= kEnvironmentItems ||
|
||||
level < 0 || level > 6 || !g.memory.has(spending_at(manager, item) + 3))
|
||||
return EnvironmentResult::invalid;
|
||||
|
||||
@@ -4,14 +4,18 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include "game/random.hpp"
|
||||
#include "formats/le.hpp"
|
||||
#include "game/state.hpp"
|
||||
|
||||
namespace bmh {
|
||||
// Verified original-program capability; unknown environment variants are not guessed.
|
||||
void install_environment_rules(const LeImage&);
|
||||
bool environment_rules_supported();
|
||||
constexpr int kEnvironmentItems = 6;
|
||||
enum EnvironmentItem : int { kYouthYoungest = 0, kYouthAcademy = 1, kYouthOldest = 2,
|
||||
kCoTrainer = 3, kDoctor = 4, kPhysio = 5 };
|
||||
// OpenBMH deviates from the original: uses six monthly environment budgets across data editions while retaining the shared staff prices and academy player-generation strength bands.
|
||||
inline constexpr std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
|
||||
// Monthly environment model verified in the supported CD and Diamond 3.6/3.7 programs.
|
||||
inline std::array<int32_t, kEnvironmentItems> kEnvironmentStep = {2000, 4000, 5000, 5000, 5000, 5000};
|
||||
struct EnvironmentState {
|
||||
std::array<int32_t, kEnvironmentItems> monthly{};
|
||||
std::array<int, kEnvironmentItems> level{};
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "formats/binary.hpp"
|
||||
#include "formats/rule_base.hpp"
|
||||
#include "launch/archive.hpp"
|
||||
#include "launch/game_data.hpp"
|
||||
|
||||
@@ -120,7 +119,6 @@ LeImage translate_fltd(const fs::path& fltd_exe) {
|
||||
}
|
||||
}
|
||||
LeImage out = LeImage::from_bytes(kDeBase, std::move(image));
|
||||
apply_rule_base(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/balance_plan.hpp"
|
||||
|
||||
@@ -52,7 +53,7 @@ BalanceState balance_from_game(const GameState& g,const BalancePlanDraft& d,cons
|
||||
const int portrait=rec+0x221<g.manager_records.size()?g.manager_records[rec+0x221]:0;
|
||||
if(portrait>14)throw FormatError("balance: invalid Source manager portrait");
|
||||
const int team=g.manager_teams[size_t(d.manager)];
|
||||
const bool fallback=team==0x0fff||(team>89&&team<138)||(team>167&&team<357);
|
||||
const bool fallback=original_badge_fallback(team);
|
||||
int badge=0;if(!fallback){if(team<0||size_t(team)*2+2>g.club_heap_78.size())throw FormatError("balance: missing Source badge selector");badge=(int(g.club_heap_78[size_t(team)*2])|int(g.club_heap_78[size_t(team)*2+1])<<8)&0x1ff;}
|
||||
const uint8_t compact_dialog_frame=g.memory.has(::bmh::layout::CompactDialogFrame)?g.memory.u8(::bmh::layout::CompactDialogFrame):exe.u8(::bmh::layout::CompactDialogFrame);
|
||||
for(auto* projection:{&s.read_only_notice,&s.close_notice}){projection->portrait=portrait;projection->badge_fallback=fallback;projection->badge_sprite=badge;projection->compact_dialog_frame=compact_dialog_frame!=0;}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/club_player_detail.hpp"
|
||||
|
||||
@@ -50,7 +51,7 @@ ClubPlayerDetailProjection club_player_detail_from_game(const GameState& g,
|
||||
club.original_short_name=club.original_short_name.substr(raw>>4,(raw&15)+1);
|
||||
}
|
||||
// SourceBadgeFallback consults the selector only for real atlas clubs.
|
||||
if(id<=89||(id>=138&&id<=167)||id>=357){
|
||||
if(!original_badge_fallback(id,&exe)){
|
||||
if(size_t(id)*2+1>=g.club_heap_78.size())throw FormatError("club player detail: truncated badge table");
|
||||
club.badge_selector=le16(g.club_heap_78,size_t(id)*2)&0x1ff;
|
||||
}
|
||||
@@ -92,7 +93,7 @@ ClubPlayerDetailScreen::ClubPlayerDetailScreen(const std::filesystem::path& data
|
||||
if(atlas_.width==314){Image padded(320,atlas_.height);padded.blit(atlas_,0,0);atlas_=std::move(padded);}
|
||||
for(size_t i=0;i<2;++i)if(projection_.clubs[i]){
|
||||
auto& club=*projection_.clubs[i];const int id=club.runtime_team;
|
||||
if(id<=89||(id>=138&&id<=167)||id>=357){
|
||||
if(!original_badge_fallback(id,&exe_)){
|
||||
badges_[i]=load_vga(asset_path(data/"W",std::to_string(club.badge_selector>>3)+".VGA"));
|
||||
}
|
||||
// TextWidth national/foreign names: longest word, then remove two
|
||||
|
||||
+3
-2
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/cup_draw.hpp"
|
||||
|
||||
@@ -229,7 +230,7 @@ struct CupDrawScreen::Impl {
|
||||
copy(screen,panel,0,0,29,22,261,203);bottom=screen;drawing=screen;present=true;flush=true;}
|
||||
else {draw_overview();drawing=screen;}
|
||||
for(size_t i=0;i<p.count;++i){const int id=p.clubs[i].runtime_id,sel=p.clubs[i].badge_selector&0x1ff;
|
||||
if(!((id>=0x5a&&id<=0x89)||(id>=0xa8&&id<=0x164)||id==0xfff)){
|
||||
if(!original_badge_fallback(id,&exe)){
|
||||
const int atlas=sel>>3;if(!badges.contains(atlas))badges.emplace(atlas,load_vga(asset_path(data/"W",std::to_string(atlas)+".VGA")));
|
||||
}
|
||||
}
|
||||
@@ -255,7 +256,7 @@ struct CupDrawScreen::Impl {
|
||||
void source_badge(Image& out,const CupDrawClub& c,int x,int y) const {
|
||||
source_frame(out,x,y);
|
||||
const int id=c.runtime_id,selector=c.badge_selector&0x1ff;
|
||||
if((id>=0x5a&&id<=0x89)||(id>=0xa8&&id<=0x164)||id==0xfff)
|
||||
if(original_badge_fallback(id,&exe))
|
||||
copy(out,widgets,8,0,x,y,38,38);
|
||||
else {
|
||||
const int atlas=selector>>3;copy(out,badges.at(atlas),(selector&7)*38,0,x,y,38,38);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/desk_state.hpp"
|
||||
|
||||
@@ -600,8 +601,7 @@ DeskState desk_from_game(const GameState& g, const LeImage& exe, uint64_t revisi
|
||||
*d.next_opponent < int(g.club_ids.size())) {
|
||||
const int opponent = *d.next_opponent;
|
||||
d.next_opponent_name = g.club_name(opponent);
|
||||
const bool fallback = opponent == 0x0fff ||
|
||||
(opponent > 0x59 && (opponent < 0x8a || opponent > 0xa7) && opponent < 0x165);
|
||||
const bool fallback = original_badge_fallback(opponent,&exe);
|
||||
d.next_opponent_badge_fallback = fallback;
|
||||
if (!fallback) {
|
||||
const size_t badge_at = size_t(opponent) * 2;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/environment.hpp"
|
||||
|
||||
@@ -50,7 +51,7 @@ const char* result_name(EnvironmentRequestKind kind) {
|
||||
bool generic_badge(int club) {
|
||||
// SourceBadgeFallback gates on the runtime club ID, before looking up its W sprite.
|
||||
const unsigned team = unsigned(club) & 0xfff;
|
||||
return team == 0xfff || (team >= 90 && team <= 137) || (team >= 168 && team <= 356);
|
||||
return original_badge_fallback(int(team));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/game_end.hpp"
|
||||
|
||||
@@ -288,7 +289,7 @@ Image GameEndTaxDialog::render(std::optional<Button> pressed) const {
|
||||
}
|
||||
bool source_badge_fallback(int token) {
|
||||
const int club=token&0x0fff;
|
||||
return club==0x0fff || (club>89&&(club<138||club>167)&&club<357);
|
||||
return original_badge_fallback(club);
|
||||
}
|
||||
void draw_source_dialog(Image& out,const SourceDialogAssets& assets,const TaxDialogProjection& p,
|
||||
bool gradient,std::optional<GameEndTaxDialog::Button> pressed) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/incoming_transfer.hpp"
|
||||
#include "ui/game_end.hpp"
|
||||
@@ -80,8 +81,7 @@ int source_seller_team_token(const IncomingTransferDecisionState& state) {
|
||||
}
|
||||
|
||||
bool source_neutral_seller_token(int token) {
|
||||
return (token >= 90 && token <= 137) || token == 0x0fff ||
|
||||
(token >= 168 && token <= 356);
|
||||
return original_badge_fallback(token);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/manager.hpp"
|
||||
|
||||
@@ -262,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 > 89 && id < 138) { copy(out, widgets_, 8, 0, x, y, 38, 38); return; }
|
||||
if (id>=90 && id<original_badge_gate(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 "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/pending_offer.hpp"
|
||||
|
||||
@@ -93,8 +94,7 @@ void manager_identity(const GameState& game, int manager, TaxDialogProjection& o
|
||||
// reserves 14 for the manager-placeholder tile drawn from KB0.VGA.
|
||||
if (out.portrait > 14) throw FormatError("pending offer UI: invalid Source manager portrait");
|
||||
|
||||
out.badge_fallback = team == 0x0fff || (team > 89 && team < 138) ||
|
||||
(team > 167 && team < 357);
|
||||
out.badge_fallback = original_badge_fallback(team);
|
||||
if (out.badge_fallback) {
|
||||
out.badge_sprite = 0;
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/player_card.hpp"
|
||||
|
||||
@@ -194,7 +195,7 @@ PlayerCardScreen::PlayerCardScreen(const std::filesystem::path& data,PlayerCardS
|
||||
badge_=load_vga(asset_path(data/"W",std::to_string(state_.badge>>3)+".VGA"));
|
||||
if(state_.loan)for(size_t i=0;i<2;++i){
|
||||
const int club=i?state_.loan->borrower:state_.loan->owner;
|
||||
if(club<=89||(club>=138&&club<=167)||club>=357)
|
||||
if(!original_badge_fallback(club,&exe_))
|
||||
loan_badges_[i]=load_vga(asset_path(data/"W",std::to_string(state_.loan->badges[i]>>3)+".VGA"));
|
||||
}
|
||||
if(atlas_.width==314){Image padded(320,atlas_.height);padded.blit(atlas_,0,0);atlas_=std::move(padded);}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/season_promotion.hpp"
|
||||
|
||||
@@ -181,7 +182,7 @@ SeasonPromotionProjection season_promotion_from_game(
|
||||
rows.reserve(event.count);
|
||||
for(size_t i=0;i<event.count;++i) {
|
||||
const uint16_t id=ids[i]&0x0fff;
|
||||
const bool fallback=id==0x0fff||(id>0x59&&((id<0x8a||id>0xa7)&&id<0x165));
|
||||
const bool fallback=original_badge_fallback(id);
|
||||
uint16_t badge=0;
|
||||
if(!fallback) {
|
||||
const size_t at=size_t(id)*2;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/sportschau.hpp"
|
||||
|
||||
@@ -375,7 +376,7 @@ SportschauMatchReport::SportschauMatchReport(const std::filesystem::path& data_d
|
||||
for (size_t side = 0; side < badge_words.size(); ++side) {
|
||||
const int team = side == 0 ? fixture_.home_team : fixture_.away_team;
|
||||
if (team == 0x0fff) continue; // SourceBadgeFallback uses its generic missing-club icon.
|
||||
const bool has_source_badge = team <= 89 || (team >= 138 && team <= 167) || team >= 357;
|
||||
const bool has_source_badge = !original_badge_fallback(team);
|
||||
if (!has_source_badge) continue; // Source FormatError draws a distinct generic icon; see notes.
|
||||
if (badge_words[side] == 0xffff) throw FormatError("sportschau: missing live Source badge word");
|
||||
const unsigned atlas = (badge_words[side] & 0x01ff) >> 3;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/sprite_font.hpp"
|
||||
|
||||
@@ -20,6 +21,7 @@ std::string original_bytes(std::string_view utf8) {
|
||||
SpriteFont::SpriteFont(const std::filesystem::path& data_directory)
|
||||
: atlas_(load_vga(asset_path(data_directory / "KB", "54.VGA"))),
|
||||
exe_(load_le(asset_path(data_directory, "BMH.exe"))) {
|
||||
install_original_badge_policy(exe_);
|
||||
if (atlas_.height < 21 || atlas_.width <= 0)
|
||||
throw FormatError("sprite font: unsupported KB/54 atlas");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/team_statistics.hpp"
|
||||
|
||||
@@ -93,7 +94,7 @@ TeamStatisticsProjection team_statistics_from_game(const GameState& game, int te
|
||||
TeamStatisticsProjection out;
|
||||
out.runtime_team = team;
|
||||
out.mode = mode;
|
||||
out.source_badge_fallback = team == 0x0fff || (team >= 90 && team <= 137) || (team >= 168 && team < 0x165);
|
||||
out.source_badge_fallback = original_badge_fallback(team,&exe);
|
||||
out.badge_heap = game.club_heap_78;
|
||||
if (team != 0x165) {
|
||||
int region_team = team;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "formats/badge_policy.hpp"
|
||||
#include "formats/executable_layout.hpp"
|
||||
#include "ui/transfer_market.hpp"
|
||||
|
||||
@@ -267,7 +268,7 @@ TaxDialogProjection poach_notice_from_game(const GameState& game,const PoachStar
|
||||
out.portrait=game.manager_records[base+0x221];
|
||||
if(out.portrait>14)throw FormatError("poach notice: invalid Original portrait");
|
||||
const int team=game.manager_teams[size_t(manager)];
|
||||
out.badge_fallback=team==0x0fff || (team>89&&team<138) || (team>167&&team<357);
|
||||
out.badge_fallback=original_badge_fallback(team);
|
||||
if(!out.badge_fallback) {
|
||||
if(team<0 || size_t(team)*2+2>game.club_heap_78.size())throw FormatError("poach notice: missing badge selector");
|
||||
out.badge_sprite=(int(game.club_heap_78[size_t(team)*2])|int(game.club_heap_78[size_t(team)*2+1])<<8)&0x1ff;
|
||||
|
||||
Reference in new issue
Block a user