(svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
authorDarkvater
Sat, 07 May 2005 10:26:45 +0000
changeset 1776 fa776997bba2
parent 1775 08ff0f12ccdc
child 1777 d328484bd6f2
(svn r2280) - Fix: Check if the passed tile to DoCommand is within the current mapsize
command.c
--- a/command.c	Sat May 07 10:26:12 2005 +0000
+++ b/command.c	Sat May 07 10:26:45 2005 +0000
@@ -177,6 +177,7 @@
 	CmdBuildSingleSignal,					/* 8  */
 	CmdRemoveSingleSignal,				/* 9  */
 	CmdTerraformLand,							/* 10 */
+	/***************************************************/
 	CmdPurchaseLandArea,					/* 11 */
 	CmdSellLandArea,							/* 12 */
 	CmdBuildTunnel,								/* 13 */
@@ -331,6 +332,9 @@
 	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 @@
 	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;