From 0a86eac2f1d8f646180cdd1d56f555e7956f7ebb Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 28 Aug 2010 17:36:28 +0000 Subject: (svn r20651) -Codechange: add a function to determine whether an object is available and use it --- src/newgrf_object.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/newgrf_object.cpp') diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp index 30dd23df5..dc01d11d3 100644 --- a/src/newgrf_object.cpp +++ b/src/newgrf_object.cpp @@ -11,6 +11,7 @@ #include "stdafx.h" #include "core/mem_func.hpp" +#include "date_func.h" #include "newgrf.h" #include "newgrf_class_func.h" #include "newgrf_object.h" @@ -35,6 +36,16 @@ ObjectSpec _object_specs[NUM_OBJECTS]; return ObjectSpec::Get(GetObjectType(tile)); } +bool ObjectSpec::IsAvailable() const +{ + return + this->enabled && + _date > this->introduction_date && + (_date < this->end_of_life_date || this->end_of_life_date < this->introduction_date + 365) && + HasBit(this->climate, _settings_game.game_creation.landscape) && + (flags & (_game_mode != GM_EDITOR ? OBJECT_FLAG_ONLY_IN_SCENEDIT : OBJECT_FLAG_ONLY_IN_GAME)) == 0; +} + /** This function initialize the spec arrays of objects. */ void ResetObjects() { -- cgit v1.2.3-54-g00ecf