command.c
changeset 903 f860c7234167
parent 889 7f8630bfea41
child 926 bd4312619522
--- a/command.c	Wed Jan 05 14:20:23 2005 +0000
+++ b/command.c	Wed Jan 05 14:39:48 2005 +0000
@@ -312,6 +312,17 @@
 	CmdReplaceVehicle,							/* 114 */
 };
 
+/* This function range-checks a cmd, and checks if the cmd is not NULL */
+bool IsValidCommand(int cmd)
+{
+	cmd = cmd & 0xFF;
+
+	if (cmd < 0 || cmd >= lengthof(_command_proc_table) || _command_proc_table[cmd] == NULL)
+		return false;
+
+	return true;
+}
+
 int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
 {
 	return DoCommand(GET_TILE_X(tile)*16, GET_TILE_Y(tile)*16, p1, p2, flags, procc);