Mercurial > hg > openttd
changeset 15964:f8b2485b1bd7 draft
(svn r20652) -Codechange: implement a function to get the index of a spec.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sat, 28 Aug 2010 17:38:07 +0000 |
parents | 3877138a17d5 |
children | ef6fb201c74f |
files | src/newgrf_object.cpp src/newgrf_object.h |
diffstat | 2 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/newgrf_object.cpp +++ b/src/newgrf_object.cpp @@ -46,6 +46,11 @@ (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() {
--- a/src/newgrf_object.h +++ b/src/newgrf_object.h @@ -88,6 +88,12 @@ 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.