From 96d52202fc04600446f04b5d47f5896b18ec2a22 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 14:21:10 +0100 Subject: [PATCH] Economy, weekly processing and side ratings follow Diamond 3.7 Credit limit 8 million, fee base 10000 per 10000 of value, DFB fee 150 %, championship bonus 700000, club-popularity premiums 400000/850000/1000000/850000, periphery prices, advertising base 0x87, start capital step 3 million, the broke limit -4 million, the training-injury chance, retirement after an injury of more than 20 matchdays (1 in 40), the contract-talk limit and the side rhythm (human: no balance term, computers: at least 48). Values read from the 3.7 programme; the earlier build the engine was derived from used other numbers. Co-Authored-By: Claude Sonnet 5.5 --- src/game/bank_credit.cpp | 4 ++-- src/game/career.cpp | 4 ++-- src/game/desk_actions.cpp | 12 ++++++------ src/game/match.cpp | 9 +++++---- src/game/season.cpp | 8 ++++---- src/game/weekly.cpp | 23 ++++++++++++++--------- 6 files changed, 33 insertions(+), 27 deletions(-) diff --git a/src/game/bank_credit.cpp b/src/game/bank_credit.cpp index 12f0679..acb1d92 100644 --- a/src/game/bank_credit.cpp +++ b/src/game/bank_credit.cpp @@ -234,7 +234,7 @@ BankCreditBounds bank_credit_bounds(const BankCreditContext& c, const BankCredit int32_t lo = 0, hi = 0; if (field == 0) { lo = 1000; - hi = sub(12000000, accrued); + hi = sub(8000000, accrued); // Diamond 3.7: credit limit 8 million (12 million before) // case 5: no more than the lender can pay out (balance + credit line) if (c.counterparty && c.lender_liquidity < hi) hi = sub(c.lender_liquidity, accrued); } @@ -256,7 +256,7 @@ BankCreditBounds bank_credit_bounds(const BankCreditContext& c, const BankCredit if (field == 6) { hi = liquidity < accrued ? liquidity : signed_word(v[0]); } // Source checks availability before overriding the principal bounds. if (lo >= hi) return {}; - if (field == 0 && lo < signed_word(c.saved[0])) { lo = signed_word(c.saved[0]); hi = 12000000; } + if (field == 0 && lo < signed_word(c.saved[0])) { lo = signed_word(c.saved[0]); hi = 8000000; } if (lo < 0 || hi < 0 || lo >= hi) return {}; return {word(lo), word(hi), word(lo - (lo == 1)), true}; } catch (const std::invalid_argument&) { return {}; } diff --git a/src/game/career.cpp b/src/game/career.cpp index e3831d1..c6d11b6 100644 --- a/src/game/career.cpp +++ b/src/game/career.cpp @@ -410,7 +410,7 @@ void starting_sponsors(GameState& g, int m) { const size_t rec = size_t(m) * kRecord; int league = g.manager_records.at(rec + 0x210); if (league > 2) league--; - const int v = (((league * -20 + 80) * 60000 + 1000000) / 12 * (mem.u8(::bmh::layout::Difficulty) * -5 + 0xaa)) / 3000000 * 10000; + const int v = (((league * -20 + 80) * 60000 + 1000000) / 12 * (mem.u8(::bmh::layout::Difficulty) * -5 + 0x7d)) / 3000000 * 10000; for (size_t o : {size_t(0xae8), size_t(0xadc), size_t(0xa34)}) put32(g.manager_records, rec + o, uint32_t(v)); for (size_t o : {size_t(0xaed), size_t(0xae1), size_t(0xa39)}) g.manager_records.at(rec + o) = 1; } @@ -567,7 +567,7 @@ bool career_add_manager(GameState& g, const LeImage& exe, int m, const CareerMan } for (size_t i = 0; i < 0x690; i++) g.manager_results.at(size_t(m) * 0x690 + i) = 0xff; const uint8_t level = mem.u8(::bmh::layout::Difficulty); - const uint32_t money = level == 0 ? 50000000u : 4000000u - level * 200000u; + const uint32_t money = level == 0 ? 50000000u : 3000000u - level * 200000u; // Diamond 3.7: 3 million start capital step base (4 million before) put32(r, rec + 0x314, money); put32(r, rec + 0x324, money); r.at(rec + 0x219) = r.at(rec + 0x218) = 0xf; diff --git a/src/game/desk_actions.cpp b/src/game/desk_actions.cpp index 90ad913..c839b98 100644 --- a/src/game/desk_actions.cpp +++ b/src/game/desk_actions.cpp @@ -619,7 +619,7 @@ TransferActionResult submit_transfer_bid_impl(GameState& g, const TransferBidReq out.status = TransferActionStatus::blocked_by_board; return out; } - const uint32_t fee_base = (g.memory.u32(entry + 0x2c) / 10000) * 0x30d4; + const uint32_t fee_base = (g.memory.u32(entry + 0x2c) / 10000) * 10000; // Diamond 3.7: base 10000 per 10000 of value (12500 before) const uint32_t salary_base = ((uint32_t((request.contract_years - 1) * 20 + 100) * g.memory.u32(entry + 0x30)) / 10000) * 100; if (fee_base == 0 || salary_base == 0) { out.status = TransferActionStatus::offer_too_low; @@ -941,11 +941,11 @@ TransferActionResult submit_transfer_bid_source_impl(GameState& g, const Transfe bool dfb_fee = false; if (uint32_t(rand.range(92, request.poach ? 98 : 150)) >= fee_pct) { if (request.poach) { - // The club refuses; as the player agreed, the DFB sets the fee to 188 % of his - // market value (AddToSquad with 0xbc) and the buyer may pay it (PresentManagerDialog). + // The club refuses; as the player agreed, the DFB sets the fee to 150 % of his + // market value (AddToSquad with 0x96, Diamond 3.7; 188 % = 0xbc before) and the buyer may pay it (PresentManagerDialog). uint32_t fee = 0, salary = 0; const bool loan = (g.memory.u8(list + 0x34 + uint32_t(bid_slot)) & 0x80) != 0; - market_value(g, request.source_slot, loan ? 1 : 0, 0xbc, fee, salary, 1, 0, rand); + market_value(g, request.source_slot, loan ? 1 : 0, 0x96, fee, salary, 1, 0, rand); g.memory.set32(list + 0x1c + uint32_t(bid_slot) * 4, fee); const std::string question = message_text(g, ::bmh::layout::DeskActions_Unsupported_TextPointer4) + format_amount(g, std::bit_cast(fee)) + message_text(g, ::bmh::layout::DeskActions_Unsupported_TextPointer5); @@ -1234,7 +1234,7 @@ void editor_project(const GameState& g,TransferOfferEditorState& state) { } else {state.years=1;state.term=0;state.fee=0;state.salary=0;state.bonuses.fill(0);} // RateTransferBidSource: explicit byte years and Source32 unsigned products. const uint8_t year_index=state.editable?uint8_t((int(state.term&127)-1)/12):uint8_t(1); - state.asking_fee=(g.memory.u32(list+0x2c)/10000u)*12500u; + state.asking_fee=(g.memory.u32(list+0x2c)/10000u)*10000u; if(state.editable&&(state.term&128))state.asking_fee>>=2; state.asking_salary=((uint32_t(year_index)*20u+100u)*g.memory.u32(list+0x30)/10000u)*100u; state.money_profiles[0]=editor_profile(0,state.asking_fee*2u|0x40000000u,0xffffffffu,10000,0,state.asking_fee,::bmh::layout::DeskActions_EditorProject_RuntimeField); @@ -1600,7 +1600,7 @@ namespace bmh { namespace { // StadiumPriceTable: base price of the 14 periphery objects. -constexpr int32_t kPeripheryPrice[14] = {2500000, 1700000, 2200000, 1000000, 1100000, 1500000, 280000, +constexpr int32_t kPeripheryPrice[14] = {2200000, 1700000, 2000000, 1000000, 1100000, 1800000, 280000, 280000, 280000, 280000, 350000, 350000, 350000, 350000}; // CareerSession_DispatchStadium_RuntimeField2[object * 5]: construction time in days. constexpr uint8_t kPeripheryDays[14] = {45, 30, 28, 40, 30, 20, 6, 6, 6, 6, 5, 5, 5, 5}; diff --git a/src/game/match.cpp b/src/game/match.cpp index 923ccf0..fdd25d4 100644 --- a/src/game/match.cpp +++ b/src/game/match.cpp @@ -136,12 +136,13 @@ void rate_side(GameState& g, const MatchSetup& m, int side, int previous6, Watco // (the original lets two cheat codes, CareerSession_FormatError_RuntimeField9, set a human side's six ratings to // fixed values; not ported) if (manager < 0) { - int rhythm = r[6] >> 1; // computer teams: half the balance, at least 50 - r[7] = uint8_t(rhythm < 50 ? 50 : rhythm); + int rhythm = r[6] >> 1; // computer teams: half the balance, at least 48 + r[7] = uint8_t(rhythm < 48 ? 48 : rhythm); // Diamond 3.7: at least 48 (50 before) } else { - // human teams: record +0xd9 (signed) * 5 plus the balance, scaled to 0-100 + // 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)); - r[7] = uint8_t((d9 * 5 + r[6]) * 100 / 0xFF); + r[7] = uint8_t((d9 * 5 + 110) * 100 / 0xFF); } } diff --git a/src/game/season.cpp b/src/game/season.cpp index 44d4645..4a3342d 100644 --- a/src/game/season.cpp +++ b/src/game/season.cpp @@ -469,13 +469,13 @@ int club_popularity(GameState& g, int m, int team, bool pay) { static const uint8_t kKind[4] = {0, 1, 3, 2}; // SeasonRuntimeField11 static const uint8_t kEntry[4] = {0x00, 0x0f, 0x13, 0x15}; // SeasonRuntimeField12 static const uint8_t kPlus[4] = {0x14, 0x1e, 0x14, 0x0f}; // SeasonRuntimeField13 - static const int32_t kPremium[4] = {500000, 1500000, 2500000, 1500000}; // SeasonRuntimeField14 + static const int32_t kPremium[4] = {400000, 850000, 1000000, 850000}; // SeasonRuntimeField14 int8_t p = int8_t(kKind[en.find(team)] * 10 + 10); if (team == mem.u16(::bmh::layout::Cup_AdvanceCup_RuntimeField6)) { if (pay) { post_composed(g, m, kChampionshipBonusText); // ChampionshipBonusText book_money(g, m, -700000, true); - set_rec32(g, m, 0x874, rec32(g, m, 0x874) + 1000000); + set_rec32(g, m, 0x874, rec32(g, m, 0x874) + 700000); } p = int8_t(p + 10); } @@ -529,7 +529,7 @@ void season_event(GameState& g, int m, GameRandom& game, WatcomRandom& rand, Min // Int64T: bankrupt, or out of credit const uint8_t cut = rec8(g, m, 0x220); const int32_t total = int32_t(rec8(g, m, 0x26f)) * 80000 + (assets(g, m, 0xf) - assets(g, m, 0x10)); - if (total < -6000000 || ((cut >> 5) == 2 && int32_t(cut & 0x1f) * 100000 <= rec32(g, m, 0x330))) return; + if (total < -4000000 || ((cut >> 5) == 2 && int32_t(cut & 0x1f) * 100000 <= rec32(g, m, 0x330))) return; if (g.memory.u8(::bmh::layout::GameMode) < 3) set_rec32(g, m, 0x320, rec32(g, m, 0x314) - rec32(g, m, 0x324)); bool poor = false; int32_t w = worth; @@ -1358,7 +1358,7 @@ void licence_withdrawals(GameState& g, int league, std::vector& down, if (kDownPlaces[league] == 0) continue; const uint8_t cut = rec8(g, int(m), 0x220); const int32_t total = int32_t(rec8(g, int(m), 0x26f)) * 80000 + (assets(g, int(m), 0xf) - assets(g, int(m), 0x10)); - const bool broke = total < -6000000 || ((cut >> 5) == 2 && int32_t(cut & 0x1f) * 100000 <= rec32(g, int(m), 0x330)); + const bool broke = total < -4000000 || ((cut >> 5) == 2 && int32_t(cut & 0x1f) * 100000 <= rec32(g, int(m), 0x330)); if (broke && rec8(g, int(m), 0x210) == 0x1e) { rec8(g, int(m), 0x210) = 0; post_text(g, int(m), text_id(::bmh::layout::Season_LicenceWithdrawals_TextPointer)); diff --git a/src/game/weekly.cpp b/src/game/weekly.cpp index 3561a0c..7e3c18f 100644 --- a/src/game/weekly.cpp +++ b/src/game/weekly.cpp @@ -75,7 +75,7 @@ constexpr int8_t kWantedBig[4] = {2, 6, 7, 5}, kWantedSmall[4] = {2, 4, 5, 4}; constexpr int8_t kEuropeBonus[4] = {0, 1, 3, 2}; constexpr uint8_t kWinnerEntry[4] = {0x00, 0x0f, 0x13, 0x15}; constexpr int8_t kWinnerBonus[4] = {0x14, 0x1e, 0x14, 0x0f}; -constexpr int32_t kWinnerPremium[4] = {500000, 1500000, 2500000, 1500000}; +constexpr int32_t kWinnerPremium[4] = {400000, 850000, 1000000, 850000}; // Diamond 3.7 (500000, 1500000, 2500000, 1500000 before) // Statistics: value of the facilities (BalancePlanRuntimeField5, u16 per facility). constexpr uint16_t kFacilityValue[22] = {2000, 3000, 3000, 8000, 4000, 3000, 2500, 2500, 2500, 2500, 2600, 2600, 2600, 2600, 13000, 9000, 9000, 8000, 1000, 1500, 1500, 2000}; @@ -529,7 +529,7 @@ void advertising_offers(GameState& g, int manager, WatcomRandom& rand, MinuteRep if (int16_t(score) < 0) score = 0; score = int16_t(score) * 100 / 0x78; int base = (int16_t(score) * 60000 + 1000000) / 0xc; - base = ((0xb4 - g.level * 5) * base) / 100; + base = ((0x87 - g.level * 5) * base) / 100; // Diamond 3.7: 0x87 (0xb4 before) for (int kind = 0; kind < 3; kind++) for (int k = 0; k < 10; k++) { const size_t o = 0x8cc + size_t(kind) * 0x78 + size_t(k) * 0xc; @@ -721,7 +721,7 @@ void transfer_bid(GameState& g, int slot, uint32_t list, bool high, int months, } // RateTransferBidSource: fee and salary bases of the offer const uint8_t term = mem.u8(list + 0x34 + uint32_t(free_bid)); - uint32_t fee_base = (mem.u32(list + 0x2c) / 10000) * 0x30d4; + uint32_t fee_base = (mem.u32(list + 0x2c) / 10000) * 10000; // Diamond 3.7: base 10000 per 10000 of value (12500 before) if (term & 0x80) fee_base >>= 2; const int years = ((term & 0x7F) - 1) / 0xc; const uint32_t salary_base = ((uint32_t(years * 0x14 + 100) * mem.u32(list + 0x30)) / 10000) * 100; @@ -741,7 +741,7 @@ void transfer_bid(GameState& g, int slot, uint32_t list, bool high, int months, namespace { // RateTransferBidSource: fee and salary bases of bid `bid` of a list entry (-1: none, a one-year -// term): the fee base is the market value / 10000 * 12500 (a quarter for a loan), the +// term): the fee base is the market value / 10000 * 10000 (a quarter for a loan), the // salary base the salary * (100 + 20 per extra contract year) / 100. void offer_bases(const StaticMemory& mem, uint32_t list, int bid, uint32_t& fee_base, uint32_t& salary_base) { bool loan = false; @@ -751,7 +751,7 @@ void offer_bases(const StaticMemory& mem, uint32_t list, int bid, uint32_t& fee_ loan = (term & 0x80) != 0; years = uint8_t(((term & 0x7F) - 1) / 0xc); } - fee_base = (mem.u32(list + 0x2c) / 10000) * 0x30d4; + fee_base = (mem.u32(list + 0x2c) / 10000) * 10000; // Diamond 3.7: base 10000 per 10000 of value (12500 before) if (loan) fee_base >>= 2; salary_base = ((uint32_t(years * 0x14 + 100) * mem.u32(list + 0x30)) / 10000) * 100; } @@ -2826,7 +2826,10 @@ void weekly_processing(GameState& g, GameRandom& game, WatcomRandom& rand, Minut const uint32_t out = p.w35c >> 27; const uint32_t w364 = p.w364; int injury = int((w364 >> 16) & 0x1F); - if (!quiet && game.range(0, 0xb4 - g.level * 2) == 0 && injury == 0 && out == 0) { + // Diamond 3.7: the chance of a training injury is 1 in (144 - (3 * level + 3) / 5 - level + 1), at least 1 in 1 + // (an older build used 1 in (180 - 2 * level + 1)). + const int training_injury_range = std::max(0, 0x90 - (g.level * 3 + 3) / 5 - g.level); + if (!quiet && game.range(0, training_injury_range) == 0 && injury == 0 && out == 0) { if (slot >= 0x870 && rand.range(0, 1) == 0) continue; int type = rand.range(0, 0x1e); const int team = slot_team(int(slot)); @@ -2840,8 +2843,10 @@ void weekly_processing(GameState& g, GameRandom& game, WatcomRandom& rand, Minut } continue; } - if (out == 0 || out == 0x1F) continue; - if (injury > 0x18 && rand.range(0, 0x25) == 0) { + // Diamond 3.7: only a player who is already retired (both the injury type and the duration are 0x1f) is skipped; + // a long injury (more than 20 matchdays) ends a career with 1 in 40 (an older build: more than 24, 1 in 38). + if (out == 0 || (out == 0x1F && injury == 0x1F)) continue; + if (injury > 0x14 && rand.range(0, 0x27) == 0) { // the career is over p.w35c = (p.w35c & 0x07FFFFFFu) | 0xF8000000u; p.w364 |= 0x1Fu << 16; @@ -2905,7 +2910,7 @@ void weekly_processing(GameState& g, GameRandom& game, WatcomRandom& rand, Minut book_money(g, m, -int32_t(pay), true); } const uint8_t mood = g.tactics.at(at + 0xc); - if (mood % 0xc <= 7 && !(g.tactics.at(at + 0xb) & 0x20) && mood % 0xc != 0 && mood <= 0xf && + if (mood % 0xc <= 7 && !(g.tactics.at(at + 0xb) & 0x20) && mood % 0xc != 0 && mood <= 0x12 && !(g.tactics.at(at + 0x4f) & 0x80) && !quiet) { const int16_t rating = int16_t(rec.i16(0x8aa) + (rec.i16(0x8ac) >> 2)); if (rand.range(0, 500 - (rating - 0x2a8) / 2) == 0) {