summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-12 19:12:15 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-12 19:12:15 +0300
commit814e88e5ca69bc54837be27429dbf42dd41f7ac6 (patch)
tree301671c06b758239f9b05b3a0e4f2774e5ab3a9e
parent261b8ab980d442d0cf1b06df244388d65f431301 (diff)
downloadmv-814e88e5ca69bc54837be27429dbf42dd41f7ac6.tar.gz
mv-814e88e5ca69bc54837be27429dbf42dd41f7ac6.tar.bz2
mv-814e88e5ca69bc54837be27429dbf42dd41f7ac6.tar.xz
mv-814e88e5ca69bc54837be27429dbf42dd41f7ac6.zip
Move being action into separate file.
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/being/being.cpp112
-rw-r--r--src/being/being.h26
-rw-r--r--src/being/beingaction.h45
-rw-r--r--src/being/localplayer.cpp79
-rw-r--r--src/being/localplayer.h4
-rw-r--r--src/gui/windows/charcreatedialog.cpp14
-rw-r--r--src/gui/windows/npcdialog.cpp2
-rw-r--r--src/net/ea/beinghandler.cpp31
-rw-r--r--src/net/ea/playerhandler.cpp6
-rw-r--r--src/net/eathena/beinghandler.cpp22
-rw-r--r--src/net/eathena/playerhandler.cpp16
-rw-r--r--src/net/eathena/playerhandler.h3
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/tmwa/beinghandler.cpp16
-rw-r--r--src/net/tmwa/playerhandler.cpp16
-rw-r--r--src/net/tmwa/playerhandler.h3
18 files changed, 227 insertions, 172 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bcc8dae34..c4d54628f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -623,6 +623,7 @@ SET(SRCS
avatar.h
being/being.cpp
being/being.h
+ being/beingaction.h
being/beingcacheentry.h
being/beingdirection.h
being/beingflag.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 89cfedc5f..5066444e6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -712,6 +712,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
avatar.h \
being/being.cpp \
being/being.h \
+ being/beingaction.h \
being/beingcacheentry.h \
being/beingdirection.h \
being/beingflag.h \
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 8db08bb68..eb2c4682f 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -34,6 +34,7 @@
#include "text.h"
#include "being/attributes.h"
+#include "being/beingaction.h"
#include "being/beingcacheentry.h"
#include "being/beingspeech.h"
#include "being/playerrelations.h"
@@ -142,7 +143,7 @@ Being::Being(const int id, const Type type, const uint16_t subtype,
mLastAttackX(0),
mLastAttackY(0),
mGender(GENDER_UNSPECIFIED),
- mAction(STAND),
+ mAction(BeingAction::STAND),
mSubType(0xFFFF),
mDirection(BeingDirection::DOWN),
mDirectionDelayed(0),
@@ -383,7 +384,7 @@ void Being::setPath(const Path &path)
if (mPath.empty())
return;
- if (mAction != MOVE && mAction != DEAD)
+ if (mAction != BeingAction::MOVE && mAction != BeingAction::DEAD)
{
nextTile();
mActionTime = tick_time;
@@ -710,7 +711,7 @@ void Being::handleAttack(Being *const victim, const int damage,
return;
if (this != player_node)
- setAction(Being::ATTACK, attackId);
+ setAction(BeingAction::ATTACK, attackId);
mLastAttackX = victim->getTileX();
mLastAttackY = victim->getTileY();
@@ -730,8 +731,11 @@ void Being::handleAttack(Being *const victim, const int damage,
if (dir)
setDirection(dir);
}
- if (damage && victim->mType == PLAYER && victim->mAction == SIT)
- victim->setAction(STAND, 0);
+ if (damage && victim->mType == PLAYER
+ && victim->mAction == BeingAction::SIT)
+ {
+ victim->setAction(BeingAction::STAND, 0);
+ }
if (mType == PLAYER)
{
@@ -760,7 +764,7 @@ void Being::handleSkill(Being *const victim, const int damage,
return;
if (this != player_node)
- setAction(Being::ATTACK, 1);
+ setAction(BeingAction::ATTACK, 1);
const SkillInfo *const skill = skillDialog->getSkill(skillId);
const SkillData *const data = skill
@@ -778,8 +782,11 @@ void Being::handleSkill(Being *const victim, const int damage,
if (dir)
setDirection(dir);
}
- if (damage && victim->mType == PLAYER && victim->mAction == SIT)
- victim->setAction(STAND, 0);
+ if (damage && victim->mType == PLAYER
+ && victim->mAction == BeingAction::SIT)
+ {
+ victim->setAction(BeingAction::STAND, 0);
+ }
if (data)
{
if (damage > 0)
@@ -1111,13 +1118,13 @@ getSpriteAction(Dead, DEAD)
getSpriteAction(Stand, STAND)
getSpriteAction(Spawn, SPAWN)
-void Being::setAction(const Action &action, const int attackId)
+void Being::setAction(const BeingAction::Action &action, const int attackId)
{
std::string currentAction = SpriteAction::INVALID;
switch (action)
{
- case MOVE:
+ case BeingAction::MOVE:
if (mInfo)
{
playSfx(mInfo->getSound(
@@ -1128,7 +1135,7 @@ void Being::setAction(const Action &action, const int attackId)
// Differentiate walk and run with action name,
// while using only the ACTION_MOVE.
break;
- case SIT:
+ case BeingAction::SIT:
currentAction = getSitAction();
if (mInfo)
{
@@ -1140,7 +1147,7 @@ void Being::setAction(const Action &action, const int attackId)
playSfx(mInfo->getSound(event), nullptr, true, mX, mY);
}
break;
- case ATTACK:
+ case BeingAction::ATTACK:
if (mEquippedWeapon)
{
currentAction = getWeaponAttackAction(mEquippedWeapon);
@@ -1181,14 +1188,14 @@ void Being::setAction(const Action &action, const int attackId)
}
}
break;
- case HURT:
+ case BeingAction::HURT:
if (mInfo)
{
playSfx(mInfo->getSound(SOUND_EVENT_HURT),
this, false, mX, mY);
}
break;
- case DEAD:
+ case BeingAction::DEAD:
currentAction = getDeadAction();
if (mInfo)
{
@@ -1197,10 +1204,10 @@ void Being::setAction(const Action &action, const int attackId)
mYDiff = mInfo->getDeadSortOffsetY();
}
break;
- case STAND:
+ case BeingAction::STAND:
currentAction = getStandAction();
break;
- case SPAWN:
+ case BeingAction::SPAWN:
if (mInfo)
{
playSfx(mInfo->getSound(SOUND_EVENT_SPAWN),
@@ -1316,7 +1323,7 @@ void Being::nextTile()
{
if (mPath.empty())
{
- setAction(STAND, 0);
+ setAction(BeingAction::STAND, 0);
return;
}
@@ -1329,7 +1336,7 @@ void Being::nextTile()
if (!mMap || !mMap->getWalk(pos.x, pos.y, getWalkMask()))
{
- setAction(STAND, 0);
+ setAction(BeingAction::STAND, 0);
return;
}
@@ -1345,7 +1352,7 @@ void Being::nextTile()
mY = pos.y;
const uint8_t height = mMap->getHeightOffset(mX, mY);
mOffsetY = height - mOldHeight;
- setAction(MOVE, 0);
+ setAction(BeingAction::MOVE, 0);
}
void Being::logic()
@@ -1374,15 +1381,15 @@ void Being::logic()
switch (mAction)
{
- case STAND:
- case SIT:
- case DEAD:
- case HURT:
- case SPAWN:
+ case BeingAction::STAND:
+ case BeingAction::SIT:
+ case BeingAction::DEAD:
+ case BeingAction::HURT:
+ case BeingAction::SPAWN:
default:
break;
- case MOVE:
+ case BeingAction::MOVE:
{
if (static_cast<float>(get_elapsed_time(
mActionTime)) >= mSpeed)
@@ -1392,7 +1399,7 @@ void Being::logic()
break;
}
- case ATTACK:
+ case BeingAction::ATTACK:
{
if (!mActionTime)
break;
@@ -1411,7 +1418,7 @@ void Being::logic()
}
}
- if (mAction == MOVE)
+ if (mAction == BeingAction::MOVE)
{
const int xOffset = getXOffset();
const int yOffset = getYOffset();
@@ -1502,7 +1509,7 @@ void Being::petLogic()
if (divX >= warpDist || divY >= warpDist)
{
- setAction(Being::STAND, 0);
+ setAction(BeingAction::STAND, 0);
fixPetSpawnPos(dstX, dstY);
setTileCoords(dstX, dstY);
Net::getPetHandler()->spawn(mOwner, mId, dstX, dstY);
@@ -1562,36 +1569,36 @@ void Being::petLogic()
return;
}
}
- if (mOwner->getCurrentAction() != ATTACK)
+ if (mOwner->getCurrentAction() != BeingAction::ATTACK)
{
- if (mAction == ATTACK)
- setAction(STAND, 0);
+ if (mAction == BeingAction::ATTACK)
+ setAction(BeingAction::STAND, 0);
}
else
{
- if (mAction == STAND || mAction == ATTACK)
- setAction(ATTACK, 0);
+ if (mAction == BeingAction::STAND || mAction == BeingAction::ATTACK)
+ setAction(BeingAction::ATTACK, 0);
}
- if (mAction == STAND || mAction == ATTACK)
+ if (mAction == BeingAction::STAND || mAction == BeingAction::ATTACK)
{
int directionType = 0;
switch (mOwner->getCurrentAction())
{
- case STAND:
- case MOVE:
- case HURT:
- case SPAWN:
+ case BeingAction::STAND:
+ case BeingAction::MOVE:
+ case BeingAction::HURT:
+ case BeingAction::SPAWN:
default:
directionType = mInfo->getDirectionType();
break;
- case SIT:
+ case BeingAction::SIT:
directionType = mInfo->getSitDirectionType();
break;
- case DEAD:
+ case BeingAction::DEAD:
directionType = mInfo->getDeadDirectionType();
break;
- case ATTACK:
+ case BeingAction::ATTACK:
directionType = mInfo->getAttackDirectionType();
break;
}
@@ -1706,7 +1713,7 @@ void Being::drawSpeech(const int offsetX, const int offsetY)
int Being::getOffset(const signed char pos, const signed char neg) const
{
// Check whether we're walking in the requested direction
- if (mAction != MOVE || !(mDirection & (pos | neg)))
+ if (mAction != BeingAction::MOVE || !(mDirection & (pos | neg)))
return 0;
int offset = 0;
@@ -2395,7 +2402,10 @@ void Being::drawSpriteAt(Graphics *const graphics,
y + mapTileSize - 6 + mInfo->getHpBarOffsetY(),
2 * 50, 4);
}
- if (mShowOwnHP && mInfo && player_node == this && mAction != DEAD)
+ if (mShowOwnHP
+ && mInfo
+ && player_node == this
+ && mAction != BeingAction::DEAD)
{
drawHpBar(graphics, PlayerInfo::getAttribute(Attributes::MAX_HP),
PlayerInfo::getAttribute(Attributes::HP), 0,
@@ -2524,7 +2534,7 @@ void Being::recalcSpritesOrder()
if (dir < 0 || dir >= 9)
dir = 0;
// hack for allow different logic in dead player
- if (mAction == DEAD)
+ if (mAction == BeingAction::DEAD)
dir = 9;
const unsigned int hairSlot = Net::getCharServerHandler()->hairSprite();
@@ -3185,29 +3195,29 @@ void Being::fixPetSpawnPos(int &dstX, int &dstY) const
int offsetY1;
switch (mOwner->getCurrentAction())
{
- case SIT:
+ case BeingAction::SIT:
offsetX1 = mInfo->getSitOffsetX();
offsetY1 = mInfo->getSitOffsetY();
break;
- case MOVE:
+ case BeingAction::MOVE:
offsetX1 = mInfo->getMoveOffsetX();
offsetY1 = mInfo->getMoveOffsetY();
break;
- case DEAD:
+ case BeingAction::DEAD:
offsetX1 = mInfo->getDeadOffsetX();
offsetY1 = mInfo->getDeadOffsetY();
break;
- case ATTACK:
+ case BeingAction::ATTACK:
offsetX1 = mInfo->getAttackOffsetX();
offsetY1 = mInfo->getAttackOffsetY();
break;
- case SPAWN:
- case HURT:
- case STAND:
+ case BeingAction::SPAWN:
+ case BeingAction::HURT:
+ case BeingAction::STAND:
default:
offsetX1 = mInfo->getTargetOffsetX();
offsetY1 = mInfo->getTargetOffsetY();
diff --git a/src/being/being.h b/src/being/being.h
index aec735215..52a88bd2e 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -29,6 +29,7 @@
#include "listeners/configlistener.h"
+#include "being/beingaction.h"
#include "being/beingdirection.h"
#include "being/beingflag.h"
#include "being/gender.h"
@@ -85,22 +86,6 @@ class Being : public ActorSprite, public ConfigListener
friend class BeingEquipBackend;
friend class LocalPlayer;
- /**
- * Action the being is currently performing
- * WARNING: Has to be in sync with the same enum in the Being class
- * of the server!
- */
- enum Action
- {
- STAND = 0,
- MOVE,
- ATTACK,
- SIT,
- DEAD,
- HURT,
- SPAWN
- };
-
enum AttackType
{
HIT = 0x00,
@@ -469,19 +454,20 @@ class Being : public ActorSprite, public ConfigListener
/**
* Sets the current action.
*/
- virtual void setAction(const Action &action, const int attackType);
+ virtual void setAction(const BeingAction::Action &action,
+ const int attackType);
/**
* Get the being's action currently performed.
*/
- Action getCurrentAction() const A_WARN_UNUSED
+ BeingAction::Action getCurrentAction() const A_WARN_UNUSED
{ return mAction; }
/**
* Returns whether this being is still alive.
*/
bool isAlive() const A_WARN_UNUSED
- { return mAction != DEAD; }
+ { return mAction != BeingAction::DEAD; }
/**
* Returns the current direction.
@@ -968,7 +954,7 @@ class Being : public ActorSprite, public ConfigListener
int mLastAttackX;
int mLastAttackY;
Gender mGender;
- Action mAction; /**< Action the being is performing */
+ BeingAction::Action mAction;
uint16_t mSubType; /**< Subtype (graphical view, basically) */
uint8_t mDirection; /**< Facing direction */
uint8_t mDirectionDelayed; /**< Facing direction */
diff --git a/src/being/beingaction.h b/src/being/beingaction.h
new file mode 100644
index 000000000..a6bc47b28
--- /dev/null
+++ b/src/being/beingaction.h
@@ -0,0 +1,45 @@
+/*
+ * 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_BEINGACTION_H
+#define BEING_BEINGACTION_H
+
+namespace BeingAction
+{
+ /**
+ * Action the being is currently performing
+ * WARNING: Has to be in sync with the same enum in the Being class
+ * of the server!
+ */
+ enum Action
+ {
+ STAND = 0,
+ MOVE,
+ ATTACK,
+ SIT,
+ DEAD,
+ HURT,
+ SPAWN
+ };
+} // BeingAction
+
+#endif // BEING_BEINGACTION_H
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 800cd10a8..2774ab86e 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -250,7 +250,7 @@ void LocalPlayer::logic()
if (mActivityTime == 0 || mLastAction != -1)
mActivityTime = cur_time;
- if ((mAction != MOVE || mNextStep) && !mNavigatePath.empty())
+ if ((mAction != BeingAction::MOVE || mNextStep) && !mNavigatePath.empty())
{
mNextStep = false;
int dist = 5;
@@ -373,9 +373,10 @@ void LocalPlayer::slowLogic()
BLOCK_END("LocalPlayer::slowLogic")
}
-void LocalPlayer::setAction(const Action &action, const int attackType)
+void LocalPlayer::setAction(const BeingAction::Action &action,
+ const int attackType)
{
- if (action == DEAD)
+ if (action == BeingAction::DEAD)
{
if (!mLastHitFrom.empty())
{
@@ -439,7 +440,7 @@ void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
if (mGoingToTarget && mTarget && withinAttackRange(mTarget))
{
- mAction = Being::STAND;
+ mAction = BeingAction::STAND;
attack(mTarget, true);
mGoingToTarget = false;
mPath.clear();
@@ -453,8 +454,8 @@ void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
if (mPath.empty())
{
- if (mNavigatePath.empty() || mAction != MOVE)
- setAction(STAND);
+ if (mNavigatePath.empty() || mAction != BeingAction::MOVE)
+ setAction(BeingAction::STAND);
else
mNextStep = true;
}
@@ -597,7 +598,7 @@ void LocalPlayer::setWalkingDir(const unsigned char dir)
mWalkingDir = dir;
// If we're not already walking, start walking.
- if (mAction != MOVE && dir)
+ if (mAction != BeingAction::MOVE && dir)
startWalking(dir);
}
@@ -609,7 +610,7 @@ void LocalPlayer::startWalking(const unsigned char dir)
return;
mPickUpTarget = nullptr;
- if (mAction == MOVE && !mPath.empty())
+ if (mAction == BeingAction::MOVE && !mPath.empty())
{
// Just finish the current action, otherwise we get out of sync
Being::setDestination(mX, mY);
@@ -656,7 +657,7 @@ void LocalPlayer::startWalking(const unsigned char dir)
void LocalPlayer::stopWalking(const bool sendToServer)
{
- if (mAction == MOVE && mWalkingDir)
+ if (mAction == BeingAction::MOVE && mWalkingDir)
{
mWalkingDir = 0;
mLocalWalkTime = 0;
@@ -670,7 +671,7 @@ void LocalPlayer::stopWalking(const bool sendToServer)
static_cast<int>(getPosition().x),
static_cast<int>(getPosition().y), -1);
}
- setAction(STAND);
+ setAction(BeingAction::STAND);
}
// No path set anymore, so we reset the path by mouse flag
@@ -685,20 +686,20 @@ bool LocalPlayer::toggleSit() const
if (!client->limitPackets(PACKET_SIT))
return false;
- Being::Action newAction;
+ BeingAction::Action newAction;
switch (mAction)
{
- case STAND:
- case SPAWN:
- newAction = SIT;
+ case BeingAction::STAND:
+ case BeingAction::SPAWN:
+ newAction = BeingAction::SIT;
break;
- case SIT:
- newAction = STAND;
+ case BeingAction::SIT:
+ newAction = BeingAction::STAND;
break;
- case MOVE:
- case ATTACK:
- case DEAD:
- case HURT:
+ case BeingAction::MOVE:
+ case BeingAction::ATTACK:
+ case BeingAction::DEAD:
+ case BeingAction::HURT:
default:
return true;
}
@@ -740,7 +741,7 @@ void LocalPlayer::attack(Being *const target, const bool keep,
const int dist_y = target->getTileY() - mY;
// Must be standing or sitting to attack
- if (mAction != STAND && mAction != SIT)
+ if (mAction != BeingAction::STAND && mAction != BeingAction::SIT)
return;
if (abs(dist_y) >= abs(dist_x))
@@ -762,7 +763,7 @@ void LocalPlayer::attack(Being *const target, const bool keep,
if (target->getType() != Being::PLAYER || checAttackPermissions(target))
{
- setAction(ATTACK);
+ setAction(BeingAction::ATTACK);
if (!client->limitPackets(PACKET_ATTACK))
return;
@@ -782,7 +783,7 @@ void LocalPlayer::stopAttack(const bool keepAttack)
if (!client->limitPackets(PACKET_STOPATTACK))
return;
- if (mServerAttack && mAction == ATTACK)
+ if (mServerAttack && mAction == BeingAction::ATTACK)
Net::getPlayerHandler()->stopAttack();
untarget();
@@ -792,8 +793,8 @@ void LocalPlayer::stopAttack(const bool keepAttack)
void LocalPlayer::untarget()
{
- if (mAction == ATTACK)
- setAction(STAND);
+ if (mAction == BeingAction::ATTACK)
+ setAction(BeingAction::STAND);
if (mTarget)
setTarget(nullptr);
@@ -1838,7 +1839,7 @@ void LocalPlayer::crazyMove()
void LocalPlayer::crazyMove1()
{
- if (mAction == MOVE)
+ if (mAction == BeingAction::MOVE)
return;
// if (!client->limitPackets(PACKET_DIRECTION))
@@ -1872,7 +1873,7 @@ void LocalPlayer::crazyMove1()
void LocalPlayer::crazyMove2()
{
- if (mAction == MOVE)
+ if (mAction == BeingAction::MOVE)
return;
// if (!client->limitPackets(PACKET_DIRECTION))
@@ -1910,7 +1911,7 @@ void LocalPlayer::crazyMove2()
void LocalPlayer::crazyMove3()
{
- if (mAction == MOVE)
+ if (mAction == BeingAction::MOVE)
return;
switch (mCrazyMoveState)
@@ -1944,7 +1945,7 @@ void LocalPlayer::crazyMove3()
void LocalPlayer::crazyMove4()
{
- if (mAction == MOVE)
+ if (mAction == BeingAction::MOVE)
return;
switch (mCrazyMoveState)
@@ -1964,7 +1965,7 @@ void LocalPlayer::crazyMove4()
void LocalPlayer::crazyMove5()
{
- if (mAction == MOVE)
+ if (mAction == BeingAction::MOVE)
return;
switch (mCrazyMoveState)
@@ -1984,7 +1985,7 @@ void LocalPlayer::crazyMove5()
void LocalPlayer::crazyMove6()
{
- if (mAction == MOVE)
+ if (mAction == BeingAction::MOVE)
return;
switch (mCrazyMoveState)
@@ -2028,7 +2029,7 @@ void LocalPlayer::crazyMove6()
void LocalPlayer::crazyMove7()
{
- if (mAction == MOVE)
+ if (mAction == BeingAction::MOVE)
return;
switch (mCrazyMoveState)
@@ -2056,7 +2057,7 @@ void LocalPlayer::crazyMove7()
void LocalPlayer::crazyMove8()
{
- if (mAction == MOVE || !mMap)
+ if (mAction == BeingAction::MOVE || !mMap)
return;
int idx = 0;
const int dist = 1;
@@ -2144,7 +2145,7 @@ void LocalPlayer::crazyMove9()
int dx = 0;
int dy = 0;
- if (mAction == MOVE)
+ if (mAction == BeingAction::MOVE)
return;
switch (mCrazyMoveState)
@@ -2165,7 +2166,7 @@ void LocalPlayer::crazyMove9()
mCrazyMoveState = 2;
if (!allowAction())
return;
- Net::getPlayerHandler()->changeAction(SIT);
+ Net::getPlayerHandler()->changeAction(BeingAction::SIT);
break;
case 2:
mCrazyMoveState = 3;
@@ -2182,7 +2183,7 @@ void LocalPlayer::crazyMoveA()
{
const std::string mMoveProgram(config.getStringValue("crazyMoveProgram"));
- if (mAction == MOVE)
+ if (mAction == BeingAction::MOVE)
return;
if (mMoveProgram.empty())
@@ -2651,7 +2652,7 @@ void LocalPlayer::specialMove(const unsigned char direction)
&& mInvertDirection <= 4)
&& !mIsServerBuggy)
{
- if (mAction == MOVE)
+ if (mAction == BeingAction::MOVE)
return;
int max;
@@ -2785,7 +2786,7 @@ void LocalPlayer::setHome()
const std::string key = mMap->getProperty("_realfilename");
Vector pos = mHomes[key];
- if (mAction == SIT)
+ if (mAction == BeingAction::SIT)
{
const std::map<std::string, Vector>::const_iterator
iter = mHomes.find(key);
@@ -3364,7 +3365,7 @@ void LocalPlayer::imitateEmote(const Being *const being,
}
void LocalPlayer::imitateAction(const Being *const being,
- const Being::Action &action)
+ const BeingAction::Action &action)
{
if (!being)
return;
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index ec789d0d2..4fa3e8328 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -86,7 +86,7 @@ class LocalPlayer final : public Being,
void slowLogic();
- void setAction(const Action &action,
+ void setAction(const BeingAction::Action &action,
const int attackType = 0) override final;
/**
@@ -344,7 +344,7 @@ class LocalPlayer final : public Being,
const unsigned char emote) const;
void imitateAction(const Being *const being,
- const Being::Action &action);
+ const BeingAction::Action &action);
void imitateDirection(const Being *const being,
const unsigned char dir);
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index b642c7f6f..72dfd21b6 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -51,15 +51,21 @@
extern int serverVersion;
-static const Being::Action actions[] =
+static const BeingAction::Action actions[] =
{
- Being::STAND, Being::SIT, Being::MOVE, Being::ATTACK, Being::DEAD
+ BeingAction::STAND,
+ BeingAction::SIT,
+ BeingAction::MOVE,
+ BeingAction::ATTACK,
+ BeingAction::DEAD
};
static const uint8_t directions[] =
{
- BeingDirection::DOWN, BeingDirection::RIGHT,
- BeingDirection::UP, BeingDirection::LEFT
+ BeingDirection::DOWN,
+ BeingDirection::RIGHT,
+ BeingDirection::UP,
+ BeingDirection::LEFT
};
CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index 56306a90f..db2800978 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -901,7 +901,7 @@ void NpcDialog::setAvatarAction(const int actionId)
{
Being *const being = mPlayerBox->getBeing();
if (being)
- being->setAction(static_cast<Being::Action>(actionId), 0);
+ being->setAction(static_cast<BeingAction::Action>(actionId), 0);
}
void NpcDialog::logic()
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index dd38dfdf7..34beab5ad 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -182,13 +182,13 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg,
if (spawnId)
{
- dstBeing->setAction(Being::SPAWN, 0);
+ dstBeing->setAction(BeingAction::SPAWN, 0);
}
else if (visible)
{
dstBeing->clearPath();
dstBeing->setActionTime(tick_time);
- dstBeing->setAction(Being::STAND, 0);
+ dstBeing->setAction(BeingAction::STAND, 0);
}
// Prevent division by 0 when calculating frame
@@ -300,7 +300,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg,
msg.readCoordinatePair(srcX, srcY, dstX, dstY);
if (!disguiseId)
{
- dstBeing->setAction(Being::STAND, 0);
+ dstBeing->setAction(BeingAction::STAND, 0);
dstBeing->setTileCoords(srcX, srcY);
if (serverVersion < 10)
dstBeing->setDestination(dstX, dstY);
@@ -366,7 +366,7 @@ void BeingHandler::processBeingMove2(Net::MessageIn &msg) const
msg.readCoordinatePair(srcX, srcY, dstX, dstY);
msg.readInt32(); // Server tick
- dstBeing->setAction(Being::STAND, 0);
+ dstBeing->setAction(BeingAction::STAND, 0);
dstBeing->setTileCoords(srcX, srcY);
dstBeing->setDestination(dstX, dstY);
if (dstBeing->getType() == Being::PLAYER)
@@ -405,9 +405,9 @@ void BeingHandler::processBeingRemove(Net::MessageIn &msg) const
if (msg.readInt8() == 1)
{
- if (dstBeing->getCurrentAction() != Being::DEAD)
+ if (dstBeing->getCurrentAction() != BeingAction::DEAD)
{
- dstBeing->setAction(Being::DEAD, 0);
+ dstBeing->setAction(BeingAction::DEAD, 0);
dstBeing->recalcSpritesOrder();
}
if (dstBeing->getName() == "Jack O" && killStats)
@@ -443,7 +443,7 @@ void BeingHandler::processBeingResurrect(Net::MessageIn &msg) const
player_node->stopAttack();
if (msg.readInt8() == 1)
- dstBeing->setAction(Being::STAND, 0);
+ dstBeing->setAction(BeingAction::STAND, 0);
}
@@ -511,17 +511,17 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) const
break;
// tmw server can send here garbage?
// if (srcBeing)
-// srcBeing->setAction(Being::DEAD, 0);
+// srcBeing->setAction(BeingAction::DEAD, 0);
case 0x02: // Sit
if (srcBeing)
{
- srcBeing->setAction(Being::SIT, 0);
+ srcBeing->setAction(BeingAction::SIT, 0);
if (srcBeing->getType() == Being::PLAYER)
{
srcBeing->setMoveTime();
if (player_node)
- player_node->imitateAction(srcBeing, Being::SIT);
+ player_node->imitateAction(srcBeing, BeingAction::SIT);
}
}
break;
@@ -529,12 +529,15 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) const
case 0x03: // Stand up
if (srcBeing)
{
- srcBeing->setAction(Being::STAND, 0);
+ srcBeing->setAction(BeingAction::STAND, 0);
if (srcBeing->getType() == Being::PLAYER)
{
srcBeing->setMoveTime();
if (player_node)
- player_node->imitateAction(srcBeing, Being::STAND);
+ {
+ player_node->imitateAction(srcBeing,
+ BeingAction::STAND);
+ }
}
}
break;
@@ -702,8 +705,8 @@ void BeingHandler::processPlayerStop(Net::MessageIn &msg) const
const uint16_t x = msg.readInt16();
const uint16_t y = msg.readInt16();
dstBeing->setTileCoords(x, y);
- if (dstBeing->getCurrentAction() == Being::MOVE)
- dstBeing->setAction(Being::STAND, 0);
+ if (dstBeing->getCurrentAction() == BeingAction::MOVE)
+ dstBeing->setAction(BeingAction::STAND, 0);
}
}
}
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index b299edd5f..efaee8857 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -203,7 +203,7 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg)
}
}
- player_node->setAction(Being::STAND, 0);
+ player_node->setAction(BeingAction::STAND, 0);
player_node->setTileCoords(x, y);
player_node->updatePets();
player_node->navigateClean();
@@ -400,9 +400,9 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
deathNotice = new OkDialog(_("Message"),
DeadDB::getRandomString(), DIALOG_OK, false);
deathNotice->addActionListener(&deathListener);
- if (player_node->getCurrentAction() != Being::DEAD)
+ if (player_node->getCurrentAction() != BeingAction::DEAD)
{
- player_node->setAction(Being::DEAD, 0);
+ player_node->setAction(BeingAction::DEAD, 0);
player_node->recalcSpritesOrder();
}
}
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index efa22e490..a6716a661 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -544,8 +544,8 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg,
dstBeing->setDirectionDelayed(static_cast<uint8_t>(d));
}
- if (player_node->getCurrentAction() != Being::STAND)
- player_node->imitateAction(dstBeing, Being::STAND);
+ if (player_node->getCurrentAction() != BeingAction::STAND)
+ player_node->imitateAction(dstBeing, BeingAction::STAND);
if (player_node->getDirection() != dstBeing->getDirection())
{
player_node->imitateDirection(dstBeing,
@@ -573,21 +573,21 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg,
switch (type)
{
case 0:
- dstBeing->setAction(Being::STAND, 0);
- player_node->imitateAction(dstBeing, Being::STAND);
+ dstBeing->setAction(BeingAction::STAND, 0);
+ player_node->imitateAction(dstBeing, BeingAction::STAND);
break;
case 1:
- if (dstBeing->getCurrentAction() != Being::DEAD)
+ if (dstBeing->getCurrentAction() != BeingAction::DEAD)
{
- dstBeing->setAction(Being::DEAD, 0);
+ dstBeing->setAction(BeingAction::DEAD, 0);
dstBeing->recalcSpritesOrder();
}
break;
case 2:
- dstBeing->setAction(Being::SIT, 0);
- player_node->imitateAction(dstBeing, Being::SIT);
+ dstBeing->setAction(BeingAction::SIT, 0);
+ player_node->imitateAction(dstBeing, BeingAction::SIT);
break;
default:
@@ -690,13 +690,13 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg,
if (spawnId)
{
- dstBeing->setAction(Being::SPAWN, 0);
+ dstBeing->setAction(BeingAction::SPAWN, 0);
}
else if (visible)
{
dstBeing->clearPath();
dstBeing->setActionTime(tick_time);
- dstBeing->setAction(Being::STAND, 0);
+ dstBeing->setAction(BeingAction::STAND, 0);
}
// Prevent division by 0 when calculating frame
@@ -776,7 +776,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg,
{
uint16_t srcX, srcY, dstX, dstY;
msg.readCoordinatePair(srcX, srcY, dstX, dstY);
- dstBeing->setAction(Being::STAND, 0);
+ dstBeing->setAction(BeingAction::STAND, 0);
dstBeing->setTileCoords(srcX, srcY);
dstBeing->setDestination(dstX, dstY);
}
diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp
index 627e5479f..17c8a6a41 100644
--- a/src/net/eathena/playerhandler.cpp
+++ b/src/net/eathena/playerhandler.cpp
@@ -183,23 +183,23 @@ void PlayerHandler::setDestination(const int x, const int y,
static_cast<unsigned char>(direction));
}
-void PlayerHandler::changeAction(const Being::Action &action) const
+void PlayerHandler::changeAction(const BeingAction::Action &action) const
{
unsigned char type;
switch (action)
{
- case Being::SIT:
+ case BeingAction::SIT:
type = 2;
break;
- case Being::STAND:
+ case BeingAction::STAND:
type = 3;
break;
default:
- case Being::MOVE:
- case Being::ATTACK:
- case Being::DEAD:
- case Being::HURT:
- case Being::SPAWN:
+ case BeingAction::MOVE:
+ case BeingAction::ATTACK:
+ case BeingAction::DEAD:
+ case BeingAction::HURT:
+ case BeingAction::SPAWN:
return;
}
diff --git a/src/net/eathena/playerhandler.h b/src/net/eathena/playerhandler.h
index 087c42973..3881150cb 100644
--- a/src/net/eathena/playerhandler.h
+++ b/src/net/eathena/playerhandler.h
@@ -50,7 +50,8 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler
void setDirection(const unsigned char direction) const override final;
void setDestination(const int x, const int y,
const int direction) const override final;
- void changeAction(const Being::Action &action) const override final;
+ void changeAction(const BeingAction::Action &action)
+ const override final;
void updateStatus(const uint8_t status) const override final;
static void processPlayerShortcuts(Net::MessageIn &msg);
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index fcb853198..de1314ddb 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -56,7 +56,7 @@ class PlayerHandler
virtual void setDestination(const int x, const int y,
const int direction) const = 0;
- virtual void changeAction(const Being::Action &action) const = 0;
+ virtual void changeAction(const BeingAction::Action &action) const = 0;
virtual void respawn() const = 0;
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index cd3a2cc15..314f9ee49 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -567,8 +567,8 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg,
dstBeing->setDirectionDelayed(static_cast<uint8_t>(d));
}
- if (player_node->getCurrentAction() != Being::STAND)
- player_node->imitateAction(dstBeing, Being::STAND);
+ if (player_node->getCurrentAction() != BeingAction::STAND)
+ player_node->imitateAction(dstBeing, BeingAction::STAND);
if (player_node->getDirection() != dstBeing->getDirection())
{
player_node->imitateDirection(dstBeing,
@@ -597,21 +597,21 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg,
switch (type)
{
case 0:
- dstBeing->setAction(Being::STAND, 0);
- player_node->imitateAction(dstBeing, Being::STAND);
+ dstBeing->setAction(BeingAction::STAND, 0);
+ player_node->imitateAction(dstBeing, BeingAction::STAND);
break;
case 1:
- if (dstBeing->getCurrentAction() != Being::DEAD)
+ if (dstBeing->getCurrentAction() != BeingAction::DEAD)
{
- dstBeing->setAction(Being::DEAD, 0);
+ dstBeing->setAction(BeingAction::DEAD, 0);
dstBeing->recalcSpritesOrder();
}
break;
case 2:
- dstBeing->setAction(Being::SIT, 0);
- player_node->imitateAction(dstBeing, Being::SIT);
+ dstBeing->setAction(BeingAction::SIT, 0);
+ player_node->imitateAction(dstBeing, BeingAction::SIT);
break;
default:
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index f9a8580df..550d0e89d 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -201,23 +201,23 @@ void PlayerHandler::setDestination(const int x, const int y,
static_cast<unsigned char>(direction));
}
-void PlayerHandler::changeAction(const Being::Action &action) const
+void PlayerHandler::changeAction(const BeingAction::Action &action) const
{
char type;
switch (action)
{
- case Being::SIT:
+ case BeingAction::SIT:
type = 2;
break;
- case Being::STAND:
+ case BeingAction::STAND:
type = 3;
break;
default:
- case Being::MOVE:
- case Being::ATTACK:
- case Being::DEAD:
- case Being::HURT:
- case Being::SPAWN:
+ case BeingAction::MOVE:
+ case BeingAction::ATTACK:
+ case BeingAction::DEAD:
+ case BeingAction::HURT:
+ case BeingAction::SPAWN:
return;
}
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index 125eea0ba..83dacf0ae 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/playerhandler.h
@@ -50,7 +50,8 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler
void setDirection(const unsigned char direction) const override final;
void setDestination(const int x, const int y,
const int direction) const override final;
- void changeAction(const Being::Action &action) const override final;
+ void changeAction(const BeingAction::Action &action)
+ const override final;
static void processOnlineList(Net::MessageIn &msg);
void requestOnlineList() const override final;
void updateStatus(const uint8_t status) const override final;