diff options
author | smatz <smatz@openttd.org> | 2009-05-18 16:21:28 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-05-18 16:21:28 +0000 |
commit | 8808f3beea881af5652716c883a21c8031b5e390 (patch) | |
tree | bc14c65d1e66c407b72d254fc926d105eea2f1e4 /src/ai/api | |
parent | 5fe906e14992f7a301ae94c357e80af076ab7a63 (diff) | |
download | openttd-8808f3beea881af5652716c883a21c8031b5e390.tar.xz |
(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()
Diffstat (limited to 'src/ai/api')
-rw-r--r-- | src/ai/api/ai_group.cpp | 3 | ||||
-rw-r--r-- | src/ai/api/ai_sign.cpp | 3 | ||||
-rw-r--r-- | src/ai/api/ai_station.cpp | 3 | ||||
-rw-r--r-- | src/ai/api/ai_vehicle.cpp | 5 | ||||
-rw-r--r-- | src/ai/api/ai_waypoint.cpp | 3 |
5 files changed, 10 insertions, 7 deletions
diff --git a/src/ai/api/ai_group.cpp b/src/ai/api/ai_group.cpp index 6f4d25de9..cbcc8162b 100644 --- a/src/ai/api/ai_group.cpp +++ b/src/ai/api/ai_group.cpp @@ -16,7 +16,8 @@ /* static */ bool AIGroup::IsValidGroup(GroupID group_id) { - return ::Group::IsValidID(group_id) && ::Group::Get(group_id)->owner == _current_company; + const Group *g = ::Group::GetIfValid(group_id); + return g != NULL && g->owner == _current_company; } /* static */ AIGroup::GroupID AIGroup::CreateGroup(AIVehicle::VehicleType vehicle_type) diff --git a/src/ai/api/ai_sign.cpp b/src/ai/api/ai_sign.cpp index 349bf42a1..63bce8fdf 100644 --- a/src/ai/api/ai_sign.cpp +++ b/src/ai/api/ai_sign.cpp @@ -20,7 +20,8 @@ /* static */ bool AISign::IsValidSign(SignID sign_id) { - return ::Sign::IsValidID(sign_id) && ::Sign::Get(sign_id)->owner == _current_company; + const Sign *si = ::Sign::GetIfValid(sign_id); + return si != NULL && si->owner == _current_company; } /* static */ bool AISign::SetName(SignID sign_id, const char *name) diff --git a/src/ai/api/ai_station.cpp b/src/ai/api/ai_station.cpp index cc1167ddc..5d73b147b 100644 --- a/src/ai/api/ai_station.cpp +++ b/src/ai/api/ai_station.cpp @@ -17,7 +17,8 @@ /* static */ bool AIStation::IsValidStation(StationID station_id) { - return ::Station::IsValidID(station_id) && ::Station::Get(station_id)->owner == _current_company; + const Station *st = ::Station::GetIfValid(station_id); + return st != NULL && st->owner == _current_company; } /* static */ StationID AIStation::GetStationID(TileIndex tile) diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp index 5d1579364..3e30601fe 100644 --- a/src/ai/api/ai_vehicle.cpp +++ b/src/ai/api/ai_vehicle.cpp @@ -19,9 +19,8 @@ /* static */ bool AIVehicle::IsValidVehicle(VehicleID vehicle_id) { - if (!::Vehicle::IsValidID(vehicle_id)) return false; - const Vehicle *v = ::Vehicle::Get(vehicle_id); - return v->owner == _current_company && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::IsFreeWagon(v))); + const Vehicle *v = ::Vehicle::GetIfValid(vehicle_id); + return v != NULL && v->owner == _current_company && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::IsFreeWagon(v))); } /* static */ int32 AIVehicle::GetNumWagons(VehicleID vehicle_id) diff --git a/src/ai/api/ai_waypoint.cpp b/src/ai/api/ai_waypoint.cpp index 0c1e3194b..b98274b63 100644 --- a/src/ai/api/ai_waypoint.cpp +++ b/src/ai/api/ai_waypoint.cpp @@ -14,7 +14,8 @@ /* static */ bool AIWaypoint::IsValidWaypoint(WaypointID waypoint_id) { - return ::Waypoint::IsValidID(waypoint_id) && ::Waypoint::Get(waypoint_id)->owner == _current_company; + const Waypoint *wp = ::Waypoint::GetIfValid(waypoint_id); + return wp != NULL && wp->owner == _current_company; } /* static */ WaypointID AIWaypoint::GetWaypointID(TileIndex tile) |