summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-05-07 10:26:45 +0000
committerDarkvater <darkvater@openttd.org>2005-05-07 10:26:45 +0000
commitf2bc27718a6c89f4395b7f3b27bab5bd70fa2704 (patch)
tree90b5a07f12f1132f12b5b50e90b683007e4b5823
parent3ad11e0ad45af46ffbc3cbe16156794d76f1cf4f (diff)
downloadopenttd-f2bc27718a6c89f4395b7f3b27bab5bd70fa2704.tar.xz
(svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
-rw-r--r--command.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/command.c b/command.c
index 22b6af6d4..f7c0f5cc1 100644
--- a/command.c
+++ b/command.c
@@ -177,6 +177,7 @@ static CommandProc * const _command_proc_table[] = {
CmdBuildSingleSignal, /* 8 */
CmdRemoveSingleSignal, /* 9 */
CmdTerraformLand, /* 10 */
+ /***************************************************/
CmdPurchaseLandArea, /* 11 */
CmdSellLandArea, /* 12 */
CmdBuildTunnel, /* 13 */
@@ -331,6 +332,9 @@ int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc)
int32 res;
CommandProc *proc;
+ /* Do not even think about executing out-of-bounds tile-commands */
+ if (TILE_FROM_XY(x,y) > MapSize()) return CMD_ERROR;
+
proc = _command_proc_table[procc];
if (_docommand_recursive == 0) {
@@ -399,6 +403,9 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
int x = TileX(tile) * 16;
int y = TileY(tile) * 16;
+ /* Do not even think about executing out-of-bounds tile-commands */
+ if (tile > MapSize()) return false;
+
assert(_docommand_recursive == 0);
_error_message = INVALID_STRING_ID;