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 | |
parent | 02e91411eb9961e95f856bd717d6ca0d8ec0e435 (diff) | |
download | ManaVerse-87c59212f8590a8dd72fac3e320fcb2ada781355.tar.gz ManaVerse-87c59212f8590a8dd72fac3e320fcb2ada781355.tar.bz2 ManaVerse-87c59212f8590a8dd72fac3e320fcb2ada781355.tar.xz ManaVerse-87c59212f8590a8dd72fac3e320fcb2ada781355.zip |
Move player attributes into separate file.
Diffstat (limited to 'src')
31 files changed, 270 insertions, 203 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e1df1a5a3..56cae8a3d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -602,6 +602,7 @@ SET(SRCS being/actor.h being/actorsprite.cpp being/actorsprite.h + being/attributes.h listeners/actorspritelistener.h listeners/arrowslistener.cpp listeners/arrowslistener.h diff --git a/src/Makefile.am b/src/Makefile.am index a5889801e..3e09cb464 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -691,6 +691,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ being/actor.h \ being/actorsprite.cpp \ being/actorsprite.h \ + being/attributes.h \ listeners/actorspritelistener.h \ listeners/arrowslistener.cpp \ listeners/arrowslistener.h \ diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index 464403eb2..444bf4134 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -27,6 +27,7 @@ #include "itemshortcut.h" #include "soundmanager.h" +#include "being/attributes.h" #include "being/localplayer.h" #include "being/playerinfo.h" #include "being/playerrelations.h" @@ -426,7 +427,7 @@ impHandler0(itenplz) if (actorManager) { if (Net::getPlayerHandler() && Net::getPlayerHandler()->canUseMagic() - && PlayerInfo::getAttribute(PlayerInfo::MP) >= 3) + && PlayerInfo::getAttribute(Attributes::MP) >= 3) { actorManager->itenplz(); } diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 2c36b972a..855ff3265 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -26,6 +26,7 @@ #include "configuration.h" #include "main.h" +#include "being/attributes.h" #include "being/localplayer.h" #include "being/playerinfo.h" #include "being/playerrelations.h" @@ -1139,9 +1140,9 @@ void ActorManager::heal(const Being *const target) const // self if (target && player_node->getName() == target->getName()) { - if (PlayerInfo::getAttribute(PlayerInfo::MP) >= 6 - && PlayerInfo::getAttribute(PlayerInfo::HP) - != PlayerInfo::getAttribute(PlayerInfo::MAX_HP)) + if (PlayerInfo::getAttribute(Attributes::MP) >= 6 + && PlayerInfo::getAttribute(Attributes::HP) + != PlayerInfo::getAttribute(Attributes::MAX_HP)) { if (!client->limitPackets(PACKET_CHAT)) return; @@ -1152,7 +1153,7 @@ void ActorManager::heal(const Being *const target) const else if (PlayerInfo::getSkillLevel(340) < 2 || PlayerInfo::getSkillLevel(341) < 2) { - if (PlayerInfo::getAttribute(PlayerInfo::MP) >= 6) + if (PlayerInfo::getAttribute(Attributes::MP) >= 6) { if (target && target->getType() != Being::MONSTER) { @@ -1161,8 +1162,8 @@ void ActorManager::heal(const Being *const target) const chatWindow->localChatInput(mSpellHeal1 + " " + target->getName()); } - else if (PlayerInfo::getAttribute(PlayerInfo::HP) - != PlayerInfo::getAttribute(PlayerInfo::MAX_HP)) + else if (PlayerInfo::getAttribute(Attributes::HP) + != PlayerInfo::getAttribute(Attributes::MAX_HP)) { if (!client->limitPackets(PACKET_CHAT)) return; @@ -1174,7 +1175,7 @@ void ActorManager::heal(const Being *const target) const else { // mp > 10 and target not monster - if (PlayerInfo::getAttribute(PlayerInfo::MP) >= 10 && target + if (PlayerInfo::getAttribute(Attributes::MP) >= 10 && target && target->getType() != Being::MONSTER) { // target not enemy @@ -1196,9 +1197,9 @@ void ActorManager::heal(const Being *const target) const } // heal self if selected monster or selection empty else if ((!target || target->getType() == Being::MONSTER) - && PlayerInfo::getAttribute(PlayerInfo::MP) >= 6 - && PlayerInfo::getAttribute(PlayerInfo::HP) - != PlayerInfo::getAttribute(PlayerInfo::MAX_HP)) + && PlayerInfo::getAttribute(Attributes::MP) >= 6 + && PlayerInfo::getAttribute(Attributes::HP) + != PlayerInfo::getAttribute(Attributes::MAX_HP)) { if (!client->limitPackets(PACKET_CHAT)) return; diff --git a/src/being/attributes.h b/src/being/attributes.h new file mode 100644 index 000000000..612ef886c --- /dev/null +++ b/src/being/attributes.h @@ -0,0 +1,52 @@ +/* + * The ManaPlus Client + * Copyright (C) 2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef BEING_ATTRIBUTES_H +#define BEING_ATTRIBUTES_H + +namespace Attributes +{ + /** + * Standard attributes for players. + */ + enum Attributes + { + LEVEL = 0, + HP, + MAX_HP, + MP, + MAX_MP, + EXP, + EXP_NEEDED, + MONEY, + TOTAL_WEIGHT, + MAX_WEIGHT, + SKILL_POINTS, + CHAR_POINTS, + CORR_POINTS, + ATTACK_DELAY = 100, + ATTACK_RANGE = 101, + WALK_SPEED = 102, + ATTACK_SPEED = 103 + }; +} // namespace Attributes + +#endif // BEING_ATTRIBUTES_H diff --git a/src/being/being.cpp b/src/being/being.cpp index c9af368b2..4cd30f35f 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -33,6 +33,7 @@ #include "soundmanager.h" #include "text.h" +#include "being/attributes.h" #include "being/beingcacheentry.h" #include "being/playerrelations.h" @@ -2392,8 +2393,8 @@ void Being::drawSpriteAt(Graphics *const graphics, } if (mShowOwnHP && mInfo && player_node == this && mAction != DEAD) { - drawHpBar(graphics, PlayerInfo::getAttribute(PlayerInfo::MAX_HP), - PlayerInfo::getAttribute(PlayerInfo::HP), 0, + drawHpBar(graphics, PlayerInfo::getAttribute(Attributes::MAX_HP), + PlayerInfo::getAttribute(Attributes::HP), 0, UserPalette::PLAYER_HP, UserPalette::PLAYER_HP2, x - 50 + mapTileSize / 2 + mInfo->getHpBarOffsetX(), y + mapTileSize - 6 + mInfo->getHpBarOffsetY(), diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 7efaaa907..ca6514ace 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -35,6 +35,7 @@ #include "statuseffect.h" #include "resources/map/walklayer.h" +#include "being/attributes.h" #include "being/playerinfo.h" #include "being/playerrelations.h" @@ -191,9 +192,9 @@ LocalPlayer::LocalPlayer(const int id, const int subtype) : else mNameColor = nullptr; - PlayerInfo::setStatBase(PlayerInfo::WALK_SPEED, + PlayerInfo::setStatBase(Attributes::WALK_SPEED, static_cast<int>(getWalkSpeed().x)); - PlayerInfo::setStatMod(PlayerInfo::WALK_SPEED, 0); + PlayerInfo::setStatMod(Attributes::WALK_SPEED, 0); loadHomes(); @@ -1075,7 +1076,7 @@ void LocalPlayer::attributeChanged(const int id, { switch (id) { - case PlayerInfo::EXP: + case Attributes::EXP: { if (oldVal > newVal) break; @@ -1088,7 +1089,7 @@ void LocalPlayer::attributeChanged(const int id, } break; } - case PlayerInfo::LEVEL: + case Attributes::LEVEL: mLevel = newVal; break; default: @@ -2693,7 +2694,7 @@ void LocalPlayer::tryMagic(const std::string &spell, const int baseMagic, if (PlayerInfo::getSkillLevel(340) >= baseMagic && PlayerInfo::getSkillLevel(342) >= schoolMagic) { - if (PlayerInfo::getAttribute(PlayerInfo::MP) >= mana) + if (PlayerInfo::getAttribute(Attributes::MP) >= mana) { if (!client->limitPackets(PACKET_CHAT)) return; @@ -3594,7 +3595,7 @@ void LocalPlayer::respawn() int LocalPlayer::getLevel() const { - return PlayerInfo::getAttribute(PlayerInfo::LEVEL); + return PlayerInfo::getAttribute(Attributes::LEVEL); } void LocalPlayer::updateNavigateList() diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp index fdbad89a5..b4824599b 100644 --- a/src/being/playerinfo.cpp +++ b/src/being/playerinfo.cpp @@ -24,6 +24,9 @@ #include "client.h" #include "configuration.h" #include "inventory.h" + +#include "being/attributes.h" + #include "itemsoundmanager.h" #include "gui/windows/inventorywindow.h" @@ -363,18 +366,18 @@ void updateAttrs() if (!handler) return; const int attr = handler->getAttackLocation(); - const int attackDelay = getStatBase(ATTACK_DELAY); + const int attackDelay = getStatBase(Attributes::ATTACK_DELAY); if (attr != -1 && attackDelay) { - setStatBase(ATTACK_SPEED, getStatBase(attr) * 1000 + setStatBase(Attributes::ATTACK_SPEED, getStatBase(attr) * 1000 / attackDelay, false); - setStatMod(ATTACK_SPEED, getStatMod(attr) * 1000 + setStatMod(Attributes::ATTACK_SPEED, getStatMod(attr) * 1000 / attackDelay, true); } else { - setStatBase(ATTACK_SPEED, 0, false); - setStatMod(ATTACK_SPEED, 0, true); + setStatBase(Attributes::ATTACK_SPEED, 0, false); + setStatMod(Attributes::ATTACK_SPEED, 0, true); } } diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h index 5139493e1..262db1a7d 100644 --- a/src/being/playerinfo.h +++ b/src/being/playerinfo.h @@ -69,30 +69,6 @@ class Item; */ namespace PlayerInfo { - /** - * Standard attributes for players. - */ - enum Attribute - { - LEVEL = 0, - HP, - MAX_HP, - MP, - MAX_MP, - EXP, - EXP_NEEDED, - MONEY, - TOTAL_WEIGHT, - MAX_WEIGHT, - SKILL_POINTS, - CHAR_POINTS, - CORR_POINTS, - ATTACK_DELAY = 100, - ATTACK_RANGE = 101, - WALK_SPEED = 102, - ATTACK_SPEED = 103 - }; - // --- Attributes ------------------------------------------------------------- /** diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index 941249560..85480db3a 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -24,6 +24,8 @@ #include "units.h" +#include "being/attributes.h" + #include "gui/gui.h" #include "gui/windows/charselectdialog.h" @@ -133,9 +135,9 @@ void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED) { mPopup->show(mouseX, mouseY, name, strprintf(_("Level: %u"), static_cast<uint32_t>( - mCharacter->data.mAttributes[PlayerInfo::LEVEL])), + mCharacter->data.mAttributes[Attributes::LEVEL])), strprintf(_("Money: %s"), Units::formatCurrency( - mCharacter->data.mAttributes[PlayerInfo::MONEY]).c_str())); + mCharacter->data.mAttributes[Attributes::MONEY]).c_str())); } else { diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 4754d01e5..33c46d4cd 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -30,6 +30,8 @@ #include "input/keydata.h" +#include "being/attributes.h" + #include "gui/windows/charcreatedialog.h" #include "gui/windows/confirmdialog.h" #include "gui/windows/logindialog.h" @@ -257,19 +259,19 @@ void CharSelectDialog::action(const ActionEvent &event) _("Hp: %u/%u\nMp: %u/%u\nLevel: %u\n" "Experience: %u\nMoney: %s"), static_cast<uint32_t>( - character->data.mAttributes[PlayerInfo::HP]), + character->data.mAttributes[Attributes::HP]), static_cast<uint32_t>( - character->data.mAttributes[PlayerInfo::MAX_HP]), + character->data.mAttributes[Attributes::MAX_HP]), static_cast<uint32_t>( - character->data.mAttributes[PlayerInfo::MP]), + character->data.mAttributes[Attributes::MP]), static_cast<uint32_t>( - character->data.mAttributes[PlayerInfo::MAX_MP]), + character->data.mAttributes[Attributes::MAX_MP]), static_cast<uint32_t>( - character->data.mAttributes[PlayerInfo::LEVEL]), + character->data.mAttributes[Attributes::LEVEL]), static_cast<uint32_t>( - character->data.mAttributes[PlayerInfo::EXP]), + character->data.mAttributes[Attributes::EXP]), Units::formatCurrency( - character->data.mAttributes[PlayerInfo::MONEY]).c_str()); + character->data.mAttributes[Attributes::MONEY]).c_str()); new OkDialog(data->getName(), msg, DIALOG_SILENCE); } } diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 316b276f3..e0f4d3c51 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -31,6 +31,7 @@ #include "party.h" #include "spellshortcut.h" +#include "being/attributes.h" #include "being/localplayer.h" #include "being/playerinfo.h" #include "being/playerrelations.h" @@ -983,7 +984,7 @@ void ChatWindow::attributeChanged(const int id, { switch (id) { - case PlayerInfo::EXP: + case Attributes::EXP: { if (oldVal > newVal) break; @@ -995,7 +996,7 @@ void ChatWindow::attributeChanged(const int id, } break; } - case PlayerInfo::LEVEL: + case Attributes::LEVEL: battleChatLog(std::string("Level: ").append(toString(newVal))); break; default: diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 2122fce2f..cf48e4fd1 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -26,6 +26,7 @@ #include "item.h" #include "units.h" +#include "being/attributes.h" #include "being/playerinfo.h" #include "events/keyevent.h" @@ -566,7 +567,7 @@ void InventoryWindow::mouseMoved(MouseEvent &event) const Rect &rect = mDimension; mTextPopup->show(rect.x + x, rect.y + y, strprintf(_("Money: %s"), Units::formatCurrency(PlayerInfo::getAttribute( - PlayerInfo::MONEY)).c_str())); + Attributes::MONEY)).c_str())); } else { @@ -694,8 +695,8 @@ void InventoryWindow::updateWeight() if (!isMainInventory() || !mWeightBar) return; - const int total = PlayerInfo::getAttribute(PlayerInfo::TOTAL_WEIGHT); - const int max = PlayerInfo::getAttribute(PlayerInfo::MAX_WEIGHT); + const int total = PlayerInfo::getAttribute(Attributes::TOTAL_WEIGHT); + const int max = PlayerInfo::getAttribute(Attributes::MAX_WEIGHT); if (max <= 0) return; @@ -814,6 +815,6 @@ void InventoryWindow::attributeChanged(const int id, const int oldVal A_UNUSED, const int newVal A_UNUSED) { - if (id == PlayerInfo::TOTAL_WEIGHT || id == PlayerInfo::MAX_WEIGHT) + if (id == Attributes::TOTAL_WEIGHT || id == Attributes::MAX_WEIGHT) updateWeight(); } diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp index 832892fac..e9dd50d5d 100644 --- a/src/gui/windows/killstats.cpp +++ b/src/gui/windows/killstats.cpp @@ -30,6 +30,7 @@ #include "client.h" #include "game.h" +#include "being/attributes.h" #include "being/localplayer.h" #include "being/playerinfo.h" @@ -109,8 +110,8 @@ KillStats::KillStats() : setStickyButtonLock(true); setDefaultSize(250, 250, 350, 300); - const int xp(PlayerInfo::getAttribute(PlayerInfo::EXP)); - int xpNextLevel(PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED)); + const int xp(PlayerInfo::getAttribute(Attributes::EXP)); + int xpNextLevel(PlayerInfo::getAttribute(Attributes::EXP_NEEDED)); if (!xpNextLevel) xpNextLevel = 1; @@ -160,7 +161,7 @@ void KillStats::action(const ActionEvent &event) mKillCounter = 0; mExpCounter = 0; mLine3->setCaption(strprintf("1%% = %d exp, avg mob for 1%%: %s", - PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED) / 100, "?")); + PlayerInfo::getAttribute(Attributes::EXP_NEEDED) / 100, "?")); // TRANSLATORS: kill stats window label mLine4->setCaption(strprintf(_("Kills: %s, total exp: %s"), "?", "?")); // TRANSLATORS: kill stats window label @@ -199,7 +200,7 @@ void KillStats::resetTimes() void KillStats::gainXp(int xp) { - const int expNeed = PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED); + const int expNeed = PlayerInfo::getAttribute(Attributes::EXP_NEEDED); if (xp == expNeed) xp = 0; else if (!xp) @@ -227,7 +228,7 @@ void KillStats::gainXp(int xp) if (timeDiff <= 0.001) timeDiff = 1; - const int exp = PlayerInfo::getAttribute(PlayerInfo::EXP); + const int exp = PlayerInfo::getAttribute(Attributes::EXP); // TRANSLATORS: kill stats window label mLine1->setCaption(strprintf(_("Level: %d at %f%%"), player_node->getLevel(), static_cast<double>(exp) @@ -290,7 +291,7 @@ void KillStats::recalcStats() // Need Update Exp Counter if (curTime - m1minExpTime > 60) { - const int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP); + const int newExp = PlayerInfo::getAttribute(Attributes::EXP); if (m1minExpTime != 0) m1minSpeed = newExp - m1minExpNum; else @@ -301,7 +302,7 @@ void KillStats::recalcStats() if (curTime != 0 && mLastHost == 0xFF6B66 && cur_time > 1) { - const int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED); + const int newExp = PlayerInfo::getAttribute(Attributes::EXP_NEEDED); if (m1minExpTime != 0) m1minSpeed = newExp - m1minExpNum; mStatsReUpdated = true; @@ -310,7 +311,7 @@ void KillStats::recalcStats() if (curTime - m5minExpTime > 60*5) { - const int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP); + const int newExp = PlayerInfo::getAttribute(Attributes::EXP); if (m5minExpTime != 0) m5minSpeed = newExp - m5minExpNum; else @@ -321,7 +322,7 @@ void KillStats::recalcStats() if (curTime - m15minExpTime > 60*15) { - const int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP); + const int newExp = PlayerInfo::getAttribute(Attributes::EXP); if (m15minExpTime != 0) m15minSpeed = newExp - m15minExpNum; else @@ -345,8 +346,8 @@ void KillStats::update() // TRANSLATORS: kill stats window label mExpTime1Label->setCaption(strprintf(_(" Time for next level: %s"), toString(static_cast<float>((PlayerInfo::getAttribute( - PlayerInfo::EXP_NEEDED) - PlayerInfo::getAttribute( - PlayerInfo::EXP)) / m1minSpeed)).c_str())); + Attributes::EXP_NEEDED) - PlayerInfo::getAttribute( + Attributes::EXP)) / m1minSpeed)).c_str())); } else { @@ -365,8 +366,8 @@ void KillStats::update() // TRANSLATORS: kill stats window label mExpTime5Label->setCaption(strprintf(_(" Time for next level: %s"), toString(static_cast<float>((PlayerInfo::getAttribute( - PlayerInfo::EXP_NEEDED) - PlayerInfo::getAttribute( - PlayerInfo::EXP)) / m5minSpeed * 5)).c_str())); + Attributes::EXP_NEEDED) - PlayerInfo::getAttribute( + Attributes::EXP)) / m5minSpeed * 5)).c_str())); } else { @@ -387,8 +388,8 @@ void KillStats::update() // TRANSLATORS: kill stats window label mExpTime15Label->setCaption(strprintf(_(" Time for next level: %s"), toString(static_cast<float>((PlayerInfo::getAttribute( - PlayerInfo::EXP_NEEDED) - PlayerInfo::getAttribute( - PlayerInfo::EXP)) / m15minSpeed * 15)).c_str())); + Attributes::EXP_NEEDED) - PlayerInfo::getAttribute( + Attributes::EXP)) / m15minSpeed * 15)).c_str())); } else { @@ -495,17 +496,17 @@ void KillStats::attributeChanged(const int id, { switch (id) { - case PlayerInfo::EXP: - case PlayerInfo::EXP_NEEDED: + case Attributes::EXP: + case Attributes::EXP_NEEDED: gainXp(newVal - oldVal); break; - case PlayerInfo::LEVEL: + case Attributes::LEVEL: mKillCounter = 0; mKillTCounter = 0; mExpCounter = 0; mExpTCounter = 0; mLine3->setCaption(strprintf("1%% = %d exp, avg mob for 1%%: %s", - PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED) / 100, "?")); + PlayerInfo::getAttribute(Attributes::EXP_NEEDED) / 100, "?")); mLine4->setCaption(strprintf( // TRANSLATORS: kill stats window label _("Kills: %s, total exp: %s"), "?", "?")); diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index 720c1375c..1a8f463e5 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -25,6 +25,7 @@ #include "animatedsprite.h" #include "configuration.h" +#include "being/attributes.h" #include "being/localplayer.h" #include "being/playerinfo.h" @@ -267,23 +268,23 @@ void MiniStatusWindow::attributeChanged(const int id, { switch (id) { - case PlayerInfo::HP: - case PlayerInfo::MAX_HP: + case Attributes::HP: + case Attributes::MAX_HP: StatusWindow::updateHPBar(mHpBar); break; - case PlayerInfo::MP: - case PlayerInfo::MAX_MP: + case Attributes::MP: + case Attributes::MAX_MP: statusWindow->updateMPBar(mMpBar); break; - case PlayerInfo::EXP: - case PlayerInfo::EXP_NEEDED: + case Attributes::EXP: + case Attributes::EXP_NEEDED: StatusWindow::updateXPBar(mXpBar); break; - case PlayerInfo::TOTAL_WEIGHT: - case PlayerInfo::MAX_WEIGHT: + case Attributes::TOTAL_WEIGHT: + case Attributes::MAX_WEIGHT: StatusWindow::updateWeightBar(mWeightBar); break; - case PlayerInfo::MONEY: + case Attributes::MONEY: StatusWindow::updateMoneyBar(mMoneyBar); break; default: @@ -339,18 +340,18 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event) { // TRANSLATORS: status bar label level = strprintf(_("Level: %d (GM %d)"), - PlayerInfo::getAttribute(PlayerInfo::LEVEL), + PlayerInfo::getAttribute(Attributes::LEVEL), player_node->getGMLevel()); } else { // TRANSLATORS: status bar label level = strprintf(_("Level: %d"), - PlayerInfo::getAttribute(PlayerInfo::LEVEL)); + PlayerInfo::getAttribute(Attributes::LEVEL)); } - const int exp = PlayerInfo::getAttribute(PlayerInfo::EXP); - const int expNeed = PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED); + const int exp = PlayerInfo::getAttribute(Attributes::EXP); + const int expNeed = PlayerInfo::getAttribute(Attributes::EXP_NEEDED); if (exp > expNeed) { mTextPopup->show(x + rect.x, y + rect.y, level, strprintf("%d/%d", @@ -368,15 +369,15 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event) else if (event.getSource() == mHpBar) { mTextPopup->show(x + rect.x, y + rect.y, event.getSource()->getId(), - strprintf("%d/%d", PlayerInfo::getAttribute(PlayerInfo::HP), - PlayerInfo::getAttribute(PlayerInfo::MAX_HP))); + strprintf("%d/%d", PlayerInfo::getAttribute(Attributes::HP), + PlayerInfo::getAttribute(Attributes::MAX_HP))); mStatusPopup->hide(); } else if (event.getSource() == mMpBar) { mTextPopup->show(x + rect.x, y + rect.y, event.getSource()->getId(), - strprintf("%d/%d", PlayerInfo::getAttribute(PlayerInfo::MP), - PlayerInfo::getAttribute(PlayerInfo::MAX_MP))); + strprintf("%d/%d", PlayerInfo::getAttribute(Attributes::MP), + PlayerInfo::getAttribute(Attributes::MAX_MP))); mStatusPopup->hide(); } else if (event.getSource() == mJobBar) @@ -407,8 +408,8 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event) { mTextPopup->show(x + rect.x, y + rect.y, event.getSource()->getId(), strprintf("%d/%d", PlayerInfo::getAttribute( - PlayerInfo::TOTAL_WEIGHT), - PlayerInfo::getAttribute(PlayerInfo::MAX_WEIGHT))); + Attributes::TOTAL_WEIGHT), + PlayerInfo::getAttribute(Attributes::MAX_WEIGHT))); mStatusPopup->hide(); } else if (event.getSource() == mInvSlotsBar) @@ -428,7 +429,7 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event) { mTextPopup->show(x + rect.x, y + rect.y, event.getSource()->getId(), - toString(PlayerInfo::getAttribute(PlayerInfo::MONEY))); + toString(PlayerInfo::getAttribute(Attributes::MONEY))); } else { diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index b44dcc19e..edd3efbc7 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -48,6 +48,7 @@ #include "soundconsts.h" #include "soundmanager.h" +#include "being/attributes.h" #include "being/localplayer.h" #include "being/playerinfo.h" #include "being/playerrelations.h" @@ -593,9 +594,9 @@ void ShopWindow::giveList(const std::string &nick, const int mode) { int amount = item->getQuantity(); if (item->getPrice() * amount > PlayerInfo::getAttribute( - PlayerInfo::MONEY)) + Attributes::MONEY)) { - amount = PlayerInfo::getAttribute(PlayerInfo::MONEY) + amount = PlayerInfo::getAttribute(Attributes::MONEY) / item->getPrice(); } @@ -655,9 +656,9 @@ void ShopWindow::showList(const std::string &nick, std::string data) return; if (buyDialog) - buyDialog->setMoney(PlayerInfo::getAttribute(PlayerInfo::MONEY)); + buyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); if (sellDialog) - sellDialog->setMoney(PlayerInfo::getAttribute(PlayerInfo::MONEY)); + sellDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); for (unsigned f = 0; f < data.length(); f += 9) { diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 0051dd1e7..b082e65d4 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -27,6 +27,7 @@ #include "effectmanager.h" #include "itemshortcut.h" +#include "being/attributes.h" #include "being/localplayer.h" #include "gui/font.h" @@ -408,7 +409,7 @@ void SkillDialog::update() { // TRANSLATORS: skills dialog label mPointsLabel->setCaption(strprintf(_("Skill points available: %d"), - PlayerInfo::getAttribute(PlayerInfo::SKILL_POINTS))); + PlayerInfo::getAttribute(Attributes::SKILL_POINTS))); mPointsLabel->adjustSize(); FOR_EACH (SkillMap::const_iterator, it, mSkills) diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index e76658b05..ae0c4fe80 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -30,6 +30,7 @@ #include "gui/windows/chatwindow.h" +#include "being/attributes.h" #include "being/localplayer.h" #include "being/playerinfo.h" @@ -188,19 +189,19 @@ StatusWindow::StatusWindow() : player_node->getRaceName().c_str())); } - int max = PlayerInfo::getAttribute(PlayerInfo::MAX_HP); + int max = PlayerInfo::getAttribute(Attributes::MAX_HP); if (!max) max = 1; mHpBar = new ProgressBar(this, static_cast<float>(PlayerInfo::getAttribute( - PlayerInfo::HP)) / static_cast<float>(max), 80, 0, Theme::PROG_HP, + Attributes::HP)) / static_cast<float>(max), 80, 0, Theme::PROG_HP, "hpprogressbar.xml", "hpprogressbar_fill.xml"); mHpBar->setColor(getThemeColor(Theme::HP_BAR), getThemeColor(Theme::HP_BAR_OUTLINE)); - max = PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED); + max = PlayerInfo::getAttribute(Attributes::EXP_NEEDED); mXpBar = new ProgressBar(this, max ? - static_cast<float>(PlayerInfo::getAttribute(PlayerInfo::EXP)) + static_cast<float>(PlayerInfo::getAttribute(Attributes::EXP)) / static_cast<float>(max) : static_cast<float>(0), 80, 0, Theme::PROG_EXP, "xpprogressbar.xml", "xpprogressbar_fill.xml"); mXpBar->setColor(getThemeColor(Theme::XP_BAR), @@ -212,12 +213,12 @@ StatusWindow::StatusWindow() : if (magicBar) { - max = PlayerInfo::getAttribute(PlayerInfo::MAX_MP); + max = PlayerInfo::getAttribute(Attributes::MAX_MP); // TRANSLATORS: status window label mMpLabel = new Label(this, _("MP:")); const bool useMagic = Net::getPlayerHandler()->canUseMagic(); mMpBar = new ProgressBar(this, max ? static_cast<float>( - PlayerInfo::getAttribute(PlayerInfo::MAX_MP)) + PlayerInfo::getAttribute(Attributes::MAX_MP)) / static_cast<float>(max) : static_cast<float>(0), 80, 0, useMagic ? Theme::PROG_MP : Theme::PROG_NO_MP, useMagic ? "mpprogressbar.xml" : "nompprogressbar.xml", @@ -312,25 +313,25 @@ StatusWindow::StatusWindow() : // TRANSLATORS: status window label mMoneyLabel->setCaption(strprintf(_("Money: %s"), Units::formatCurrency( - PlayerInfo::getAttribute(PlayerInfo::MONEY)).c_str())); + PlayerInfo::getAttribute(Attributes::MONEY)).c_str())); mMoneyLabel->adjustSize(); // TRANSLATORS: status window label mCharacterPointsLabel->setCaption(strprintf(_("Character points: %d"), - PlayerInfo::getAttribute(PlayerInfo::CHAR_POINTS))); + PlayerInfo::getAttribute(Attributes::CHAR_POINTS))); mCharacterPointsLabel->adjustSize(); if (player_node && player_node->isGM()) { // TRANSLATORS: status window label mLvlLabel->setCaption(strprintf(_("Level: %d (GM %d)"), - PlayerInfo::getAttribute(PlayerInfo::LEVEL), + PlayerInfo::getAttribute(Attributes::LEVEL), player_node->getGMLevel())); } else { // TRANSLATORS: status window label mLvlLabel->setCaption(strprintf(_("Level: %d"), - PlayerInfo::getAttribute(PlayerInfo::LEVEL))); + PlayerInfo::getAttribute(Attributes::LEVEL))); } mLvlLabel->adjustSize(); } @@ -401,29 +402,29 @@ void StatusWindow::attributeChanged(const int id, { switch (id) { - case PlayerInfo::HP: - case PlayerInfo::MAX_HP: + case Attributes::HP: + case Attributes::MAX_HP: updateHPBar(mHpBar, true); break; - case PlayerInfo::MP: - case PlayerInfo::MAX_MP: + case Attributes::MP: + case Attributes::MAX_MP: updateMPBar(mMpBar, true); break; - case PlayerInfo::EXP: - case PlayerInfo::EXP_NEEDED: + case Attributes::EXP: + case Attributes::EXP_NEEDED: updateXPBar(mXpBar, false); break; - case PlayerInfo::MONEY: + case Attributes::MONEY: // TRANSLATORS: status window label mMoneyLabel->setCaption(strprintf(_("Money: %s"), Units::formatCurrency(newVal).c_str())); mMoneyLabel->adjustSize(); break; - case PlayerInfo::CHAR_POINTS: + case Attributes::CHAR_POINTS: mCharacterPointsLabel->setCaption(strprintf( // TRANSLATORS: status window label _("Character points: %d"), newVal)); @@ -438,7 +439,7 @@ void StatusWindow::attributeChanged(const int id, } break; - case PlayerInfo::CORR_POINTS: + case Attributes::CORR_POINTS: mCorrectionPointsLabel->setCaption(strprintf( // TRANSLATORS: status window label _("Correction points: %d"), newVal)); @@ -452,7 +453,7 @@ void StatusWindow::attributeChanged(const int id, } break; - case PlayerInfo::LEVEL: + case Attributes::LEVEL: // TRANSLATORS: status window label mLvlLabel->setCaption(strprintf(_("Level: %d"), newVal)); mLvlLabel->adjustSize(); @@ -510,8 +511,8 @@ void StatusWindow::updateHPBar(ProgressBar *const bar, const bool showMax) if (!bar) return; - const int hp = PlayerInfo::getAttribute(PlayerInfo::HP); - const int maxHp = PlayerInfo::getAttribute(PlayerInfo::MAX_HP); + const int hp = PlayerInfo::getAttribute(Attributes::HP); + const int maxHp = PlayerInfo::getAttribute(Attributes::MAX_HP); if (showMax) bar->setText(toString(hp).append("/").append(toString(maxHp))); else @@ -529,8 +530,8 @@ void StatusWindow::updateMPBar(ProgressBar *const bar, if (!bar) return; - const int mp = PlayerInfo::getAttribute(PlayerInfo::MP); - const int maxMp = PlayerInfo::getAttribute(PlayerInfo::MAX_MP); + const int mp = PlayerInfo::getAttribute(Attributes::MP); + const int maxMp = PlayerInfo::getAttribute(Attributes::MAX_MP); if (showMax) bar->setText(toString(mp).append("/").append(toString(maxMp))); else @@ -591,8 +592,8 @@ void StatusWindow::updateXPBar(ProgressBar *const bar, const bool percent) if (!bar) return; - updateProgressBar(bar, PlayerInfo::getAttribute(PlayerInfo::EXP), - PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED), percent); + updateProgressBar(bar, PlayerInfo::getAttribute(Attributes::EXP), + PlayerInfo::getAttribute(Attributes::EXP_NEEDED), percent); } void StatusWindow::updateJobBar(ProgressBar *const bar, const bool percent) @@ -617,7 +618,7 @@ void StatusWindow::updateWeightBar(ProgressBar *const bar) if (!bar) return; - if (PlayerInfo::getAttribute(PlayerInfo::MAX_WEIGHT) == 0) + if (PlayerInfo::getAttribute(Attributes::MAX_WEIGHT) == 0) { // TRANSLATORS: status bar label bar->setText(_("Max")); @@ -626,8 +627,8 @@ void StatusWindow::updateWeightBar(ProgressBar *const bar) else { const int totalWeight = PlayerInfo::getAttribute( - PlayerInfo::TOTAL_WEIGHT); - const int maxWeight = PlayerInfo::getAttribute(PlayerInfo::MAX_WEIGHT); + Attributes::TOTAL_WEIGHT); + const int maxWeight = PlayerInfo::getAttribute(Attributes::MAX_WEIGHT); float progress = 1.0F; if (maxWeight) { @@ -645,7 +646,7 @@ void StatusWindow::updateMoneyBar(ProgressBar *const bar) if (!bar) return; - const int money = PlayerInfo::getAttribute(PlayerInfo::MONEY); + const int money = PlayerInfo::getAttribute(Attributes::MONEY); bar->setText(Units::formatCurrency(money)); if (money > 0) { @@ -858,9 +859,9 @@ std::string ChangeDisplay::update() } if (mDec) - mDec->setEnabled(PlayerInfo::getAttribute(PlayerInfo::CORR_POINTS)); + mDec->setEnabled(PlayerInfo::getAttribute(Attributes::CORR_POINTS)); - mInc->setEnabled(PlayerInfo::getAttribute(PlayerInfo::CHAR_POINTS) + mInc->setEnabled(PlayerInfo::getAttribute(Attributes::CHAR_POINTS) >= mNeeded && mNeeded > 0); return AttrDisplay::update(); @@ -878,12 +879,12 @@ void ChangeDisplay::action(const ActionEvent &event) event.getSource() == mDec) { const int newcorrpoints = PlayerInfo::getAttribute( - PlayerInfo::CORR_POINTS); - PlayerInfo::setAttribute(PlayerInfo::CORR_POINTS, newcorrpoints - 1); + Attributes::CORR_POINTS); + PlayerInfo::setAttribute(Attributes::CORR_POINTS, newcorrpoints - 1); const int newpoints = PlayerInfo::getAttribute( - PlayerInfo::CHAR_POINTS) + 1; - PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, newpoints); + Attributes::CHAR_POINTS) + 1; + PlayerInfo::setAttribute(Attributes::CHAR_POINTS, newpoints); const int newbase = PlayerInfo::getStatBase(mId) - 1; PlayerInfo::setStatBase(mId, newbase); @@ -901,8 +902,8 @@ void ChangeDisplay::action(const ActionEvent &event) } const int newpoints = PlayerInfo::getAttribute( - PlayerInfo::CHAR_POINTS) - cnt; - PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, newpoints); + Attributes::CHAR_POINTS) - cnt; + PlayerInfo::setAttribute(Attributes::CHAR_POINTS, newpoints); const int newbase = PlayerInfo::getStatBase(mId) + cnt; PlayerInfo::setStatBase(mId, newbase); diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index f05cf1cac..985ebdfad 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -27,6 +27,7 @@ #include "item.h" #include "units.h" +#include "being/attributes.h" #include "being/localplayer.h" #include "being/playerinfo.h" #include "being/playerrelations.h" @@ -379,7 +380,7 @@ void TradeWindow::action(const ActionEvent &event) return; int v = atoi(mMoneyField->getText().c_str()); - const int curMoney = PlayerInfo::getAttribute(PlayerInfo::MONEY); + const int curMoney = PlayerInfo::getAttribute(Attributes::MONEY); if (v > curMoney) { if (localChatTab) 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); diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index aaf7ad302..80927c693 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -24,6 +24,7 @@ #include "configuration.h" +#include "being/attributes.h" #include "being/localplayer.h" #include "being/playerinfo.h" @@ -144,7 +145,7 @@ void SpellManager::invoke(const int spellId) const >= static_cast<signed>(spell->getBaseLvl()) && PlayerInfo::getSkillLevel(static_cast<int>( spell->getSchool())) >= static_cast<signed>(spell->getSchoolLvl()) - && PlayerInfo::getAttribute(PlayerInfo::MP) >= spell->getMana())) + && PlayerInfo::getAttribute(Attributes::MP) >= spell->getMana())) { const Being *const target = player_node->getTarget(); if (spell->getTargetType() == NOTARGET) |