From 5b6ffbd361cdaa068389b4599f5028d64aed4356 Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Fri, 21 Sep 2012 23:45:59 +0000 Subject: [PATCH] again new morphing feature: better way to handle the blocked places for morphing units --- source/glest_game/type_instances/unit.cpp | 1 + source/glest_game/type_instances/unit.h | 5 +++++ source/glest_game/world/map.cpp | 9 +++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 688fe9d6..d58b083d 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -424,6 +424,7 @@ Unit::Unit(int id, UnitPathInterface *unitpath, const Vec2i &pos, this->ignoreCheckCommand = false; this->inBailOutAttempt = false; this->lastHarvestResourceTarget.first = Vec2i(0); + this->morphFieldsBlocked=false; //this->lastBadHarvestListPurge = 0; level= NULL; diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index 82595929..fd2c5a1d 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -345,6 +345,7 @@ private: int progress2; int kills; int enemyKills; + bool morphFieldsBlocked; UnitReference targetRef; @@ -562,6 +563,10 @@ public: inline void setCurrField(Field currField) {this->currField= currField;} void setCurrSkill(const SkillType *currSkill); void setCurrSkill(SkillClass sc); + + void setMorphFieldsBlocked ( bool value ) {this->morphFieldsBlocked=value;} + bool getMorphFieldsBlocked() const { return morphFieldsBlocked; } + inline void setLoadCount(int loadCount) {this->loadCount= loadCount;} inline void setLoadType(const ResourceType *loadType) {this->loadType= loadType;} inline void setProgress2(int progress2) {this->progress2= progress2;} diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index 025b7f6a..d29a1505 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -1390,9 +1390,8 @@ void Map::putUnitCells(Unit *unit, const Vec2i &pos, bool ignoreSkill) { Command *command= unit->getCurrCommand(); if(command != NULL && command->getCommandType()->commandTypeClass == ccMorph){ const MorphCommandType *mct= static_cast(command->getCommandType()); - if(unit->getType()->getSize()<=mct->getMorphUnit()->getSize()){ - putUnitCellsPrivate(unit, pos, mct->getMorphUnit(),true); - } + putUnitCellsPrivate(unit, pos, mct->getMorphUnit(),true); + unit->setMorphFieldsBlocked(true); } } } @@ -1490,12 +1489,14 @@ void Map::clearUnitCells(Unit *unit, const Vec2i &pos, bool ignoreSkill) { if(ignoreSkill==false && unit->getCurrSkill() != NULL && - unit->getCurrSkill()->getClass() == scMorph) { + unit->getCurrSkill()->getClass() == scMorph && + unit->getMorphFieldsBlocked() == true) { Command *command= unit->getCurrCommand(); const MorphCommandType *mct= static_cast(command->getCommandType()); if(unit->getType()->getSize()<=mct->getMorphUnit()->getSize()){ ut=mct->getMorphUnit(); currentField=ut->getField(); + unit->setMorphFieldsBlocked(false); } }