mirror of https://github.com/OpenTTD/OpenTTD
(svn r4683) - Backport from trunk (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 usedrelease/0.4
parent
52d25fe06f
commit
8e4cf4d599
|
@ -195,7 +195,6 @@ int32 CmdTerraformLand(int x, int y, 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;
|
||||||
|
|
|
@ -602,8 +602,8 @@ static int32 CmdRailTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32 p2
|
||||||
ret = DoCommand(x, y, railtype, TrackdirToTrack(trackdir), flags, (mode == 0) ? CMD_BUILD_SINGLE_RAIL : CMD_REMOVE_SINGLE_RAIL);
|
ret = DoCommand(x, y, 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;
|
||||||
|
|
||||||
|
@ -895,6 +895,7 @@ static int32 CmdSignalTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32
|
||||||
* 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;
|
||||||
|
|
|
@ -546,6 +546,7 @@ int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
ret = DoCommandByTile(tile, bits, 0, flags, CMD_BUILD_ROAD);
|
ret = DoCommandByTile(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