diff --git a/source/glest_game/game/commander.cpp b/source/glest_game/game/commander.cpp index 44484aad..7826cd93 100644 --- a/source/glest_game/game/commander.cpp +++ b/source/glest_game/game/commander.cpp @@ -175,13 +175,15 @@ bool Commander::canSubmitCommandType(const Unit *unit, const CommandType *comman const MorphCommandType *mct = dynamic_cast(commandType); if(mct && unit->getCommandSize() > 0) { Command *cur_command= unit->getCurrCommand(); - const MorphCommandType *cur_mct= dynamic_cast(cur_command->getCommandType()); - if(cur_mct && unit->getCurrSkill()->getClass() == scMorph) { - const UnitType *morphUnitType = mct->getMorphUnit(); - const UnitType *cur_morphUnitType = cur_mct->getMorphUnit(); + if(cur_command != NULL) { + const MorphCommandType *cur_mct= dynamic_cast(cur_command->getCommandType()); + if(cur_mct && unit->getCurrSkill() && unit->getCurrSkill()->getClass() == scMorph) { + const UnitType *morphUnitType = mct->getMorphUnit(); + const UnitType *cur_morphUnitType = cur_mct->getMorphUnit(); - if(morphUnitType->getId() == cur_morphUnitType->getId()) { - canSubmitCommand = false; + if(morphUnitType != NULL && cur_morphUnitType != NULL && morphUnitType->getId() == cur_morphUnitType->getId()) { + canSubmitCommand = false; + } } } } diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index d740731d..3b04db7d 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -2559,6 +2559,31 @@ void Renderer::renderSelectionEffects() { } renderSelectionCircle(currVec, unit->getType()->getSize(), selectionCircleRadius); + if( showDebugUI == true && + (showDebugUILevel & debugui_unit_titles) == debugui_unit_titles) { + + const UnitPathInterface *path= unit->getPath(); + if(path != NULL) { + vector pathList = path->getQueue(); + + Vec2i lastPosValue; + for(int i = 0; i < pathList.size(); ++i) { + Vec2i curPosValue = pathList[i]; + if(i == 0) { + lastPosValue = curPosValue; + } + Vec3f currVec2 = unit->getVectorFlat(lastPosValue,curPosValue); + currVec2.y+= 0.3f; + renderSelectionCircle(currVec2, 1, selectionCircleRadius); + //renderSelectionCircle(currVec2, unit->getType()->getSize(), selectionCircleRadius); + + //SurfaceCell *cell= map->getSurfaceCell(currVec2.x, currVec2.y); + //currVec2.z = cell->getHeight() + 2.0; + //renderSelectionCircle(currVec2, unit->getType()->getSize(), selectionCircleRadius); + } + } + } + //magic circle if(world->getThisFactionIndex() == unit->getFactionIndex() && unit->getType()->getMaxEp() > 0) { glColor4f(unit->getEpRatio()/2.f, unit->getEpRatio(), unit->getEpRatio(), 0.5f); diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 7beda7cf..4192c317 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -668,7 +668,9 @@ Vec3f Unit::getCurrVector() const{ } Vec3f Unit::getCurrVectorFlat() const{ - Vec3f v; + return getVectorFlat(lastPos, pos); +/* + Vec3f v; float y1= computeHeight(lastPos); float y2= computeHeight(pos); @@ -686,6 +688,29 @@ Vec3f Unit::getCurrVectorFlat() const{ v.x+= type->getSize()/2.f-0.5f; v.z+= type->getSize()/2.f-0.5f; + return v; +*/ +} + +Vec3f Unit::getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const { + Vec3f v; + + float y1= computeHeight(lastPosValue); + float y2= computeHeight(curPosValue); + + if(currSkill->getClass() == scMove) { + v.x= lastPosValue.x + progress * (curPosValue.x-lastPosValue.x); + v.z= lastPosValue.y + progress * (curPosValue.y-lastPosValue.y); + v.y= y1+progress*(y2-y1); + } + else{ + v.x= static_cast(curPosValue.x); + v.z= static_cast(curPosValue.y); + v.y= y2; + } + v.x+= type->getSize()/2.f-0.5f; + v.z+= type->getSize()/2.f-0.5f; + return v; } diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index 7b4a5fdb..d4575b8d 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -399,6 +399,7 @@ public: Model *getCurrentModelPtr() const; Vec3f getCurrVector() const; Vec3f getCurrVectorFlat() const; + Vec3f getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) const; //command related bool anyCommand(bool validateCommandtype=false) const;