Skip to content

Commit

Permalink
Unit: serialize hidden= attribute
Browse files Browse the repository at this point in the history
This allows units hidden with [hide_unit] to remain hidden after reloading a save.
  • Loading branch information
Vultraz committed Feb 11, 2018
1 parent 7e00c61 commit 298b448
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog
Expand Up @@ -95,6 +95,7 @@ Version 1.13.11:
the variable, which may be either a scalar or a container.
* A missing [event] name= key will now raise a WML error instead of being
silently ignored.
* Units hidden with [hide_unit] will remain hidden after reloading saves.
* Miscellaneous and bug fixes:
* Suggested save file names now use spaces instead of underscores.
* Fixed crash after canceling add-on download (bug #2203)
Expand Down
4 changes: 3 additions & 1 deletion src/units/unit.cpp
Expand Up @@ -385,7 +385,7 @@ unit::unit(const config& cfg, bool use_traits, const vconfig* vcfg)
, modification_descriptions_()
, anim_comp_(new unit_animation_component(*this))
, getsHit_(0)
, hidden_(false)
, hidden_(cfg["hidden"].to_bool(false))
, hp_bar_scaling_(cfg["hp_bar_scaling"].blank() ? type_->hp_bar_scaling() : cfg["hp_bar_scaling"])
, xp_bar_scaling_(cfg["xp_bar_scaling"].blank() ? type_->xp_bar_scaling() : cfg["xp_bar_scaling"])
, modifications_()
Expand Down Expand Up @@ -1492,6 +1492,8 @@ void unit::write(config& cfg) const
cfg["max_attacks"] = max_attacks_;
cfg["zoc"] = emit_zoc_;

cfg["hidden"] = hidden_;

cfg.clear_children("attack");
for(attack_ptr i : attacks_) {
i->write(cfg.add_child("attack"));
Expand Down

0 comments on commit 298b448

Please sign in to comment.