summaryrefslogtreecommitdiff
path: root/src/being/being.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/being/being.cpp')
-rw-r--r--src/being/being.cpp238
1 files changed, 120 insertions, 118 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 53db29cff..75a18b2f2 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -388,137 +388,139 @@ void Being::setSubtype(const BeingTypeId subtype,
mSubType = subtype;
mLook = look;
- if (mType == ActorType::Monster)
+ switch (mType)
{
- mInfo = MonsterDB::get(mSubType);
- if (mInfo)
- {
- setName(mInfo->getName());
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_true,
- 0,
- mInfo->getColor(fromInt(mLook, ItemColor)));
- mYDiff = mInfo->getSortOffsetY();
- }
- }
+ case ActorType::Monster:
+ mInfo = MonsterDB::get(mSubType);
+ if (mInfo)
+ {
+ setName(mInfo->getName());
+ setupSpriteDisplay(mInfo->getDisplay(),
+ ForceDisplay_true,
+ 0,
+ mInfo->getColor(fromInt(mLook, ItemColor)));
+ mYDiff = mInfo->getSortOffsetY();
+ }
+ break;
#ifdef EATHENA_SUPPORT
- if (mType == ActorType::Pet)
- {
- mInfo = PETDB::get(mSubType);
- if (mInfo)
- {
- setName(mInfo->getName());
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_true,
- 0,
- mInfo->getColor(fromInt(mLook, ItemColor)));
- mYDiff = mInfo->getSortOffsetY();
- }
- }
- else if (mType == ActorType::Mercenary)
- {
- mInfo = MercenaryDB::get(mSubType);
- if (mInfo)
- {
- setName(mInfo->getName());
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_true,
- 0,
- mInfo->getColor(fromInt(mLook, ItemColor)));
- mYDiff = mInfo->getSortOffsetY();
- }
- }
- if (mType == ActorType::Homunculus)
- {
- mInfo = HomunculusDB::get(mSubType);
- if (mInfo)
- {
- setName(mInfo->getName());
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_true,
- 0,
- mInfo->getColor(fromInt(mLook, ItemColor)));
- mYDiff = mInfo->getSortOffsetY();
- }
- }
- if (mType == ActorType::SkillUnit)
- {
- mInfo = SkillUnitDb::get(mSubType);
- if (mInfo)
- {
- setName(mInfo->getName());
- setupSpriteDisplay(mInfo->getDisplay(),
- ForceDisplay_false,
- 0,
- mInfo->getColor(fromInt(mLook, ItemColor)));
- mYDiff = mInfo->getSortOffsetY();
- }
- }
+ case ActorType::Pet:
+ mInfo = PETDB::get(mSubType);
+ if (mInfo)
+ {
+ setName(mInfo->getName());
+ setupSpriteDisplay(mInfo->getDisplay(),
+ ForceDisplay_true,
+ 0,
+ mInfo->getColor(fromInt(mLook, ItemColor)));
+ mYDiff = mInfo->getSortOffsetY();
+ }
+ break;
+ case ActorType::Mercenary:
+ mInfo = MercenaryDB::get(mSubType);
+ if (mInfo)
+ {
+ setName(mInfo->getName());
+ setupSpriteDisplay(mInfo->getDisplay(),
+ ForceDisplay_true,
+ 0,
+ mInfo->getColor(fromInt(mLook, ItemColor)));
+ mYDiff = mInfo->getSortOffsetY();
+ }
+ break;
+ case ActorType::Homunculus:
+ mInfo = HomunculusDB::get(mSubType);
+ if (mInfo)
+ {
+ setName(mInfo->getName());
+ setupSpriteDisplay(mInfo->getDisplay(),
+ ForceDisplay_true,
+ 0,
+ mInfo->getColor(fromInt(mLook, ItemColor)));
+ mYDiff = mInfo->getSortOffsetY();
+ }
+ break;
+ case ActorType::SkillUnit:
+ mInfo = SkillUnitDb::get(mSubType);
+ if (mInfo)
+ {
+ setName(mInfo->getName());
+ setupSpriteDisplay(mInfo->getDisplay(),
+ ForceDisplay_false,
+ 0,
+ mInfo->getColor(fromInt(mLook, ItemColor)));
+ mYDiff = mInfo->getSortOffsetY();
+ }
+ break;
#endif
- else if (mType == ActorType::Npc)
- {
- mInfo = NPCDB::get(mSubType);
- if (mInfo)
- {
- setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false);
- mYDiff = mInfo->getSortOffsetY();
- }
- }
- else if (mType == ActorType::Avatar)
- {
- mInfo = AvatarDB::get(mSubType);
- if (mInfo)
- setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false);
- }
- else if (mType == ActorType::LocalPet)
- {
- mInfo = PETDB::get(fromInt(mId, BeingTypeId));
- if (mInfo)
- {
- setName(mInfo->getName());
- setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false);
- mYDiff = mInfo->getSortOffsetY();
- const int speed = mInfo->getWalkSpeed();
- if (!speed)
+ case ActorType::Npc:
+ mInfo = NPCDB::get(mSubType);
+ if (mInfo)
{
- if (playerHandler)
- setWalkSpeed(playerHandler->getDefaultWalkSpeed());
- else
- setWalkSpeed(1);
+ setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false);
+ mYDiff = mInfo->getSortOffsetY();
}
- else
+ break;
+ case ActorType::Avatar:
+ mInfo = AvatarDB::get(mSubType);
+ if (mInfo)
+ setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false);
+ break;
+ case ActorType::LocalPet:
+ mInfo = PETDB::get(fromInt(mId, BeingTypeId));
+ if (mInfo)
{
- setWalkSpeed(speed);
+ setName(mInfo->getName());
+ setupSpriteDisplay(mInfo->getDisplay(), ForceDisplay_false);
+ mYDiff = mInfo->getSortOffsetY();
+ const int speed = mInfo->getWalkSpeed();
+ if (!speed)
+ {
+ if (playerHandler)
+ setWalkSpeed(playerHandler->getDefaultWalkSpeed());
+ else
+ setWalkSpeed(1);
+ }
+ else
+ {
+ setWalkSpeed(speed);
+ }
}
- }
- }
- else if (mType == ActorType::Player)
- {
- int id = -100 - toInt(subtype, int);
-
- // Prevent showing errors when sprite doesn't exist
- if (!ItemDB::exists(id))
+ break;
+ case ActorType::Player:
{
- id = -100;
- // TRANSLATORS: default race name
- setRaceName(_("Human"));
- if (charServerHandler)
+ int id = -100 - toInt(subtype, int);
+ // Prevent showing errors when sprite doesn't exist
+ if (!ItemDB::exists(id))
{
- setSpriteId(charServerHandler->baseSprite(),
- id);
+ id = -100;
+ // TRANSLATORS: default race name
+ setRaceName(_("Human"));
+ if (charServerHandler)
+ {
+ setSpriteId(charServerHandler->baseSprite(),
+ id);
+ }
}
- }
- else
- {
- const ItemInfo &restrict info = ItemDB::get(id);
- setRaceName(info.getName());
- if (charServerHandler)
+ else
{
- setSpriteColor(charServerHandler->baseSprite(),
- id,
- info.getColor(fromInt(mLook, ItemColor)));
+ const ItemInfo &restrict info = ItemDB::get(id);
+ setRaceName(info.getName());
+ if (charServerHandler)
+ {
+ setSpriteColor(charServerHandler->baseSprite(),
+ id,
+ info.getColor(fromInt(mLook, ItemColor)));
+ }
}
+ break;
}
+ case ActorType::Unknown:
+ case ActorType::FloorItem:
+ case ActorType::Portal:
+ default:
+ reportAlways("Wrong being type %d in setSubType",
+ CAST_S32(mType));
+ break;
}
}