diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-29 20:59:14 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-29 20:59:14 +0300 |
commit | 390e5da0f9ecc4407aa7d4bcba1af5730db56271 (patch) | |
tree | ee0879cba3fec38740f1e51f2d1d35719ec3d8ae | |
parent | 9f1994182d4225f630a93ae06b01927c4f7a9a37 (diff) | |
download | manaverse-390e5da0f9ecc4407aa7d4bcba1af5730db56271.tar.gz manaverse-390e5da0f9ecc4407aa7d4bcba1af5730db56271.tar.bz2 manaverse-390e5da0f9ecc4407aa7d4bcba1af5730db56271.tar.xz manaverse-390e5da0f9ecc4407aa7d4bcba1af5730db56271.zip |
Convert AttackType enum into strong typed enum.
-rw-r--r-- | src/being/being.cpp | 6 | ||||
-rw-r--r-- | src/being/being.h | 6 | ||||
-rw-r--r-- | src/enums/being/attacktype.h | 40 | ||||
-rw-r--r-- | src/net/ea/beinghandler.cpp | 11 | ||||
-rw-r--r-- | src/net/eathena/beinghandler.cpp | 5 |
5 files changed, 35 insertions, 33 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index 1362c904a..947e98fb6 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -587,7 +587,7 @@ void Being::setSpeech(const std::string &text, const std::string &channel, void Being::takeDamage(Being *const attacker, const int amount, - const AttackType::Type type, + const AttackTypeT type, const int attackId, const int level) { @@ -770,7 +770,7 @@ void Being::takeDamage(Being *const attacker, } int Being::getHitEffect(const Being *const attacker, - const AttackType::Type type, + const AttackTypeT type, const int attackId, const int level) const { @@ -850,7 +850,7 @@ int Being::getHitEffect(const Being *const attacker, return hitEffectId; } -int Being::getDefaultEffectId(const AttackType::Type &type) +int Being::getDefaultEffectId(const AttackTypeT &type) { if (type == AttackType::MISS) return paths.getIntValue("missEffectId"); diff --git a/src/being/being.h b/src/being/being.h index b1639f250..83ca7785a 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -189,7 +189,7 @@ class Being notfinal : public ActorSprite, */ void takeDamage(Being *const attacker, const int damage, - const AttackType::Type type, + const AttackTypeT type, const int attackId = 1, const int level = 1); @@ -793,7 +793,7 @@ class Being notfinal : public ActorSprite, void recalcSpritesOrder(); int getHitEffect(const Being *const attacker, - const AttackType::Type type, + const AttackTypeT type, const int attackId, const int level) const A_WARN_UNUSED; @@ -938,7 +938,7 @@ class Being notfinal : public ActorSprite, void createSpeechBubble(); - static int getDefaultEffectId(const AttackType::Type &type); + static int getDefaultEffectId(const AttackTypeT &type); BeingInfo *mInfo; AnimatedSprite *mEmotionSprite; diff --git a/src/enums/being/attacktype.h b/src/enums/being/attacktype.h index d04f88ed9..f9424ebd4 100644 --- a/src/enums/being/attacktype.h +++ b/src/enums/being/attacktype.h @@ -23,26 +23,26 @@ #ifndef ENUMS_BEING_ATTACKTYPE_H #define ENUMS_BEING_ATTACKTYPE_H -namespace AttackType +#include "enums/simpletypes/enumdefines.h" + +enumStart(AttackType) { - enum Type - { - HIT = 0, - PICKUP = 1, - SIT = 2, - STAND = 3, - REFLECT = 4, - SPLASH = 5, - SKILL = 6, - REPEATE = 7, - MULTI = 8, - MULTI_REFLECT = 9, - CRITICAL = 10, - FLEE = 11, - TOUCH_SKILL = 12, - MISS = 0xffff, // pseudo value for miss attacks - SKILLMISS // pseudo value for skill miss attacks - }; -} // namespace AttackType + HIT = 0, + PICKUP = 1, + SIT = 2, + STAND = 3, + REFLECT = 4, + SPLASH = 5, + SKILL = 6, + REPEATE = 7, + MULTI = 8, + MULTI_REFLECT = 9, + CRITICAL = 10, + FLEE = 11, + TOUCH_SKILL = 12, + MISS = 0xffff, // pseudo value for miss attacks + SKILLMISS // pseudo value for skill miss attacks +} +enumEnd(AttackType); #endif // ENUMS_BEING_ATTACKTYPE_H diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index ba1d21fbd..a80a9d4f6 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -178,7 +178,8 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) msg.readInt32("dst speed"); const int param1 = msg.readInt16("param1"); msg.readInt16("param 2"); - const uint8_t type = msg.readUInt8("type"); + const AttackTypeT type = static_cast<AttackTypeT>( + msg.readUInt8("type")); msg.readInt16("param 3"); switch (type) @@ -201,17 +202,17 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) { // level not present, using 1 dstBeing->takeDamage(srcBeing, param1, - static_cast<AttackType::Type>(type), 1); + static_cast<AttackTypeT>(type), 1); } break; - case 0x01: // dead or pickup? + case AttackType::PICKUP: break; // tmw server can send here garbage? // if (srcBeing) // srcBeing->setAction(BeingAction::DEAD, 0); - case 0x02: // Sit + case AttackType::SIT: if (srcBeing) { srcBeing->setAction(BeingAction::SIT, 0); @@ -224,7 +225,7 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) } break; - case 0x03: // Stand up + case AttackType::STAND: if (srcBeing) { srcBeing->setAction(BeingAction::STAND, 0); diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index 99866bfbf..79354e34c 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -1280,7 +1280,8 @@ void BeingHandler::processBeingAction2(Net::MessageIn &msg) msg.readInt32("dst speed"); const int param1 = msg.readInt32("damage"); msg.readInt16("count"); - const uint8_t type = msg.readUInt8("action"); + const AttackTypeT type = static_cast<AttackTypeT>( + msg.readUInt8("action")); msg.readInt32("left damage"); switch (type) @@ -1307,7 +1308,7 @@ void BeingHandler::processBeingAction2(Net::MessageIn &msg) { // level not present, using 1 dstBeing->takeDamage(srcBeing, param1, - static_cast<AttackType::Type>(type), 1); + static_cast<AttackTypeT>(type), 1); } break; |