diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-11 19:28:57 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-11 19:28:57 +0300 |
commit | 87c59212f8590a8dd72fac3e320fcb2ada781355 (patch) | |
tree | 198d627c44f1164140659827a5c782d30bec375b /src/net | |
parent | 02e91411eb9961e95f856bd717d6ca0d8ec0e435 (diff) | |
download | manaplus-87c59212f8590a8dd72fac3e320fcb2ada781355.tar.gz manaplus-87c59212f8590a8dd72fac3e320fcb2ada781355.tar.bz2 manaplus-87c59212f8590a8dd72fac3e320fcb2ada781355.tar.xz manaplus-87c59212f8590a8dd72fac3e320fcb2ada781355.zip |
Move player attributes into separate file.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/buysellhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/ea/inventoryhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 53 | ||||
-rw-r--r-- | src/net/eathena/buysellhandler.cpp | 3 | ||||
-rw-r--r-- | src/net/eathena/charserverhandler.cpp | 16 | ||||
-rw-r--r-- | src/net/eathena/generalhandler.cpp | 10 | ||||
-rw-r--r-- | src/net/eathena/playerhandler.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwa/buysellhandler.cpp | 3 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.cpp | 16 | ||||
-rw-r--r-- | src/net/tmwa/generalhandler.cpp | 10 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 4 |
11 files changed, 73 insertions, 56 deletions
diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index d55a3cea6..28ec4497e 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -27,6 +27,7 @@ #include "notifications.h" #include "notifymanager.h" +#include "being/attributes.h" #include "being/playerinfo.h" #include "gui/windows/chatwindow.h" @@ -144,7 +145,7 @@ void BuySellHandler::processNpcSell(Net::MessageIn &msg, if (n_items > 0) { SellDialog *const dialog = new SellDialog(mNpcId); - dialog->setMoney(PlayerInfo::getAttribute(PlayerInfo::MONEY)); + dialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); for (int k = 0; k < n_items; k++) { @@ -176,7 +177,7 @@ void BuySellHandler::processNpcBuyResponse(Net::MessageIn &msg) const // Reset player money since buy dialog already assumed purchase // would go fine if (mBuyDialog) - mBuyDialog->setMoney(PlayerInfo::getAttribute(PlayerInfo::MONEY)); + mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); NotifyManager::notify(NotifyManager::BUY_FAILED); } } diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 2f5ec35ce..46f87f089 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -25,6 +25,7 @@ #include "notifications.h" #include "notifymanager.h" +#include "being/attributes.h" #include "being/localplayer.h" #include "net/messagein.h" @@ -575,8 +576,8 @@ void InventoryHandler::processPlayerAttackRange(Net::MessageIn &msg) const int range = msg.readInt16(); if (player_node) player_node->setAttackRange(range); - PlayerInfo::setStatBase(PlayerInfo::ATTACK_RANGE, range); - PlayerInfo::setStatMod(PlayerInfo::ATTACK_RANGE, 0); + PlayerInfo::setStatBase(Attributes::ATTACK_RANGE, range); + PlayerInfo::setStatMod(Attributes::ATTACK_RANGE, 0); } void InventoryHandler::processPlayerArrowEquip(Net::MessageIn &msg) diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 475df2db0..1b324e376 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -29,6 +29,7 @@ #include "notifymanager.h" #include "units.h" +#include "being/attributes.h" #include "being/localplayer.h" #include "gui/viewport.h" @@ -233,13 +234,13 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) case 0x0000: player_node->setWalkSpeed(Vector(static_cast<float>( value), static_cast<float>(value), 0)); - PlayerInfo::setStatBase(PlayerInfo::WALK_SPEED, value); - PlayerInfo::setStatMod(PlayerInfo::WALK_SPEED, 0); + PlayerInfo::setStatBase(Attributes::WALK_SPEED, value); + PlayerInfo::setStatMod(Attributes::WALK_SPEED, 0); break; case 0x0004: break; // manner case 0x0005: - PlayerInfo::setAttribute(PlayerInfo::HP, value); + PlayerInfo::setAttribute(Attributes::HP, value); if (player_node->isInParty() && Party::getParty(1)) { PartyMember *const m = Party::getParty(1) @@ -247,12 +248,12 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) if (m) { m->setHp(value); - m->setMaxHp(PlayerInfo::getAttribute(PlayerInfo::MAX_HP)); + m->setMaxHp(PlayerInfo::getAttribute(Attributes::MAX_HP)); } } break; case 0x0006: - PlayerInfo::setAttribute(PlayerInfo::MAX_HP, value); + PlayerInfo::setAttribute(Attributes::MAX_HP, value); if (player_node->isInParty() && Party::getParty(1)) { @@ -260,22 +261,22 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) player_node->getId()); if (m) { - m->setHp(PlayerInfo::getAttribute(PlayerInfo::HP)); + m->setHp(PlayerInfo::getAttribute(Attributes::HP)); m->setMaxHp(value); } } break; case 0x0007: - PlayerInfo::setAttribute(PlayerInfo::MP, value); + PlayerInfo::setAttribute(Attributes::MP, value); break; case 0x0008: - PlayerInfo::setAttribute(PlayerInfo::MAX_MP, value); + PlayerInfo::setAttribute(Attributes::MAX_MP, value); break; case 0x0009: - PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, value); + PlayerInfo::setAttribute(Attributes::CHAR_POINTS, value); break; case 0x000b: - PlayerInfo::setAttribute(PlayerInfo::LEVEL, value); + PlayerInfo::setAttribute(Attributes::LEVEL, value); if (player_node) { player_node->setLevel(value); @@ -283,7 +284,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) } break; case 0x000c: - PlayerInfo::setAttribute(PlayerInfo::SKILL_POINTS, value); + PlayerInfo::setAttribute(Attributes::SKILL_POINTS, value); if (skillDialog) skillDialog->update(); break; @@ -291,9 +292,9 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) if (!weightNotice && config.getBoolValue("weightMsg")) { const int max = PlayerInfo::getAttribute( - PlayerInfo::MAX_WEIGHT) / 2; + Attributes::MAX_WEIGHT) / 2; const int total = PlayerInfo::getAttribute( - PlayerInfo::TOTAL_WEIGHT); + Attributes::TOTAL_WEIGHT); if (value >= max && total < max) { weightNoticeTime = cur_time + 5; @@ -319,10 +320,10 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) &weightListener); } } - PlayerInfo::setAttribute(PlayerInfo::TOTAL_WEIGHT, value); + PlayerInfo::setAttribute(Attributes::TOTAL_WEIGHT, value); break; case 0x0019: - PlayerInfo::setAttribute(PlayerInfo::MAX_WEIGHT, value); + PlayerInfo::setAttribute(Attributes::MAX_WEIGHT, value); break; case 0x0029: @@ -372,8 +373,8 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) case 0x0035: player_node->setAttackSpeed(value); - PlayerInfo::setStatBase(PlayerInfo::ATTACK_DELAY, value); - PlayerInfo::setStatMod(PlayerInfo::ATTACK_DELAY, 0); + PlayerInfo::setStatBase(Attributes::ATTACK_DELAY, value); + PlayerInfo::setStatMod(Attributes::ATTACK_DELAY, 0); PlayerInfo::updateAttrs(); break; @@ -391,7 +392,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) break; } - if (PlayerInfo::getAttribute(PlayerInfo::HP) == 0 && !deathNotice) + if (PlayerInfo::getAttribute(Attributes::HP) == 0 && !deathNotice) { // TRANSLATORS: message header deathNotice = new OkDialog(_("Message"), @@ -413,7 +414,7 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg) switch (type) { case 0x0001: - PlayerInfo::setAttribute(PlayerInfo::EXP, msg.readInt32()); + PlayerInfo::setAttribute(Attributes::EXP, msg.readInt32()); break; case 0x0002: PlayerInfo::setStatExperience(EA_JOB, msg.readInt32(), @@ -421,7 +422,7 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg) break; case 0x0014: { - const int oldMoney = PlayerInfo::getAttribute(PlayerInfo::MONEY); + const int oldMoney = PlayerInfo::getAttribute(Attributes::MONEY); const int newMoney = msg.readInt32(); if (newMoney > oldMoney) { @@ -434,11 +435,11 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg) Units::formatCurrency(oldMoney - newMoney).c_str()); } - PlayerInfo::setAttribute(PlayerInfo::MONEY, newMoney); + PlayerInfo::setAttribute(Attributes::MONEY, newMoney); break; } case 0x0016: - PlayerInfo::setAttribute(PlayerInfo::EXP_NEEDED, msg.readInt32()); + PlayerInfo::setAttribute(Attributes::EXP_NEEDED, msg.readInt32()); break; case 0x0017: PlayerInfo::setStatExperience(EA_JOB, @@ -460,7 +461,7 @@ void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg) PlayerInfo::setStatBase(type, base, false); PlayerInfo::setStatMod(type, bonus); - if (type == EA_ATK || type == PlayerInfo::ATTACK_DELAY) + if (type == EA_ATK || type == Attributes::ATTACK_DELAY) PlayerInfo::updateAttrs(); BLOCK_END("PlayerHandler::processPlayerStatUpdate3") } @@ -475,9 +476,9 @@ void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg) if (ok != 1) { const int oldValue = PlayerInfo::getStatBase(type); - const int points = PlayerInfo::getAttribute(PlayerInfo::CHAR_POINTS) + const int points = PlayerInfo::getAttribute(Attributes::CHAR_POINTS) + oldValue - value; - PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, points); + PlayerInfo::setAttribute(Attributes::CHAR_POINTS, points); NotifyManager::notify(NotifyManager::SKILL_RAISE_ERROR); } @@ -488,7 +489,7 @@ void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg) void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg) { BLOCK_START("PlayerHandler::processPlayerStatUpdate5") - PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, msg.readInt16()); + PlayerInfo::setAttribute(Attributes::CHAR_POINTS, msg.readInt16()); int val = msg.readInt8(); PlayerInfo::setStatBase(EA_STR, val); diff --git a/src/net/eathena/buysellhandler.cpp b/src/net/eathena/buysellhandler.cpp index 31a831b25..65e955d91 100644 --- a/src/net/eathena/buysellhandler.cpp +++ b/src/net/eathena/buysellhandler.cpp @@ -25,6 +25,7 @@ #include "notifications.h" #include "notifymanager.h" +#include "being/attributes.h" #include "being/playerinfo.h" #include "gui/windows/buydialog.h" @@ -93,7 +94,7 @@ void BuySellHandler::processNpcBuy(Net::MessageIn &msg) const int sz = 11; const int n_items = (msg.getLength() - 4) / sz; mBuyDialog = new BuyDialog(mNpcId); - mBuyDialog->setMoney(PlayerInfo::getAttribute(PlayerInfo::MONEY)); + mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); for (int k = 0; k < n_items; k++) { diff --git a/src/net/eathena/charserverhandler.cpp b/src/net/eathena/charserverhandler.cpp index f24c984ed..fdcf2ed22 100644 --- a/src/net/eathena/charserverhandler.cpp +++ b/src/net/eathena/charserverhandler.cpp @@ -25,6 +25,8 @@ #include "client.h" #include "configuration.h" +#include "being/attributes.h" + #include "net/logindata.h" #include "net/net.h" @@ -129,8 +131,8 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, tempPlayer->setGender(token.sex); PlayerInfoBackend &data = character->data; - data.mAttributes[PlayerInfo::EXP] = msg.readInt32(); - data.mAttributes[PlayerInfo::MONEY] = msg.readInt32(); + data.mAttributes[Attributes::EXP] = msg.readInt32(); + data.mAttributes[Attributes::MONEY] = msg.readInt32(); Stat &jobStat = data.mStats[JOB]; jobStat.exp = msg.readInt32(); @@ -148,10 +150,10 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, msg.readInt32(); // manner msg.readInt16(); // character points left - data.mAttributes[PlayerInfo::HP] = msg.readInt16(); - data.mAttributes[PlayerInfo::MAX_HP] = msg.readInt16(); - data.mAttributes[PlayerInfo::MP] = msg.readInt16(); - data.mAttributes[PlayerInfo::MAX_MP] = msg.readInt16(); + data.mAttributes[Attributes::HP] = msg.readInt16(); + data.mAttributes[Attributes::MAX_HP] = msg.readInt16(); + data.mAttributes[Attributes::MP] = msg.readInt16(); + data.mAttributes[Attributes::MAX_MP] = msg.readInt16(); msg.readInt16(); // speed tempPlayer->setSubtype(msg.readInt16(), 0); // class (used for race) @@ -160,7 +162,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, tempPlayer->setSprite(SPRITE_WEAPON, weapon, "", 1, true); - data.mAttributes[PlayerInfo::LEVEL] = msg.readInt16(); + data.mAttributes[Attributes::LEVEL] = msg.readInt16(); msg.readInt16(); // skill point const int bottomClothes = msg.readInt16(); diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp index 92afd945c..8a96bde05 100644 --- a/src/net/eathena/generalhandler.cpp +++ b/src/net/eathena/generalhandler.cpp @@ -26,6 +26,8 @@ #include "configuration.h" #include "logger.h" +#include "being/attributes.h" + #include "gui/windows/inventorywindow.h" #include "gui/windows/skilldialog.h" #include "gui/windows/socialwindow.h" @@ -257,10 +259,10 @@ void GeneralHandler::gameStarted() const statusWindow->addAttribute(FLEE, _("% Evade")); // xgettext:no-c-format statusWindow->addAttribute(CRIT, _("% Critical")); - statusWindow->addAttribute(PlayerInfo::ATTACK_DELAY, _("Attack Delay")); - statusWindow->addAttribute(PlayerInfo::WALK_SPEED, _("Walk Delay")); - statusWindow->addAttribute(PlayerInfo::ATTACK_RANGE, _("Attack Range")); - statusWindow->addAttribute(PlayerInfo::ATTACK_SPEED, _("Damage per sec.")); + statusWindow->addAttribute(Attributes::ATTACK_DELAY, _("Attack Delay")); + statusWindow->addAttribute(Attributes::WALK_SPEED, _("Walk Delay")); + statusWindow->addAttribute(Attributes::ATTACK_RANGE, _("Attack Range")); + statusWindow->addAttribute(Attributes::ATTACK_SPEED, _("Damage per sec.")); } void GeneralHandler::gameEnded() const diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp index f4305f280..627e5479f 100644 --- a/src/net/eathena/playerhandler.cpp +++ b/src/net/eathena/playerhandler.cpp @@ -22,6 +22,8 @@ #include "net/eathena/playerhandler.h" +#include "being/attributes.h" + #include "net/net.h" #include "net/eathena/messageout.h" @@ -145,7 +147,7 @@ void PlayerHandler::increaseAttribute(const int attr) const void PlayerHandler::increaseSkill(const uint16_t skillId) const { - if (PlayerInfo::getAttribute(PlayerInfo::SKILL_POINTS) <= 0) + if (PlayerInfo::getAttribute(Attributes::SKILL_POINTS) <= 0) return; MessageOut outMsg(CMSG_SKILL_LEVELUP_REQUEST); diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp index 0be6839a7..5cc23a786 100644 --- a/src/net/tmwa/buysellhandler.cpp +++ b/src/net/tmwa/buysellhandler.cpp @@ -25,6 +25,7 @@ #include "notifications.h" #include "notifymanager.h" +#include "being/attributes.h" #include "being/playerinfo.h" #include "gui/windows/buydialog.h" @@ -98,7 +99,7 @@ void BuySellHandler::processNpcBuy(Net::MessageIn &msg) sz += 1; const int n_items = (msg.getLength() - 4) / sz; mBuyDialog = new BuyDialog(mNpcId); - mBuyDialog->setMoney(PlayerInfo::getAttribute(PlayerInfo::MONEY)); + mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); for (int k = 0; k < n_items; k++) { diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index c4fc9001c..7bd057231 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -25,6 +25,8 @@ #include "client.h" #include "configuration.h" +#include "being/attributes.h" + #include "net/logindata.h" #include "net/net.h" @@ -132,8 +134,8 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, tempPlayer->setGender(token.sex); PlayerInfoBackend &data = character->data; - data.mAttributes[PlayerInfo::EXP] = msg.readInt32(); - data.mAttributes[PlayerInfo::MONEY] = msg.readInt32(); + data.mAttributes[Attributes::EXP] = msg.readInt32(); + data.mAttributes[Attributes::MONEY] = msg.readInt32(); Stat &jobStat = data.mStats[static_cast<size_t>(JOB)]; jobStat.exp = msg.readInt32(); @@ -151,10 +153,10 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, msg.readInt32(); // manner msg.readInt16(); // character points left - data.mAttributes[PlayerInfo::HP] = msg.readInt16(); - data.mAttributes[PlayerInfo::MAX_HP] = msg.readInt16(); - data.mAttributes[PlayerInfo::MP] = msg.readInt16(); - data.mAttributes[PlayerInfo::MAX_MP] = msg.readInt16(); + data.mAttributes[Attributes::HP] = msg.readInt16(); + data.mAttributes[Attributes::MAX_HP] = msg.readInt16(); + data.mAttributes[Attributes::MP] = msg.readInt16(); + data.mAttributes[Attributes::MAX_MP] = msg.readInt16(); msg.readInt16(); // speed const uint16_t race = msg.readInt16(); // class (used for race) @@ -164,7 +166,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, const uint16_t weapon = msg.readInt16(); // unused on server. need use? tempPlayer->setSprite(SPRITE_WEAPON, weapon, "", 1, true); - data.mAttributes[PlayerInfo::LEVEL] = msg.readInt16(); + data.mAttributes[Attributes::LEVEL] = msg.readInt16(); msg.readInt16(); // skill point const int bottomClothes = msg.readInt16(); diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index eef89324e..9fd4eb78e 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -26,6 +26,8 @@ #include "configuration.h" #include "logger.h" +#include "being/attributes.h" + #include "gui/windows/inventorywindow.h" #include "gui/windows/skilldialog.h" #include "gui/windows/socialwindow.h" @@ -302,13 +304,13 @@ void GeneralHandler::gameStarted() const // xgettext:no-c-format statusWindow->addAttribute(CRIT, _("% Critical")); // TRANSLATORS: player stat - statusWindow->addAttribute(PlayerInfo::ATTACK_DELAY, _("Attack Delay")); + statusWindow->addAttribute(Attributes::ATTACK_DELAY, _("Attack Delay")); // TRANSLATORS: player stat - statusWindow->addAttribute(PlayerInfo::WALK_SPEED, _("Walk Delay")); + statusWindow->addAttribute(Attributes::WALK_SPEED, _("Walk Delay")); // TRANSLATORS: player stat - statusWindow->addAttribute(PlayerInfo::ATTACK_RANGE, _("Attack Range")); + statusWindow->addAttribute(Attributes::ATTACK_RANGE, _("Attack Range")); // TRANSLATORS: player stat - statusWindow->addAttribute(PlayerInfo::ATTACK_SPEED, _("Damage per sec.")); + statusWindow->addAttribute(Attributes::ATTACK_SPEED, _("Damage per sec.")); } void GeneralHandler::gameEnded() const diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 25a2e0cde..591c9c44e 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -26,6 +26,8 @@ #include "game.h" #include "soundmanager.h" +#include "being/attributes.h" + #include "net/net.h" #include "net/tmwa/inventoryhandler.h" @@ -161,7 +163,7 @@ void PlayerHandler::increaseAttribute(const int attr) const void PlayerHandler::increaseSkill(const uint16_t skillId) const { - if (PlayerInfo::getAttribute(PlayerInfo::SKILL_POINTS) <= 0) + if (PlayerInfo::getAttribute(Attributes::SKILL_POINTS) <= 0) return; MessageOut outMsg(CMSG_SKILL_LEVELUP_REQUEST); |