Give added players their nation index 32-61 (sixth nationality bit)

The engine's nationality is six bits: w368 bits 27-31 plus bit 7 of the
player bonus (0-63). The expansion wrote only the five low bits and
sent every nation from index 32 on (Brazil, Argentina, USA, Japan, ...)
to 31, Wales. Added players now get their index with the high bit;
nations without an original index get 63, a code no nation or national
team uses. Data set 1.4: 80 players without an original index (223
before). Data format F11 lists two duplicate nations for revision 1.5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-25 09:34:13 +01:00
1 parent 0cace5a984
commit ec1d804d08
2 files changed
+19 -4

No files matched your search

+7 -4
View File
@@ -309,8 +309,11 @@ ExpandReport expand_to_world(ModernState& g, const World& world) {
const WorldPlayer& p = *player_at[i];
const auto clamp7 = [](int v) { return uint32_t(std::clamp(v, 0, 127)); };
const auto skill = [](int v) { return uint32_t(std::clamp(v, 0, 3)); };
int nationality = 31;
if (const auto it = world.nationality.find(p.nation); it != world.nationality.end() && it->second < 32)
// The nationality is six bits: w368 bits 27-31 and bit 7 of player_bonus (+32), the
// original nations 0-61. A nation without an original index gets 63, a code no nation
// and no national team uses (the engine only compares nationalities).
int nationality = 63;
if (const auto it = world.nationality.find(p.nation); it != world.nationality.end() && it->second >= 0 && it->second < 64)
nationality = it->second;
else
++report.fallback_nationalities;
@@ -322,9 +325,9 @@ ExpandReport expand_to_world(ModernState& g, const World& world) {
Player& pl = g.players[i];
pl.w35c = clamp7(p.form) | clamp7(p.technique) << 7 | clamp7(p.condition) << 14;
pl.w368 = skill(p.teamplay) | skill(p.speed) << 2 | skill(p.shooting) << 4 | skill(p.passing) << 6 |
skill(p.tackling) << 8 | skill(p.free_kick) << 10 | skill(p.corner) << 12 | uint32_t(nationality) << 27;
skill(p.tackling) << 8 | skill(p.free_kick) << 10 | skill(p.corner) << 12 | uint32_t(nationality & 31) << 27;
pl.w364 = uint32_t(p.position & 3) | uint32_t(age - 16) << 21;
g.player_bonus[i] = uint8_t(std::clamp(p.bonus, 0, 50));
g.player_bonus[i] = uint8_t(std::clamp(p.bonus, 0, 50) | (nationality >= 32 ? 0x80 : 0));
g.player_name_offsets[i] = append_name(g.player_names, upper(legacy_encoding(p.last)));
++report.added_players;
}