Search profile: session API and console commands (ShowSearchProfile, SuggestSearchProfile, SetSearchProfile)

CareerSession gets search_profile, suggest_search_profile and dispatch_search_profile (owner and
modal-state checks, revision only when the stored profile changed). The console replaces the
OpenSearch placeholder with three commands and documents them; with apply the matching listings
are reported with the original's "Spieler ... ist interessant!" message. search_profile_valid
separates a refused profile from a switched-off one.

Part of #79 (the dialog in the graphical client is still open)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-11-07 21:35:02 +01:00
1 parent ff4ad035a7
commit b2484350d9
8 files changed
+145 -7

No files matched your search

+8 -3
View File
@@ -45,9 +45,7 @@ SearchProfile search_profile(const GameState& g, int manager) {
return profile;
}
bool set_search_profile(GameState& g, int manager, SearchProfile profile, bool cancelled) {
if (manager < 0 || size_t(manager) >= g.manager_teams.size() ||
(size_t(manager) + 1) * kRecord > g.manager_records.size()) return false;
bool search_profile_valid(SearchProfile profile) {
profile[0] &= 0x3F; // the dialog starts from the stored profile without the "off" bit
for (size_t i = 0; i < profile.size(); ++i) {
const bool range = i >= 4 && i <= 7;
@@ -55,6 +53,13 @@ bool set_search_profile(GameState& g, int manager, SearchProfile profile, bool c
if (i >= 4 && i <= 5 && profile[i] > 24) return false; // age bar: 25 cells
if (i >= 6 && i <= 7 && profile[i] > 99) return false; // strength bar: 100 cells
}
return true;
}
bool set_search_profile(GameState& g, int manager, SearchProfile profile, bool cancelled) {
if (manager < 0 || size_t(manager) >= g.manager_teams.size() ||
(size_t(manager) + 1) * kRecord > g.manager_records.size() || !search_profile_valid(profile)) return false;
profile[0] &= 0x3F;
int sum = 0;
for (uint8_t value : profile) sum += value;
if (sum == 0 || sum == 18 || cancelled) profile[0] |= kSearchProfileOff;
+6 -1
View File
@@ -24,10 +24,15 @@ constexpr uint8_t kSearchProfileOff = 0x40;
// The stored profile of a manager slot (all zero for an invalid slot).
SearchProfile search_profile(const GameState& g, int manager);
// Whether the values can come out of the dialog: bytes 0..3 and 8..17 are switches (0 or 1, the "off" bit is
// ignored in byte 0), the age bar has 25 cells (bytes 4 and 5 are 0..24) and the strength bar 100 (bytes 6 and 7 are 0..99).
bool search_profile_valid(SearchProfile profile);
// Stores the profile the way the original dialog does when it is closed: a profile with every value 0 or
// every value 1 is switched off (bit 0x40), and so is any profile that was left by right click
// (`cancelled`). Returns whether the stored profile is active. Fails (false, nothing stored) for an
// invalid manager slot or a value above 1 where the original has only switches.
// invalid manager slot or invalid values (see search_profile_valid) - check these first to tell
// "refused" from "switched off".
bool set_search_profile(GameState& g, int manager, SearchProfile profile, bool cancelled);
// Average strengths per position class of the manager's own squad (original sub_19A38): index 0..3