Retire ageing market players without age wrap or duplicate entries (by Codex)
This commit is contained in:
1 parent
3cce6465d0
commit
6b942a2293
7 files changed
+92
-5
No files matched your search
@@ -1115,3 +1115,8 @@ file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/package-dependencies.json" CONTENT "${
|
||||
add_executable(classic_rules_unit_tests tests/classic_rules_unit_tests.cpp)
|
||||
target_link_libraries(classic_rules_unit_tests PRIVATE bmhcore)
|
||||
add_test(NAME classic_rules_unit_tests COMMAND classic_rules_unit_tests)
|
||||
|
||||
add_executable(season_player_reset_tests tests/season_player_reset_tests.cpp)
|
||||
target_link_libraries(season_player_reset_tests PRIVATE bmhcore)
|
||||
add_test(NAME season_player_reset_tests COMMAND season_player_reset_tests)
|
||||
set_tests_properties(season_player_reset_tests PROPERTIES TIMEOUT 10)
|
||||
@@ -17,6 +17,7 @@ describe deliberate changes; they are not a list of every known compatibility li
|
||||
- [src/game/match.hpp](../src/game/match.hpp): uses the enhanced injury selection and suspension rules.
|
||||
- [src/game/match_engine.cpp](../src/game/match_engine.cpp): supports designated set-piece takers, the enhanced injury tables, and the extended suspension fields.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/game/season.cpp](../src/game/season.cpp): includes transfer-market players in retirement so the five-bit age cannot wrap to 16.
|
||||
- [src/game/season.hpp](../src/game/season.hpp): retains the enhanced academy player-generation strength bands with monthly youth budgets.
|
||||
- [src/game/state.hpp](../src/game/state.hpp): retains designated set-piece selections in the supported manager-record extension.
|
||||
- [src/game/week.cpp](../src/game/week.cpp): uses the enhanced training rules: focus strength is at least five below its target, and completed skills rotate to another focus.
|
||||
|
||||
@@ -41,6 +41,7 @@ caves are evidence of the old defect, not an implementation requirement.
|
||||
|
||||
Initial source review finds corrected camp field packing and separated card
|
||||
save-back contexts already present. Their dedicated regression acceptance is
|
||||
still pending. Retirement handling still excludes transfer-market slots and
|
||||
requires correction. The complete 33-item review is tracked privately; none of
|
||||
still pending. Transfer-market retirement is now corrected and covered by a
|
||||
synthetic season-boundary regression test, including relocation uniqueness and
|
||||
unchanged club-player random draws. The complete 33-item review is tracked privately; none of
|
||||
the unreviewed entries is claimed complete.
|
||||
@@ -7,3 +7,5 @@ Reviewed backports include host filename/path handling, explicit quit confirmati
|
||||
This candidate is under compatibility validation, especially edition-dependent rules and environment behaviour. No complete platform or original-game acceptance is claimed before its recorded tests pass. Existing 0.2/editor releases remain historical; NextGen development moves to Dreierpack Manager.
|
||||
|
||||
Diamond 3.7 foreign league crests use the supplied edition's original drawing gate, database selectors and W sheets. Older editions retain their original neutral foreign-club crest.
|
||||
|
||||
Transfer-market players now enter the season-boundary retirement process, preventing the five-bit age from wrapping from 47 to 16. Relocated free agents no longer leave a duplicate in their old market slot. Young club players retain their existing random-draw count.
|
||||
+9
-3
@@ -1104,8 +1104,6 @@ bool release_player(GameState& g, int slot, GameRandom& game, WatcomRandom& rand
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// CareerSeasonSetup3: the players' new season. Records and boards of the managers restart
|
||||
// (with new advertising offers, TransferListCountdown2); then every squad and pool slot: players
|
||||
// out for their career recover now and then with a human club's good doctor, else leave;
|
||||
@@ -1234,7 +1232,9 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
|
||||
// a year older
|
||||
p.w368 &= 0xf8003fffu;
|
||||
int age = int16_t(((p.w364 >> 21) & 0x1f) + 1);
|
||||
if (s < 0xb70 && rand.range(0x10, 0x16) < age && owner == -1) {
|
||||
// OpenBMH deviates from the original: includes transfer-market
|
||||
// players in retirement so the five-bit age cannot wrap to 16.
|
||||
if (rand.range(0x10, 0x16) < age && owner == -1) {
|
||||
if (count != 0xff) count = uint8_t(squad_count(g, team, 2) + loans[team]);
|
||||
if (count > 0xd) {
|
||||
count--;
|
||||
@@ -1252,6 +1252,10 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
|
||||
if (std::getenv("BMH_TRACE"))
|
||||
std::printf(" [release slot %d player %d team %d age %u count %u]\n", s, player, team, (p.w364 >> 21) & 0x1f, count);
|
||||
if (!release_player(g, s, game, rand, report)) return;
|
||||
// Club releases compact their squad in remove_from_seller. Pool
|
||||
// releases have no club: retire this source entry explicitly after
|
||||
// the regenerated player has been placed in the free-agent pool.
|
||||
if (team < 0) g.squad_slots.at(size_t(s)) = 0x0fff;
|
||||
}
|
||||
}
|
||||
g.lineups_frozen = false;
|
||||
@@ -1262,6 +1266,8 @@ void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteRe
|
||||
std::fill(g.results.begin(), g.results.end(), uint8_t(0xcc));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// The end of the CareerSession_RuntimeError_RuntimeField4 branch of DailyInterest: histories beyond 50 seasons shift
|
||||
// (SeasonEndSteps), the managers' season record starts (ManagerOf(m, 0, -2)), the
|
||||
// limited game length counts down (CareerDuration), the days pass (DayStepRest) up to the
|
||||
|
||||
@@ -187,6 +187,10 @@ void cup_group_overview_effects(GameState& g, int group_index);
|
||||
// LeagueName: the name of a league below 5 (with its letter, e.g. for the third divisions).
|
||||
std::string league_name(const GameState& g, int league);
|
||||
|
||||
// Season boundary: reset manager boards, age/retire players and clear seasonal
|
||||
// histories. Kept separate from cup draws, accounts and calendar advancement.
|
||||
void season_players(GameState& g, GameRandom& game, WatcomRandom& rand, MinuteReport& report);
|
||||
|
||||
// MonthChange(absolute squad slot): the player leaves his club for the free agents with new
|
||||
// values (W and game draws) and an age W(4, 15); his club closes the gap (ReleasePlayer,
|
||||
// with a human club its tactics board as well). False if the source ownership/state
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
#include "game/season.hpp"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace {
|
||||
void check(bool ok, const char* message) { if (!ok) throw std::runtime_error(message); }
|
||||
bmh::GameState fixture(int slot, int age, bool foreign = false) {
|
||||
bmh::GameState g;
|
||||
constexpr uint32_t data_begin = 0xa0000;
|
||||
constexpr size_t data_size = 0x21000;
|
||||
g.memory.add_block(data_begin, data_size);
|
||||
g.squad_slots.assign(3096, 0xfff);
|
||||
g.squad_slots.at(size_t(slot)) = 0;
|
||||
g.players.resize(1);
|
||||
g.players[0].w364 = uint32_t(age - 16) << 21;
|
||||
g.players[0].w368 = foreign ? 1u << 27 : 0;
|
||||
g.player_bonus.assign(1, 0);
|
||||
g.date = 365;
|
||||
return g;
|
||||
}
|
||||
void run(bmh::GameState& g, bmh::GameRandom& game, bmh::WatcomRandom& rand) {
|
||||
bmh::MinuteReport report;
|
||||
bmh::season_players(g, game, rand, report);
|
||||
check(!report.unsupported, "season reset unexpectedly unsupported");
|
||||
check(!g.lineups_frozen, "season reset left lineups frozen");
|
||||
}
|
||||
}
|
||||
int main() try {
|
||||
for (const auto [slot, foreign] : {std::pair{2928, false}, {2971, false}, {2972, false}, {3071, true}}) {
|
||||
auto g = fixture(slot, 47, foreign);
|
||||
bmh::GameRandom game(4711); bmh::WatcomRandom rand(815);
|
||||
run(g, game, rand);
|
||||
check(g.players[0].age() >= 20 && g.players[0].age() <= 32,
|
||||
"old market player wrapped to age 16 instead of retiring/regenerating");
|
||||
check(std::count(g.squad_slots.begin(), g.squad_slots.end(), 0) == 1,
|
||||
"retired market player duplicated or lost during free-agent relocation");
|
||||
check(g.squad_slots[size_t(slot)] == 0xfff,
|
||||
"retired market player's source slot was not cleared");
|
||||
}
|
||||
{
|
||||
auto g = fixture(0, 20);
|
||||
bmh::GameRandom game(4711); bmh::WatcomRandom rand(815);
|
||||
run(g, game, rand);
|
||||
check(g.players[0].age() == 21 && g.squad_slots[0] == 0,
|
||||
"young club player changed ownership or age progression");
|
||||
check(game.calls() == 0 && rand.calls() == 1,
|
||||
"unchanged club ageing consumed additional random draws");
|
||||
}
|
||||
{
|
||||
auto g = fixture(3072, 47);
|
||||
bmh::GameRandom game(4711); bmh::WatcomRandom rand(815);
|
||||
run(g, game, rand);
|
||||
check(g.players[0].age() == 47 && g.squad_slots[3072] == 0 &&
|
||||
game.calls() == 0 && rand.calls() == 0,
|
||||
"non-seasonal extra slots entered the retirement loop");
|
||||
}
|
||||
{
|
||||
auto g = fixture(2928, 47); g.date = 0;
|
||||
bmh::GameRandom game(4711); bmh::WatcomRandom rand(815);
|
||||
run(g, game, rand);
|
||||
check(g.players[0].age() == 47 && game.calls() == 0 && rand.calls() == 0,
|
||||
"new-career setup unexpectedly aged market players");
|
||||
}
|
||||
std::cout << "Season player reset: market retirement and unchanged ageing passed\n";
|
||||
return 0;
|
||||
} catch (const std::exception& e) { std::cerr << e.what() << '\n'; return 1; }
|
||||
Reference in new issue
Block a user