diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-01-09 12:09:01 +0100 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-01-09 12:09:01 +0100 |
commit | 8ff3e6674c1d4fc05fc1ba87f42484689fca0879 (patch) | |
tree | 0c05e984fe61d9e28e9bf014d6b4a70645d27a7e /src | |
parent | 57701ac70f2b81e11eedb4c01f680e46c1abadb2 (diff) | |
download | manaserv-8ff3e6674c1d4fc05fc1ba87f42484689fca0879.tar.gz manaserv-8ff3e6674c1d4fc05fc1ba87f42484689fca0879.tar.bz2 manaserv-8ff3e6674c1d4fc05fc1ba87f42484689fca0879.tar.xz manaserv-8ff3e6674c1d4fc05fc1ba87f42484689fca0879.zip |
Removed the superfluous point struct.
It was too close from the Position class and it leads to
making the server handle one or another type through the
code. Still bugged me many times while making changes.
Reviewed-by: Jaxad.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/account-server/accounthandler.cpp | 2 | ||||
-rw-r--r-- | src/account-server/character.h | 2 | ||||
-rw-r--r-- | src/account-server/storage.cpp | 5 | ||||
-rw-r--r-- | src/game-server/actor.h | 2 | ||||
-rw-r--r-- | src/game-server/being.cpp | 5 | ||||
-rw-r--r-- | src/game-server/collisiondetection.cpp | 2 | ||||
-rw-r--r-- | src/game-server/map.cpp | 4 | ||||
-rw-r--r-- | src/game-server/map.h | 16 | ||||
-rw-r--r-- | src/game-server/mapcomposite.cpp | 2 | ||||
-rw-r--r-- | src/game-server/spawnarea.h | 2 | ||||
-rw-r--r-- | src/game-server/state.cpp | 2 | ||||
-rw-r--r-- | src/game-server/trigger.h | 2 | ||||
-rw-r--r-- | src/serialize/characterdata.h | 2 | ||||
-rw-r--r-- | src/utils/point.h (renamed from src/point.h) | 18 |
15 files changed, 29 insertions, 39 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0ab2272d..cf04d397 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -102,7 +102,6 @@ MARK_AS_ADVANCED(PHYSFS_LIBRARY) SET(SRCS defines.h manaserv_protocol.h - point.h common/configuration.h common/configuration.cpp common/inventorydata.h @@ -123,6 +122,7 @@ SET(SRCS serialize/characterdata.h utils/logger.h utils/logger.cpp + utils/point.h utils/processorutils.h utils/processorutils.cpp utils/string.h diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp index 22deafa3..9948f1ea 100644 --- a/src/account-server/accounthandler.cpp +++ b/src/account-server/accounthandler.cpp @@ -21,7 +21,6 @@ #include "account-server/accounthandler.h" #include "manaserv_protocol.h" -#include "point.h" #include "account-server/account.h" #include "account-server/accountclient.h" #include "account-server/character.h" @@ -37,6 +36,7 @@ #include "net/netcomputer.h" #include "utils/functors.h" #include "utils/logger.h" +#include "utils/point.h" #include "utils/stringfilter.h" #include "utils/tokencollector.h" #include "utils/tokendispenser.h" diff --git a/src/account-server/character.h b/src/account-server/character.h index a0d4b61c..daa8a31c 100644 --- a/src/account-server/character.h +++ b/src/account-server/character.h @@ -26,8 +26,8 @@ #include <map> #include "defines.h" -#include "point.h" #include "common/inventorydata.h" +#include "utils/point.h" class Account; class MessageIn; diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp index 448fc289..9bc67edb 100644 --- a/src/account-server/storage.cpp +++ b/src/account-server/storage.cpp @@ -23,7 +23,6 @@ #include "account-server/storage.h" -#include "point.h" #include "account-server/account.h" #include "chat-server/chatchannel.h" #include "chat-server/guild.h" @@ -32,6 +31,7 @@ #include "dal/dalexcept.h" #include "dal/dataproviderfactory.h" #include "utils/functors.h" +#include "utils/point.h" #include "utils/throwerror.h" #include "utils/xml.h" @@ -333,6 +333,7 @@ Character *Storage::getCharacterBySQL(Account *owner) // Specialize the string_to functor to convert // a string to an unsigned int. string_to< unsigned > toUint; + string_to< int > toInt; try { @@ -355,7 +356,7 @@ Character *Storage::getCharacterBySQL(Account *owner) character->setLevel(toUshort(charInfo(0, 6))); character->setCharacterPoints(toUshort(charInfo(0, 7))); character->setCorrectionPoints(toUshort(charInfo(0, 8))); - Point pos(toUshort(charInfo(0, 9)), toUshort(charInfo(0, 10))); + Point pos(toInt(charInfo(0, 9)), toInt(charInfo(0, 10))); character->setPosition(pos); int mapId = toUint(charInfo(0, 11)); diff --git a/src/game-server/actor.h b/src/game-server/actor.h index fa443559..3aac3b60 100644 --- a/src/game-server/actor.h +++ b/src/game-server/actor.h @@ -21,9 +21,9 @@ #ifndef ACTOR_H #define ACTOR_H -#include "point.h" #include "game-server/map.h" #include "game-server/thing.h" +#include "utils/point.h" /** * Flags that are raised as necessary. They trigger messages that are sent to diff --git a/src/game-server/being.cpp b/src/game-server/being.cpp index c0fc65e9..65736774 100644 --- a/src/game-server/being.cpp +++ b/src/game-server/being.cpp @@ -270,16 +270,17 @@ void Being::move() setAction(WALK); - Position prev(tileSX, tileSY); + Point prev(tileSX, tileSY); Point pos; do { - Position next = mPath.front(); + Point next = mPath.front(); mPath.pop_front(); // SQRT2 is used for diagonal movement. mMoveTime += (prev.x == next.x || prev.y == next.y) ? getModifiedAttribute(ATTR_MOVE_SPEED_RAW) : getModifiedAttribute(ATTR_MOVE_SPEED_RAW) * SQRT2; + if (mPath.empty()) { // skip last tile center diff --git a/src/game-server/collisiondetection.cpp b/src/game-server/collisiondetection.cpp index 55e40d65..9aab4c5b 100644 --- a/src/game-server/collisiondetection.cpp +++ b/src/game-server/collisiondetection.cpp @@ -22,8 +22,8 @@ #include <cmath> -#include "point.h" #include "utils/mathutils.h" +#include "utils/point.h" #define D_TO_R 0.0174532925 // PI / 180 #define R_TO_D 57.2957795 // 180 / PI diff --git a/src/game-server/map.cpp b/src/game-server/map.cpp index 8a3c3e63..e1cebd0e 100644 --- a/src/game-server/map.cpp +++ b/src/game-server/map.cpp @@ -203,7 +203,7 @@ Path Map::findSimplePath(int startX, int startY, if (getWalk(positionX, positionY, walkmask)) { - path.push_back(Position(positionX, positionY)); + path.push_back(Point(positionX, positionY)); if ((positionX == destX) && (positionY == destY)) { @@ -374,7 +374,7 @@ Path Map::findPath(int startX, int startY, while (pathX != startX || pathY != startY) { // Add the new path node to the start of the path list - path.push_front(Position(pathX, pathY)); + path.push_front(Point(pathX, pathY)); // Find out the next parent MetaTile *tile = getMetaTile(pathX, pathY); diff --git a/src/game-server/map.h b/src/game-server/map.h index ba46f737..c5be38cc 100644 --- a/src/game-server/map.h +++ b/src/game-server/map.h @@ -25,21 +25,9 @@ #include <map> #include <string> -/** - * A position along a being's path. - * Used to compute each Path Nodes of the path. - */ -struct Position -{ - Position(int x, int y): - x(x), y(y) - { } - - int x; - int y; -}; +#include "utils/point.h" -typedef std::list<Position> Path; +typedef std::list<Point> Path; typedef Path::iterator PathIterator; /** diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp index b5a950b1..ae88a37c 100644 --- a/src/game-server/mapcomposite.cpp +++ b/src/game-server/mapcomposite.cpp @@ -21,13 +21,13 @@ #include <algorithm> #include <cassert> -#include "point.h" #include "common/configuration.h" #include "game-server/map.h" #include "game-server/mapcomposite.h" #include "game-server/character.h" #include "scripting/script.h" #include "utils/logger.h" +#include "utils/point.h" /* TODO: Implement overlapping map zones instead of strict partitioning. Purpose: to decrease the number of zone changes, as overlapping allows for diff --git a/src/game-server/spawnarea.h b/src/game-server/spawnarea.h index d3b2fd08..48bfede7 100644 --- a/src/game-server/spawnarea.h +++ b/src/game-server/spawnarea.h @@ -21,9 +21,9 @@ #ifndef SPAWNAREA_H #define SPAWNAREA_H -#include "point.h" #include "game-server/eventlistener.h" #include "game-server/thing.h" +#include "utils/point.h" class Being; class MonsterClass; diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp index c652549b..bed47805 100644 --- a/src/game-server/state.cpp +++ b/src/game-server/state.cpp @@ -22,7 +22,6 @@ #include "game-server/state.h" -#include "point.h" #include "common/configuration.h" #include "game-server/accountconnection.h" #include "game-server/gamehandler.h" @@ -39,6 +38,7 @@ #include "net/messageout.h" #include "scripting/script.h" #include "utils/logger.h" +#include "utils/point.h" #include "utils/speedconv.h" enum diff --git a/src/game-server/trigger.h b/src/game-server/trigger.h index f6649f1b..f6f0e170 100644 --- a/src/game-server/trigger.h +++ b/src/game-server/trigger.h @@ -21,9 +21,9 @@ #ifndef TRIGGER_H #define TRIGGER_H -#include "point.h" #include "game-server/thing.h" #include "scripting/script.h" +#include "utils/point.h" class Actor; diff --git a/src/serialize/characterdata.h b/src/serialize/characterdata.h index f36581d0..009d0efa 100644 --- a/src/serialize/characterdata.h +++ b/src/serialize/characterdata.h @@ -27,7 +27,7 @@ #include "common/inventorydata.h" #include "net/messagein.h" #include "net/messageout.h" -#include "point.h" +#include "utils/point.h" template< class T > void serializeCharacterData(const T &data, MessageOut &msg) diff --git a/src/point.h b/src/utils/point.h index 7d1bead8..0ebc37c0 100644 --- a/src/point.h +++ b/src/utils/point.h @@ -33,12 +33,12 @@ class Point x(0), y(0) {} - Point(unsigned short X, unsigned short Y): + Point(int X, int Y): x(X), y(Y) {} - unsigned short x; /**< x coordinate */ - unsigned short y; /**< y coordinate */ + int x; /**< x coordinate */ + int y; /**< y coordinate */ /** * Check whether the given point is within range of this point. @@ -67,15 +67,15 @@ class Point class Rectangle { public: - unsigned short x; /**< x coordinate */ - unsigned short y; /**< y coordinate */ - unsigned short w; /**< width */ - unsigned short h; /**< height */ + int x; /**< x coordinate */ + int y; /**< y coordinate */ + int w; /**< width */ + int h; /**< height */ bool contains(const Point &p) const { - return (unsigned short)(p.x - x) < w && - (unsigned short)(p.y - y) < h; + return (p.x - x) < w && + (p.y - y) < h; } bool intersects(const Rectangle &r) const |