(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
StationClass _station_classes[STAT_CLASS_MAX];
|
||||
static StationClass _station_classes[STAT_CLASS_MAX];
|
||||
|
||||
enum {
|
||||
MAX_SPECLIST = 255,
|
||||
@@ -156,8 +156,14 @@ const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx)
|
||||
/**
|
||||
* Retrieve a station spec by GRF location.
|
||||
* @param grfid GRF ID of station spec.
|
||||
* @param localidx Index within GRF file of station spec.
|
||||
* @param index Pointer to return the index of the station spec in its station class. If NULL then not used.
|
||||
* @return The station spec.
|
||||
*/
|
||||
const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx, int *index)
|
||||
{
|
||||
uint j;
|
||||
|
||||
@@ -165,7 +171,10 @@ const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx)
|
||||
for (j = 0; j < _station_classes[i].stations; j++) {
|
||||
const StationSpec *statspec = _station_classes[i].spec[j];
|
||||
if (statspec == NULL) continue;
|
||||
if (statspec->grffile->grfid == grfid && statspec->localidx == localidx) return statspec;
|
||||
if (statspec->grffile->grfid == grfid && statspec->localidx == localidx) {
|
||||
if (index != NULL) *index = j;
|
||||
return statspec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user