summaryrefslogtreecommitdiff
path: root/src/vehicle.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-08-02 21:19:07 +0000
committerrubidium <rubidium@openttd.org>2007-08-02 21:19:07 +0000
commitb15c0efaa951425d74e8a9ca4104da72a81fe50c (patch)
treec9214850b82261724c3e006bdb90aae810fb06bb /src/vehicle.h
parentdb374f600c319f0d230cf5f84e120ea06b5fa41e (diff)
downloadopenttd-b15c0efaa951425d74e8a9ca4104da72a81fe50c.tar.xz
(svn r10756) -Codechange: use vehicle->IsValid in favour of IsValidVehicle(vehicle).
Diffstat (limited to 'src/vehicle.h')
-rw-r--r--src/vehicle.h14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/vehicle.h b/src/vehicle.h
index 207893c34..0ff3c247f 100644
--- a/src/vehicle.h
+++ b/src/vehicle.h
@@ -432,6 +432,8 @@ struct Vehicle {
* Calls the tick handler of the vehicle
*/
virtual void Tick() = 0;
+
+ bool IsValid() const { return this->type != VEH_INVALID; }
};
/**
@@ -634,14 +636,6 @@ static inline uint GetNumVehicles()
return GetVehiclePoolSize();
}
-/**
- * Check if a Vehicle really exists.
- */
-static inline bool IsValidVehicle(const Vehicle *v)
-{
- return v->type != VEH_INVALID;
-}
-
void DestroyVehicle(Vehicle *v);
static inline void DeleteVehicle(Vehicle *v)
@@ -668,7 +662,7 @@ static inline bool IsPlayerBuildableVehicleType(const Vehicle *v)
return IsPlayerBuildableVehicleType(v->type);
}
-#define FOR_ALL_VEHICLES_FROM(v, start) for (v = GetVehicle(start); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) if (IsValidVehicle(v))
+#define FOR_ALL_VEHICLES_FROM(v, start) for (v = GetVehicle(start); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) if (v->IsValid())
#define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0)
/**
@@ -678,7 +672,7 @@ static inline bool IsPlayerBuildableVehicleType(const Vehicle *v)
*/
static inline bool IsValidVehicleID(uint index)
{
- return index < GetVehiclePoolSize() && IsValidVehicle(GetVehicle(index));
+ return index < GetVehiclePoolSize() && GetVehicle(index)->IsValid();
}
/* Returns order 'index' of a vehicle or NULL when it doesn't exists */