Skip to content

Commit

Permalink
use game_data* instead of boost::optional<game_data&> in tod_manager
Browse files Browse the repository at this point in the history
after updating to boost 1.60 boost have me erros related to
boost::optional<game_data&> in stage_sf_with_rca.cpp where game_data is
not defined (only declared).

Using game_data* solved this problems and also simplies the code by
using simpler datatypes.
  • Loading branch information
gfgtdf committed Feb 24, 2016
1 parent a33e37a commit b282ef7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/ai/testing/stage_sf_with_rca.cpp
Expand Up @@ -278,7 +278,7 @@ void strategy_formulation_with_rca::switch_side()
else
this->set_side(1);

resources::tod_manager->next_turn(*resources::gamedata);
resources::tod_manager->next_turn(resources::gamedata);

DBG_AI_TESTING_SF_WITH_RCA << "switch to turn " << resources::tod_manager->turn() << std::endl;
DBG_AI_TESTING_SF_WITH_RCA << "------switch_side() end------" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/game_events/action_wml.cpp
Expand Up @@ -409,7 +409,7 @@ WML_HANDLER_FUNCTION(modify_turns, /*event_info*/, cfg)
if(new_turn_number_u < 1 || (new_turn_number > tod_man.number_of_turns() && tod_man.number_of_turns() != -1)) {
ERR_NG << "attempted to change current turn number to one out of range (" << new_turn_number << ")" << std::endl;
} else if(new_turn_number_u != current_turn_number) {
tod_man.set_turn_by_wml(new_turn_number_u, *resources::gamedata);
tod_man.set_turn_by_wml(new_turn_number_u, resources::gamedata);
resources::screen->new_turn();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/play_controller.cpp
Expand Up @@ -1234,7 +1234,7 @@ void play_controller::play_turn()

void play_controller::check_time_over()
{
const bool time_left = gamestate().tod_manager_.next_turn(gamestate().gamedata_);
const bool time_left = gamestate().tod_manager_.next_turn(&gamestate().gamedata_);

if(!time_left) {
LOG_NG << "firing time over event...\n";
Expand Down
2 changes: 1 addition & 1 deletion src/synced_commands.cpp
Expand Up @@ -549,7 +549,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_turn, child, use_undo, /*show*/, /*error_h

debug_notification(":turn debug command was used during turn of $player");

resources::tod_manager->set_turn(child["turn"].to_int(1), *resources::gamedata);
resources::tod_manager->set_turn(child["turn"].to_int(1), resources::gamedata);

resources::screen->new_turn();
resources::screen->redraw_everything();
Expand Down
6 changes: 3 additions & 3 deletions src/tod_manager.cpp
Expand Up @@ -410,7 +410,7 @@ void tod_manager::set_number_of_turns_by_wml(int num)
update_server_information();
}

void tod_manager::set_turn(const int num, boost::optional<game_data &> vars, const bool increase_limit_if_needed)
void tod_manager::set_turn(const int num, game_data* vars, const bool increase_limit_if_needed)
{
const int new_turn = std::max<int>(num, 1);
LOG_NG << "changing current turn number from " << turn_ << " to " << new_turn << '\n';
Expand All @@ -425,7 +425,7 @@ void tod_manager::set_turn(const int num, boost::optional<game_data &> vars, con
vars->get_variable("turn_number") = new_turn;
}

void tod_manager::set_turn_by_wml(const int num, boost::optional<game_data &> vars, const bool increase_limit_if_needed)
void tod_manager::set_turn_by_wml(const int num, game_data* vars, const bool increase_limit_if_needed)
{
set_turn(num, vars, increase_limit_if_needed);
update_server_information();
Expand Down Expand Up @@ -455,7 +455,7 @@ int tod_manager::calculate_current_time(
return new_current_time;
}

bool tod_manager::next_turn(boost::optional<game_data&> vars)
bool tod_manager::next_turn(game_data* vars)
{
set_turn(turn_ + 1, vars, false);
has_turn_event_fired_ = false;
Expand Down
6 changes: 3 additions & 3 deletions src/tod_manager.hpp
Expand Up @@ -163,16 +163,16 @@ class tod_manager : public savegame::savegame_config
void set_number_of_turns_by_wml(int num);

/** Dynamically change the current turn number. */
void set_turn(const int num, boost::optional<game_data&> vars = boost::none, const bool increase_limit_if_needed = true);
void set_turn(const int num, game_data* vars = NULL, const bool increase_limit_if_needed = true);
/** Dynamically change the current turn number. */
void set_turn_by_wml(const int num, boost::optional<game_data&> vars = boost::none, const bool increase_limit_if_needed = true);
void set_turn_by_wml(const int num, game_data* vars = NULL, const bool increase_limit_if_needed = true);

/**
* Function to move to the next turn.
*
* @returns True if time has not expired.
*/
bool next_turn(boost::optional<game_data&> vars);
bool next_turn(game_data* vars);

/**
* Function to check the end of turns.
Expand Down

0 comments on commit b282ef7

Please sign in to comment.