summaryrefslogtreecommitdiff
path: root/src/newgrf_station.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2009-02-09 22:49:28 +0000
committerpeter1138 <peter1138@openttd.org>2009-02-09 22:49:28 +0000
commitad30a3c4caaad54f1b0b279bb0fc78254016efe3 (patch)
tree5980ebeefe7c6c93c1f872cad92d616b259b03dc /src/newgrf_station.cpp
parentd846eef0b68474970d7ffe5f1d667d866ddff7a8 (diff)
downloadopenttd-ad30a3c4caaad54f1b0b279bb0fc78254016efe3.tar.xz
(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...
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;
+ }
}
}