mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-19 19:19:40 +00:00
Avoided costly roundtrip through strings.
This commit is contained in:
parent
ccb8eadb3f
commit
a48d16687d
@ -69,15 +69,9 @@ tod_manager& tod_manager::operator=(const tod_manager& manager)
|
||||
config tod_manager::to_config() const
|
||||
{
|
||||
config cfg;
|
||||
std::stringstream buf;
|
||||
buf << turn_;
|
||||
cfg["turn_at"] = buf.str();
|
||||
buf.str(std::string());
|
||||
buf << num_turns_;
|
||||
cfg["turns"] = buf.str();
|
||||
buf.str(std::string());
|
||||
buf << currentTime_;
|
||||
cfg["current_tod"] = buf.str();
|
||||
cfg["turn_at"] = turn_;
|
||||
cfg["turns"] = num_turns_;
|
||||
cfg["current_tod"] = currentTime_;
|
||||
|
||||
std::vector<time_of_day>::const_iterator t;
|
||||
for(t = times_.begin(); t != times_.end(); ++t) {
|
||||
@ -216,9 +210,7 @@ void tod_manager::set_start_ToD(config &level, int current_turn)
|
||||
}
|
||||
// Setting ToD to level data
|
||||
|
||||
std::stringstream buf;
|
||||
buf << currentTime_;
|
||||
level["current_tod"] = buf.str();
|
||||
level["current_tod"] = currentTime_;
|
||||
|
||||
}
|
||||
|
||||
@ -316,5 +308,5 @@ bool tod_manager::next_turn()
|
||||
|
||||
bool tod_manager::is_time_left()
|
||||
{
|
||||
return num_turns_ == -1 || turn_ <= size_t(num_turns_);
|
||||
return num_turns_ == -1 || turn_ <= num_turns_;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class tod_manager : public savegame::savegame_config
|
||||
time_of_day time_of_day_at(const map_location& loc) const;
|
||||
|
||||
//turn functions
|
||||
size_t turn() const {return turn_;}
|
||||
int turn() const { return turn_; }
|
||||
int number_of_turns() const {return num_turns_;}
|
||||
void modify_turns(const std::string& mod);
|
||||
void set_number_of_turns(int num);
|
||||
@ -142,7 +142,7 @@ class tod_manager : public savegame::savegame_config
|
||||
std::vector<time_of_day> times_;
|
||||
std::vector<area_time_of_day> areas_;
|
||||
|
||||
size_t turn_;
|
||||
int turn_;
|
||||
int num_turns_;
|
||||
};
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user