From ec3c689c64922baf4a9f99bc6e9345e0a80403e8 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Wed, 22 Jun 2011 18:51:36 +0200 Subject: Applied fixes requested by cody. - Made the map teleport distance fixed for manaserv. - Small cleanups. The branch is considered reviewed by: Cody. Resolves Mana-Mantis: #74. --- src/being.cpp | 4 ++-- src/localplayer.cpp | 8 ++++---- src/map.cpp | 6 +++--- src/net/manaserv/playerhandler.cpp | 8 +++----- src/net/tmwa/charserverhandler.cpp | 4 ++-- src/net/tmwa/gamehandler.cpp | 4 ++-- src/net/tmwa/playerhandler.cpp | 2 +- 7 files changed, 17 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index 69c233f2..42043313 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -196,8 +196,8 @@ void Being::setDestination(int dstX, int dstY) return; // If the destination is unwalkable, don't bother trying to get there - int tileWidth = mMap->getTileWidth(); - int tileHeight = mMap->getTileHeight(); + const int tileWidth = mMap->getTileWidth(); + const int tileHeight = mMap->getTileHeight(); if (!mMap->getWalk(dstX / tileWidth, dstY / tileHeight)) return; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index d9eb3f1f..f941dd5f 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -213,12 +213,12 @@ Position LocalPlayer::getNextWalkPosition(unsigned char dir) if (!mMap || (!dx && !dy)) return Position((int)pos.x, (int)pos.y); - int tileW = mMap->getTileWidth(); - int tileH = mMap->getTileHeight(); + const int tileW = mMap->getTileWidth(); + const int tileH = mMap->getTileHeight(); // Get the current tile pos and its offset - int tileX = (int)pos.x / tileW; - int tileY = (int)pos.y / tileH; + const int tileX = (int)pos.x / tileW; + const int tileY = (int)pos.y / tileH; int offsetX = (int)pos.x % tileW; int offsetY = (int)pos.y % tileH; diff --git a/src/map.cpp b/src/map.cpp index e47e5b7a..3f1f9167 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -711,7 +711,7 @@ Position Map::checkNodeOffsets(int radius, unsigned char walkMask, && fy > (mTileHeight - radius) && fx > (mTileWidth - radius)) { fx = mTileWidth - radius; - fy = mTileHeight -radius; + fy = mTileHeight - radius; } // Fix coordinates so that the player does not seem to dig into walls. @@ -805,9 +805,9 @@ Path Map::findPath(int startX, int startY, int destX, int destY, unsigned char walkmask, int maxCost) { // The basic walking cost of a tile. - static const int basicCost = 100; + const int basicCost = 100; // Used to compute the path G cost for diagonal moves. - static const int GCOST_SQRT2 = 362 / 256; + const int GCOST_SQRT2 = 362 / 256; // Path to be built up (empty by default) Path path; diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index ec71143f..a114da3d 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -50,7 +50,7 @@ * everything beyond will reset the port hard. * @todo: Make this parameter read from config. */ -static const int MAP_TELEPORT_SCROLL_DISTANCE = 8; +const int MAP_TELEPORT_SCROLL_DISTANCE = 256; extern Net::PlayerHandler *playerHandler; @@ -297,10 +297,8 @@ void PlayerHandler::handleMapChangeMessage(Net::MessageIn &msg) /* Scroll if neccessary */ if (!sameMap - || (abs(x - (int) playerPos.x) > MAP_TELEPORT_SCROLL_DISTANCE - * game->getCurrentTileWidth()) - || (abs(y - (int) playerPos.y) > MAP_TELEPORT_SCROLL_DISTANCE - * game->getCurrentTileHeight())) + || (abs(x - (int) playerPos.x) > MAP_TELEPORT_SCROLL_DISTANCE) + || (abs(y - (int) playerPos.y) > MAP_TELEPORT_SCROLL_DISTANCE)) { scrollOffsetX = x - (int) playerPos.x; scrollOffsetY = y - (int) playerPos.y; diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index dcc68fb3..1df84b84 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -186,8 +186,8 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) mNetwork->disconnect(); Client::setState(STATE_CHANGE_MAP); Map *map = player_node->getMap(); - int tileWidth = map->getTileWidth(); - int tileHeight = map->getTileHeight(); + const int tileWidth = map->getTileWidth(); + const int tileHeight = map->getTileHeight(); player_node->setPosition(Vector(x * tileWidth + tileWidth / 2, y * tileHeight + tileHeight / 2)); player_node->setMap(0); diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index 8ba2e200..6430b476 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -109,8 +109,8 @@ void GameHandler::event(Event::Channel channel, const Event &event) Game *game = Game::instance(); game->changeMap(mMap); Map *map = game->getCurrentMap(); - int tileWidth = map->getTileWidth(); - int tileHeight = map->getTileHeight(); + const int tileWidth = map->getTileWidth(); + const int tileHeight = map->getTileHeight(); if (mTileX && mTileY) { player_node->setPosition(Vector(mTileX * tileWidth + tileWidth / 2, diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index ab63cc1d..f30baecd 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -50,7 +50,7 @@ extern OkDialog *deathNotice; // Max. distance we are willing to scroll after a teleport; // everything beyond will reset the port hard. -static const int MAP_TELEPORT_SCROLL_DISTANCE = 8; +const int MAP_TELEPORT_SCROLL_DISTANCE = 8; // TODO Move somewhere else namespace { -- cgit v1.2.3-60-g2f50