summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-03-28 20:37:05 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-03-28 20:37:05 +0200
commite7e550c863c3bb5d5e8697ecce1ea37ad248e362 (patch)
tree3928fa5a167a0bd3975a6c889775bc4ddea195a2 /src
parent25bfbc30fb4958a3a754d74bbe971dec717f831c (diff)
downloadmana-e7e550c863c3bb5d5e8697ecce1ea37ad248e362.tar.gz
mana-e7e550c863c3bb5d5e8697ecce1ea37ad248e362.tar.bz2
mana-e7e550c863c3bb5d5e8697ecce1ea37ad248e362.tar.xz
mana-e7e550c863c3bb5d5e8697ecce1ea37ad248e362.zip
Random code cleanups requested righteously by Thorbjorn - part 1.
- Fixed bogus documentation. - Fixed Vector parameters to const Vector& where releavant. - Removed a false comment. - Removed superfluous headers in src/net/tmwa/beinghandler.h. - Optimize a bit the tmwa::beingHandler::getPixelsPerTickMoveSpeed() function.
Diffstat (limited to 'src')
-rw-r--r--src/actorsprite.cpp1
-rw-r--r--src/being.cpp2
-rw-r--r--src/being.h8
-rw-r--r--src/net/manaserv/playerhandler.cpp17
-rw-r--r--src/net/manaserv/playerhandler.h4
-rw-r--r--src/net/playerhandler.h7
-rw-r--r--src/net/tmwa/beinghandler.h3
-rw-r--r--src/net/tmwa/playerhandler.cpp21
-rw-r--r--src/net/tmwa/playerhandler.h4
9 files changed, 29 insertions, 38 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 0b1dfd39..b2f921cd 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -71,7 +71,6 @@ bool ActorSprite::draw(Graphics *graphics, int offsetX, int offsetY) const
// these translations aren't necessary anymore. The sprites know
// best where their base point should be.
const int px = getPixelX() + offsetX - 16;
- // Temporary fix to the Y offset.
const int py = getPixelY() + offsetY - 16;
if (mUsedTargetCursor)
diff --git a/src/being.cpp b/src/being.cpp
index 7429a95d..36646006 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -167,7 +167,7 @@ Map::BlockType Being::getBlockType() const
return mInfo->getBlockType();
}
-void Being::setMoveSpeed(Vector speed)
+void Being::setMoveSpeed(const Vector &speed)
{
mMoveSpeed = speed;
// If we already can, recalculate the system speed right away.
diff --git a/src/being.h b/src/being.h
index fcd2b8f8..f19e3df4 100644
--- a/src/being.h
+++ b/src/being.h
@@ -310,9 +310,9 @@ class Being : public ActorSprite, public Mana::Listener
/**
* Sets the move speed.
* in ticks per tile for eAthena,
- * in tiles per second for Manaserv.
+ * in tiles per second for Manaserv (0.1 precision).
*/
- void setMoveSpeed(Vector speed);
+ void setMoveSpeed(const Vector &speed);
/**
* Gets the original Move speed.
@@ -522,13 +522,13 @@ class Being : public ActorSprite, public Mana::Listener
/**
* Walk speed for x and y movement values.
* In ticks per tile for eAthena,
- * In pixels per ticks for Manaserv.
- * @see MILLISECONDS_IN_A_TICK
+ * In pixels per second for Manaserv.
*/
Vector mMoveSpeed;
/**
* Being speed in pixel per ticks. Used internally for the being logic.
+ * @see MILLISECONDS_IN_A_TICK
*/
Vector mSpeedPixelsPerTick;
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 38eb2678..317481ab 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -412,16 +412,18 @@ int PlayerHandler::getJobLocation()
return -1;
}
-Vector PlayerHandler::getDefaultMoveSpeed()
+Vector PlayerHandler::getDefaultMoveSpeed() const
{
// Return default speed at 6 tiles per second.
return Vector(6.0f, 6.0f, 0.0f);
}
-Vector PlayerHandler::getPixelsPerTickMoveSpeed(Vector speed, Map *map)
+Vector PlayerHandler::getPixelsPerTickMoveSpeed(const Vector &speed, Map *map)
{
// We don't use z for now.
- speed.z = 0;
+ Vector speedInTicks;
+ // speedInTicks.x = speedInTicks.y = speedInTicks.z = 0;
+ // ^ Done by constructor
Game *game = Game::instance();
if (game && !map)
@@ -431,18 +433,17 @@ Vector PlayerHandler::getPixelsPerTickMoveSpeed(Vector speed, Map *map)
{
logger->log("Manaserv::PlayerHandler: Speed wasn't given back"
" because Map not initialized.");
- speed.x = speed.y = 0;
- return speed;
+ return speedInTicks;
}
- speed.x = speed.x
+ speedInTicks.x = speed.x
* (float)map->getTileWidth()
/ 1000 * (float) MILLISECONDS_IN_A_TICK;
- speed.y = speed.y
+ speedInTicks.y = speed.y
* (float)map->getTileHeight()
/ 1000 * (float) MILLISECONDS_IN_A_TICK;
- return speed;
+ return speedInTicks;
}
} // namespace ManaServ
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index 8bba1580..3e3f8aad 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -65,9 +65,9 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
int getJobLocation();
- Vector getDefaultMoveSpeed();
+ Vector getDefaultMoveSpeed() const;
- Vector getPixelsPerTickMoveSpeed(Vector speed, Map *map = 0);
+ Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = 0);
bool usePixelPrecision()
{ return true; }
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 5d94a093..f9396caf 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -66,14 +66,15 @@ class PlayerHandler
* Get the original default movement speed.
* Example:
* In ticks per tiles for eAthena
- * In pixels per second for Manaserv
+ * In tiles per second for Manaserv
*/
- virtual Vector getDefaultMoveSpeed() = 0;
+ virtual Vector getDefaultMoveSpeed() const = 0;
/**
* Convert the original speed in pixel per tick for internal use.
*/
- virtual Vector getPixelsPerTickMoveSpeed(Vector speed, Map *map = 0) = 0;
+ virtual Vector getPixelsPerTickMoveSpeed(const Vector &speed,
+ Map *map = 0) = 0;
/**
* Tells whether the client has to use pixel paths.
diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h
index 32b4a7bd..ab833af0 100644
--- a/src/net/tmwa/beinghandler.h
+++ b/src/net/tmwa/beinghandler.h
@@ -22,9 +22,6 @@
#ifndef NET_TA_BEINGHANDLER_H
#define NET_TA_BEINGHANDLER_H
-#include "vector.h"
-
-#include "net/net.h"
#include "net/tmwa/messagehandler.h"
namespace TmwAthena {
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index 9210de6e..9d97dc73 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -615,7 +615,7 @@ int PlayerHandler::getJobLocation()
return JOB;
}
-Vector PlayerHandler::getDefaultMoveSpeed()
+Vector PlayerHandler::getDefaultMoveSpeed() const
{
// Return an normalized speed for any side
// as the offset is calculated elsewhere.
@@ -623,30 +623,23 @@ Vector PlayerHandler::getDefaultMoveSpeed()
return Vector(15.0f, 15.0f, 0.0f);
}
-Vector PlayerHandler::getPixelsPerTickMoveSpeed(Vector speed, Map *map)
+Vector PlayerHandler::getPixelsPerTickMoveSpeed(const Vector &speed, Map *map)
{
Game *game = Game::instance();
if (game && !map)
map = game->getCurrentMap();
- if (!map)
+ if (!map || speed.x == 0 || speed.y == 0)
{
- logger->log("TmwAthena::PlayerHandler: Speed not given back"
- " because Map not yet initialized.");
- return Vector(0.0f, 0.0f, 0.0f);
- }
-
- if (speed.x == 0 || speed.y == 0)
- {
- logger->log("TmwAthena::PlayerHandler: "
- "Invalid Speed given from server.");
- speed = getDefaultMoveSpeed();
+ logger->log("TmwAthena::PlayerHandler: Speed set to default: "
+ "Map not yet initialized or invalid speed.");
+ return getDefaultMoveSpeed();
}
Vector speedInTicks;
- speedInTicks.z = 0; // We don't use z for now.
+ // speedInTicks.z = 0; // We don't use z for now.
speedInTicks.x = 1 / speed.x * (float)map->getTileWidth();
speedInTicks.y = 1 / speed.y * (float)map->getTileHeight();
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index 42eb85f2..63812f47 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/playerhandler.h
@@ -58,9 +58,9 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
int getJobLocation();
- Vector getDefaultMoveSpeed();
+ Vector getDefaultMoveSpeed() const;
- Vector getPixelsPerTickMoveSpeed(Vector speed, Map *map = 0);
+ Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = 0);
bool usePixelPrecision()
{ return false; }