summaryrefslogtreecommitdiff
path: root/src/game-server
diff options
context:
space:
mode:
authorPhilipp Sehmisch <crush@themanaworld.org>2009-07-08 19:37:20 +0200
committerPhilipp Sehmisch <crush@themanaworld.org>2009-07-08 19:37:20 +0200
commitc04d6befd07a57331a3ea3f360261d80fa9a0e69 (patch)
treee55879ab9998febd5966b4d16279fb13c2ccfe37 /src/game-server
parent5b56b981f9957597f8fb9761c7cac77b88761c52 (diff)
downloadmanaserv-c04d6befd07a57331a3ea3f360261d80fa9a0e69.tar.gz
manaserv-c04d6befd07a57331a3ea3f360261d80fa9a0e69.tar.bz2
manaserv-c04d6befd07a57331a3ea3f360261d80fa9a0e69.tar.xz
manaserv-c04d6befd07a57331a3ea3f360261d80fa9a0e69.zip
Sending spell recharge status to the clients
Diffstat (limited to 'src/game-server')
-rw-r--r--src/game-server/character.cpp52
-rw-r--r--src/game-server/character.hpp13
2 files changed, 57 insertions, 8 deletions
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index 9e68667c..301a8c5c 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -54,9 +54,19 @@ const AttackZone Character::UNARMED_ATTACK_ZONE = {ATTZONESHAPE_RECT, true, 48,
Character::Character(MessageIn &msg):
Being(OBJECT_CHARACTER),
- mClient(NULL), mTransactionHandler(NULL), mDatabaseID(-1),
- mGender(0), mHairStyle(0), mHairColor(0), mLevel(1), mLevelProgress(0),
- mUpdateLevelProgress(false), mRecalculateLevel(true), mParty(0),
+ mClient(NULL),
+ mTransactionHandler(NULL),
+ mRechargePerSpecial(0),
+ mSpecialUpdateNeeded(false),
+ mDatabaseID(-1),
+ mGender(0),
+ mHairStyle(0),
+ mHairColor(0),
+ mLevel(1),
+ mLevelProgress(0),
+ mUpdateLevelProgress(false),
+ mRecalculateLevel(true),
+ mParty(0),
mTransaction(TRANS_NONE)
{
Attribute attr = { 0, 0 };
@@ -103,13 +113,19 @@ void Character::update()
}
if (numRechargeNeeded > 0)
{
- int rechargePerSpecial = getModifiedAttribute(CHAR_ATTR_INTELLIGENCE) / numRechargeNeeded;
+ mRechargePerSpecial = getModifiedAttribute(CHAR_ATTR_INTELLIGENCE) / numRechargeNeeded;
for (std::list<Special*>::iterator i = rechargeNeeded.begin(); i != rechargeNeeded.end(); i++)
{
- (*i)->currentMana += rechargePerSpecial;
+ (*i)->currentMana += mRechargePerSpecial;
}
}
+ if (mSpecialUpdateNeeded)
+ {
+ sendSpecialUpdate();
+ mSpecialUpdateNeeded = false;
+ }
+
Being::update();
}
@@ -215,9 +231,30 @@ void Character::useSpecial(int id)
script->execute();
}
+ mSpecialUpdateNeeded = true;
return;
}
+void Character::sendSpecialUpdate()
+{
+ //GPMSG_SPECIAL_STATUS = 0x0293, // { B specialID, L current, L max, L recharge }
+ for (std::map<int, Special*>::iterator i = mSpecials.begin();
+ i != mSpecials.end();
+ i++)
+ {
+
+ MessageOut msg(GPMSG_SPECIAL_STATUS );
+ msg.writeByte(i->first);
+ msg.writeLong(i->second->currentMana);
+ msg.writeLong(i->second->neededMana);
+ msg.writeLong(mRechargePerSpecial);
+ /* yes, the last one is redundant because it is the same for each
+ special, but I would like to keep the netcode flexible enough
+ to allow different recharge speed per special when necessary */
+ gameHandler->sendTo(this, msg);
+ }
+}
+
int Character::getMapId() const
{
return getMap()->getID();
@@ -410,6 +447,10 @@ void Character::flagAttribute(int attr)
{
// Warn the player of this attribute modification.
mModifiedAttributes.insert(attr);
+ if (attr = CHAR_ATTR_INTELLIGENCE)
+ {
+ mSpecialUpdateNeeded = true;
+ }
}
int Character::expForLevel(int level)
@@ -574,5 +615,6 @@ void Character::giveSpecial(int id)
Special *s = new Special(neededMana);
mSpecials[id] = s;
+ mSpecialUpdateNeeded = true;
}
}
diff --git a/src/game-server/character.hpp b/src/game-server/character.hpp
index 5eb9198e..ea979184 100644
--- a/src/game-server/character.hpp
+++ b/src/game-server/character.hpp
@@ -239,10 +239,10 @@ class Character : public Being
void setMapId(int);
/**
- * Over loads Being::getAttribute, character skills are
+ * Over loads Being::getAttribute, character skills are
* treated as extend attributes
*/
- int getAttribute(int) const;
+ int getAttribute(int) const;
/**
* Over loads Being::getModifiedAttribute
@@ -277,7 +277,7 @@ class Character : public Being
const std::map<int, int>::const_iterator getSkillBegin() const
{ return mExperience.begin(); }
-
+
const std::map<int, int>::const_iterator getSkillEnd() const
{ return mExperience.end(); }
@@ -377,6 +377,11 @@ class Character : public Being
*/
void recalculateLevel();
+ /**
+ * Informs the client about his characters special charge status
+ */
+ void sendSpecialUpdate();
+
enum TransactionType
{ TRANS_NONE, TRANS_TRADE, TRANS_BUYSELL };
@@ -393,6 +398,8 @@ class Character : public Being
std::map<int, int> mExperience; /**< experience collected for each skill.*/
std::map<int, Special*> mSpecials;
+ int mRechargePerSpecial;
+ bool mSpecialUpdateNeeded;
int mDatabaseID; /**< Character's database ID. */
unsigned char mGender; /**< Gender of the character. */