Avoid dangling company purchase timeout when no clients connected to company

This commit is contained in:
Jonathan G Rennison
2022-09-16 16:05:17 +01:00
parent 839746d2bb
commit 175ef00985
2 changed files with 12 additions and 2 deletions

View File

@@ -2891,7 +2891,7 @@ struct BuyCompanyWindow : Window {
~BuyCompanyWindow()
{
const Company *c = Company::GetIfValid((CompanyID)this->window_number);
if (c != nullptr && HasBit(c->bankrupt_asked, this->owner)) {
if (c != nullptr && HasBit(c->bankrupt_asked, this->owner) && _current_company == this->owner) {
EnqueueDoCommandP(NewCommandContainerBasic(0, this->window_number, 0, CMD_DECLINE_BUY_COMPANY | CMD_NO_SHIFT_ESTIMATE));
}
}