fix what I broke yesterday

This commit is contained in:
Jérémy Rosen 2006-08-07 19:52:30 +00:00
parent 55ab869242
commit 94cf19fe44
4 changed files with 13 additions and 3 deletions

View file

@ -80,6 +80,13 @@ void animated<T,T_void_value>::add_frame()
frames_.push_back(frame(ending_frame_time_));
}
template<typename T, typename T_void_value>
void animated<T,T_void_value>::add_frame(int start)
{
frames_.push_back(frame(start));
starting_frame_time_ = minimum<int>(starting_frame_time_, start);
ending_frame_time_ = maximum<int>(ending_frame_time_, start);
}
template<typename T, typename T_void_value>
void animated<T,T_void_value>::add_frame(int start, const T& value)

View file

@ -48,6 +48,7 @@ public:
// Adds a void frame at the end
void add_frame();
// Adds a void frame
void add_frame(int start);
// Adds a frame
void add_frame(int start, const T& value);

View file

@ -139,7 +139,7 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
temp_anim.add_frame(current_time, flag_image);
current_time += time;
}
temp_anim.add_frame();
temp_anim.add_frame(current_time);
flags_.push_back(temp_anim);
flags_.back().start_animation(rand()%flags_.back().get_frames_count(), animated<image::locator>::INFINITE_CYCLES);

View file

@ -96,10 +96,12 @@ unit_animation::unit_animation(const std::string image )
unit_animation::unit_animation(const config& cfg,const std::string frame_string ):terrain_types(utils::split(cfg["terrain"])){
config::const_child_itors range = cfg.child_range(frame_string);
int last_end = INT_MIN;
for(; range.first != range.second; ++range.first) {
add_frame(atoi((**range.first)["begin"].c_str()), unit_frame(**range.first));
last_end = maximum<int>(atoi((**range.first)["end"].c_str()), last_end);
}
add_frame();
add_frame(last_end);
const std::vector<std::string>& my_directions = utils::split(cfg["direction"]);
for(std::vector<std::string>::const_iterator i = my_directions.begin(); i != my_directions.end(); ++i) {
@ -118,7 +120,7 @@ unit_animation::unit_animation(const std::string image, int begin_at, int end_at
{
add_frame(begin_at, unit_frame(image,image_diagonal,begin_at,end_at,0,0.0,ftofxp(1),halo,halo_x,halo_y));
if (end_at != begin_at) {
add_frame();
add_frame(end_at);
}
}