Fix #9877: GS could trigger 'Cost: 0' cost message (#9878)

pull/390/head
Charles Pigott 2 years ago committed by GitHub
parent 142321da79
commit 146827c458
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -262,7 +262,7 @@ void CommandHelperBase::InternalPostResult(const CommandCost &res, TileIndex til
}
} else if (estimate_only) {
ShowEstimatedCostOrIncome(res.GetCost(), x, y);
} else if (!only_sending && res.GetCost() != 0 && tile != 0 && IsLocalCompany() && _game_mode != GM_EDITOR) {
} else if (!only_sending && tile != 0 && IsLocalCompany() && _game_mode != GM_EDITOR) {
/* Only show the cost animation when we did actually
* execute the command, i.e. we're not sending it to
* the server, when it has cost the local company

@ -1188,7 +1188,7 @@ CargoPayment::~CargoPayment()
if (this->visual_transfer != 0) {
ShowFeederIncomeAnimation(this->front->x_pos, this->front->y_pos,
this->front->z_pos, this->visual_transfer, -this->visual_profit);
} else if (this->visual_profit != 0) {
} else {
ShowCostOrIncomeAnimation(this->front->x_pos, this->front->y_pos,
this->front->z_pos, -this->visual_profit);
}

@ -565,7 +565,7 @@ void ShowEstimatedCostOrIncome(Money cost, int x, int y)
}
/**
* Display animated income or costs on the map.
* Display animated income or costs on the map. Does nothing if cost is zero.
* @param x World X position of the animation location.
* @param y World Y position of the animation location.
* @param z World Z position of the animation location.
@ -573,6 +573,9 @@ void ShowEstimatedCostOrIncome(Money cost, int x, int y)
*/
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
{
if (cost == 0) {
return;
}
Point pt = RemapCoords(x, y, z);
StringID msg = STR_INCOME_FLOAT_COST;

@ -1060,7 +1060,7 @@ void CallVehicleTicks()
if (!IsLocalCompany()) continue;
if (res.Succeeded() && res.GetCost() != 0) {
if (res.Succeeded()) {
ShowCostOrIncomeAnimation(x, y, z, res.GetCost());
continue;
}

Loading…
Cancel
Save