diff options
author | Roderic Morris <roderic@ccs.neu.edu> | 2008-10-24 00:28:05 +0000 |
---|---|---|
committer | Roderic Morris <roderic@ccs.neu.edu> | 2008-10-24 00:28:05 +0000 |
commit | 0b2235dfff7f7c0f534746271ff66275297fd328 (patch) | |
tree | 27d0ed8f487ccf7793606f20d8ce5d9814343efd | |
parent | afa57ceea0df1ce1ca494d7794e2f6542befc214 (diff) | |
download | mana-0b2235dfff7f7c0f534746271ff66275297fd328.tar.gz mana-0b2235dfff7f7c0f534746271ff66275297fd328.tar.bz2 mana-0b2235dfff7f7c0f534746271ff66275297fd328.tar.xz mana-0b2235dfff7f7c0f534746271ff66275297fd328.zip |
fixes for targetting (by Chuck Miller)
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/beingmanager.cpp | 6 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 19 | ||||
-rw-r--r-- | src/main.cpp | 6 |
4 files changed, 23 insertions, 15 deletions
@@ -1,3 +1,10 @@ +2008-10-23 Chuck Miller <shadowmil@gmail.com> + + * src/beingmanager.cpp: Fixed a bug causing targets not to work, and + added code that sets player_node's target to null if it gets deleted + * src/gui/viewport.cpp: Changed some values to make targets show + correctly + 2008-10-23 Bjørn Lindeijer <bjorn@lindeijer.nl> * src/Makefile.am: Fixed building with configure. diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index abb23f5e..22b3de9b 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -89,6 +89,8 @@ Being* BeingManager::createBeing(int id, int type, int subtype) void BeingManager::destroyBeing(Being *being) { mBeings.remove(being); + if(being == player_node->getTarget()) + player_node->setTarget(NULL); delete being; } @@ -179,7 +181,7 @@ Being* BeingManager::findNearestLivingBeing(Uint16 x, Uint16 y, int maxdist, } } - return (maxdist >= dist) ? closestBeing : NULL; + return (maxdist >= dist) ? NULL : closestBeing; } Being* BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxdist, @@ -207,5 +209,5 @@ Being* BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxdist, } } - return (maxdist >= dist) ? closestBeing : NULL; + return (maxdist >= dist) ? NULL : closestBeing; } diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 80dcf489..d086418f 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -298,18 +298,15 @@ void Viewport::drawTargetCursor(Graphics *graphics) Being::TargetCursorSize cursorSize = target->getTargetCursorSize(); Image* targetCursor; if (rangeX > attackRange || rangeY > attackRange) - { - targetCursor = mTargetCursorOutRange[cursorSize]->getCurrentImage(); - } - else { - targetCursor = mTargetCursorInRange[cursorSize]->getCurrentImage(); - } + targetCursor = mTargetCursorOutRange[cursorSize]->getCurrentImage(); + else + targetCursor = mTargetCursorInRange[cursorSize]->getCurrentImage(); // Draw the target cursor at the correct position - int posX = target->getPixelX() + 16 - - targetCursor->getWidth() / 2 - (int) mViewX; - int posY = target->getPixelY() + 16 - - targetCursor->getHeight() / 2 - (int) mViewY; + int posX = target->getPixelX() - + targetCursor->getWidth() / 2 - (int) mViewX; + int posY = target->getPixelY() - 16 - + targetCursor->getHeight() / 2 - (int) mViewY; graphics->drawImage(targetCursor, posX, posY); } @@ -325,7 +322,7 @@ void Viewport::drawTargetName(Graphics *graphics) graphics->setColor(gcn::Color(255, 32, 32)); const MonsterInfo &mi = static_cast<Monster*>(target)->getInfo(); - int posX = target->getPixelX() + 16 - (int) mViewX; + int posX = target->getPixelX() - (int) mViewX; int posY = target->getPixelY() + 16 - target->getHeight() - (int) mViewY; graphics->drawText(mi.getName(), posX, posY, gcn::Graphics::CENTER); diff --git a/src/main.cpp b/src/main.cpp index 59c7f74f..628ad8dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -798,8 +798,10 @@ int main(int argc, char *argv[]) while (state != STATE_FORCE_QUIT) { // Handle SDL events - while (SDL_PollEvent(&event)) { - switch (event.type) { + while (SDL_PollEvent(&event)) + { + switch (event.type) + { case SDL_QUIT: state = STATE_FORCE_QUIT; break; |