Add the base read queries for the new UI; fix ages and save limits
- ModernSession::read(request): status, leagues, table, fixtures and squad as JSON with the same club/player/league objects everywhere (docs/new_engine/ui-abfragen.md); the statistics answer through it. Further queries follow per menu once the GUI is finished. - Ages: data set 1.3 gives ages only for the 840 added players (birth dates); the 2574 original players carry the placeholder 16 and now get their age drawn as in the original (human squad 20-25) instead of all being 16. Birth dates for all players go into data 1.4. - Saves of Modern matchdays with more than six match groups (nine leagues on one day) were refused on loading; Classic keeps six. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f92be693af
commit
4639fe5a91
12 files changed
+344
-8
No files matched your search
@@ -277,10 +277,11 @@ bool new_career_players(ModernState& g, GameRandom& game, WatcomRandom& rand, Mi
|
||||
if (id == 0x0fff) continue;
|
||||
Player& p = g.players.at(size_t(id));
|
||||
const uint32_t age = uint32_t(rand.range(4, 0x10)), skills = uint32_t(rand.range(0, 0x3fff));
|
||||
// Modern (balance.md): a player of the data set keeps his age; his seven skills are drawn
|
||||
// as in the original unless the data set gives him some (data sets have none so far).
|
||||
// Modern (balance.md): a player of the data set keeps the age and the seven skills the
|
||||
// data set gives him; what it leaves at 0 is drawn as in the original (data set 1.3 has
|
||||
// ages only for the players it added, skills for nobody).
|
||||
const bool world = keeps_world_values(g, id);
|
||||
if (!world) p.w364 |= age << 21;
|
||||
if (!keeps_world_age(g, id)) p.w364 = (p.w364 & ~(0x1fu << 21)) | age << 21;
|
||||
if (!world || (p.w368 & 0x3fff) == 0) p.w368 = (p.w368 & 0xffffc000u) + skills;
|
||||
}
|
||||
for (int slot = int(pool_end_slot() + 24); slot < int(pool_end_slot() + 24) + 0x36; slot++)
|
||||
@@ -600,7 +601,7 @@ bool career_add_manager(ModernState& g, const LeImage& exe, int m, const CareerM
|
||||
for (int i = 0; i < players; i++) {
|
||||
const size_t slot = squad.first + size_t(i);
|
||||
Player& p = g.players.at(size_t(g.squad_slots.at(slot) & 0x0fff));
|
||||
if (!keeps_world_values(g, g.squad_slots.at(slot) & 0x0fff)) { // Modern: the data set's age stays
|
||||
if (!keeps_world_age(g, g.squad_slots.at(slot) & 0x0fff)) { // Modern: an age of the data set stays
|
||||
p.w364 &= ~(0x1fu << 21);
|
||||
p.w364 |= uint32_t(rand.range(4, 9)) << 21;
|
||||
}
|
||||
@@ -619,7 +620,7 @@ bool career_add_manager(ModernState& g, const LeImage& exe, int m, const CareerM
|
||||
const int id = g.squad_slots.at(slot) & 0x0fff;
|
||||
if (id == 0x0fff) continue;
|
||||
Player& p = g.players.at(size_t(id));
|
||||
if (!keeps_world_values(g, id)) { // Modern: the data set's age stays
|
||||
if (!keeps_world_age(g, id)) { // Modern: an age of the data set stays
|
||||
p.w364 &= ~(0x1fu << 21);
|
||||
p.w364 |= uint32_t(rand.range(4, 9)) << 21;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ struct ModernState : GameState {
|
||||
std::vector<TrainingCamp> training_camps;
|
||||
// The football almanac (docs/new_engine/almanach.md): every match of the career.
|
||||
Almanac almanac;
|
||||
// Players whose age the data set gives (birth date); the others carry a placeholder the
|
||||
// career start replaces as in the original. Needed only while a career starts (not saved).
|
||||
std::vector<bool> world_age_known;
|
||||
|
||||
ModernState() { season_hooks = &modern::season_hooks(); }
|
||||
// Takes over a state built by shared code (save loading, career setup).
|
||||
@@ -66,4 +69,9 @@ inline bool keeps_world_values(const ModernState& g, int player) {
|
||||
!g.world_player_id[size_t(player)].starts_with("player:gen-");
|
||||
}
|
||||
|
||||
// A player of the data set whose age it gives (balance.md).
|
||||
inline bool keeps_world_age(const ModernState& g, int player) {
|
||||
return keeps_world_values(g, player) && size_t(player) < g.world_age_known.size() && g.world_age_known[size_t(player)];
|
||||
}
|
||||
|
||||
} // namespace bmh::modern
|
||||
Reference in new issue
Block a user