summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/newgrf_object.cpp5
-rw-r--r--src/newgrf_object.h6
2 files changed, 11 insertions, 0 deletions
diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp
index dc01d11d3..dc1ac84f8 100644
--- a/src/newgrf_object.cpp
+++ b/src/newgrf_object.cpp
@@ -46,6 +46,11 @@ bool ObjectSpec::IsAvailable() const
(flags & (_game_mode != GM_EDITOR ? OBJECT_FLAG_ONLY_IN_SCENEDIT : OBJECT_FLAG_ONLY_IN_GAME)) == 0;
}
+uint ObjectSpec::Index() const
+{
+ return this - _object_specs;
+}
+
/** This function initialize the spec arrays of objects. */
void ResetObjects()
{
diff --git a/src/newgrf_object.h b/src/newgrf_object.h
index 5aaf5c286..cf8b6a9de 100644
--- a/src/newgrf_object.h
+++ b/src/newgrf_object.h
@@ -88,6 +88,12 @@ struct ObjectSpec {
Money GetClearCost() const { return (_price[PR_CLEAR_OBJECT] * this->clear_cost_multiplier); }
/**
+ * Gets the index of this spec.
+ * @return The index.
+ */
+ uint Index() const;
+
+ /**
* Get the specification associated with a specific ObjectType.
* @param index The object type to fetch.
* @return The specification.