summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actormanager.cpp15
-rw-r--r--src/actormanager.h7
-rw-r--r--src/being/being.cpp39
-rw-r--r--src/being/being.h12
-rw-r--r--src/being/localplayer.cpp2
-rw-r--r--src/being/localplayer.h2
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.cpp2
-rw-r--r--src/gui/windows/charcreatedialog.cpp4
-rw-r--r--src/gui/windows/npcdialog.cpp2
-rw-r--r--src/gui/windows/questswindow.cpp16
-rw-r--r--src/gui/windows/questswindow.h4
-rw-r--r--src/inventory.cpp2
-rw-r--r--src/inventory.h4
-rw-r--r--src/itemsoundmanager.cpp2
-rw-r--r--src/net/ea/beinghandler.cpp5
-rw-r--r--src/net/ea/beinghandler.h2
-rw-r--r--src/net/eathena/beinghandler.cpp13
-rw-r--r--src/net/eathena/charserverhandler.cpp4
-rw-r--r--src/net/eathena/pethandler.cpp3
-rw-r--r--src/net/tmwa/beinghandler.cpp12
-rw-r--r--src/net/tmwa/charserverhandler.cpp4
-rw-r--r--src/resources/iteminfo.cpp5
-rw-r--r--src/resources/iteminfo.h5
-rw-r--r--src/resources/questeffect.h6
24 files changed, 96 insertions, 76 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 4544e445f..8c7d48752 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -240,7 +240,7 @@ void ActorManager::setPlayer(LocalPlayer *const player)
Being *ActorManager::createBeing(const BeingId id,
const ActorType::Type type,
- const uint16_t subtype)
+ const BeingTypeId subtype)
{
Being *const being = new Being(id, type, subtype, mMap);
@@ -1380,7 +1380,7 @@ void ActorManager::printBeingsToChat(const ActorSprites &beings,
debugChatTab->chatLog(strprintf("%s (%d,%d) %d",
being->getName().c_str(), being->getTileX(), being->getTileY(),
- being->getSubType()), ChatMsgType::BY_SERVER);
+ toInt(being->getSubType(), int)), ChatMsgType::BY_SERVER);
}
debugChatTab->chatLog("---------------------------------------",
ChatMsgType::BY_SERVER);
@@ -1405,7 +1405,7 @@ void ActorManager::printBeingsToChat(const std::vector<Being*> &beings,
debugChatTab->chatLog(strprintf("%s (%d,%d) %d",
being->getName().c_str(), being->getTileX(), being->getTileY(),
- being->getSubType()), ChatMsgType::BY_SERVER);
+ toInt(being->getSubType(), int)), ChatMsgType::BY_SERVER);
}
debugChatTab->chatLog("---------------------------------------",
ChatMsgType::BY_SERVER);
@@ -1775,18 +1775,19 @@ bool ActorManager::checkForPickup(const FloorItem *const item) const
return false;
}
-void ActorManager::updateEffects(const std::map<int, int> &addEffects,
- const std::set<int> &removeEffects) const
+void ActorManager::updateEffects(const std::map<BeingTypeId, int> &addEffects,
+ const std::set<BeingTypeId> &removeEffects)
+ const
{
for_actorsm
{
if (!*it || (*it)->getType() != ActorType::Npc)
continue;
Being *const being = static_cast<Being*>(*it);
- const int type = being->getSubType();
+ const BeingTypeId type = being->getSubType();
if (removeEffects.find(type) != removeEffects.end())
being->removeSpecialEffect();
- const std::map<int, int>::const_iterator idAdd = addEffects.find(type);
+ const std::map<BeingTypeId, int>::const_iterator idAdd = addEffects.find(type);
if (idAdd != addEffects.end())
being->addSpecialEffect((*idAdd).second);
}
diff --git a/src/actormanager.h b/src/actormanager.h
index 073a5a025..3dbf24d34 100644
--- a/src/actormanager.h
+++ b/src/actormanager.h
@@ -28,6 +28,7 @@
#include "enums/simpletypes/allowsort.h"
#include "enums/simpletypes/allplayers.h"
#include "enums/simpletypes/beingid.h"
+#include "enums/simpletypes/beingtypeid.h"
#include "enums/simpletypes/npcnames.h"
#include "listeners/configlistener.h"
@@ -71,7 +72,7 @@ class ActorManager final: public ConfigListener
*/
Being *createBeing(const BeingId id,
const ActorType::Type type,
- const uint16_t subtype) A_WARN_UNUSED;
+ const BeingTypeId subtype) A_WARN_UNUSED;
static Being *cloneBeing(const Being *const srcBeing,
const int dx, const int dy,
@@ -325,8 +326,8 @@ class ActorManager final: public ConfigListener
bool checkForPickup(const FloorItem *const item) const A_WARN_UNUSED;
- void updateEffects(const std::map<int, int> &addEffects,
- const std::set<int> &removeEffects) const;
+ void updateEffects(const std::map<BeingTypeId, int> &addEffects,
+ const std::set<BeingTypeId> &removeEffects) const;
#ifdef EATHENA_SUPPORT
void removeRoom(const int chatId);
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 12209df81..68efe4c65 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -127,7 +127,7 @@ typedef std::map<int, int>::const_iterator IntMapCIter;
Being::Being(const BeingId id,
const ActorType::Type type,
- const uint16_t subtype,
+ const BeingTypeId subtype,
Map *const map) :
ActorSprite(id),
mNextSound(),
@@ -164,7 +164,7 @@ Being::Being(const BeingId id,
mPreStandTime(0),
mGender(Gender::UNSPECIFIED),
mAction(BeingAction::STAND),
- mSubType(0xFFFF),
+ mSubType(fromInt(0xFFFF, BeingTypeId)),
mDirection(BeingDirection::DOWN),
mDirectionDelayed(0),
mSpriteDirection(SpriteDirection::DOWN),
@@ -320,7 +320,8 @@ void Being::createSpeechBubble()
mSpeechBubble->postInit();
}
-void Being::setSubtype(const uint16_t subtype, const uint16_t look)
+void Being::setSubtype(const BeingTypeId subtype,
+ const uint16_t look)
{
if (!mInfo)
return;
@@ -333,7 +334,7 @@ void Being::setSubtype(const uint16_t subtype, const uint16_t look)
if (mType == ActorType::Monster)
{
- mInfo = MonsterDB::get(fromInt(mSubType, BeingTypeId));
+ mInfo = MonsterDB::get(mSubType);
if (mInfo)
{
setName(mInfo->getName());
@@ -347,7 +348,7 @@ void Being::setSubtype(const uint16_t subtype, const uint16_t look)
#ifdef EATHENA_SUPPORT
if (mType == ActorType::Pet)
{
- mInfo = PETDB::get(fromInt(mSubType, BeingTypeId));
+ mInfo = PETDB::get(mSubType);
if (mInfo)
{
setName(mInfo->getName());
@@ -360,7 +361,7 @@ void Being::setSubtype(const uint16_t subtype, const uint16_t look)
}
else if (mType == ActorType::Mercenary)
{
- mInfo = MercenaryDB::get(fromInt(mSubType, BeingTypeId));
+ mInfo = MercenaryDB::get(mSubType);
if (mInfo)
{
setName(mInfo->getName());
@@ -373,7 +374,7 @@ void Being::setSubtype(const uint16_t subtype, const uint16_t look)
}
if (mType == ActorType::Homunculus)
{
- mInfo = HomunculusDB::get(fromInt(mSubType, BeingTypeId));
+ mInfo = HomunculusDB::get(mSubType);
if (mInfo)
{
setName(mInfo->getName());
@@ -387,7 +388,7 @@ void Being::setSubtype(const uint16_t subtype, const uint16_t look)
#endif
else if (mType == ActorType::Npc)
{
- mInfo = NPCDB::get(fromInt(mSubType, BeingTypeId));
+ mInfo = NPCDB::get(mSubType);
if (mInfo)
{
setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false);
@@ -396,7 +397,7 @@ void Being::setSubtype(const uint16_t subtype, const uint16_t look)
}
else if (mType == ActorType::Avatar)
{
- mInfo = AvatarDB::get(fromInt(mSubType, BeingTypeId));
+ mInfo = AvatarDB::get(mSubType);
if (mInfo)
setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false);
}
@@ -417,7 +418,7 @@ void Being::setSubtype(const uint16_t subtype, const uint16_t look)
}
else if (mType == ActorType::Player)
{
- int id = -100 - subtype;
+ int id = -100 - toInt(subtype, int);
// Prevent showing errors when sprite doesn't exist
if (!ItemDB::exists(id))
@@ -902,7 +903,7 @@ void Being::handleAttack(Being *const victim, const int damage,
// here 10 is weapon slot
int weaponId = mSpriteIDs[10];
if (!weaponId)
- weaponId = -100 - mSubType;
+ weaponId = -100 - toInt(mSubType, int);
const ItemInfo &info = ItemDB::get(weaponId);
playSfx(info.getSound(
(damage > 0) ? ItemSoundEvent::HIT : ItemSoundEvent::MISS),
@@ -2199,7 +2200,8 @@ void Being::setSprite(const unsigned int slot, const int id,
else
{
const ItemInfo &info = ItemDB::get(id);
- const std::string &filename = info.getSprite(mGender, mSubType);
+ const std::string &filename = info.getSprite(
+ mGender, mSubType);
AnimatedSprite *equipmentSprite = nullptr;
if (!isTempSprite && mType == ActorType::Player)
@@ -2291,15 +2293,15 @@ void Being::load()
// Hairstyles are encoded as negative numbers. Count how far negative
// we can go.
int hairstyles = 1;
- while (ItemDB::get(-hairstyles).getSprite(Gender::MALE, 0) !=
- paths.getStringValue("spriteErrorFile"))
+ while (ItemDB::get(-hairstyles).getSprite(Gender::MALE,
+ BeingTypeId_zero) != paths.getStringValue("spriteErrorFile"))
{
hairstyles ++;
}
mNumberOfHairstyles = hairstyles;
int races = 100;
- while (ItemDB::get(-races).getSprite(Gender::MALE, 0) !=
+ while (ItemDB::get(-races).getSprite(Gender::MALE, BeingTypeId_zero) !=
paths.getStringValue("spriteErrorFile"))
{
races ++;
@@ -2552,7 +2554,10 @@ void Being::drawSpriteAt(Graphics *const graphics,
if (!userPalette)
return;
- if (mHighlightMapPortals && mMap && mSubType == 45 && !mMap->getHasWarps())
+ if (mHighlightMapPortals &&
+ mMap &&
+ mSubType == fromInt(45, BeingTypeId) &&
+ !mMap->getHasWarps())
{
graphics->setColor(userPalette->
getColorWithAlpha(UserPalette::PORTAL_HIGHLIGHT));
@@ -3336,7 +3341,7 @@ void Being::addPet(const BeingId id)
}
Being *const being = actorManager->createBeing(
- id, ActorType::LocalPet, 0);
+ id, ActorType::LocalPet, BeingTypeId_zero);
if (being)
{
being->setOwner(this);
diff --git a/src/being/being.h b/src/being/being.h
index 1b7db882a..b7ac4fcf0 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -107,7 +107,7 @@ class Being notfinal : public ActorSprite,
*/
Being(const BeingId id,
const ActorType::Type type,
- const uint16_t subtype,
+ const BeingTypeId subtype,
Map *const map);
A_DELETE_COPY(Being)
@@ -361,13 +361,13 @@ class Being notfinal : public ActorSprite,
void drawEmotion(Graphics *const graphics, const int offsetX,
const int offsetY) const;
- uint16_t getSubType() const
+ BeingTypeId getSubType() const
{ return mSubType; }
/**
* Set Being's subtype (mostly for view for monsters and NPCs)
*/
- void setSubtype(const uint16_t subtype, const uint16_t look);
+ void setSubtype(const BeingTypeId subtype, const uint16_t look);
const BeingInfo *getInfo() const A_WARN_UNUSED
{ return mInfo; }
@@ -997,9 +997,9 @@ class Being notfinal : public ActorSprite,
Gender::Type mGender;
BeingAction::Action mAction;
- uint16_t mSubType; /**< Subtype (graphical view, basically) */
- uint8_t mDirection; /**< Facing direction */
- uint8_t mDirectionDelayed; /**< Facing direction */
+ BeingTypeId mSubType; /**< Subtype (graphical view, basically) */
+ uint8_t mDirection; /**< Facing direction */
+ uint8_t mDirectionDelayed; /**< Facing direction */
SpriteDirection::Type mSpriteDirection; /**< Facing direction */
bool mShowName;
bool mIsGM;
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 2bc2d928b..58b25630e 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -112,7 +112,7 @@ extern MiniStatusWindow *miniStatusWindow;
extern SkillDialog *skillDialog;
LocalPlayer::LocalPlayer(const BeingId id,
- const uint16_t subtype) :
+ const BeingTypeId subtype) :
Being(id, ActorType::Player, subtype, nullptr),
AttributeListener(),
PlayerDeathListener(),
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index 0d890c985..093b188c4 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -58,7 +58,7 @@ class LocalPlayer final : public Being,
* Constructor.
*/
explicit LocalPlayer(const BeingId id,
- const uint16_t subtype = 0U);
+ const BeingTypeId subtype = BeingTypeId_zero);
A_DELETE_COPY(LocalPlayer)
diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp
index 704f1a114..1dfd56c1a 100644
--- a/src/gui/widgets/tabs/debugwindowtabs.cpp
+++ b/src/gui/widgets/tabs/debugwindowtabs.cpp
@@ -326,7 +326,7 @@ void TargetDebugTab::logic()
_("Target Id:"), toInt(target->getId(), int)));
mTargetTypeLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
- _("Target type:"), target->getSubType()));
+ _("Target type:"), toInt(target->getSubType(), int)));
if (target->getLevel())
{
mTargetLevelLabel->setCaption(strprintf("%s %d",
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index 917cc51fb..f37749756 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -124,7 +124,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
mCancelButton(new Button(this, _("Cancel"), "cancel", this)),
mPlayer(new Being(BeingId_zero,
ActorType::Player,
- static_cast<uint16_t>(0U),
+ BeingTypeId_zero,
nullptr)),
mPlayerBox(new PlayerBox(this, mPlayer, "charcreate_playerbox.xml",
"charcreate_selectedplayerbox.xml")),
@@ -652,7 +652,7 @@ void CharCreateDialog::updateLook()
{
mLook = 0;
}
- mPlayer->setSubtype(static_cast<uint16_t>(mRace),
+ mPlayer->setSubtype(fromInt(mRace, BeingTypeId),
static_cast<uint8_t>(mLook));
if (mRaceNameLabel)
{
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index c60cbd9b4..ebc716d0f 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -870,7 +870,7 @@ void NpcDialog::showAvatar(const BeingTypeId avatarId)
delete mAvatarBeing;
mAvatarBeing = new Being(BeingId_zero,
ActorType::Avatar,
- toInt(avatarId, uint16_t),
+ avatarId,
nullptr);
mPlayerBox->setPlayer(mAvatarBeing);
if (!mAvatarBeing->empty())
diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp
index 9279220ac..608d84954 100644
--- a/src/gui/windows/questswindow.cpp
+++ b/src/gui/windows/questswindow.cpp
@@ -245,12 +245,12 @@ void QuestsWindow::loadEffect(const int var, const XmlNodePtr node)
{
QuestEffect *const effect = new QuestEffect;
effect->map = XML::getProperty(node, "map", "");
- effect->id = XML::getProperty(node, "npc", -1);
+ effect->id = fromInt(XML::getProperty(node, "npc", -1), BeingTypeId);
effect->effectId = XML::getProperty(node, "effect", -1);
const std::string values = XML::getProperty(node, "value", "");
splitToIntSet(effect->values, values, ',');
- if (effect->map.empty() || effect->id == -1
+ if (effect->map.empty() || effect->id == BeingTypeId_negOne
|| effect->effectId == -1 || values.empty())
{
delete effect;
@@ -465,13 +465,13 @@ void QuestsWindow::updateEffects()
if (!actorManager)
return;
- std::set<int> removeEffects;
- std::map<int, int> addEffects;
+ std::set<BeingTypeId> removeEffects;
+ std::map<BeingTypeId, int> addEffects;
// for old effects
FOR_EACH (NpcQuestEffectMapCIter, it, oldNpc)
{
- const int id = (*it).first;
+ const BeingTypeId id = (*it).first;
const QuestEffect *const effect = (*it).second;
const NpcQuestEffectMapCIter itNew = mNpcEffects.find(id);
@@ -493,7 +493,7 @@ void QuestsWindow::updateEffects()
// for new effects
FOR_EACH (NpcQuestEffectMapCIter, it, mNpcEffects)
{
- const int id = (*it).first;
+ const BeingTypeId id = (*it).first;
const QuestEffect *const effect = (*it).second;
const NpcQuestEffectMapCIter itNew = oldNpc.find(id);
@@ -509,8 +509,8 @@ void QuestsWindow::addEffect(Being *const being)
{
if (!being)
return;
- const int id = being->getSubType();
- const std::map<int, const QuestEffect*>::const_iterator
+ const BeingTypeId id = being->getSubType();
+ const std::map<BeingTypeId, const QuestEffect*>::const_iterator
it = mNpcEffects.find(id);
if (it != mNpcEffects.end())
{
diff --git a/src/gui/windows/questswindow.h b/src/gui/windows/questswindow.h
index 927b32540..0430569a3 100644
--- a/src/gui/windows/questswindow.h
+++ b/src/gui/windows/questswindow.h
@@ -23,6 +23,8 @@
#include "localconsts.h"
+#include "enums/simpletypes/beingtypeid.h"
+
#include "gui/widgets/window.h"
#include "utils/xml.h"
@@ -41,7 +43,7 @@ class QuestsModel;
struct QuestEffect;
struct QuestItem;
-typedef std::map<int, const QuestEffect*> NpcQuestEffectMap;
+typedef std::map<BeingTypeId, const QuestEffect*> NpcQuestEffectMap;
typedef NpcQuestEffectMap::const_iterator NpcQuestEffectMapCIter;
class QuestsWindow final : public Window,
diff --git a/src/inventory.cpp b/src/inventory.cpp
index c58997ce6..dd0e516ad 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -255,7 +255,7 @@ void Inventory::distributeSlotsChangedEvent()
const Item *Inventory::findItemBySprite(std::string spritePath,
const Gender::Type gender,
- const int race) const
+ const BeingTypeId race) const
{
spritePath = removeSpriteIndex(spritePath);
diff --git a/src/inventory.h b/src/inventory.h
index 4bde1a3da..f7b647780 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -25,6 +25,7 @@
#include "enums/inventorytype.h"
+#include "enums/simpletypes/beingtypeid.h"
#include "enums/simpletypes/damaged.h"
#include "enums/simpletypes/equipm.h"
#include "enums/simpletypes/equipped.h"
@@ -163,7 +164,8 @@ class Inventory final
const Item *findItemBySprite(std::string spritePath,
const Gender::Type gender,
- const int race) const A_WARN_UNUSED;
+ const BeingTypeId race)
+ const A_WARN_UNUSED;
std::string getName() const A_WARN_UNUSED;
diff --git a/src/itemsoundmanager.cpp b/src/itemsoundmanager.cpp
index 647b54820..36238274f 100644
--- a/src/itemsoundmanager.cpp
+++ b/src/itemsoundmanager.cpp
@@ -59,7 +59,7 @@ void ItemSoundManager::playSfx(const ItemInfo &info,
if (sfx.empty())
{
// fallback to player race sound if no item sound.
- const int id = -100 - localPlayer->getSubType();
+ const int id = -100 - toInt(localPlayer->getSubType(), int);
const ItemInfo &info2 = ItemDB::get(id);
sfx = info2.getSound(sound).sound;
}
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index ab32a3f84..5bfdf5212 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -53,7 +53,7 @@ BeingHandler::BeingHandler(const bool enableSync)
}
Being *BeingHandler::createBeing(const BeingId id,
- const int16_t job)
+ const int job)
{
if (!actorManager)
return nullptr;
@@ -68,7 +68,8 @@ Being *BeingHandler::createBeing(const BeingId id,
else if (job == 45)
type = ActorType::Portal;
- Being *const being = actorManager->createBeing(id, type, job);
+ Being *const being = actorManager->createBeing(
+ id, type, fromInt(job, BeingTypeId));
return being;
}
diff --git a/src/net/ea/beinghandler.h b/src/net/ea/beinghandler.h
index 632381fb3..55e4a3ef2 100644
--- a/src/net/ea/beinghandler.h
+++ b/src/net/ea/beinghandler.h
@@ -37,7 +37,7 @@ class BeingHandler notfinal : public Net::BeingHandler
explicit BeingHandler(const bool enableSync);
static Being *createBeing(const BeingId id,
- const int16_t job) A_WARN_UNUSED;
+ const int job) A_WARN_UNUSED;
static void setSprite(Being *const being, const unsigned int slot,
const int id,
diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp
index 9bc79c407..1b566edc7 100644
--- a/src/net/eathena/beinghandler.cpp
+++ b/src/net/eathena/beinghandler.cpp
@@ -460,7 +460,8 @@ Being *BeingHandler::createBeing2(Net::MessageIn &msg,
if (job == 45 && beingType == BeingType::NPC_EVENT)
type = ActorType::Portal;
- Being *const being = actorManager->createBeing(id, type, job);
+ Being *const being = actorManager->createBeing(
+ id, type, fromInt(job, BeingTypeId));
if (beingType == BeingType::MERSOL)
{
MercenaryInfo *const info = PlayerInfo::getMercenary();
@@ -524,7 +525,7 @@ void BeingHandler::processBeingChangeLookContinue(Net::MessageIn &msg,
switch (type)
{
case 0: // change race
- dstBeing->setSubtype(static_cast<uint16_t>(id),
+ dstBeing->setSubtype(fromInt(id, BeingTypeId),
dstBeing->getLook());
break;
case 1: // eAthena LOOK_HAIR
@@ -689,7 +690,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
speed = 150;
dstBeing->setWalkSpeed(Vector(speed, speed, 0));
- dstBeing->setSubtype(job, 0);
+ dstBeing->setSubtype(fromInt(job, BeingTypeId), 0);
if (dstBeing->getType() == ActorType::Monster && localPlayer)
localPlayer->checkNewName(dstBeing);
@@ -849,7 +850,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
speed = 150;
dstBeing->setWalkSpeed(Vector(speed, speed, 0));
- dstBeing->setSubtype(job, 0);
+ dstBeing->setSubtype(fromInt(job, BeingTypeId), 0);
if (dstBeing->getType() == ActorType::Monster && localPlayer)
localPlayer->checkNewName(dstBeing);
@@ -1019,7 +1020,7 @@ void BeingHandler::processBeingSpawn(Net::MessageIn &msg)
speed = 150;
dstBeing->setWalkSpeed(Vector(speed, speed, 0));
- dstBeing->setSubtype(job, 0);
+ dstBeing->setSubtype(fromInt(job, BeingTypeId), 0);
if (dstBeing->getType() == ActorType::Monster && localPlayer)
localPlayer->checkNewName(dstBeing);
@@ -1700,7 +1701,7 @@ void BeingHandler::processBeingFakeName(Net::MessageIn &msg)
msg.skip(4, "unsued");
Being *const dstBeing = createBeing2(msg, id, job, type);
- dstBeing->setSubtype(job, 0);
+ dstBeing->setSubtype(fromInt(job, BeingTypeId), 0);
dstBeing->setTileCoords(x, y);
dstBeing->setDirection(dir);
}
diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp
index f94e3a34f..76005d968 100644
--- a/src/net/eathena/charserverhandler.cpp
+++ b/src/net/eathena/charserverhandler.cpp
@@ -201,7 +201,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
static_cast<LoginHandler*>(loginHandler)->getToken();
LocalPlayer *const tempPlayer = new LocalPlayer(
- msg.readBeingId("player id"), 0);
+ msg.readBeingId("player id"), BeingTypeId_zero);
tempPlayer->setGender(token.sex);
PlayerInfoBackend &data = character->data;
@@ -252,7 +252,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
color));
const uint16_t look = msg.readInt16("clothes color");
- tempPlayer->setSubtype(race, look);
+ tempPlayer->setSubtype(fromInt(race, BeingTypeId), look);
tempPlayer->setName(msg.readString(24, "name"));
character->dummy = tempPlayer;
diff --git a/src/net/eathena/pethandler.cpp b/src/net/eathena/pethandler.cpp
index 32f902e80..f89a6d53a 100644
--- a/src/net/eathena/pethandler.cpp
+++ b/src/net/eathena/pethandler.cpp
@@ -166,7 +166,8 @@ void PetHandler::processPetMessage(Net::MessageIn &msg)
if (!dstBeing)
return;
- const int hungry = data - (dstBeing->getSubType() - 100) * 100 - 50;
+ const int hungry = data - (toInt(dstBeing->getSubType(), int)
+ - 100) * 100 - 50;
if (hungry >= 0 && hungry <= 4)
{
if (localChatTab && localPlayer)
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 0191953a4..451a88ec5 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -330,7 +330,7 @@ void BeingHandler::processBeingChangeLookContinue(Net::MessageIn &msg,
switch (type)
{
case 0: // change race
- dstBeing->setSubtype(static_cast<uint16_t>(id),
+ dstBeing->setSubtype(fromInt(id, BeingTypeId),
dstBeing->getLook());
break;
case 1: // eAthena LOOK_HAIR
@@ -479,7 +479,7 @@ void BeingHandler::processPlayerUpdate1(Net::MessageIn &msg)
const uint8_t hairStyle = msg.readUInt8("hair style");
const uint16_t look = msg.readUInt8("look");
- dstBeing->setSubtype(job, look);
+ dstBeing->setSubtype(fromInt(job, BeingTypeId), look);
const uint16_t weapon = msg.readInt16("weapon");
const uint16_t shield = msg.readInt16("shield");
const uint16_t headBottom = msg.readInt16("head bottom");
@@ -631,7 +631,7 @@ void BeingHandler::processPlayerUpdate2(Net::MessageIn &msg)
const uint8_t hairStyle = msg.readUInt8("hair style");
const uint16_t look = msg.readUInt8("look");
- dstBeing->setSubtype(job, look);
+ dstBeing->setSubtype(fromInt(job, BeingTypeId), look);
const uint16_t weapon = msg.readInt16("weapon");
const uint16_t shield = msg.readInt16("shield");
const uint16_t headBottom = msg.readInt16("head bottom");
@@ -779,7 +779,7 @@ void BeingHandler::processPlayerMove(Net::MessageIn &msg)
const uint8_t hairStyle = msg.readUInt8("hair style");
const uint16_t look = msg.readUInt8("look");
- dstBeing->setSubtype(job, look);
+ dstBeing->setSubtype(fromInt(job, BeingTypeId), look);
const uint16_t weapon = msg.readInt16("weapon");
const uint16_t shield = msg.readInt16("shield");
const uint16_t headBottom = msg.readInt16("head bottom");
@@ -986,7 +986,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
const uint8_t hairStyle = msg.readUInt8("hair style");
const uint16_t look = msg.readUInt8("look");
- dstBeing->setSubtype(job, look);
+ dstBeing->setSubtype(fromInt(job, BeingTypeId), look);
if (dstBeing->getType() == ActorType::Monster && localPlayer)
localPlayer->checkNewName(dstBeing);
dstBeing->setWalkSpeed(Vector(speed, speed, 0));
@@ -1185,7 +1185,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
const uint8_t hairStyle = msg.readUInt8("hair style");
const uint16_t look = msg.readUInt8("look");
- dstBeing->setSubtype(job, look);
+ dstBeing->setSubtype(fromInt(job, BeingTypeId), look);
if (dstBeing->getType() == ActorType::Monster && localPlayer)
localPlayer->checkNewName(dstBeing);
dstBeing->setWalkSpeed(Vector(speed, speed, 0));
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index f3a8ab0c6..0ae7bfc4f 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -141,7 +141,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
static_cast<LoginHandler*>(loginHandler)->getToken();
LocalPlayer *const tempPlayer = new LocalPlayer(
- msg.readBeingId("account id"), 0);
+ msg.readBeingId("account id"), BeingTypeId_zero);
tempPlayer->setGender(token.sex);
PlayerInfoBackend &data = character->data;
@@ -173,7 +173,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg,
const uint16_t race = msg.readInt16("class");
const uint8_t hairStyle = msg.readUInt8("hair style");
const uint16_t look = msg.readUInt8("look");
- tempPlayer->setSubtype(race, look);
+ tempPlayer->setSubtype(fromInt(race, BeingTypeId), look);
const uint16_t weapon = msg.readInt16("weapon");
tempPlayer->setSprite(SPRITE_BODY, weapon, "", 1, true);
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index c68762728..0cdbed04d 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -87,7 +87,7 @@ ItemInfo::~ItemInfo()
}
const std::string &ItemInfo::getSprite(const Gender::Type gender,
- const int race) const
+ const BeingTypeId race) const
{
if (mView)
{
@@ -98,7 +98,8 @@ const std::string &ItemInfo::getSprite(const Gender::Type gender,
{
static const std::string empty;
std::map<int, std::string>::const_iterator i =
- mAnimationFiles.find(static_cast<int>(gender) + race * 4);
+ mAnimationFiles.find(static_cast<int>(gender) +
+ toInt(race, int) * 4);
if (i != mAnimationFiles.end())
return i->second;
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 55e35ea22..3331d7882 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -25,6 +25,8 @@
#include "enums/being/gender.h"
+#include "enums/simpletypes/beingtypeid.h"
+
#include "resources/cursor.h"
#include "resources/itemtype.h"
#include "resources/soundinfo.h"
@@ -125,7 +127,8 @@ class ItemInfo final
const Gender::Type gender, const int race);
const std::string &getSprite(const Gender::Type gender,
- const int race) const A_WARN_UNUSED;
+ const BeingTypeId race)
+ const A_WARN_UNUSED;
void setAttackAction(const std::string &attackAction);
diff --git a/src/resources/questeffect.h b/src/resources/questeffect.h
index c152ce0e8..c4cb13e3e 100644
--- a/src/resources/questeffect.h
+++ b/src/resources/questeffect.h
@@ -21,6 +21,8 @@
#ifndef RESOURCES_QUESTEFFECT_H
#define RESOURCES_QUESTEFFECT_H
+#include "enums/simpletypes/beingtypeid.h"
+
#include <set>
#include <string>
@@ -31,7 +33,7 @@ struct QuestEffect final
QuestEffect() :
map(),
var(0),
- id(0),
+ id(BeingTypeId_zero),
effectId(0),
values()
{
@@ -39,7 +41,7 @@ struct QuestEffect final
std::string map;
int var;
- int id;
+ BeingTypeId id;
int effectId;
std::set<int> values;
};