Fix company selection when clicking in online players window
This commit is contained in:
@@ -75,6 +75,7 @@ This is usable for any OpenTTD servers
|
|||||||
== CHANGELOG ==
|
== CHANGELOG ==
|
||||||
|
|
||||||
*** ??? ***
|
*** ??? ***
|
||||||
|
- Fix company selection when clicking in online players window.
|
||||||
- Fix cargo selection in charts.
|
- Fix cargo selection in charts.
|
||||||
- Fix shaded trees setting UI.
|
- Fix shaded trees setting UI.
|
||||||
|
|
||||||
|
|||||||
@@ -1877,8 +1877,7 @@ public:
|
|||||||
// NOTE: needs to match company order in DrawWidget
|
// NOTE: needs to match company order in DrawWidget
|
||||||
if (button == nullptr) {
|
if (button == nullptr) {
|
||||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(widget);
|
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(widget);
|
||||||
int y = _cursor.pos.y - this->top - nwi->pos_y - 2;
|
int index = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_CL_MATRIX);
|
||||||
int index = y / this->line_height;
|
|
||||||
NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
|
NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
|
||||||
CompanyID client_playas = own_ci == nullptr ? COMPANY_SPECTATOR : own_ci->client_playas;
|
CompanyID client_playas = own_ci == nullptr ? COMPANY_SPECTATOR : own_ci->client_playas;
|
||||||
if (client_playas == COMPANY_SPECTATOR && !NetworkMaxCompaniesReached()) index--;
|
if (client_playas == COMPANY_SPECTATOR && !NetworkMaxCompaniesReached()) index--;
|
||||||
@@ -1896,6 +1895,12 @@ public:
|
|||||||
for (const Company *c : Company::Iterate()) {
|
for (const Company *c : Company::Iterate()) {
|
||||||
if (client_playas == c->index) continue;
|
if (client_playas == c->index) continue;
|
||||||
if (count_company(c->index)) break;
|
if (count_company(c->index)) break;
|
||||||
|
|
||||||
|
// Skip lines with company players
|
||||||
|
for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
|
||||||
|
if (ci->client_playas == c->index) index--;
|
||||||
|
}
|
||||||
|
if (index < 0) break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user