- added more code guards around morph validation

- some render debug info
This commit is contained in:
Mark Vejvoda 2011-02-11 04:48:17 +00:00
parent 2d76d348c7
commit 7cae047f15
4 changed files with 60 additions and 7 deletions

View File

@ -175,13 +175,15 @@ bool Commander::canSubmitCommandType(const Unit *unit, const CommandType *comman
const MorphCommandType *mct = dynamic_cast<const MorphCommandType*>(commandType);
if(mct && unit->getCommandSize() > 0) {
Command *cur_command= unit->getCurrCommand();
const MorphCommandType *cur_mct= dynamic_cast<const MorphCommandType*>(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<const MorphCommandType*>(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;
}
}
}
}

View File

@ -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<Vec2i> 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);

View File

@ -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<float>(curPosValue.x);
v.z= static_cast<float>(curPosValue.y);
v.y= y2;
}
v.x+= type->getSize()/2.f-0.5f;
v.z+= type->getSize()/2.f-0.5f;
return v;
}

View File

@ -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;