mirror of https://github.com/OpenTTD/OpenTTD
(svn r17473) -Codechange: use the post destructor for destroying companies too instead of complicating the graph GUI invalidate code.
parent
535f71fc13
commit
472ed0dc76
|
@ -103,6 +103,8 @@ struct Company : CompanyPool::PoolItem<&_company_pool> {
|
||||||
{
|
{
|
||||||
return !Company::Get(index)->is_ai;
|
return !Company::Get(index)->is_ai;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PostDestructor(size_t index);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FOR_ALL_COMPANIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Company, company_index, var, start)
|
#define FOR_ALL_COMPANIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Company, company_index, var, start)
|
||||||
|
|
|
@ -69,8 +69,16 @@ Company::~Company()
|
||||||
if (CleaningPool()) return;
|
if (CleaningPool()) return;
|
||||||
|
|
||||||
DeleteCompanyWindows(this->index);
|
DeleteCompanyWindows(this->index);
|
||||||
InvalidateWindowData(WC_GRAPH_LEGEND, 0, this->index);
|
}
|
||||||
InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, this->index);
|
|
||||||
|
/**
|
||||||
|
* Invalidating some stuff after removing item from the pool.
|
||||||
|
* @param index index of deleted item
|
||||||
|
*/
|
||||||
|
void Company::PostDestructor(size_t index)
|
||||||
|
{
|
||||||
|
InvalidateWindowData(WC_GRAPH_LEGEND, 0, index);
|
||||||
|
InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1198,11 +1198,11 @@ struct PerformanceRatingDetailWindow : Window {
|
||||||
{
|
{
|
||||||
/* Disable the companies who are not active */
|
/* Disable the companies who are not active */
|
||||||
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
|
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
|
||||||
this->SetWidgetDisabledState(i + PRW_COMPANY_FIRST, !Company::IsValidID(i) || i == data);
|
this->SetWidgetDisabledState(i + PRW_COMPANY_FIRST, !Company::IsValidID(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the currently selected company is still active. */
|
/* Check if the currently selected company is still active. */
|
||||||
if (this->company == data || (this->company != INVALID_COMPANY && !Company::IsValidID(this->company))) {
|
if (this->company != INVALID_COMPANY && !Company::IsValidID(this->company)) {
|
||||||
/* Raise the widget for the previous selection. */
|
/* Raise the widget for the previous selection. */
|
||||||
this->RaiseWidget(this->company + PRW_COMPANY_FIRST);
|
this->RaiseWidget(this->company + PRW_COMPANY_FIRST);
|
||||||
this->company = INVALID_COMPANY;
|
this->company = INVALID_COMPANY;
|
||||||
|
@ -1211,7 +1211,6 @@ struct PerformanceRatingDetailWindow : Window {
|
||||||
if (this->company == INVALID_COMPANY) {
|
if (this->company == INVALID_COMPANY) {
|
||||||
const Company *c;
|
const Company *c;
|
||||||
FOR_ALL_COMPANIES(c) {
|
FOR_ALL_COMPANIES(c) {
|
||||||
if (c->index == data) continue; // Ignore to-be-removed company
|
|
||||||
this->company = c->index;
|
this->company = c->index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue