diff options
author | tron <tron@openttd.org> | 2006-03-12 12:19:25 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-03-12 12:19:25 +0000 |
commit | b394f72fa9305094ddf672564a0f4a0c8f16e89b (patch) | |
tree | a2aa298975f3b0ba6fb0889afdfb76c415951aa7 /tree_cmd.c | |
parent | 214b5eb42f8296965837a29e086fd4c6a7406c37 (diff) | |
download | openttd-b394f72fa9305094ddf672564a0f4a0c8f16e89b.tar.xz |
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
Diffstat (limited to 'tree_cmd.c')
-rw-r--r-- | tree_cmd.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tree_cmd.c b/tree_cmd.c index 5742f916e..7a699efdb 100644 --- a/tree_cmd.c +++ b/tree_cmd.c @@ -130,6 +130,7 @@ void GenerateTrees(void) */ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) { + StringID msg = INVALID_STRING_ID; int32 cost; int sx, sy, x, y; @@ -158,7 +159,7 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) case MP_TREES: // no more space for trees? if (_game_mode != GM_EDITOR && GetTreeCount(tile) == 3) { - _error_message = STR_2803_TREE_ALREADY_HERE; + msg = STR_2803_TREE_ALREADY_HERE; continue; } @@ -172,7 +173,7 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) case MP_CLEAR: if (!IsTileOwner(tile, OWNER_NONE)) { - _error_message = STR_2804_SITE_UNSUITABLE; + msg = STR_2804_SITE_UNSUITABLE; continue; } @@ -213,13 +214,17 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) break; default: - _error_message = STR_2804_SITE_UNSUITABLE; + msg = STR_2804_SITE_UNSUITABLE; break; } } } - return (cost == 0) ? CMD_ERROR : cost; + if (cost == 0) { + return_cmd_error(msg); + } else { + return cost; + } } typedef struct TreeListEnt { |