summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-07-23 13:30:43 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-07-23 13:30:43 +0000
commit2aa377c9f3c5a1a6079be6c91a14777a357e270a (patch)
treeba308874148089e319f2ca796964d089d9beb344
parenta9f0bca7aab054aae146a4044a4a904d0c54020b (diff)
downloadmana-client-2aa377c9f3c5a1a6079be6c91a14777a357e270a.tar.gz
mana-client-2aa377c9f3c5a1a6079be6c91a14777a357e270a.tar.bz2
mana-client-2aa377c9f3c5a1a6079be6c91a14777a357e270a.tar.xz
mana-client-2aa377c9f3c5a1a6079be6c91a14777a357e270a.zip
Removed knowledge about the engine and maps from the being class..
-rw-r--r--src/being.cpp15
-rw-r--r--src/being.h10
-rw-r--r--src/game.cpp31
-rw-r--r--src/gui/gui.cpp4
4 files changed, 22 insertions, 38 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 0d1933bb..069172c3 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -169,7 +169,7 @@ void sort() {
Being::Being():
job(0),
- x(0), y(0), destX(0), destY(0), direction(0),
+ x(0), y(0), direction(0),
action(0), frame(0),
speech_color(0),
walk_time(0),
@@ -208,19 +208,6 @@ void Being::setPath(std::list<PATH_NODE> path)
}
}
-void Being::setDestination(int destX, int destY)
-{
- this->destX = destX;
- this->destY = destY;
-
- Map *map = engine->getCurrentMap();
-
- if (map != NULL)
- {
- setPath(map->findPath(x, y, destX, destY));
- }
-}
-
void Being::setHairColor(int color)
{
hairColor = color;
diff --git a/src/being.h b/src/being.h
index 16273bdd..bb5c5393 100644
--- a/src/being.h
+++ b/src/being.h
@@ -45,7 +45,6 @@ class Being
public:
unsigned short job; /**< Job (player job, npc, monster, ) */
unsigned short x, y; /**< Tile coordinates */
- unsigned short destX, destY; /**< Destination tile coordinates */
unsigned char direction; /**< Facing direction */
unsigned char action;
unsigned char frame;
@@ -75,9 +74,9 @@ class Being
void clearPath();
/**
- * Sets a new destination for this being to walk to.
+ * Sets the new path for this being.
*/
- void setDestination(int x, int y);
+ void setPath(std::list<PATH_NODE> path);
/**
* Puts a "speech balloon" above this being for the specified amount
@@ -188,11 +187,6 @@ class Being
void setId(unsigned int id);
private:
- /**
- * Sets the new path for this being.
- */
- void setPath(std::list<PATH_NODE> path);
-
unsigned short m_weapon;
unsigned int m_id; /**< Unique id */
diff --git a/src/game.cpp b/src/game.cpp
index 3d963421..4feb097e 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -675,11 +675,13 @@ void do_input()
Direction = NE;
}
+ Map *tiledMap = engine->getCurrentMap();
+
// Allow keyboard control to interrupt an existing path
if ((xDirection != 0 || yDirection != 0) && player_node->action == WALK)
- player_node->setDestination(x, y);
-
- Map *tiledMap = engine->getCurrentMap();
+ player_node->setPath(tiledMap->findPath(
+ player_node->x, player_node->y,
+ x, y));
if (player_node->action != WALK)
{
@@ -699,7 +701,9 @@ void do_input()
tiledMap->getWalk(x + xDirection, y + yDirection))
{
walk(x + xDirection, y + yDirection, Direction);
- player_node->setDestination(x + xDirection, y + yDirection);
+ player_node->setPath(tiledMap->findPath(
+ player_node->x, player_node->y,
+ x + xDirection, y + yDirection));
}
else if (Direction != DIR_NONE)
{
@@ -978,14 +982,12 @@ void do_parse()
being->action = STAND;
being->x = get_src_x(RFIFOP(50));
being->y = get_src_y(RFIFOP(50));
- being->destX = get_dest_x(RFIFOP(50));
- being->destY = get_dest_y(RFIFOP(50));
being->speed = RFIFOW(6);
being->job = RFIFOW(14);
- //being->setWeapon(RFIFOW(18));
- being->setDestination(
- get_dest_x(RFIFOP(50)),
- get_dest_y(RFIFOP(50)));
+ being->setPath(tiledMap->findPath(
+ being->x, being->y,
+ get_dest_x(RFIFOP(50)),
+ get_dest_y(RFIFOP(50))));
break;
case SMSG_MOVE_PLAYER_BEING:
@@ -1004,15 +1006,14 @@ void do_parse()
being->job = RFIFOW(14);
being->x = get_src_x(RFIFOP(50));
being->y = get_src_y(RFIFOP(50));
- being->destX = get_dest_x(RFIFOP(50));
- being->destY = get_dest_y(RFIFOP(50));
being->setHairStyle(RFIFOW(16));
being->setWeaponById(RFIFOW(18));
being->setHairColor(RFIFOW(32));
- being->setDestination(
- get_dest_x(RFIFOP(50)),
- get_dest_y(RFIFOP(50)));
+ being->setPath(tiledMap->findPath(
+ being->x, being->y,
+ get_dest_x(RFIFOP(50)),
+ get_dest_y(RFIFOP(50))));
break;
// NPC dialog
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index cf98dde9..c93061a2 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -235,7 +235,9 @@ void Gui::mousePress(int mx, int my, int button)
if (state == GAME && tiledMap->getWalk(tilex, tiley)) {
walk(tilex, tiley, 0);
- player_node->setDestination(tilex, tiley);
+ player_node->setPath(tiledMap->findPath(
+ player_node->x, player_node->y,
+ tilex, tiley));
autoTarget = NULL;
}