From a97d5cb3338883f32818cb576e4454b27c3a3e41 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 7 Sep 2022 19:42:06 +0100 Subject: [PATCH] Fix incorrect template replacement error message when chain not buildable And no specific error returned See: #419 --- src/train_cmd.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 51000ac71a..46711c8b89 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -7091,14 +7091,13 @@ CommandCost CmdTemplateReplaceVehicle(TileIndex tile, DoCommandFlag flags, uint3 } } else { CommandCost buyCost = TestBuyAllTemplateVehiclesInChain(tv, tile); - if (!buyCost.Succeeded() || !CheckCompanyHasMoney(buyCost)) { + if (!buyCost.Succeeded()) { if (leaveDepot) incoming->vehstatus &= ~VS_STOPPED; - - if (!buyCost.Succeeded() && buyCost.GetErrorMessage() != INVALID_STRING_ID) { - return buyCost; - } else { - return_cmd_error(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY); - } + if (buyCost.GetErrorMessage() == INVALID_STRING_ID) return_cmd_error(STR_ERROR_CAN_T_BUY_TRAIN); + return buyCost; + } else if (!CheckCompanyHasMoney(buyCost)) { + if (leaveDepot) incoming->vehstatus &= ~VS_STOPPED; + return_cmd_error(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY); } }