summaryrefslogtreecommitdiffstats
path: root/src/account-server
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2012-04-03 13:29:05 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2012-04-04 16:22:11 +0200
commitf8e816d9185c09d1c17d921b775e483d132982e5 (patch)
tree3ab299ab6057db3bfd8feb24130a6fcb7e64a60d /src/account-server
parente4baa92aae537921dd17873328a95ab17afcfdfc (diff)
downloadmanaserv-f8e816d9185c09d1c17d921b775e483d132982e5.tar.gz
manaserv-f8e816d9185c09d1c17d921b775e483d132982e5.tar.xz
manaserv-f8e816d9185c09d1c17d921b775e483d132982e5.zip
Enhanced special support
- Made the current charge being saved. - Added script binds: - chr_set_special_recharge_speed - chr_get_special_recharge_speed - chr_set_special_mana - chr_get_special_mana - get_special_info - Added special info lua class. Functions: - name - needed_mana - rechargeable - on_use - on_recharged - category Further the engine no longer sets charge to 0 after using of specials this allows more flexbilillity (like failing specials). Changes on the xml database: - recharge renamed to rechargeable (needed by client and server) - needed - the needed mana to trigger a special (server only) - rechargespeed - the defailt recharge speed in mana per tick (server only) - target - the type of target (either being or point) (server and client) I also made the lua engine pushing nil instead of a 0 light userdata when the pointer was 0. Database update needed. Change is tested. Mana-Mantis: #167, #156 Reviewed-by: bjorn.
Diffstat (limited to 'src/account-server')
-rw-r--r--src/account-server/character.cpp8
-rw-r--r--src/account-server/character.h31
-rw-r--r--src/account-server/storage.cpp23
3 files changed, 47 insertions, 15 deletions
diff --git a/src/account-server/character.cpp b/src/account-server/character.cpp
index 535ee67..3219e3c 100644
--- a/src/account-server/character.cpp
+++ b/src/account-server/character.cpp
@@ -45,3 +45,11 @@ void Character::setAccount(Account *acc)
mAccountID = acc->getID();
mAccountLevel = acc->getLevel();
}
+
+void Character::giveSpecial(int id, int currentMana)
+{
+ if (mSpecials.find(id) == mSpecials.end())
+ {
+ mSpecials[id] = SpecialValue(currentMana);
+ }
+}
diff --git a/src/account-server/character.h b/src/account-server/character.h
index 74fe923..5e6bd3b 100644
--- a/src/account-server/character.h
+++ b/src/account-server/character.h
@@ -49,13 +49,28 @@ struct AttributeValue
double modified; /**< Value after various modifiers have been applied. */
};
+struct SpecialValue
+{
+ SpecialValue()
+ : currentMana(0)
+ {}
+
+ SpecialValue(unsigned int currentMana)
+ : currentMana(currentMana)
+ {}
+
+ unsigned int currentMana;
+};
+
/**
* Stores attributes by their id.
*/
-typedef std::map< unsigned int, AttributeValue > AttributeMap;
+typedef std::map<unsigned int, AttributeValue> AttributeMap;
-/** placeholder type needed for include compatibility with game server*/
-typedef void Special;
+/**
+ * Stores specials by their id.
+ */
+typedef std::map<unsigned int, SpecialValue> SpecialMap;
class Character
{
@@ -193,17 +208,17 @@ class Character
int getSpecialSize() const
{ return mSpecials.size(); }
- const std::map<int, Special*>::const_iterator getSpecialBegin() const
+ SpecialMap::const_iterator getSpecialBegin() const
{ return mSpecials.begin(); }
- const std::map<int, Special*>::const_iterator getSpecialEnd() const
+ SpecialMap::const_iterator getSpecialEnd() const
{ return mSpecials.end(); }
+
void clearSpecials()
{ mSpecials.clear(); }
- void giveSpecial(int id)
- { mSpecials[id] = NULL; }
+ void giveSpecial(int id, int currentMana);
/**
* Gets the Id of the map that the character is on.
@@ -270,7 +285,7 @@ class Character
std::map<int, int> mExperience; //!< Skill Experience.
std::map<int, int> mStatusEffects; //!< Status Effects
std::map<int, int> mKillCount; //!< Kill Count
- std::map<int, Special*> mSpecials;
+ SpecialMap mSpecials;
unsigned short mMapId; //!< Map the being is on.
unsigned char mGender; //!< Gender of the being.
unsigned char mHairStyle; //!< Hair style of the being.
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp
index 9a19a67..8876cd4 100644
--- a/src/account-server/storage.cpp
+++ b/src/account-server/storage.cpp
@@ -24,6 +24,7 @@
#include "account-server/storage.h"
#include "account-server/account.h"
+#include "account-server/character.h"
#include "account-server/flooritem.h"
#include "chat-server/chatchannel.h"
#include "chat-server/guild.h"
@@ -483,14 +484,18 @@ Character *Storage::getCharacterBySQL(Account *owner)
// Load the special status
s.clear();
s.str("");
- s << "select special_id FROM " << CHAR_SPECIALS_TBL_NAME
+ s << "SELECT special_id, special_current_mana FROM "
+ << CHAR_SPECIALS_TBL_NAME
<< " WHERE char_id = " << character->getDatabaseID();
const dal::RecordSet &specialsInfo = mDb->execSql(s.str());
if (!specialsInfo.isEmpty())
{
const unsigned int nRows = specialsInfo.rows();
for (unsigned int row = 0; row < nRows; row++)
- character->giveSpecial(toUint(specialsInfo(row, 0)));
+ {
+ character->giveSpecial(toUint(specialsInfo(row, 0)),
+ toUint(specialsInfo(row, 1)));
+ }
}
}
catch (const dal::DbSqlQueryExecFailure &e)
@@ -777,15 +782,19 @@ bool Storage::updateCharacter(Character *character)
<< character->getDatabaseID() << "';";
mDb->execSql(deleteSql.str());
// In with the new
- std::map<int, Special*>::const_iterator special_it;
- for (special_it = character->getSpecialBegin();
- special_it != character->getSpecialEnd(); special_it++)
+ SpecialMap::const_iterator special_it, special_it_end;
+ for (special_it = character->getSpecialBegin(),
+ special_it_end = character->getSpecialEnd();
+ special_it != special_it_end; ++special_it)
{
insertSql.str("");
insertSql << "INSERT INTO " << CHAR_SPECIALS_TBL_NAME
- << " (char_id, special_id) VALUES ("
+ << " (char_id, special_id, special_current_mana)"
+ << " VALUES ("
<< " '" << character->getDatabaseID() << "',"
- << " '" << special_it->first << "');";
+ << " '" << special_it->first << "',"
+ << " '" << special_it->second.currentMana
+ << "');";
mDb->execSql(insertSql.str());
}
}