Skip to content

Commit

Permalink
Extensive cleanup of unit animation frame code
Browse files Browse the repository at this point in the history
The majority of which consists of code formatting, but also a few small semantic changes (tristate -> boost::tribool, etc).
  • Loading branch information
Vultraz committed Mar 2, 2017
1 parent a3c2f02 commit 42f087a
Show file tree
Hide file tree
Showing 4 changed files with 982 additions and 713 deletions.
8 changes: 4 additions & 4 deletions src/units/animation.cpp
Expand Up @@ -1084,10 +1084,10 @@ void unit_animation::redraw(frame_parameters& value, halo::manager& halo_man)
invalidated_ = false;
overlaped_hex_.clear();

value.primary_frame = t_true;
value.primary_frame = true;
unit_anim_.redraw(value,src_,dst_, halo_man);

value.primary_frame = t_false;
value.primary_frame = false;
for(auto& anim : sub_anims_) {
anim.second.redraw(value, src_, dst_, halo_man);
}
Expand All @@ -1111,9 +1111,9 @@ bool unit_animation::invalidate(frame_parameters& value)

if(overlaped_hex_.empty()) {
if(complete_redraw) {
value.primary_frame = t_true;
value.primary_frame = true;
overlaped_hex_ = unit_anim_.get_overlaped_hex(value, src_, dst_);
value.primary_frame = t_false;
value.primary_frame = false;

for(auto& anim : sub_anims_) {
std::set<map_location> tmp = anim.second.get_overlaped_hex(value, src_, dst_);
Expand Down
2 changes: 1 addition & 1 deletion src/units/drawer.cpp
Expand Up @@ -147,7 +147,7 @@ void unit_drawer::redraw_unit (const unit & u) const


if(u.incapacitated()) params.image_mod +="~GS()";
params.primary_frame = t_true;
params.primary_frame = true;


const frame_parameters adjusted_params = ac.anim_->get_current_params(params);
Expand Down

3 comments on commit 42f087a

@CelticMinstrel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the tristate isn't quite the same semantically as a tribool, since the third state is not technically an indeterminate state but rather a distinct value... but it should probably be fine as long as you don't try to do boolean operations on these tribools.

@Vultraz
Copy link
Member Author

@Vultraz Vultraz commented on 42f087a Mar 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CelticMinstrel actually, boost::tribool supports conversion to bool. true is true, while any other value is false. The old tristate functioned much the same way, only difference being the tristate_to_bool function accepted an argument for a retval if the tristate equaled t_unset. The single usecase defaulted to true in that case... which actually makes me realize I made a mistake here. Hang on :/

@CelticMinstrel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you misunderstood the complaint here. Basically, you've changed tristate to tribool, when the actual original semantic of tristate was optional<bool>. Both have three possible values, but the meaning of the third value is quite different.

Sure it'll work this way, but it might get someone confused later on.

Please sign in to comment.