From 001a6393499708fe4c64e2376885c7e0c33036e8 Mon Sep 17 00:00:00 2001 From: Dominic Bolin Date: Wed, 9 Aug 2006 18:12:31 +0000 Subject: [PATCH] Do not serialize detailed unit description, unless it has changed. --- src/unit.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/unit.cpp b/src/unit.cpp index cd211d5bed4..cfe6b8c25f5 100644 --- a/src/unit.cpp +++ b/src/unit.cpp @@ -1149,9 +1149,15 @@ void unit::read(const config& cfg) } std::map::const_iterator uti = gamedata_->unit_types.find(cfg["type"]); + const unit_type* ut = NULL; + if(uti != gamedata_->unit_types.end()) { + ut = &uti->second.get_gender_unit_type(gender_).get_variation(variation_); + } if(!type_set) { - if(uti != gamedata_->unit_types.end()) { - const unit_type* ut = &uti->second.get_gender_unit_type(gender_).get_variation(variation_); + if(ut) { + if(cfg_["unit_description"] == "") { + cfg_["unit_description"] = ut->unit_description(); + } config t_atks; config u_atks; config::const_child_itors range; @@ -1249,8 +1255,7 @@ void unit::read(const config& cfg) } if(!type_set) { - if(uti != gamedata_->unit_types.end()) { - const unit_type* ut = &uti->second.get_gender_unit_type(gender_).get_variation(variation_); + if(ut) { defensive_animations_ = ut->defensive_animations_; teleport_animations_ = ut->teleport_animations_; extra_animations_ = ut->extra_animations_; @@ -1360,6 +1365,14 @@ void unit::write(config& cfg) const cfg["y"] = y; cfg["id"] = id(); cfg["type"] = id(); + std::map::const_iterator uti = gamedata_->unit_types.find(id()); + const unit_type* ut = NULL; + if(uti != gamedata_->unit_types.end()) { + ut = &uti->second.get_gender_unit_type(gender_).get_variation(variation_); + } + if(ut && cfg["unit_description"] == ut->unit_description()) { + cfg["unit_description"] = ""; + } std::stringstream hp; hp << hit_points_;