Modern UI contract: indoor surface and substitution pairs in the line-up read

The lineup read now passes on the prepared match context: surface
(indoor during the indoor tournament, rebuilt from the cup groups when a
save is loaded), durationMinutes and starterCount (always eleven). The
first eleven's pairs come from the board's partner byte (+0x3f) as
stored: pairs lists rows that name each other, every position carries
its partnerId. Nothing is cut or relabelled; lineup.commit keeps owner,
order and pairs (checked at the winter indoor tournament). Refs #27.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-29 14:56:15 +01:00
1 parent 50541207eb
commit 179843700a
5 files changed
+64 -7

No files matched your search

+30 -4
View File
@@ -9195,22 +9195,48 @@ cli::Json ModernSession::ui_read(const cli::Json& request, uint64_t revision) co
// the squad rows in order: the first eleven start (+0x8000), the bench (+0x4000) follows;
// the starters' places on the manager's tactics board: depth 0-19, lane 0-8
const SquadRange range = squad_range(team);
A order, rows, positions;
A order, rows, positions, pairs;
// The indoor tournament (CareerSessionRuntimeField, set while the cup stage is prepared and
// rebuilt when a save is loaded) keeps the first eleven: they play in pairs that change
// together. Board byte +0x3f holds the partner's row (0xff none); the original pitch shows
// every player with a partner in colour 3. The read passes the stored references on as they
// are; a pair is two rows that name each other.
std::vector<std::string> row_ids(range.count);
for (size_t row = 0; row < range.count; ++row) {
const int p = g_.squad_slots[range.first + row] & 0x0fff;
if (p != 0x0fff) row_ids[row] = modern::ui_player_id(g_, p);
}
const auto partner_of = [&](size_t row) -> int {
const size_t at = size_t(manager) * 0x840 + row * 0x58 + 0x3f;
if (row >= 11 || at >= g_.tactics.size()) return -1;
const size_t partner = g_.tactics[at];
return partner < 11 && partner < range.count && partner != row && !row_ids[partner].empty() ? int(partner) : -1;
};
for (size_t row = 0; row < 11 && row < range.count; ++row) {
const int partner = partner_of(row);
if (partner > int(row) && partner_of(size_t(partner)) == int(row) && !row_ids[row].empty())
pairs.push_back(O{{"rows", A{int(row), partner}}, {"playerIds", A{row_ids[row], row_ids[size_t(partner)]}}});
}
for (size_t row = 0; row < range.count; ++row) {
const uint16_t e = g_.squad_slots[range.first + row];
const int p = e & 0x0fff;
if (p == 0x0fff) continue;
const std::string id = modern::ui_player_id(g_, p);
const std::string& id = row_ids[row];
order.push_back(id);
rows.push_back(O{{"row", int(row)}, {"playerId", id},
{"role", (e & 0x8000) ? "starter" : (e & 0x4000) ? "bench" : "reserve"}});
const size_t at = size_t(manager) * 0x840 + row * 0x58;
if (row < 11 && at + 0x43 <= g_.tactics.size())
if (row < 11 && at + 0x43 <= g_.tactics.size()) {
const int partner = partner_of(row);
positions.push_back(O{{"playerId", id}, {"depth", int(int8_t(g_.tactics[at + 0x41]))},
{"lane", int(int8_t(g_.tactics[at + 0x42]))}});
{"lane", int(int8_t(g_.tactics[at + 0x42]))},
{"partnerId", partner >= 0 ? cli::Json(row_ids[size_t(partner)]) : cli::Json(nullptr)}});
}
}
return modern::ui_snapshot(g_, context, request_id,
O{{"kind", "lineup"}, {"teamId", modern::ui_team_id(g_, team)}, {"formationId", nullptr}, {"order", std::move(order)},
{"surface", g_.indoor ? "indoor" : "outdoor"}, {"durationMinutes", g_.indoor ? 40 : 90}, {"starterCount", 11},
{"pairs", std::move(pairs)},
{"rows", std::move(rows)}, {"positions", std::move(positions)}, {"depthMax", 19}, {"laneMax", 8},
{"manual", g_.manager_options.size() > size_t(manager) * 5 && g_.manager_options[size_t(manager) * 5] == 0}});
}