summaryrefslogtreecommitdiff
path: root/src/newgrf_station.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/newgrf_station.cpp')
-rw-r--r--src/newgrf_station.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index 5bca75fe2..26b49cc87 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -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;
+ }
}
}