From 98351fedbaad7b74b6aae263b7a9fd3da922b0f2 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sun, 25 Mar 2012 20:38:05 +0000 Subject: [PATCH] - bugfix when morphing, do a level check to see if the morphed unit should have its level updated based on current kills --- source/glest_game/type_instances/unit.cpp | 9 ++++++++- source/glest_game/type_instances/unit.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 79e0a4ed..3c74bcef 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -2636,6 +2636,10 @@ void Unit::incKills(int team) { ++enemyKills; } + checkUnitLevel(); +} + +void Unit::checkUnitLevel() { const Level *nextLevel= getNextLevel(); if(nextLevel != NULL && enemyKills >= nextLevel->getKills()) { level= nextLevel; @@ -2680,13 +2684,16 @@ bool Unit::morph(const MorphCommandType *mct){ checkModelStateInfoForNewHpValue(); type= morphUnitType; - level= NULL; currField=morphUnitField; computeTotalUpgrade(); map->putUnitCells(this, pos); faction->applyDiscount(morphUnitType, mct->getDiscount()); faction->addStore(type); faction->applyStaticProduction(morphUnitType); + + level= NULL; + checkUnitLevel(); + return true; } else{ diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index a184bc7c..458766f9 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -659,6 +659,7 @@ private: int getFrameCount() const; void checkCustomizedParticleTriggers(bool force); bool checkModelStateInfoForNewHpValue(); + void checkUnitLevel(); }; }}// end namespace