Use default parameter to combine 2 functions
This commit is contained in:
parent
a0fe68705e
commit
569386d5e1
3 changed files with 6 additions and 13 deletions
|
@ -783,7 +783,8 @@ WML_HANDLER_FUNCTION(store_time_of_day, /*event_info*/, cfg)
|
|||
{
|
||||
const map_location loc = cfg_to_loc(cfg, -999, -999);
|
||||
const size_t turn = lexical_cast_default<size_t>(cfg["turn"], 0);
|
||||
const time_of_day tod = turn ? resources::tod_manager->get_time_of_day(loc,turn) : resources::tod_manager->get_time_of_day(loc);
|
||||
// using 0 will use the current turn
|
||||
const time_of_day& tod = resources::tod_manager->get_time_of_day(loc,turn);
|
||||
|
||||
std::string variable = cfg["variable"];
|
||||
if(variable.empty()) {
|
||||
|
|
|
@ -121,7 +121,7 @@ const time_of_day& tod_manager::get_previous_time_of_day() const
|
|||
|
||||
time_of_day tod_manager::get_time_of_day(const map_location& loc, int n_turn) const
|
||||
{
|
||||
time_of_day res = get_time_of_day_turn(n_turn);
|
||||
time_of_day res = get_time_of_day_turn(n_turn ? n_turn : turn_);
|
||||
|
||||
if (loc.valid()) {
|
||||
for (std::vector<area_time_of_day>::const_reverse_iterator
|
||||
|
@ -137,11 +137,6 @@ time_of_day tod_manager::get_time_of_day(const map_location& loc, int n_turn) co
|
|||
return res;
|
||||
}
|
||||
|
||||
time_of_day tod_manager::get_time_of_day(const map_location& loc) const
|
||||
{
|
||||
return get_time_of_day(loc, turn_);
|
||||
}
|
||||
|
||||
bool tod_manager::is_start_ToD(const std::string& random_start_time)
|
||||
{
|
||||
return !random_start_time.empty()
|
||||
|
|
|
@ -39,14 +39,11 @@ class tod_manager : public savegame::savegame_config
|
|||
/** Returns time of day object for current turn. */
|
||||
const time_of_day& get_time_of_day() const;
|
||||
const time_of_day& get_previous_time_of_day() const;
|
||||
time_of_day get_time_of_day(const map_location& loc) const;
|
||||
/**
|
||||
* Returns time of day object in the turn.
|
||||
*
|
||||
* It first tries to look for specified. If no area time specified in
|
||||
* location, it returns global time.
|
||||
* Returns time of day object in the turn at a location.
|
||||
* If nturn = 0 use current turn
|
||||
*/
|
||||
time_of_day get_time_of_day(const map_location& loc, int n_turn) const;
|
||||
time_of_day get_time_of_day(const map_location& loc, int n_turn = 0) const;
|
||||
/**
|
||||
* Sets global time of day in this turn.
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue