changeset 11908:ad77de09aa35 draft

(svn r16308) -Fix: parameter is invalid when it's equal to length of an array (Yexo)
author smatz <smatz@openttd.org>
date Thu, 14 May 2009 23:40:03 +0000
parents ae4ef10e7535
children 110b7d9966e6
files src/station_cmd.cpp src/town_cmd.cpp
diffstat 2 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1820,7 +1820,7 @@
 	if (distant_join && (!_settings_game.station.distant_join_stations || !IsValidStationID(station_to_join))) return CMD_ERROR;
 
 	/* Check if a valid, buildable airport was chosen for construction */
-	if (p1 > lengthof(_airport_sections) || !HasBit(GetValidAirports(), p1)) return CMD_ERROR;
+	if (p1 >= lengthof(_airport_sections) || !HasBit(GetValidAirports(), p1)) return CMD_ERROR;
 
 	if (!CheckIfAuthorityAllowsNewStation(tile, flags)) {
 		return CMD_ERROR;
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -2553,7 +2553,7 @@
  */
 CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 {
-	if (!IsValidTownID(p1) || p2 > lengthof(_town_action_proc)) return CMD_ERROR;
+	if (!IsValidTownID(p1) || p2 >= lengthof(_town_action_proc)) return CMD_ERROR;
 
 	Town *t = GetTown(p1);