summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-12 17:17:53 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-12 17:17:53 +0300
commit81f319af0c6321474282de8928378366bbb6e44d (patch)
tree7250047bc275bd3ad399d28cfe954a48bafbd92a
parentdb6b712e4169d80f8f2c84a0efbc553d2058c191 (diff)
downloadplus-81f319af0c6321474282de8928378366bbb6e44d.tar.gz
plus-81f319af0c6321474282de8928378366bbb6e44d.tar.bz2
plus-81f319af0c6321474282de8928378366bbb6e44d.tar.xz
plus-81f319af0c6321474282de8928378366bbb6e44d.zip
Move being directions into separate file.
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/actionmanager.cpp33
-rw-r--r--src/being/being.cpp67
-rw-r--r--src/being/being.h16
-rw-r--r--src/being/beingdirection.h40
-rw-r--r--src/being/localplayer.cpp264
-rw-r--r--src/game.cpp16
-rw-r--r--src/gui/windows/charcreatedialog.cpp3
9 files changed, 260 insertions, 181 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 46ce71ab1..e914fbb14 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -624,6 +624,7 @@ SET(SRCS
being/being.cpp
being/being.h
being/beingcacheentry.h
+ being/beingdirection.h
beingequipbackend.cpp
beingequipbackend.h
spellmanager.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index c5ff53410..ff3d1dc85 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -713,6 +713,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
being/being.cpp \
being/being.h \
being/beingcacheentry.h \
+ being/beingdirection.h \
beingequipbackend.cpp \
beingequipbackend.h \
spellmanager.cpp \
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index e02014781..ffb26799e 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -919,13 +919,13 @@ impHandler0(directUp)
{
if (player_node)
{
- if (player_node->getDirection() != Being::UP)
+ if (player_node->getDirection() != BeingDirection::UP)
{
// if (client->limitPackets(PACKET_DIRECTION))
{
- player_node->setDirection(Being::UP);
+ player_node->setDirection(BeingDirection::UP);
if (Net::getPlayerHandler())
- Net::getPlayerHandler()->setDirection(Being::UP);
+ Net::getPlayerHandler()->setDirection(BeingDirection::UP);
}
}
return true;
@@ -937,13 +937,16 @@ impHandler0(directDown)
{
if (player_node)
{
- if (player_node->getDirection() != Being::DOWN)
+ if (player_node->getDirection() != BeingDirection::DOWN)
{
// if (client->limitPackets(PACKET_DIRECTION))
{
- player_node->setDirection(Being::DOWN);
+ player_node->setDirection(BeingDirection::DOWN);
if (Net::getPlayerHandler())
- Net::getPlayerHandler()->setDirection(Being::DOWN);
+ {
+ Net::getPlayerHandler()->setDirection(
+ BeingDirection::DOWN);
+ }
}
}
return true;
@@ -955,13 +958,16 @@ impHandler0(directLeft)
{
if (player_node)
{
- if (player_node->getDirection() != Being::LEFT)
+ if (player_node->getDirection() != BeingDirection::LEFT)
{
// if (client->limitPackets(PACKET_DIRECTION))
{
- player_node->setDirection(Being::LEFT);
+ player_node->setDirection(BeingDirection::LEFT);
if (Net::getPlayerHandler())
- Net::getPlayerHandler()->setDirection(Being::LEFT);
+ {
+ Net::getPlayerHandler()->setDirection(
+ BeingDirection::LEFT);
+ }
}
}
return true;
@@ -973,13 +979,16 @@ impHandler0(directRight)
{
if (player_node)
{
- if (player_node->getDirection() != Being::RIGHT)
+ if (player_node->getDirection() != BeingDirection::RIGHT)
{
// if (client->limitPackets(PACKET_DIRECTION))
{
- player_node->setDirection(Being::RIGHT);
+ player_node->setDirection(BeingDirection::RIGHT);
if (Net::getPlayerHandler())
- Net::getPlayerHandler()->setDirection(Being::RIGHT);
+ {
+ Net::getPlayerHandler()->setDirection(
+ BeingDirection::RIGHT);
+ }
}
}
return true;
diff --git a/src/being/being.cpp b/src/being/being.cpp
index db8d3eee3..e06190623 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -143,7 +143,7 @@ Being::Being(const int id, const Type type, const uint16_t subtype,
mGender(GENDER_UNSPECIFIED),
mAction(STAND),
mSubType(0xFFFF),
- mDirection(DOWN),
+ mDirection(BeingDirection::DOWN),
mDirectionDelayed(0),
mSpriteDirection(DIRECTION_DOWN),
mShowName(false),
@@ -1247,25 +1247,25 @@ void Being::setDirection(const uint8_t direction)
mFaceDirection = direction;
SpriteDirection dir;
- if (mFaceDirection & UP)
+ if (mFaceDirection & BeingDirection::UP)
{
- if (mFaceDirection & LEFT)
+ if (mFaceDirection & BeingDirection::LEFT)
dir = DIRECTION_UPLEFT;
- else if (mFaceDirection & RIGHT)
+ else if (mFaceDirection & BeingDirection::RIGHT)
dir = DIRECTION_UPRIGHT;
else
dir = DIRECTION_UP;
}
- else if (mFaceDirection & DOWN)
+ else if (mFaceDirection & BeingDirection::DOWN)
{
- if (mFaceDirection & LEFT)
+ if (mFaceDirection & BeingDirection::LEFT)
dir = DIRECTION_DOWNLEFT;
- else if (mFaceDirection & RIGHT)
+ else if (mFaceDirection & BeingDirection::RIGHT)
dir = DIRECTION_DOWNRIGHT;
else
dir = DIRECTION_DOWN;
}
- else if (mFaceDirection & RIGHT)
+ else if (mFaceDirection & BeingDirection::RIGHT)
{
dir = DIRECTION_RIGHT;
}
@@ -1287,13 +1287,13 @@ uint8_t Being::calcDirection() const
{
uint8_t dir = 0;
if (mDest.x > mX)
- dir |= RIGHT;
+ dir |= BeingDirection::RIGHT;
else if (mDest.x < mX)
- dir |= LEFT;
+ dir |= BeingDirection::LEFT;
if (mDest.y > mY)
- dir |= DOWN;
+ dir |= BeingDirection::DOWN;
else if (mDest.y < mY)
- dir |= UP;
+ dir |= BeingDirection::UP;
return dir;
}
@@ -1301,13 +1301,13 @@ uint8_t Being::calcDirection(const int dstX, const int dstY) const
{
uint8_t dir = 0;
if (dstX > mX)
- dir |= RIGHT;
+ dir |= BeingDirection::RIGHT;
else if (dstX < mX)
- dir |= LEFT;
+ dir |= BeingDirection::LEFT;
if (dstY > mY)
- dir |= DOWN;
+ dir |= BeingDirection::DOWN;
else if (dstY < mY)
- dir |= UP;
+ dir |= BeingDirection::UP;
return dir;
}
@@ -1608,24 +1608,24 @@ void Being::petLogic()
case 2:
if (dstX > dstX0)
- newDir |= LEFT;
+ newDir |= BeingDirection::LEFT;
else if (dstX < dstX0)
- newDir |= RIGHT;
+ newDir |= BeingDirection::RIGHT;
if (dstY > dstY0)
- newDir |= UP;
+ newDir |= BeingDirection::UP;
else if (dstY < dstY0)
- newDir |= DOWN;
+ newDir |= BeingDirection::DOWN;
break;
case 3:
if (dstX > dstX0)
- newDir |= RIGHT;
+ newDir |= BeingDirection::RIGHT;
else if (dstX < dstX0)
- newDir |= LEFT;
+ newDir |= BeingDirection::LEFT;
if (dstY > dstY0)
- newDir |= DOWN;
+ newDir |= BeingDirection::DOWN;
else if (dstY < dstY0)
- newDir |= UP;
+ newDir |= BeingDirection::UP;
break;
case 4:
@@ -1633,13 +1633,13 @@ void Being::petLogic()
const int dstX2 = mOwner->getLastAttackX();
const int dstY2 = mOwner->getLastAttackY();
if (dstX > dstX2)
- newDir |= LEFT;
+ newDir |= BeingDirection::LEFT;
else if (dstX < dstX2)
- newDir |= RIGHT;
+ newDir |= BeingDirection::RIGHT;
if (dstY > dstY2)
- newDir |= UP;
+ newDir |= BeingDirection::UP;
else if (dstY < dstY2)
- newDir |= DOWN;
+ newDir |= BeingDirection::DOWN;
break;
}
}
@@ -1713,7 +1713,8 @@ int Being::getOffset(const signed char pos, const signed char neg) const
if (mMap)
{
const int time = get_elapsed_time(mActionTime);
- offset = (pos == LEFT && neg == RIGHT) ?
+ offset = (pos == BeingDirection::LEFT
+ && neg == BeingDirection::RIGHT) ?
static_cast<int>((static_cast<float>(time)
* static_cast<float>(mMap->getTileWidth())) / mSpeed) :
static_cast<int>((static_cast<float>(time)
@@ -3216,20 +3217,20 @@ void Being::fixPetSpawnPos(int &dstX, int &dstY) const
int offsetY = offsetY1;
switch (mOwner->getDirection())
{
- case LEFT:
+ case BeingDirection::LEFT:
offsetX = -offsetY1;
offsetY = offsetX1;
break;
- case RIGHT:
+ case BeingDirection::RIGHT:
offsetX = offsetY1;
offsetY = -offsetX1;
break;
- case UP:
+ case BeingDirection::UP:
offsetY = -offsetY;
offsetX = -offsetX;
break;
default:
- case DOWN:
+ case BeingDirection::DOWN:
break;
}
dstX += offsetX;
diff --git a/src/being/being.h b/src/being/being.h
index 869cb374f..c476e45b3 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -29,6 +29,7 @@
#include "listeners/configlistener.h"
+#include "being/beingdirection.h"
#include "being/gender.h"
#include <map>
@@ -137,17 +138,6 @@ class Being : public ActorSprite, public ConfigListener
};
/**
- * Directions, to be used as bitmask values
- */
- enum BeingDirection
- {
- DOWN = 1,
- LEFT = 2,
- UP = 4,
- RIGHT = 8
- };
-
- /**
* Constructor.
*
* @param id a unique being id
@@ -193,14 +183,14 @@ class Being : public ActorSprite, public ConfigListener
* TODO: Used by eAthena only?
*/
int getXOffset() const A_WARN_UNUSED
- { return getOffset(LEFT, RIGHT); }
+ { return getOffset(BeingDirection::LEFT, BeingDirection::RIGHT); }
/**
* Get the current Y pixel offset.
* TODO: Used by eAthena only?
*/
int getYOffset() const A_WARN_UNUSED
- { return getOffset(UP, DOWN); }
+ { return getOffset(BeingDirection::UP, BeingDirection::DOWN); }
/**
* Creates a path for the being from current position to ex and ey
diff --git a/src/being/beingdirection.h b/src/being/beingdirection.h
new file mode 100644
index 000000000..7d17b788f
--- /dev/null
+++ b/src/being/beingdirection.h
@@ -0,0 +1,40 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BEING_BEINGDIRECTION_H
+#define BEING_BEINGDIRECTION_H
+
+namespace BeingDirection
+{
+ /**
+ * Directions, to be used as bitmask values
+ */
+ enum BeingDirection
+ {
+ DOWN = 1,
+ LEFT = 2,
+ UP = 4,
+ RIGHT = 8
+ };
+}
+
+#endif // BEING_BEINGDIRECTION_H
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 320b57eca..283024243 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -568,14 +568,14 @@ void LocalPlayer::setDestination(const int x, const int y)
else
{
uint8_t newDir = 0;
- if (mDirection & UP)
- newDir |= DOWN;
- if (mDirection & LEFT)
- newDir |= RIGHT;
- if (mDirection & DOWN)
- newDir |= UP;
- if (mDirection & RIGHT)
- newDir |= LEFT;
+ if (mDirection & BeingDirection::UP)
+ newDir |= BeingDirection::DOWN;
+ if (mDirection & BeingDirection::LEFT)
+ newDir |= BeingDirection::RIGHT;
+ if (mDirection & BeingDirection::DOWN)
+ newDir |= BeingDirection::UP;
+ if (mDirection & BeingDirection::RIGHT)
+ newDir |= BeingDirection::LEFT;
Net::getPlayerHandler()->setDestination(x, y, newDir);
@@ -617,13 +617,13 @@ void LocalPlayer::startWalking(const unsigned char dir)
}
int dx = 0, dy = 0;
- if (dir & UP)
+ if (dir & BeingDirection::UP)
dy--;
- if (dir & DOWN)
+ if (dir & BeingDirection::DOWN)
dy++;
- if (dir & LEFT)
+ if (dir & BeingDirection::LEFT)
dx--;
- if (dir & RIGHT)
+ if (dir & BeingDirection::RIGHT)
dx++;
const unsigned char walkMask = getWalkMask();
@@ -746,16 +746,16 @@ void LocalPlayer::attack(Being *const target, const bool keep,
if (abs(dist_y) >= abs(dist_x))
{
if (dist_y > 0)
- setDirection(DOWN);
+ setDirection(BeingDirection::DOWN);
else
- setDirection(UP);
+ setDirection(BeingDirection::UP);
}
else
{
if (dist_x > 0)
- setDirection(RIGHT);
+ setDirection(BeingDirection::RIGHT);
else
- setDirection(LEFT);
+ setDirection(BeingDirection::LEFT);
}
mActionTime = tick_time;
@@ -1844,29 +1844,29 @@ void LocalPlayer::crazyMove1()
// if (!client->limitPackets(PACKET_DIRECTION))
// return;
- if (mDirection == Being::UP)
+ if (mDirection == BeingDirection::UP)
{
- setWalkingDir(Being::UP);
- setDirection(Being::LEFT);
- Net::getPlayerHandler()->setDirection(Being::LEFT);
+ setWalkingDir(BeingDirection::UP);
+ setDirection(BeingDirection::LEFT);
+ Net::getPlayerHandler()->setDirection(BeingDirection::LEFT);
}
- else if (mDirection == Being::LEFT)
+ else if (mDirection == BeingDirection::LEFT)
{
- setWalkingDir(Being::LEFT);
- setDirection(Being::DOWN);
- Net::getPlayerHandler()->setDirection(Being::DOWN);
+ setWalkingDir(BeingDirection::LEFT);
+ setDirection(BeingDirection::DOWN);
+ Net::getPlayerHandler()->setDirection(BeingDirection::DOWN);
}
- else if (mDirection == Being::DOWN)
+ else if (mDirection == BeingDirection::DOWN)
{
- setWalkingDir(Being::DOWN);
- setDirection(Being::RIGHT);
- Net::getPlayerHandler()->setDirection(Being::RIGHT);
+ setWalkingDir(BeingDirection::DOWN);
+ setDirection(BeingDirection::RIGHT);
+ Net::getPlayerHandler()->setDirection(BeingDirection::RIGHT);
}
- else if (mDirection == Being::RIGHT)
+ else if (mDirection == BeingDirection::RIGHT)
{
- setWalkingDir(Being::RIGHT);
- setDirection(Being::UP);
- Net::getPlayerHandler()->setDirection(Being::UP);
+ setWalkingDir(BeingDirection::RIGHT);
+ setDirection(BeingDirection::UP);
+ Net::getPlayerHandler()->setDirection(BeingDirection::UP);
}
}
@@ -1878,29 +1878,33 @@ void LocalPlayer::crazyMove2()
// if (!client->limitPackets(PACKET_DIRECTION))
// return;
- if (mDirection == Being::UP)
+ if (mDirection == BeingDirection::UP)
{
- setWalkingDir(Being::UP | Being::LEFT);
- setDirection(Being::RIGHT);
- Net::getPlayerHandler()->setDirection(Being::DOWN | Being::RIGHT);
+ setWalkingDir(BeingDirection::UP | BeingDirection::LEFT);
+ setDirection(BeingDirection::RIGHT);
+ Net::getPlayerHandler()->setDirection(
+ BeingDirection::DOWN | BeingDirection::RIGHT);
}
- else if (mDirection == Being::RIGHT)
+ else if (mDirection == BeingDirection::RIGHT)
{
- setWalkingDir(Being::UP | Being::RIGHT);
- setDirection(Being::DOWN);
- Net::getPlayerHandler()->setDirection(Being::DOWN | Being::LEFT);
+ setWalkingDir(BeingDirection::UP | BeingDirection::RIGHT);
+ setDirection(BeingDirection::DOWN);
+ Net::getPlayerHandler()->setDirection(
+ BeingDirection::DOWN | BeingDirection::LEFT);
}
- else if (mDirection == Being::DOWN)
+ else if (mDirection == BeingDirection::DOWN)
{
- setWalkingDir(Being::DOWN | Being::RIGHT);
- setDirection(Being::LEFT);
- Net::getPlayerHandler()->setDirection(Being::UP | Being::LEFT);
+ setWalkingDir(BeingDirection::DOWN | BeingDirection::RIGHT);
+ setDirection(BeingDirection::LEFT);
+ Net::getPlayerHandler()->setDirection(
+ BeingDirection::UP | BeingDirection::LEFT);
}
- else if (mDirection == Being::LEFT)
+ else if (mDirection == BeingDirection::LEFT)
{
- setWalkingDir(Being::DOWN | Being::LEFT);
- setDirection(Being::UP);
- Net::getPlayerHandler()->setDirection(Being::UP | Being::RIGHT);
+ setWalkingDir(BeingDirection::DOWN | BeingDirection::LEFT);
+ setDirection(BeingDirection::UP);
+ Net::getPlayerHandler()->setDirection(
+ BeingDirection::UP | BeingDirection::RIGHT);
}
}
@@ -1934,8 +1938,8 @@ void LocalPlayer::crazyMove3()
// if (!client->limitPackets(PACKET_DIRECTION))
// return;
- setDirection(Being::DOWN);
- Net::getPlayerHandler()->setDirection(Being::DOWN);
+ setDirection(BeingDirection::DOWN);
+ Net::getPlayerHandler()->setDirection(BeingDirection::DOWN);
}
void LocalPlayer::crazyMove4()
@@ -2077,13 +2081,13 @@ void LocalPlayer::crazyMove8()
{ 1, 0, -1, 0} // move down
};
- if (mDirection == Being::UP)
+ if (mDirection == BeingDirection::UP)
idx = 0;
- else if (mDirection == Being::RIGHT)
+ else if (mDirection == BeingDirection::RIGHT)
idx = 1;
- else if (mDirection == Being::DOWN)
+ else if (mDirection == BeingDirection::DOWN)
idx = 2;
- else if (mDirection == Being::LEFT)
+ else if (mDirection == BeingDirection::LEFT)
idx = 3;
@@ -2148,10 +2152,10 @@ void LocalPlayer::crazyMove9()
case 0:
switch (mDirection)
{
- case UP : dy = -1; break;
- case DOWN : dy = 1; break;
- case LEFT : dx = -1; break;
- case RIGHT: dx = 1; break;
+ case BeingDirection::UP : dy = -1; break;
+ case BeingDirection::DOWN : dy = 1; break;
+ case BeingDirection::LEFT : dx = -1; break;
+ case BeingDirection::RIGHT: dx = 1; break;
default: break;
}
move(dx, dy);
@@ -2230,24 +2234,24 @@ void LocalPlayer::crazyMoveA()
move(1, -1);
break;
case 'f':
- if (mDirection & UP)
+ if (mDirection & BeingDirection::UP)
dy = -1;
- else if (mDirection & DOWN)
+ else if (mDirection & BeingDirection::DOWN)
dy = 1;
- if (mDirection & LEFT)
+ if (mDirection & BeingDirection::LEFT)
dx = -1;
- else if (mDirection & RIGHT)
+ else if (mDirection & BeingDirection::RIGHT)
dx = 1;
move(dx, dy);
break;
case 'b':
- if (mDirection & UP)
+ if (mDirection & BeingDirection::UP)
dy = 1;
- else if (mDirection & DOWN)
+ else if (mDirection & BeingDirection::DOWN)
dy = -1;
- if (mDirection & LEFT)
+ if (mDirection & BeingDirection::LEFT)
dx = 1;
- else if (mDirection & RIGHT)
+ else if (mDirection & BeingDirection::RIGHT)
dx = -1;
move(dx, dy);
break;
@@ -2276,29 +2280,29 @@ void LocalPlayer::crazyMoveA()
// if (client->limitPackets(PACKET_DIRECTION))
{
- setDirection(Being::DOWN);
- Net::getPlayerHandler()->setDirection(Being::DOWN);
+ setDirection(BeingDirection::DOWN);
+ Net::getPlayerHandler()->setDirection(BeingDirection::DOWN);
}
break;
case 'u':
// if (client->limitPackets(PACKET_DIRECTION))
{
- setDirection(Being::UP);
- Net::getPlayerHandler()->setDirection(Being::UP);
+ setDirection(BeingDirection::UP);
+ Net::getPlayerHandler()->setDirection(BeingDirection::UP);
}
break;
case 'l':
// if (client->limitPackets(PACKET_DIRECTION))
{
- setDirection(Being::LEFT);
- Net::getPlayerHandler()->setDirection(Being::LEFT);
+ setDirection(BeingDirection::LEFT);
+ Net::getPlayerHandler()->setDirection(BeingDirection::LEFT);
}
break;
case 'r':
// if (client->limitPackets(PACKET_DIRECTION))
{
- setDirection(Being::RIGHT);
- Net::getPlayerHandler()->setDirection(Being::RIGHT);
+ setDirection(BeingDirection::RIGHT);
+ Net::getPlayerHandler()->setDirection(BeingDirection::RIGHT);
}
break;
case 'L':
@@ -2307,11 +2311,20 @@ void LocalPlayer::crazyMoveA()
uint8_t dir = 0;
switch (mDirection)
{
- case UP : dir = Being::LEFT; break;
- case DOWN : dir = Being::RIGHT; break;
- case LEFT : dir = Being::DOWN; break;
- case RIGHT : dir = Being::UP; break;
- default: break;
+ case BeingDirection::UP:
+ dir = BeingDirection::LEFT;
+ break;
+ case BeingDirection::DOWN:
+ dir = BeingDirection::RIGHT;
+ break;
+ case BeingDirection::LEFT:
+ dir = BeingDirection::DOWN;
+ break;
+ case BeingDirection::RIGHT:
+ dir = BeingDirection::UP;
+ break;
+ default:
+ break;
}
setDirection(dir);
Net::getPlayerHandler()->setDirection(dir);
@@ -2323,11 +2336,20 @@ void LocalPlayer::crazyMoveA()
uint8_t dir = 0;
switch (mDirection)
{
- case UP : dir = Being::RIGHT; break;
- case DOWN : dir = Being::LEFT; break;
- case LEFT : dir = Being::UP; break;
- case RIGHT : dir = Being::DOWN; break;
- default: break;
+ case BeingDirection::UP:
+ dir = BeingDirection::RIGHT;
+ break;
+ case BeingDirection::DOWN:
+ dir = BeingDirection::LEFT;
+ break;
+ case BeingDirection::LEFT:
+ dir = BeingDirection::UP;
+ break;
+ case BeingDirection::RIGHT:
+ dir = BeingDirection::DOWN;
+ break;
+ default:
+ break;
}
setDirection(dir);
Net::getPlayerHandler()->setDirection(dir);
@@ -2339,11 +2361,20 @@ void LocalPlayer::crazyMoveA()
uint8_t dir = 0;
switch (mDirection)
{
- case UP : dir = Being::DOWN; break;
- case DOWN : dir = Being::UP; break;
- case LEFT : dir = Being::RIGHT; break;
- case RIGHT : dir = Being::LEFT; break;
- default: break;
+ case BeingDirection::UP:
+ dir = BeingDirection::DOWN;
+ break;
+ case BeingDirection::DOWN:
+ dir = BeingDirection::UP;
+ break;
+ case BeingDirection::LEFT:
+ dir = BeingDirection::RIGHT;
+ break;
+ case BeingDirection::RIGHT:
+ dir = BeingDirection::LEFT;
+ break;
+ default:
+ break;
}
setDirection(dir);
Net::getPlayerHandler()->setDirection(dir);
@@ -2522,10 +2553,10 @@ bool LocalPlayer::pickUpItems(int pickUpType)
case 1:
switch (mDirection)
{
- case UP : --y; break;
- case DOWN : ++y; break;
- case LEFT : --x; break;
- case RIGHT: ++x; break;
+ case BeingDirection::UP : --y; break;
+ case BeingDirection::DOWN : ++y; break;
+ case BeingDirection::LEFT : --x; break;
+ case BeingDirection::RIGHT: ++x; break;
default: break;
}
item = actorManager->findItem(x, y);
@@ -2535,11 +2566,16 @@ bool LocalPlayer::pickUpItems(int pickUpType)
case 2:
switch (mDirection)
{
- case UP : x1 = x - 1; y1 = y - 1; x2 = x + 1; y2 = y; break;
- case DOWN : x1 = x - 1; y1 = y; x2 = x + 1; y2 = y + 1; break;
- case LEFT : x1 = x - 1; y1 = y - 1; x2 = x; y2 = y + 1; break;
- case RIGHT: x1 = x; y1 = y - 1; x2 = x + 1; y2 = y + 1; break;
- default: x1 = x; x2 = x; y1 = y; y2 = y; break;
+ case BeingDirection::UP:
+ x1 = x - 1; y1 = y - 1; x2 = x + 1; y2 = y; break;
+ case BeingDirection::DOWN:
+ x1 = x - 1; y1 = y; x2 = x + 1; y2 = y + 1; break;
+ case BeingDirection::LEFT:
+ x1 = x - 1; y1 = y - 1; x2 = x; y2 = y + 1; break;
+ case BeingDirection::RIGHT:
+ x1 = x; y1 = y - 1; x2 = x + 1; y2 = y + 1; break;
+ default:
+ x1 = x; x2 = x; y1 = y; y2 = y; break;
}
if (actorManager->pickUpAll(x1, y1, x2, y2))
status = true;
@@ -2595,13 +2631,13 @@ bool LocalPlayer::pickUpItems(int pickUpType)
void LocalPlayer::moveByDirection(const unsigned char dir)
{
int dx = 0, dy = 0;
- if (dir & UP)
+ if (dir & BeingDirection::UP)
dy--;
- if (dir & DOWN)
+ if (dir & BeingDirection::DOWN)
dy++;
- if (dir & LEFT)
+ if (dir & BeingDirection::LEFT)
dx--;
- if (dir & RIGHT)
+ if (dir & BeingDirection::RIGHT)
dx++;
move(dx, dy);
}
@@ -2808,13 +2844,13 @@ void LocalPlayer::setHome()
if (!mapItem || mapItem->getType() == MapItem::EMPTY)
{
- if (mDirection & UP)
+ if (mDirection & BeingDirection::UP)
type = MapItem::ARROW_UP;
- else if (mDirection & LEFT)
+ else if (mDirection & BeingDirection::LEFT)
type = MapItem::ARROW_LEFT;
- else if (mDirection & DOWN)
+ else if (mDirection & BeingDirection::DOWN)
type = MapItem::ARROW_DOWN;
- else if (mDirection & RIGHT)
+ else if (mDirection & BeingDirection::RIGHT)
type = MapItem::ARROW_RIGHT;
}
else
@@ -3354,14 +3390,14 @@ void LocalPlayer::imitateDirection(const Being *const being,
if (mFollowMode == 2)
{
uint8_t dir2 = 0;
- if (dir & Being::LEFT)
- dir2 |= Being::RIGHT;
- else if (dir & Being::RIGHT)
- dir2 |= Being::LEFT;
- if (dir & Being::UP)
- dir2 |= Being::DOWN;
- else if (dir & Being::DOWN)
- dir2 |= Being::UP;
+ if (dir & BeingDirection::LEFT)
+ dir2 |= BeingDirection::RIGHT;
+ else if (dir & BeingDirection::RIGHT)
+ dir2 |= BeingDirection::LEFT;
+ if (dir & BeingDirection::UP)
+ dir2 |= BeingDirection::DOWN;
+ else if (dir & BeingDirection::DOWN)
+ dir2 |= BeingDirection::UP;
setDirection(dir2);
Net::getPlayerHandler()->setDirection(dir2);
diff --git a/src/game.cpp b/src/game.cpp
index 462479bea..f9f5305ae 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -865,14 +865,14 @@ void Game::handleMove()
if (inputManager.isActionActive(Input::KEY_MOVE_UP) ||
(joystick && joystick->isUp()))
{
- direction |= Being::UP;
+ direction |= BeingDirection::UP;
setValidSpeed();
player_node->cancelFollow();
}
else if (inputManager.isActionActive(Input::KEY_MOVE_DOWN) ||
(joystick && joystick->isDown()))
{
- direction |= Being::DOWN;
+ direction |= BeingDirection::DOWN;
setValidSpeed();
player_node->cancelFollow();
}
@@ -880,14 +880,14 @@ void Game::handleMove()
if (inputManager.isActionActive(Input::KEY_MOVE_LEFT) ||
(joystick && joystick->isLeft()))
{
- direction |= Being::LEFT;
+ direction |= BeingDirection::LEFT;
setValidSpeed();
player_node->cancelFollow();
}
else if (inputManager.isActionActive(Input::KEY_MOVE_RIGHT) ||
(joystick && joystick->isRight()))
{
- direction |= Being::RIGHT;
+ direction |= BeingDirection::RIGHT;
setValidSpeed();
player_node->cancelFollow();
}
@@ -917,14 +917,14 @@ void Game::moveInDirection(const unsigned char direction)
{
int dx = 0;
int dy = 0;
- if (direction & Being::LEFT)
+ if (direction & BeingDirection::LEFT)
dx = -5;
- else if (direction & Being::RIGHT)
+ else if (direction & BeingDirection::RIGHT)
dx = 5;
- if (direction & Being::UP)
+ if (direction & BeingDirection::UP)
dy = -5;
- else if (direction & Being::DOWN)
+ else if (direction & BeingDirection::DOWN)
dy = 5;
viewport->moveCamera(dx, dy);
}
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index c1e8217d8..b642c7f6f 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -58,7 +58,8 @@ static const Being::Action actions[] =
static const uint8_t directions[] =
{
- Being::DOWN, Being::RIGHT, Being::UP, Being::LEFT
+ BeingDirection::DOWN, BeingDirection::RIGHT,
+ BeingDirection::UP, BeingDirection::LEFT
};
CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,