summaryrefslogtreecommitdiff
path: root/src/playerinfo.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-11 15:34:12 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-11 15:34:12 +0300
commitcd51470e6fe2cc30b6d533cc0183639041613680 (patch)
treefea875a1087d24775c302508d8b0c7662a46ed04 /src/playerinfo.cpp
parenta09da2427062c4454bd9691489289d45b3473fda (diff)
downloadmanaplus-cd51470e6fe2cc30b6d533cc0183639041613680.tar.gz
manaplus-cd51470e6fe2cc30b6d533cc0183639041613680.tar.bz2
manaplus-cd51470e6fe2cc30b6d533cc0183639041613680.tar.xz
manaplus-cd51470e6fe2cc30b6d533cc0183639041613680.zip
Improve playerinfo class.
Diffstat (limited to 'src/playerinfo.cpp')
-rw-r--r--src/playerinfo.cpp44
1 files changed, 13 insertions, 31 deletions
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index af4ed6837..7e837162b 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -50,8 +50,10 @@ int mCharId = 0;
Inventory *mInventory = nullptr;
Equipment *mEquipment = nullptr;
+#ifdef MANASERV_SUPPORT
std::map<int, Special> mSpecials;
signed char mSpecialRechargeUpdateNeeded = 0;
+#endif
bool mTrading = false;
int mLevelProgress = 0;
@@ -165,7 +167,7 @@ int getStatEffective(const int id)
return 0;
}
-std::pair<int, int> getStatExperience(const int id)
+const std::pair<int, int> getStatExperience(const int id)
{
const StatMap::const_iterator it = mData.mStats.find(id);
int a, b;
@@ -240,23 +242,6 @@ void setEquipmentBackend(Equipment::Backend *const backend)
mEquipment->setBackend(backend);
}
-// --- Specials ---------------------------------------------------------------
-
-void setSpecialStatus(const int id, const int current,
- const int max, const int recharge)
-{
- logger->log("SpecialUpdate Skill #%d -- (%d/%d) -> %d", id, current, max,
- recharge);
- mSpecials[id].currentMana = current;
- mSpecials[id].neededMana = max;
- mSpecials[id].recharge = recharge;
-}
-
-const SpecialsMap &getSpecialStatus()
-{
- return mSpecials;
-}
-
// --- Misc -------------------------------------------------------------------
void setBackend(const PlayerInfoBackend &backend)
@@ -276,6 +261,7 @@ int getCharId()
void logic()
{
+#ifdef MANASERV_SUPPORT
if ((mSpecialRechargeUpdateNeeded % 11) == 0)
{
mSpecialRechargeUpdateNeeded = 0;
@@ -288,6 +274,7 @@ void logic()
}
}
mSpecialRechargeUpdateNeeded++;
+#endif
}
bool isTrading()
@@ -297,26 +284,22 @@ bool isTrading()
void setTrading(const bool trading)
{
- const bool notify = mTrading != trading;
mTrading = trading;
-
- if (notify)
- {
- DepricatedEvent event(EVENT_TRADING);
- event.setInt("trading", trading);
- DepricatedEvent::trigger(CHANNEL_STATUS, event);
- }
}
void updateAttrs()
{
- const int attr = Net::getPlayerHandler()->getAttackLocation();
- if (attr != -1 && getStatBase(ATTACK_DELAY))
+ const Net::PlayerHandler *const handler = Net::getPlayerHandler();
+ if (!handler)
+ return;
+ const int attr = handler->getAttackLocation();
+ const int attackDelay = getStatBase(ATTACK_DELAY);
+ if (attr != -1 && attackDelay)
{
setStatBase(ATTACK_SPEED, getStatBase(attr) * 1000
- / getStatBase(ATTACK_DELAY), false);
+ / attackDelay, false);
setStatMod(ATTACK_SPEED, getStatMod(attr) * 1000
- / getStatBase(ATTACK_DELAY), true);
+ / attackDelay, true);
}
else
{
@@ -341,7 +324,6 @@ public:
if (event.getName() == EVENT_STATECHANGE)
{
const int newState = event.getInt("newState");
-
if (newState == STATE_GAME)
{
if (!mInventory)