From d1c92918319afa943bbc0ced77765563f1fdf559 Mon Sep 17 00:00:00 2001 From: Chuck Miller Date: Sat, 1 Aug 2009 22:39:01 -0400 Subject: Fixes pickup items on eA, also cleaned up some code --- src/being.cpp | 15 ++++++--------- src/game.cpp | 5 +++++ 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index 5395f064..70be4ddb 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -172,16 +172,13 @@ void Being::setDestination(int dstX, int dstY) // FIXME: Look into making this code neater. // Interpolate the offsets. Also convert from tile based to pixel based - // Note: I divided the offsets by 32 then muilpied it back to get the top left - // Conner of where the tile is. (If you know a better way then please change it) - // Find the starting offset - int startX = srcX - ((srcX / 32) * 32 + 16); - int startY = srcY - ((srcY / 32) * 32 + 16); + int startX = (srcX % 32); + int startY = (srcY % 32); // Find the ending offset - int endX = dstX - ((dstX / 32) * 32 + 16); - int endY = dstY - ((dstY / 32) * 32 + 16); + int endX = (dstX % 32); + int endY = (dstY % 32); // Find the distance, and divide it by the number of steps int changeX = (endX - startX) / thisPath.size(); @@ -193,8 +190,8 @@ void Being::setDestination(int dstX, int dstY) int i = 0; while(it != thisPath.end()) { - it->x = (it->x * 32 + 16) + startX + (changeX * i); - it->y = (it->y * 32 + 16) + startY + (changeY * i); + it->x = (it->x * 32) + startX + (changeX * i); + it->y = (it->y * 32) + startY + (changeY * i); i++; it++; } diff --git a/src/game.cpp b/src/game.cpp index abb74b2a..f424ad50 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -759,9 +759,14 @@ void Game::handleInput() { case KeyboardConfig::KEY_PICKUP: { +#ifdef TMWSERV_SUPPORT const Vector &pos = player_node->getPosition(); Uint16 x = (int) pos.x / 32; Uint16 y = (int) pos.y / 32; +#else + Uint16 x = player_node->getTileX(); + Uint16 y = player_node->getTileY(); +#endif FloorItem *item = floorItemManager->findByCoordinates(x, y); -- cgit v1.2.3-60-g2f50