summaryrefslogtreecommitdiff
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
parenta09da2427062c4454bd9691489289d45b3473fda (diff)
downloadmv-cd51470e6fe2cc30b6d533cc0183639041613680.tar.gz
mv-cd51470e6fe2cc30b6d533cc0183639041613680.tar.bz2
mv-cd51470e6fe2cc30b6d533cc0183639041613680.tar.xz
mv-cd51470e6fe2cc30b6d533cc0183639041613680.zip
Improve playerinfo class.
-rw-r--r--src/depricatedevent.h4
-rw-r--r--src/playerinfo.cpp44
-rw-r--r--src/playerinfo.h15
3 files changed, 15 insertions, 48 deletions
diff --git a/src/depricatedevent.h b/src/depricatedevent.h
index 1574983c0..2cdceb9f6 100644
--- a/src/depricatedevent.h
+++ b/src/depricatedevent.h
@@ -33,8 +33,7 @@ enum Channels
CHANNEL_ATTRIBUTES = 0,
CHANNEL_CLIENT,
CHANNEL_GAME,
- CHANNEL_NOTICES,
- CHANNEL_STATUS
+ CHANNEL_NOTICES
};
enum DepricatedEvents
@@ -50,7 +49,6 @@ enum DepricatedEvents
EVENT_MAPLOADED,
EVENT_SERVERNOTICE,
EVENT_STATECHANGE,
- EVENT_TRADING,
EVENT_UPDATEATTRIBUTE,
EVENT_UPDATESTAT,
};
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)
diff --git a/src/playerinfo.h b/src/playerinfo.h
index d96e3e126..ff149b2cc 100644
--- a/src/playerinfo.h
+++ b/src/playerinfo.h
@@ -154,7 +154,7 @@ namespace PlayerInfo
/**
* Returns the experience of the given stat.
*/
- std::pair<int, int> getStatExperience(const int id) A_WARN_UNUSED;
+ const std::pair<int, int> getStatExperience(const int id) A_WARN_UNUSED;
/**
* Changes the experience of the given stat.
@@ -192,19 +192,6 @@ namespace PlayerInfo
*/
Item *getEquipment(const unsigned int slot) A_WARN_UNUSED;
-// --- Specials ---------------------------------------------------------------
-
- /**
- * Changes the status of the given special.
- */
- void setSpecialStatus(const int id, const int current,
- const int max, const int recharge);
-
- /**
- * Returns the status of the given special.
- */
- const SpecialsMap &getSpecialStatus();
-
// --- Misc -------------------------------------------------------------------
/**