Skip to content
This repository has been archived by the owner on Sep 25, 2018. It is now read-only.

Commit

Permalink
Removed the superfluous point struct.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Yohann Ferreira committed Jan 9, 2011
1 parent 57701ac commit 8ff3e66
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 41 deletions.
2 changes: 1 addition & 1 deletion accountserver.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<Unit filename="src\net\messageout.h" />
<Unit filename="src\net\netcomputer.cpp" />
<Unit filename="src\net\netcomputer.h" />
<Unit filename="src\point.h" />
<Unit filename="src\utils\point.h" />
<Unit filename="src\protocol.h" />
<Unit filename="src\serialize\characterdata.h" />
<Unit filename="src\utils\base64.cpp" />
Expand Down
2 changes: 1 addition & 1 deletion gameserver.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
<Unit filename="src\net\messageout.h" />
<Unit filename="src\net\netcomputer.cpp" />
<Unit filename="src\net\netcomputer.h" />
<Unit filename="src\point.h" />
<Unit filename="src\utils\point.h" />
<Unit filename="src\protocol.h" />
<Unit filename="src\scripting\lua.cpp" />
<Unit filename="src\scripting\luascript.cpp" />
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/account-server/accounthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/account-server/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include <map>

#include "defines.h"
#include "point.h"
#include "common/inventorydata.h"
#include "utils/point.h"

class Account;
class MessageIn;
Expand Down
5 changes: 3 additions & 2 deletions src/account-server/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down Expand Up @@ -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
{
Expand All @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/game-server/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/game-server/being.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/game-server/collisiondetection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/game-server/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 2 additions & 14 deletions src/game-server/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/game-server/mapcomposite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/game-server/spawnarea.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/game-server/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/game-server/trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/serialize/characterdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions src/point.h → src/utils/point.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8ff3e66

Please sign in to comment.