diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-29 17:45:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-29 17:45:52 +0300 |
commit | 2d32dc27210d16102f9200de115f2c3f79a5cb22 (patch) | |
tree | 5aa84ebe6c5c1d708b14bee2bf0ce95df714fc1d /src/being | |
parent | 7bdb50605562e47f1d6ae134881c09bd42293be5 (diff) | |
download | mv-2d32dc27210d16102f9200de115f2c3f79a5cb22.tar.gz mv-2d32dc27210d16102f9200de115f2c3f79a5cb22.tar.bz2 mv-2d32dc27210d16102f9200de115f2c3f79a5cb22.tar.xz mv-2d32dc27210d16102f9200de115f2c3f79a5cb22.zip |
Use BeingTypeId in Being for subtypeid.
Diffstat (limited to 'src/being')
-rw-r--r-- | src/being/being.cpp | 39 | ||||
-rw-r--r-- | src/being/being.h | 12 | ||||
-rw-r--r-- | src/being/localplayer.cpp | 2 | ||||
-rw-r--r-- | src/being/localplayer.h | 2 |
4 files changed, 30 insertions, 25 deletions
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) |