mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r4586) - Codechange: Recursive commands that rely on _error_message to handle success/failure can fail if a recursive call fails but doesn't set the error message, thus resulting in an old, possibly erroneous being used (see FS#130 prior to r4585). Now properly reset the global variable _error_message in these cases.
This commit is contained in:
parent
939dd7d2bf
commit
feefbbbf06
|
@ -197,7 +197,6 @@ int32 CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
_error_message = INVALID_STRING_ID;
|
|
||||||
_terraform_err_tile = 0;
|
_terraform_err_tile = 0;
|
||||||
|
|
||||||
ts.direction = direction = p2 ? 1 : -1;
|
ts.direction = direction = p2 ? 1 : -1;
|
||||||
|
|
|
@ -511,8 +511,8 @@ static int32 CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32
|
||||||
ret = DoCommand(tile, railtype, TrackdirToTrack(trackdir), flags, (mode == 0) ? CMD_BUILD_SINGLE_RAIL : CMD_REMOVE_SINGLE_RAIL);
|
ret = DoCommand(tile, railtype, TrackdirToTrack(trackdir), flags, (mode == 0) ? CMD_BUILD_SINGLE_RAIL : CMD_REMOVE_SINGLE_RAIL);
|
||||||
|
|
||||||
if (CmdFailed(ret)) {
|
if (CmdFailed(ret)) {
|
||||||
if ((_error_message != STR_1007_ALREADY_BUILT) && (mode == 0))
|
if ((_error_message != STR_1007_ALREADY_BUILT) && (mode == 0)) break;
|
||||||
break;
|
_error_message = INVALID_STRING_ID;
|
||||||
} else
|
} else
|
||||||
total_cost += ret;
|
total_cost += ret;
|
||||||
|
|
||||||
|
@ -771,6 +771,7 @@ static int32 CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint3
|
||||||
* This includes vehicles on track, competitor's tracks, etc. */
|
* This includes vehicles on track, competitor's tracks, etc. */
|
||||||
if (CmdFailed(ret)) {
|
if (CmdFailed(ret)) {
|
||||||
if (_error_message != STR_1005_NO_SUITABLE_RAILROAD_TRACK && mode != 1) return CMD_ERROR;
|
if (_error_message != STR_1005_NO_SUITABLE_RAILROAD_TRACK && mode != 1) return CMD_ERROR;
|
||||||
|
_error_message = INVALID_STRING_ID;
|
||||||
} else {
|
} else {
|
||||||
error = false;
|
error = false;
|
||||||
total_cost += ret;
|
total_cost += ret;
|
||||||
|
|
|
@ -474,6 +474,7 @@ int32 CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
ret = DoCommand(tile, bits, 0, flags, CMD_BUILD_ROAD);
|
ret = DoCommand(tile, bits, 0, flags, CMD_BUILD_ROAD);
|
||||||
if (CmdFailed(ret)) {
|
if (CmdFailed(ret)) {
|
||||||
if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR;
|
if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR;
|
||||||
|
_error_message = INVALID_STRING_ID;
|
||||||
} else {
|
} else {
|
||||||
cost += ret;
|
cost += ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue