Prepare Classic 1.0 edition rules and Diamond 3.7 foreign crests (by Codex)

This commit is contained in:
Codex committed 2026-10-30 15:39:56 +01:00
1 parent c293a35f56
commit 8ee062ea46
46 files changed
+296 -147

No files matched your search

+2 -1
View File
@@ -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;}
+3 -2
View File
@@ -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
View File
@@ -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);
+2 -2
View File
@@ -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;
+2 -1
View File
@@ -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
View File
@@ -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) {
+2 -2
View File
@@ -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
View File
@@ -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);
+2 -2
View File
@@ -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 {
+2 -1
View File
@@ -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);}
+2 -1
View File
@@ -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;
+2 -1
View File
@@ -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;
+2
View File
@@ -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");
}
+2 -1
View File
@@ -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;
+2 -1
View File
@@ -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;