fix bug #10836 Standing animations stay accelerated after releasing SHIFT key
This commit is contained in:
parent
673df7e664
commit
7b101e6b6f
4 changed files with 25 additions and 12 deletions
|
@ -15,6 +15,7 @@ Version 1.3.15+svn:
|
|||
* Moved destruction of conditional object before the mutex. This should
|
||||
fix random crash in network disconnect.
|
||||
* Fixed reference to invalid pointer in attack::attack
|
||||
* pressing shift affects acceleration immediately
|
||||
|
||||
Version 1.3.15:
|
||||
* language and i18n:
|
||||
|
|
|
@ -59,8 +59,9 @@ public:
|
|||
int get_end_time() const;
|
||||
|
||||
int time_to_tick(int animation_time) const;
|
||||
int tick_to_time(int animation_tick) const;
|
||||
|
||||
void update_last_draw_time();
|
||||
void update_last_draw_time(double acceleration = 0);
|
||||
bool need_update() const;
|
||||
|
||||
bool cycles() const {return cycles_;};
|
||||
|
|
|
@ -95,11 +95,11 @@ void animated<T,T_void_value>::start_animation(int start_time, bool cycles, doub
|
|||
{
|
||||
started_ = true;
|
||||
last_update_tick_ = current_ticks;
|
||||
acceleration_ = acceleration;
|
||||
start_tick_ = last_update_tick_ +
|
||||
static_cast<int>(( starting_frame_time_ - start_time)/acceleration);
|
||||
static_cast<int>(( starting_frame_time_ - start_time)/acceleration_);
|
||||
|
||||
cycles_ = cycles;
|
||||
acceleration_ = acceleration;
|
||||
if(acceleration_ <=0) acceleration_ = 1;
|
||||
current_frame_key_= 0;
|
||||
need_first_update_ = !frames_.empty();
|
||||
|
@ -107,8 +107,13 @@ void animated<T,T_void_value>::start_animation(int start_time, bool cycles, doub
|
|||
|
||||
|
||||
template<typename T, typename T_void_value>
|
||||
void animated<T,T_void_value>::update_last_draw_time()
|
||||
void animated<T,T_void_value>::update_last_draw_time(double acceleration)
|
||||
{
|
||||
if (acceleration > 0 && acceleration_ != acceleration) {
|
||||
int tmp = tick_to_time(start_tick_);
|
||||
acceleration_ = acceleration;
|
||||
start_tick_ = time_to_tick(tmp);
|
||||
}
|
||||
last_update_tick_ = current_ticks;
|
||||
if (need_first_update_) {
|
||||
need_first_update_ = false;
|
||||
|
@ -171,8 +176,7 @@ bool animated<T,T_void_value>::animation_would_finish() const
|
|||
return true;
|
||||
if(cycles_ )
|
||||
return true;
|
||||
if(((static_cast<double>(current_ticks - start_tick_) *
|
||||
acceleration_) + starting_frame_time_) > get_end_time())
|
||||
if(tick_to_time(current_ticks) > get_end_time())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -197,9 +201,7 @@ int animated<T,T_void_value>::get_animation_time() const
|
|||
{
|
||||
if(!started_ ) return starting_frame_time_;
|
||||
|
||||
return static_cast<int>(
|
||||
(static_cast<double>(last_update_tick_ - start_tick_) *
|
||||
acceleration_) + starting_frame_time_);
|
||||
return tick_to_time(last_update_tick_);
|
||||
}
|
||||
|
||||
template<typename T, typename T_void_value>
|
||||
|
@ -284,6 +286,14 @@ int animated<T,T_void_value>::time_to_tick(int animation_time) const
|
|||
return start_tick_ + static_cast<int>(animation_time/acceleration_);
|
||||
}
|
||||
template<typename T, typename T_void_value>
|
||||
int animated<T,T_void_value>::tick_to_time(int animation_tick) const
|
||||
{
|
||||
if(!started_) return 0;
|
||||
return static_cast<int>(
|
||||
(static_cast<double>(animation_tick - start_tick_) *
|
||||
acceleration_) + starting_frame_time_);
|
||||
}
|
||||
template<typename T, typename T_void_value>
|
||||
int animated<T,T_void_value>::get_end_time() const
|
||||
{
|
||||
if(frames_.empty())
|
||||
|
|
|
@ -603,10 +603,10 @@ bool unit_animation::animation_would_finish() const
|
|||
|
||||
void unit_animation::update_last_draw_time()
|
||||
{
|
||||
unit_anim_.update_last_draw_time();
|
||||
unit_anim_.update_last_draw_time(game_display::get_singleton()->turbo_speed());
|
||||
std::map<std::string,crude_animation>::iterator anim_itor =sub_anims_.begin();
|
||||
for( /*null*/; anim_itor != sub_anims_.end() ; anim_itor++) {
|
||||
anim_itor->second.update_last_draw_time();
|
||||
anim_itor->second.update_last_draw_time(game_display::get_singleton()->turbo_speed());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -663,7 +663,7 @@ void unit_animation::crude_animation::redraw()
|
|||
double tmp_offset = offset();
|
||||
int d2 = game_display::get_singleton()->hex_size() / 2;
|
||||
|
||||
update_last_draw_time();
|
||||
update_last_draw_time(game_display::get_singleton()->turbo_speed());
|
||||
const unit_frame& current_frame= get_current_frame();
|
||||
if(get_current_frame_begin_time() != last_frame_begin_time_ ) {
|
||||
// stuff sthat should be done only once per frame
|
||||
|
@ -845,6 +845,7 @@ void unit_animator::wait_until(int animation_time) const
|
|||
int end_tick = animated_units_[0].my_unit->get_animation()->time_to_tick(animation_time);
|
||||
while (SDL_GetTicks() < (unsigned int)end_tick - 20*disp->turbo_speed()) {
|
||||
disp->draw();
|
||||
end_tick = animated_units_[0].my_unit->get_animation()->time_to_tick(animation_time);
|
||||
events::pump();
|
||||
disp->delay(maximum<int>(0,
|
||||
minimum<int>(10,
|
||||
|
|
Loading…
Add table
Reference in a new issue