summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-29 20:33:10 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-29 20:33:10 +0300
commit9f1994182d4225f630a93ae06b01927c4f7a9a37 (patch)
treeb3557f6c6e6a923170929fd6553b59f872634291 /src
parentaef032f93b7bdc6e5908b2fa5f940a43bcfce50e (diff)
downloadmanaplus-9f1994182d4225f630a93ae06b01927c4f7a9a37.tar.gz
manaplus-9f1994182d4225f630a93ae06b01927c4f7a9a37.tar.bz2
manaplus-9f1994182d4225f630a93ae06b01927c4f7a9a37.tar.xz
manaplus-9f1994182d4225f630a93ae06b01927c4f7a9a37.zip
Convert ActorType enum into strong typed enum.
Diffstat (limited to 'src')
-rw-r--r--src/actions/target.cpp2
-rw-r--r--src/actormanager.cpp20
-rw-r--r--src/actormanager.h18
-rw-r--r--src/being/actorsprite.h2
-rw-r--r--src/being/being.cpp6
-rw-r--r--src/being/being.h10
-rw-r--r--src/enums/being/actortype.h32
-rw-r--r--src/flooritem.h2
-rw-r--r--src/gui/popups/beingpopup.cpp2
-rw-r--r--src/gui/popups/popupmenu.cpp2
-rw-r--r--src/gui/popups/popupmenu.h2
-rw-r--r--src/gui/viewport.cpp4
-rw-r--r--src/gui/widgets/avatarlistbox.cpp3
-rw-r--r--src/listeners/playerlistener.cpp2
-rw-r--r--src/listeners/playerlistener.h4
-rw-r--r--src/net/ea/beinghandler.cpp2
-rw-r--r--src/net/eathena/beinghandler.cpp2
17 files changed, 57 insertions, 58 deletions
diff --git a/src/actions/target.cpp b/src/actions/target.cpp
index 2c18b80f2..f5bf636d4 100644
--- a/src/actions/target.cpp
+++ b/src/actions/target.cpp
@@ -33,7 +33,7 @@
namespace Actions
{
-static bool setTarget(const ActorType::Type type, const AllowSort allowSort)
+static bool setTarget(const ActorTypeT type, const AllowSort allowSort)
{
if (actorManager && localPlayer)
{
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 8c7d48752..121f5e3f3 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -93,7 +93,7 @@ class FindBeingFunctor final
}
uint16_t x, y;
- ActorType::Type type;
+ ActorTypeT type;
} beingActorFinder;
class FindBeingEqualFunctor final
@@ -239,7 +239,7 @@ void ActorManager::setPlayer(LocalPlayer *const player)
}
Being *ActorManager::createBeing(const BeingId id,
- const ActorType::Type type,
+ const ActorTypeT type,
const BeingTypeId subtype)
{
Being *const being = new Being(id, type, subtype, mMap);
@@ -344,7 +344,7 @@ Being *ActorManager::findBeing(const BeingId id) const
}
Being *ActorManager::findBeing(const int x, const int y,
- const ActorType::Type type) const
+ const ActorTypeT type) const
{
beingActorFinder.x = static_cast<uint16_t>(x);
beingActorFinder.y = static_cast<uint16_t>(y);
@@ -726,7 +726,7 @@ bool ActorManager::pickUpNearest(const int x, const int y,
}
Being *ActorManager::findBeingByName(const std::string &name,
- const ActorType::Type type) const
+ const ActorTypeT type) const
{
for_actorsm
{
@@ -750,7 +750,7 @@ Being *ActorManager::findBeingByName(const std::string &name,
}
Being *ActorManager::findNearestByName(const std::string &name,
- const ActorType::Type &type) const
+ const ActorTypeT &type) const
{
if (!localPlayer)
return nullptr;
@@ -826,7 +826,7 @@ void ActorManager::logic()
if (!actor)
continue;
- const ActorType::Type &type = actor->getType();
+ const ActorTypeT &type = actor->getType();
if (type == ActorType::Player)
{
const Being *const being = static_cast<const Being*>(actor);
@@ -880,7 +880,7 @@ void ActorManager::clear()
Being *ActorManager::findNearestLivingBeing(const int x, const int y,
const int maxTileDist,
- const ActorType::Type type,
+ const ActorTypeT type,
const Being *const excluded) const
{
const int maxDist = maxTileDist * mapTileSize;
@@ -894,7 +894,7 @@ Being *ActorManager::findNearestLivingBeing(const int x, const int y,
Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
const int maxDist,
- const ActorType::Type type,
+ const ActorTypeT type,
const AllowSort allowSort) const
{
if (!aroundBeing)
@@ -911,7 +911,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
int maxDist,
- const ActorType::Type &type,
+ const ActorTypeT &type,
const int x, const int y,
const Being *const excluded,
const AllowSort allowSort) const
@@ -1178,7 +1178,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
bool ActorManager::validateBeing(const Being *const aroundBeing,
Being *const being,
- const ActorType::Type &type,
+ const ActorTypeT &type,
const Being* const excluded,
const int maxCost) const
{
diff --git a/src/actormanager.h b/src/actormanager.h
index 3dbf24d34..483a2d2c9 100644
--- a/src/actormanager.h
+++ b/src/actormanager.h
@@ -71,7 +71,7 @@ class ActorManager final: public ConfigListener
* Create a Being and add it to the list of ActorSprites.
*/
Being *createBeing(const BeingId id,
- const ActorType::Type type,
+ const ActorTypeT type,
const BeingTypeId subtype) A_WARN_UNUSED;
static Being *cloneBeing(const Being *const srcBeing,
@@ -106,7 +106,7 @@ class ActorManager final: public ConfigListener
/**
* Returns a being at specific coordinates.
*/
- Being *findBeing(const int x, const int y, const ActorType::Type
+ Being *findBeing(const int x, const int y, const ActorTypeT
type = ActorType::Unknown) const A_WARN_UNUSED;
/**
@@ -149,7 +149,7 @@ class ActorManager final: public ConfigListener
*/
Being *findNearestLivingBeing(const int x, const int y,
int maxTileDist,
- const ActorType::Type type,
+ const ActorTypeT type,
const Being *const excluded)
const A_WARN_UNUSED;
@@ -163,7 +163,7 @@ class ActorManager final: public ConfigListener
*/
Being *findNearestLivingBeing(const Being *const aroundBeing,
const int maxTileDist,
- const ActorType::Type type,
+ const ActorTypeT type,
const AllowSort allowSort)
const A_WARN_UNUSED;
@@ -171,7 +171,7 @@ class ActorManager final: public ConfigListener
* Finds a being by name and (optionally) by type.
*/
Being *findBeingByName(const std::string &name,
- const ActorType::Type
+ const ActorTypeT
type = ActorType::Unknown)
const A_WARN_UNUSED;
@@ -179,7 +179,7 @@ class ActorManager final: public ConfigListener
* Finds a nearest being by name and (optionally) by type.
*/
Being *findNearestByName(const std::string &name,
- const ActorType::Type &type
+ const ActorTypeT &type
= ActorType::Unknown) const A_WARN_UNUSED;
/**
@@ -194,7 +194,7 @@ class ActorManager final: public ConfigListener
* no being is returned
*/
// void HealAllTargets(Being *aroundBeing, int maxdist,
-// ActorType::Type type) const;
+// ActorTypeT type) const;
void healTarget() const;
@@ -338,13 +338,13 @@ class ActorManager final: public ConfigListener
protected:
bool validateBeing(const Being *const aroundBeing,
Being *const being,
- const ActorType::Type &type,
+ const ActorTypeT &type,
const Being *const excluded = nullptr,
const int maxCost = 20) const A_WARN_UNUSED;
Being *findNearestLivingBeing(const Being *const aroundBeing,
const int maxdist,
- const ActorType::Type &type,
+ const ActorTypeT &type,
const int x, const int y,
const Being *const excluded,
const AllowSort allowSort)
diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h
index 9e676193e..97553171a 100644
--- a/src/being/actorsprite.h
+++ b/src/being/actorsprite.h
@@ -65,7 +65,7 @@ class ActorSprite notfinal : public CompoundSprite, public Actor
/**
* Returns the type of the ActorSprite.
*/
- virtual ActorType::Type getType() const A_WARN_UNUSED
+ virtual ActorTypeT getType() const A_WARN_UNUSED
{ return ActorType::Unknown; }
void draw1(Graphics *const graphics,
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 68efe4c65..1362c904a 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -126,7 +126,7 @@ typedef std::map<int, Guild*>::const_iterator GuildsMapCIter;
typedef std::map<int, int>::const_iterator IntMapCIter;
Being::Being(const BeingId id,
- const ActorType::Type type,
+ const ActorTypeT type,
const BeingTypeId subtype,
Map *const map) :
ActorSprite(id),
@@ -3083,7 +3083,7 @@ void Being::updateComment()
}
std::string Being::loadComment(const std::string &name,
- const ActorType::Type &type)
+ const ActorTypeT &type)
{
std::string str;
switch (type)
@@ -3122,7 +3122,7 @@ std::string Being::loadComment(const std::string &name,
void Being::saveComment(const std::string &restrict name,
const std::string &restrict comment,
- const ActorType::Type &restrict type)
+ const ActorTypeT &restrict type)
{
std::string dir;
switch (type)
diff --git a/src/being/being.h b/src/being/being.h
index b7ac4fcf0..b1639f250 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -106,7 +106,7 @@ class Being notfinal : public ActorSprite,
* @param map the map the being is on
*/
Being(const BeingId id,
- const ActorType::Type type,
+ const ActorTypeT type,
const BeingTypeId subtype,
Map *const map);
@@ -114,7 +114,7 @@ class Being notfinal : public ActorSprite,
virtual ~Being();
- ActorType::Type getType() const override final A_WARN_UNUSED
+ ActorTypeT getType() const override final A_WARN_UNUSED
{ return mType; }
/**
@@ -736,12 +736,12 @@ class Being notfinal : public ActorSprite,
static void clearCache();
static std::string loadComment(const std::string &name,
- const ActorType::Type &type)
+ const ActorTypeT &type)
A_WARN_UNUSED;
static void saveComment(const std::string &restrict name,
const std::string &restrict comment,
- const ActorType::Type &restrict type);
+ const ActorTypeT &restrict type);
bool isAdvanced() const A_WARN_UNUSED
{ return mAdvanced; }
@@ -1023,7 +1023,7 @@ class Being notfinal : public ActorSprite,
void dumpSprites() const;
- const ActorType::Type mType;
+ const ActorTypeT mType;
/** Speech Bubble components */
SpeechBubble *mSpeechBubble;
diff --git a/src/enums/being/actortype.h b/src/enums/being/actortype.h
index c9e39e1f7..d9bf7b3f5 100644
--- a/src/enums/being/actortype.h
+++ b/src/enums/being/actortype.h
@@ -22,24 +22,24 @@
#ifndef ENUMS_BEING_ACTORTYPE_H
#define ENUMS_BEING_ACTORTYPE_H
-namespace ActorType
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(ActorType)
{
- enum Type
- {
- Unknown = 0,
- Player,
- Npc,
- Monster,
- FloorItem,
- Portal,
- LocalPet,
- Avatar,
+ Unknown = 0,
+ Player,
+ Npc,
+ Monster,
+ FloorItem,
+ Portal,
+ LocalPet,
+ Avatar,
#ifdef EATHENA_SUPPORT
- Pet,
- Mercenary,
- Homunculus
+ Pet,
+ Mercenary,
+ Homunculus
#endif
- };
-} // namespace ActorType
+}
+enumEnd(ActorType);
#endif // ENUMS_BEING_ACTORTYPE_H
diff --git a/src/flooritem.h b/src/flooritem.h
index dbeffa8dd..c7a333329 100644
--- a/src/flooritem.h
+++ b/src/flooritem.h
@@ -57,7 +57,7 @@ class FloorItem final : public ActorSprite
void postInit(Map *const map, int subX, int subY);
- ActorType::Type getType() const override final A_WARN_UNUSED
+ ActorTypeT getType() const override final A_WARN_UNUSED
{ return ActorType::FloorItem; }
void draw(Graphics *const graphics,
diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp
index 167767e74..8cacafefb 100644
--- a/src/gui/popups/beingpopup.cpp
+++ b/src/gui/popups/beingpopup.cpp
@@ -157,7 +157,7 @@ void BeingPopup::show(const int x, const int y, Being *const b)
label7->setCaption("");
#ifdef EATHENA_SUPPORT
- const ActorType::Type type = b->getType();
+ const ActorTypeT type = b->getType();
if (type == ActorType::Pet)
{
PetInfo *const info = PlayerInfo::getPet();
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 59c1cc469..6c348a8e5 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1070,7 +1070,7 @@ void PopupMenu::handleLink(const std::string &link,
else
{
dialog->setText(Being::loadComment(mNick,
- static_cast<ActorType::Type>(mType)));
+ static_cast<ActorTypeT>(mType)));
}
dialog->setActionEventId("ok");
dialog->addActionListener(&mPlayerListener);
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index e1f9b3ba7..d963591bc 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -216,7 +216,7 @@ class PopupMenu final : public Popup, public LinkHandler
Button *mButton;
std::string mNick;
TextField *mTextField;
- ActorType::Type mType;
+ ActorTypeT mType;
int mX;
int mY;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index e0ffd732f..2beed89d0 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -437,7 +437,7 @@ bool Viewport::leftMouseAction()
}
else
{
- const ActorType::Type type = mHoverBeing->getType();
+ const ActorTypeT type = mHoverBeing->getType();
if (type == ActorType::Player)
{
validateSpeed();
@@ -778,7 +778,7 @@ void Viewport::mouseMoved(MouseEvent &event)
const int x = mMouseX + mPixelViewX;
const int y = mMouseY + mPixelViewY;
- ActorType::Type type = ActorType::Unknown;
+ ActorTypeT type = ActorType::Unknown;
mHoverBeing = actorManager->findBeingByPixel(x, y, AllPlayers_true);
if (mHoverBeing)
type = mHoverBeing->getType();
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 7bbaf5196..a3c29a68a 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -660,8 +660,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
popupMenu->showAttackMonsterPopup(viewport->mMouseX,
viewport->mMouseY,
name,
- static_cast<ActorType::Type>(model->getAvatarAt(
- selected)->getType()));
+ model->getAvatarAt(selected)->getType());
break;
}
case MapItemType::PICKUP:
diff --git a/src/listeners/playerlistener.cpp b/src/listeners/playerlistener.cpp
index ae0f3aca7..99d06458b 100644
--- a/src/listeners/playerlistener.cpp
+++ b/src/listeners/playerlistener.cpp
@@ -42,7 +42,7 @@ void PlayerListener::action(const ActionEvent &event)
{
std::string comment = mDialog->getText();
Being *const being = actorManager->findBeingByName(
- mNick, static_cast<ActorType::Type>(mType));
+ mNick, static_cast<ActorTypeT>(mType));
if (being)
being->setComment(comment);
Being::saveComment(mNick, comment, mType);
diff --git a/src/listeners/playerlistener.h b/src/listeners/playerlistener.h
index 52527fafc..fd503da95 100644
--- a/src/listeners/playerlistener.h
+++ b/src/listeners/playerlistener.h
@@ -44,13 +44,13 @@ class PlayerListener final : public ActionListener
void setDialog(TextDialog *const dialog)
{ mDialog = dialog; }
- void setType(const ActorType::Type type)
+ void setType(const ActorTypeT type)
{ mType = type; }
private:
std::string mNick;
TextDialog *mDialog;
- ActorType::Type mType;
+ ActorTypeT mType;
};
#endif // LISTENERS_PLAYERLISTENER_H
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 5bfdf5212..ba1d21fbd 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -58,7 +58,7 @@ Being *BeingHandler::createBeing(const BeingId id,
if (!actorManager)
return nullptr;
- ActorType::Type type = ActorType::Unknown;
+ ActorTypeT type = ActorType::Unknown;
if (job <= 25 || (job >= 4001 && job <= 4049))
type = ActorType::Player;
else if (job >= 46 && job <= 1000)
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index 1b566edc7..99866bfbf 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -421,7 +421,7 @@ Being *BeingHandler::createBeing2(Net::MessageIn &msg,
if (!actorManager)
return nullptr;
- ActorType::Type type = ActorType::Unknown;
+ ActorTypeT type = ActorType::Unknown;
switch (beingType)
{
case BeingType::PC: