mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-23 22:40:25 +00:00
Remove some dead code (maybe a merge defect?)
* small formatting changes * small rearrange
This commit is contained in:
parent
1838041a37
commit
4476ee403b
@ -31,12 +31,13 @@ template<typename T>
|
||||
class animated
|
||||
{
|
||||
public:
|
||||
animated(int start_time = 0);
|
||||
virtual ~animated() {}
|
||||
|
||||
typedef std::pair<int, T> frame_description;
|
||||
typedef std::vector<frame_description> anim_description;
|
||||
animated(const std::vector<frame_description>& cfg, int start_time = 0, bool force_change = false);
|
||||
|
||||
animated(int start_time = 0);
|
||||
explicit animated(const std::vector<frame_description>& cfg, int start_time = 0, bool force_change = false);
|
||||
|
||||
virtual ~animated() = default;
|
||||
|
||||
/** Adds a frame to an animation. */
|
||||
void add_frame(int duration, const T& value, bool force_change = false);
|
||||
@ -107,10 +108,12 @@ public:
|
||||
|
||||
protected:
|
||||
friend class unit_animation;
|
||||
int starting_frame_time_;
|
||||
|
||||
void remove_frames_until(int starting_time);
|
||||
void set_end_time(int ending_time);
|
||||
|
||||
int starting_frame_time_;
|
||||
|
||||
private:
|
||||
struct frame
|
||||
{
|
||||
|
@ -78,12 +78,8 @@ inline void animated<T>::start_animation(int start_time, bool cycles)
|
||||
started_ = true;
|
||||
last_update_tick_ = get_current_animation_tick();
|
||||
acceleration_ = 1.0; // assume acceleration is 1, this will be fixed at first update_last_draw_time
|
||||
start_tick_ = last_update_tick_ + static_cast<int>((starting_frame_time_ - start_time) / acceleration_);
|
||||
|
||||
start_tick_ = last_update_tick_ + (starting_frame_time_ - start_time);
|
||||
cycles_ = cycles;
|
||||
if(acceleration_ <= 0) {
|
||||
acceleration_ = 1;
|
||||
}
|
||||
current_frame_key_ = 0;
|
||||
force_next_update_ = !frames_.empty();
|
||||
}
|
||||
@ -129,8 +125,9 @@ inline void animated<T>::update_last_draw_time(double acceleration)
|
||||
}
|
||||
}
|
||||
|
||||
if(get_current_frame_end_time() < get_animation_time() && // catch up
|
||||
get_current_frame_end_time() < get_end_time()) { // don't go after the end
|
||||
const int current_frame_end_time = get_current_frame_end_time();
|
||||
// catch up && don't go after the end
|
||||
if(current_frame_end_time < get_animation_time() && current_frame_end_time < get_end_time()) {
|
||||
current_frame_key_++;
|
||||
}
|
||||
}
|
||||
@ -223,7 +220,7 @@ inline int animated<T>::get_animation_time() const
|
||||
}
|
||||
|
||||
int time = tick_to_time(last_update_tick_);
|
||||
if (time > max_animation_time_ && max_animation_time_ > 0) {
|
||||
if(time > max_animation_time_ && max_animation_time_ > 0) {
|
||||
return max_animation_time_;
|
||||
}
|
||||
return time;
|
||||
@ -386,8 +383,8 @@ template<typename T>
|
||||
inline void animated<T>::set_end_time(int new_ending_time)
|
||||
{
|
||||
int last_start_time = starting_frame_time_;
|
||||
typename std::vector<frame>::iterator current_frame = frames_.begin();
|
||||
while(last_start_time < new_ending_time && current_frame != frames_.end()) {
|
||||
auto current_frame = frames_.cbegin();
|
||||
while(last_start_time < new_ending_time && current_frame != frames_.cend()) {
|
||||
last_start_time += current_frame->duration_;
|
||||
++current_frame;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user