fix bug #7236 - substitution in turn_at by variable.
Thanks Glen Whitney for help and patch.
This commit is contained in:
parent
052bf9cdfe
commit
52dcc92cb1
5 changed files with 50 additions and 47 deletions
|
@ -164,11 +164,13 @@ void parse_times(const config& cfg, std::vector<time_of_day>& normal_times)
|
|||
|
||||
}
|
||||
|
||||
gamestatus::gamestatus(const config& time_cfg, int num_turns) :
|
||||
gamestatus::gamestatus(const config& time_cfg, int num_turns, game_state* s_o_g) :
|
||||
turn_(1),numTurns_(num_turns)
|
||||
{
|
||||
(const_cast<config&>(time_cfg))["turn_at"] = utils::interpolate_variables_into_string(time_cfg["turn_at"],&time_cfg.values);
|
||||
const std::string& turn_at = time_cfg["turn_at"];
|
||||
std::string turn_at = time_cfg["turn_at"];
|
||||
if (s_o_g) {
|
||||
turn_at = utils::interpolate_variables_into_string(turn_at, *s_o_g);
|
||||
}
|
||||
if(turn_at.empty() == false) {
|
||||
turn_ = atoi(turn_at.c_str());
|
||||
}
|
||||
|
|
|
@ -46,44 +46,6 @@ struct time_of_day
|
|||
int red, green, blue;
|
||||
};
|
||||
|
||||
//class which contains the global status of the game -- namely
|
||||
//the current turn, the number of turns, and the time of day.
|
||||
class gamestatus
|
||||
{
|
||||
public:
|
||||
gamestatus(const config& time_cfg, int num_turns);
|
||||
void write(config& cfg) const;
|
||||
|
||||
time_of_day get_time_of_day() const;
|
||||
time_of_day get_previous_time_of_day() const;
|
||||
time_of_day get_time_of_day(int illuminated, const gamemap::location& loc) const;
|
||||
time_of_day get_time_of_day(int illuminated, const gamemap::location& loc, int n_turn) const;
|
||||
size_t turn() const;
|
||||
int number_of_turns() const;
|
||||
void modify_turns(const std::string& mod);
|
||||
void add_turns(int num);
|
||||
|
||||
//function to move to the next turn. Returns true iff time
|
||||
//has expired.
|
||||
bool next_turn();
|
||||
|
||||
private:
|
||||
time_of_day get_time_of_day_turn(int nturn) const;
|
||||
|
||||
std::vector<time_of_day> times_;
|
||||
|
||||
struct area_time_of_day {
|
||||
std::string xsrc, ysrc;
|
||||
std::vector<time_of_day> times;
|
||||
std::set<gamemap::location> hexes;
|
||||
};
|
||||
|
||||
std::vector<area_time_of_day> areas_;
|
||||
|
||||
size_t turn_;
|
||||
int numTurns_;
|
||||
};
|
||||
|
||||
/** Information on a particular player of the game. */
|
||||
struct player_info
|
||||
{
|
||||
|
@ -95,9 +57,6 @@ struct player_info
|
|||
std::set<std::string> can_recruit; /** < units the player has the ability to recruit */
|
||||
};
|
||||
|
||||
//object which holds all the data needed to start a scenario.
|
||||
//i.e. this is the object serialized to disk when saving/loading a game.
|
||||
//is also the object which needs to be created to start a new game
|
||||
struct game_state : public variable_set
|
||||
{
|
||||
game_state() : difficulty("NORMAL") {}
|
||||
|
@ -149,6 +108,48 @@ private:
|
|||
t_string** varout, config** cfgout);
|
||||
};
|
||||
|
||||
//class which contains the global status of the game -- namely
|
||||
//the current turn, the number of turns, and the time of day.
|
||||
class gamestatus
|
||||
{
|
||||
public:
|
||||
gamestatus(const config& time_cfg, int num_turns, game_state* s_o_g = 0);
|
||||
void write(config& cfg) const;
|
||||
|
||||
time_of_day get_time_of_day() const;
|
||||
time_of_day get_previous_time_of_day() const;
|
||||
time_of_day get_time_of_day(int illuminated, const gamemap::location& loc) const;
|
||||
time_of_day get_time_of_day(int illuminated, const gamemap::location& loc, int n_turn) const;
|
||||
size_t turn() const;
|
||||
int number_of_turns() const;
|
||||
void modify_turns(const std::string& mod);
|
||||
void add_turns(int num);
|
||||
|
||||
//function to move to the next turn. Returns true iff time
|
||||
//has expired.
|
||||
bool next_turn();
|
||||
|
||||
private:
|
||||
time_of_day get_time_of_day_turn(int nturn) const;
|
||||
|
||||
std::vector<time_of_day> times_;
|
||||
|
||||
struct area_time_of_day {
|
||||
std::string xsrc, ysrc;
|
||||
std::vector<time_of_day> times;
|
||||
std::set<gamemap::location> hexes;
|
||||
};
|
||||
|
||||
std::vector<area_time_of_day> areas_;
|
||||
|
||||
size_t turn_;
|
||||
int numTurns_;
|
||||
};
|
||||
|
||||
//object which holds all the data needed to start a scenario.
|
||||
//i.e. this is the object serialized to disk when saving/loading a game.
|
||||
//is also the object which needs to be created to start a new game
|
||||
|
||||
struct save_info {
|
||||
save_info(const std::string& n, time_t t) : name(n), time_modified(t) {}
|
||||
std::string name;
|
||||
|
|
|
@ -30,7 +30,7 @@ play_controller::play_controller(const config& level, const game_data& gameinfo,
|
|||
mouse_handler_(gui_, teams_, units_, map_, status_, gameinfo, undo_stack_, redo_stack_),
|
||||
menu_handler_(gui_, units_, teams_, level, gameinfo, map_, game_config, status_, state_of_game, undo_stack_, redo_stack_),
|
||||
generator_setter(&recorder), statistics_context_(level["name"]), gameinfo_(gameinfo), level_(level), game_config_(game_config),
|
||||
gamestate_(state_of_game), status_(level, num_turns),
|
||||
gamestate_(state_of_game), status_(level, num_turns, &state_of_game),
|
||||
map_(game_config, level["map_data"]), ticks_(ticks),
|
||||
xp_mod_(atoi(level["experience_modifier"].c_str()) > 0 ? atoi(level["experience_modifier"].c_str()) : 100),
|
||||
loading_game_(level["playing_team"].empty() == false),
|
||||
|
|
|
@ -63,7 +63,7 @@ replay_controller::replay_controller(const config& level, const game_data& gamei
|
|||
const int ticks, const int num_turns, const config& game_config,
|
||||
CVideo& video)
|
||||
: play_controller(level, gameinfo, state_of_game, ticks, num_turns, game_config, video, false),
|
||||
gamestate_start_(state_of_game), status_start_(level, num_turns)
|
||||
gamestate_start_(state_of_game), status_start_(level, num_turns, &state_of_game)
|
||||
{
|
||||
current_turn_ = 1;
|
||||
delay_ = 0;
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
const_iterator() { }
|
||||
const_iterator(const iterator &i) : i_(i.i_) { }
|
||||
|
||||
const std::pair<gamemap::location,unit> *operator->() const
|
||||
const std::pair<gamemap::location,unit>* operator->() const
|
||||
{ return i_->second; }
|
||||
|
||||
std::pair<gamemap::location,unit> operator*() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue