summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aircraft_cmd.c3
-rw-r--r--command.c4
-rw-r--r--misc_cmd.c4
3 files changed, 8 insertions, 3 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index c6cf89282..333679295 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -170,7 +170,7 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
Vehicle *vl[3], *v, *u, *w;
UnitID unit_num;
TileIndex tile = TILE_FROM_XY(x,y);
- const AircraftVehicleInfo *avi = AircraftVehInfo(p1);
+ const AircraftVehicleInfo *avi;
Engine *e;
if (!IsEngineBuildable(p1, VEH_Aircraft)) return CMD_ERROR;
@@ -186,6 +186,7 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_QUERY_COST) return value;
+ avi = AircraftVehInfo(p1);
// allocate 2 or 3 vehicle structs, depending on type
if (!AllocateVehicles(vl, (avi->subtype & 1) == 0 ? 3 : 2) ||
IsOrderPoolFull())
diff --git a/command.c b/command.c
index 29ab994fc..7c198ec36 100644
--- a/command.c
+++ b/command.c
@@ -428,6 +428,10 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
// get pointer to command handler
assert((cmd & 0xFF) < lengthof(_command_proc_table));
proc = _command_proc_table[cmd & 0xFF].proc;
+ if (proc == NULL) {
+ _cmd_text = NULL;
+ return false;
+ }
// Some commands have a different output in dryrun than the realrun
// e.g.: if you demolish a whole town, the dryrun would say okay.
diff --git a/misc_cmd.c b/misc_cmd.c
index e26b4b346..eeae8e0c1 100644
--- a/misc_cmd.c
+++ b/misc_cmd.c
@@ -256,7 +256,7 @@ int32 CmdGiveMoney(int x, int y, uint32 flags, uint32 p1, uint32 p2)
*/
int32 CmdChangeDifficultyLevel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
- if ((int32)p1 >= GAME_DIFFICULTY_NUM && p1 != (uint32)-1L) return CMD_ERROR;
+ if (p1 != (uint32)-1L && ((int32)p1 >= GAME_DIFFICULTY_NUM || (int32)p1 < 0)) return CMD_ERROR;
if (flags & DC_EXEC) {
if (p1 != (uint32)-1L) {
@@ -267,7 +267,7 @@ int32 CmdChangeDifficultyLevel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* If we are a network-client, update the difficult setting (if it is open).
* Use this instead of just dirtying the window because we need to load in
- * the new difficulty settings */
+ * the new difficulty settings */
if (_networking && !_network_server && FindWindowById(WC_GAME_OPTIONS, 0) != NULL)
ShowGameDifficulty();
}