1
0
Fork 0

(svn r24160) -Codechange: Split parts of ObjectSpec::IsAvailable() into ObjectSpec::IsEverAvailable().

release/1.3
frosch 2012-04-22 16:27:45 +00:00
parent 1b0d3e3034
commit 27ffb03383
2 changed files with 13 additions and 4 deletions

View File

@ -53,16 +53,24 @@ ObjectSpec _object_specs[NUM_OBJECTS];
return ObjectSpec::Get(GetObjectType(tile)); return ObjectSpec::Get(GetObjectType(tile));
} }
/**
* Check whether the object might be available at some point in this game with the current game mode.
* @return true if it might be available.
*/
bool ObjectSpec::IsEverAvailable() const
{
return this->enabled && HasBit(this->climate, _settings_game.game_creation.landscape) &&
(this->flags & (_game_mode != GM_EDITOR ? OBJECT_FLAG_ONLY_IN_SCENEDIT : OBJECT_FLAG_ONLY_IN_GAME)) == 0;
}
/** /**
* Check whether the object is available at this time. * Check whether the object is available at this time.
* @return true if it is available. * @return true if it is available.
*/ */
bool ObjectSpec::IsAvailable() const bool ObjectSpec::IsAvailable() const
{ {
return this->enabled && _date > this->introduction_date && return this->IsEverAvailable() && _date > this->introduction_date &&
(_date < this->end_of_life_date || this->end_of_life_date < this->introduction_date + 365) && (_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;
} }
/** /**

View File

@ -82,6 +82,7 @@ struct ObjectSpec {
*/ */
Money GetClearCost() const { return GetPrice(PR_CLEAR_OBJECT, this->clear_cost_multiplier, this->grf_prop.grffile, 0); } Money GetClearCost() const { return GetPrice(PR_CLEAR_OBJECT, this->clear_cost_multiplier, this->grf_prop.grffile, 0); }
bool IsEverAvailable() const;
bool IsAvailable() const; bool IsAvailable() const;
uint Index() const; uint Index() const;