(svn r12220) [NoAI] -Fix: minor type in AIVehicleStation, and missing security check
--- a/src/ai/api/ai_vehiclelist.cpp Sat Feb 23 14:14:06 2008 +0000
+++ b/src/ai/api/ai_vehiclelist.cpp Sat Feb 23 14:33:18 2008 +0000
@@ -1,4 +1,5 @@
#include "ai_vehiclelist.hpp"
+#include "ai_station.hpp"
#include "../../player_func.h"
#include "../../station.h"
#include "../../vehicle_base.h"
@@ -11,8 +12,10 @@
}
}
-AIStationVehicleList::AIStationVehicleList(StationID station)
+AIStationVehicleList::AIStationVehicleList(StationID station_id)
{
+ if (!AIStation::IsValidStation(station_id)) return;
+
Vehicle *v;
FOR_ALL_VEHICLES(v) {
@@ -20,7 +23,7 @@
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
- if (order->type == OT_GOTO_STATION && order->dest == station) {
+ if (order->type == OT_GOTO_STATION && order->dest == station_id) {
this->AddItem(v->index);
break;
}
--- a/src/ai/api/ai_vehiclelist.hpp Sat Feb 23 14:14:06 2008 +0000
+++ b/src/ai/api/ai_vehiclelist.hpp Sat Feb 23 14:33:18 2008 +0000
@@ -37,7 +37,7 @@
* The constructor to make a list of vehicles that goes to this station.
* @param station The station to get the list of vehicles that go here from.
*/
- AIStationVehicleList(StationID station);
+ AIStationVehicleList(StationID station_id);
};
#endif /* AI_VEHICLELIST_HPP */
--- a/src/ai/api/ai_vehiclelist.hpp.sq Sat Feb 23 14:14:06 2008 +0000
+++ b/src/ai/api/ai_vehiclelist.hpp.sq Sat Feb 23 14:33:18 2008 +0000
@@ -31,7 +31,7 @@
void SQAIStationVehicleListRegister(Squirrel *engine) {
DefSQClass <AIStationVehicleList> SQAIStationVehicleList("AIStationVehicleList");
SQAIStationVehicleList.PreRegister(engine, "AIAbstractList");
- SQAIStationVehicleList.AddConstructor<void (AIStationVehicleList::*)(StationID station), 2>(engine, "xi");
+ SQAIStationVehicleList.AddConstructor<void (AIStationVehicleList::*)(StationID station_id), 2>(engine, "xi");
SQAIStationVehicleList.DefSQStaticMethod(engine, &AIStationVehicleList::GetClassName, "GetClassName", 1, "x");