mirror of https://github.com/OpenTTD/OpenTTD.git
Change: Allow to configure AI slots above max_no_competitors (#11961)
This commit is contained in:
parent
fe4494ec11
commit
27a920c4a8
|
@ -149,20 +149,14 @@ struct AIConfigWindow : public Window {
|
||||||
/**
|
/**
|
||||||
* Can the AI config in the given company slot be edited?
|
* Can the AI config in the given company slot be edited?
|
||||||
* @param slot The slot to query.
|
* @param slot The slot to query.
|
||||||
* @return True if and only if the given AI Config slot can e edited.
|
* @return True if and only if the given AI Config slot can be edited.
|
||||||
*/
|
*/
|
||||||
static bool IsEditable(CompanyID slot)
|
static bool IsEditable(CompanyID slot)
|
||||||
{
|
{
|
||||||
if (_game_mode != GM_NORMAL) {
|
if (_game_mode != GM_NORMAL) {
|
||||||
return slot > 0 && slot <= GetGameSettings().difficulty.max_no_competitors;
|
return slot > 0 && slot < MAX_COMPANIES;
|
||||||
}
|
}
|
||||||
if (Company::IsValidID(slot)) return false;
|
return slot < MAX_COMPANIES && !Company::IsValidID(slot);
|
||||||
|
|
||||||
int max_slot = GetGameSettings().difficulty.max_no_competitors;
|
|
||||||
for (CompanyID cid = COMPANY_FIRST; cid < (CompanyID)max_slot && cid < MAX_COMPANIES; cid++) {
|
|
||||||
if (Company::IsValidHumanID(cid)) max_slot++;
|
|
||||||
}
|
|
||||||
return slot < max_slot;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawWidget(const Rect &r, WidgetID widget) const override
|
void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||||
|
@ -186,7 +180,14 @@ struct AIConfigWindow : public Window {
|
||||||
if (this->selected_slot == i) {
|
if (this->selected_slot == i) {
|
||||||
tc = TC_WHITE;
|
tc = TC_WHITE;
|
||||||
} else if (IsEditable((CompanyID)i)) {
|
} else if (IsEditable((CompanyID)i)) {
|
||||||
tc = TC_ORANGE;
|
int max_slot = GetGameSettings().difficulty.max_no_competitors;
|
||||||
|
for (const Company *c : Company::Iterate()) {
|
||||||
|
if (c->is_ai) max_slot--;
|
||||||
|
}
|
||||||
|
for (CompanyID cid = COMPANY_FIRST; cid < (CompanyID)max_slot && cid < MAX_COMPANIES; cid++) {
|
||||||
|
if (Company::IsValidHumanID(cid)) max_slot++;
|
||||||
|
}
|
||||||
|
if (i < max_slot) tc = TC_ORANGE;
|
||||||
} else if (Company::IsValidAiID(i)) {
|
} else if (Company::IsValidAiID(i)) {
|
||||||
tc = TC_GREEN;
|
tc = TC_GREEN;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue