(svn r8336) -Codechange: added function to translate vehicle types to 0,1,2... for use for index to arrays
Used this function to get rid of some switch-cases in build_vehicle_gui.cpp -Fix (r8335): ship build window didn't remember assending/decending sort setting
This commit is contained in:
@@ -424,6 +424,19 @@ static inline bool IsPlayerBuildableVehicleType(const Vehicle *v)
|
||||
return IsPlayerBuildableVehicleType(v->type);
|
||||
}
|
||||
|
||||
/** Function to give index of a vehicle type
|
||||
* Since the return value is 0 for VEH_train, it's perfect for index to arrays
|
||||
*/
|
||||
static inline byte VehTypeToIndex(byte type)
|
||||
{
|
||||
return type - VEH_Train;
|
||||
}
|
||||
|
||||
static inline byte VehTypeToIndex(const Vehicle *v)
|
||||
{
|
||||
return VehTypeToIndex(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(v) FOR_ALL_VEHICLES_FROM(v, 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user