summaryrefslogtreecommitdiff
path: root/src/rail.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2012-01-05 19:40:34 +0000
committermichi_cc <michi_cc@openttd.org>2012-01-05 19:40:34 +0000
commitee0fcb25670d1b559cdfdb31e6b7d0da4ec3713d (patch)
tree6801ecd572e6dd07d0b4b045cdcbd1bafea78617 /src/rail.cpp
parent69e197c87fc23e5492f4b59f8e1ba8757d65c41e (diff)
downloadopenttd-ee0fcb25670d1b559cdfdb31e6b7d0da4ec3713d.tar.xz
(svn r23758) -Feature: [NewGRF] Alternate rail type label list.
Diffstat (limited to 'src/rail.cpp')
-rw-r--r--src/rail.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/rail.cpp b/src/rail.cpp
index 13346d607..fa0d86c88 100644
--- a/src/rail.cpp
+++ b/src/rail.cpp
@@ -277,9 +277,10 @@ RailTypes GetCompanyRailtypes(CompanyID company)
/**
* Get the rail type for a given label.
* @param label the railtype label.
+ * @param allow_alternate_labels Search in the alternate label lists as well.
* @return the railtype.
*/
-RailType GetRailTypeByLabel(RailTypeLabel label)
+RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels)
{
/* Loop through each rail type until the label is found */
for (RailType r = RAILTYPE_BEGIN; r != RAILTYPE_END; r++) {
@@ -287,6 +288,14 @@ RailType GetRailTypeByLabel(RailTypeLabel label)
if (rti->label == label) return r;
}
+ if (allow_alternate_labels) {
+ /* Test if any rail type defines the label as an alternate. */
+ for (RailType r = RAILTYPE_BEGIN; r != RAILTYPE_END; r++) {
+ const RailtypeInfo *rti = GetRailTypeInfo(r);
+ if (rti->alternate_labels.Contains(label)) return r;
+ }
+ }
+
/* No matching label was found, so it is invalid */
return INVALID_RAILTYPE;
}