From 45a36012861b6edfbfdec83afa9e935bfee54054 Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Mon, 20 Dec 2010 20:01:14 +0000 Subject: [PATCH] you can attack teammates again; fix for attack queuing, units don't walk to dead bodies if next attack command is in queue ; --- source/glest_game/game/game.cpp | 7 +++++++ source/glest_game/game/game.h | 2 ++ source/glest_game/world/unit_updater.cpp | 16 +++++++++++----- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 45105bac..78054dd3 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -58,6 +58,7 @@ Game::Game(Program *program, const GameSettings *gameSettings): lastRenderLog2d = 0; totalRenderFps = 0; + mouseMoved= false; quitTriggeredIndicator = false; originalDisplayMsgCallback = NULL; thisGamePtr = this; @@ -1029,6 +1030,11 @@ void Game::mouseDownRight(int x, int y){ } } + void Game::mouseUpCenter(int x, int y){ + if (!mouseMoved) gameCamera.resetPosition(); + else mouseMoved = false; +} + void Game::mouseUpLeft(int x, int y){ try { gui.mouseUpLeftGraphics(x, y); @@ -1085,6 +1091,7 @@ void Game::mouseMove(int x, int y, const MouseState *ms){ // gameCamera.moveForwardH((y - lastMousePos.y) * speed, response); // gameCamera.moveSideH((x - lastMousePos.x) * speed, response); //} else + mouseMoved = true; { //float ymult = Config::getInstance().getCameraInvertYAxis() ? -0.2f : 0.2f; //float xmult = Config::getInstance().getCameraInvertXAxis() ? -0.2f : 0.2f; diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index 75a428e8..7b1716db 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -86,6 +86,7 @@ private: bool gameOver; bool renderNetworkStatus; bool showFullConsole; + bool mouseMoved; float scrollSpeed; Speed speed; GraphicMessageBox mainMessageBox; @@ -147,6 +148,7 @@ public: virtual void keyPress(char c); virtual void mouseDownLeft(int x, int y); virtual void mouseDownRight(int x, int y); + virtual void mouseUpCenter(int x, int y); virtual void mouseUpLeft(int x, int y); virtual void mouseDoubleClickLeft(int x, int y); virtual void eventMouseWheel(int x, int y, int zDelta); diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 3dbbbbed..b10b9f69 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -389,6 +389,12 @@ void UnitUpdater::updateAttack(Unit *unit) { if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + + if(command->getUnit()!=NULL && !command->getUnit()->isAlive() && unit->getCommandSize()>1) + {// don't run over to dead body if there is still something to do in the queue + unit->finishCommand(); + } + else { //if unit arrives destPos order has ended switch (tsValue){ case tsMoving: @@ -402,7 +408,8 @@ void UnitUpdater::updateAttack(Unit *unit) { default: unit->finishCommand(); } - + } + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } @@ -1755,7 +1762,7 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr, //attack enemies that can attack first for(int i = 0; i< enemies.size(); ++i) { - if(enemies[i]->getType()->hasSkillClass(scAttack) && enemies[i]->isAlive() == true && !(unit->isAlly(enemies[i]))) { + if(enemies[i]->getType()->hasSkillClass(scAttack) && enemies[i]->isAlive() == true ) { *rangedPtr= enemies[i]; enemySeen=enemies[i]; result=true; @@ -1765,7 +1772,7 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr, //any enemy for(int i = 0; i< enemies.size(); ++i) { - if(enemies[i]->isAlive() == true && !(unit->isAlly(enemies[i]))) { + if(enemies[i]->isAlive() == true ) { *rangedPtr= enemies[i]; enemySeen=enemies[i]; result=true; @@ -1773,9 +1780,8 @@ bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr, } } - if(result) + if(result && !(unit->isAlly(enemySeen))) { - if(world->getFrameCount()-lastWarnFrameCount>100) //after 100 frames attack break we warn again { world->addAttackEffects(enemySeen);