changeset 14609:69c586c53c78 draft

(svn r19186) -Codechange: Remove use of _error_message from CmdLevelLand().
author alberth <alberth@openttd.org>
date Sun, 21 Feb 2010 17:02:28 +0000
parents 94969f662ceb
children a0d5460f3f3d
files src/terraform_cmd.cpp
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/terraform_cmd.cpp
+++ b/src/terraform_cmd.cpp
@@ -376,7 +376,6 @@
 
 	/* Check range of destination height */
 	if (h > MAX_TILE_HEIGHT) return_cmd_error((oldh == 0) ? STR_ERROR_ALREADY_AT_SEA_LEVEL : STR_ERROR_TOO_HIGH);
-	if (p2 == 0) _error_message = STR_ERROR_ALREADY_LEVELLED;
 
 	Money money = GetAvailableMoneyForCommand();
 	CommandCost cost(EXPENSES_CONSTRUCTION);
@@ -402,5 +401,10 @@
 		}
 	}
 
-	return (cost.GetCost() == 0) ? CMD_ERROR : cost;
+	if (cost.GetCost() == 0) {
+		if (p2 != 0) return CMD_ERROR;
+		cost.MakeError(STR_ERROR_ALREADY_LEVELLED);
+		cost.SetGlobalErrorMessage();
+	}
+	return cost;
 }