summaryrefslogtreecommitdiff
path: root/src/account-server
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-07-01 17:00:26 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-07-01 17:00:26 +0000
commitd44476beb6736faafe6480cfbe527aef7e88427a (patch)
tree1a92c517d9bdd064aa6999bb5841ab8e4952913b /src/account-server
parentd7e84be1d3dc935f47cefc0f600ced74f37e46fb (diff)
downloadmanaserv-d44476beb6736faafe6480cfbe527aef7e88427a.tar.gz
manaserv-d44476beb6736faafe6480cfbe527aef7e88427a.tar.bz2
manaserv-d44476beb6736faafe6480cfbe527aef7e88427a.tar.xz
manaserv-d44476beb6736faafe6480cfbe527aef7e88427a.zip
Reverted inventory handling code to the last known working state. Simplified serialization interface along the way.
Diffstat (limited to 'src/account-server')
-rw-r--r--src/account-server/characterdata.cpp19
-rw-r--r--src/account-server/characterdata.hpp40
-rw-r--r--src/account-server/dalstorage.cpp2
-rw-r--r--src/account-server/serverhandler.cpp3
4 files changed, 23 insertions, 41 deletions
diff --git a/src/account-server/characterdata.cpp b/src/account-server/characterdata.cpp
index 95b5e75a..5dab4c08 100644
--- a/src/account-server/characterdata.cpp
+++ b/src/account-server/characterdata.cpp
@@ -21,8 +21,8 @@
*/
#include "account-server/characterdata.hpp"
-
#include "net/messagein.hpp"
+#include "serialize/characterdata.hpp"
CharacterData::CharacterData(std::string const &name, int id):
mDatabaseID(id), mAccountID(-1), mName(name), mGender(0), mHairStyle(0),
@@ -42,21 +42,6 @@ CharacterData::CharacterData(MessageIn & msg):
{
mBaseAttributes[i] = 0;
}
- deserialize(msg);
-}
-
-InventoryItem const &
-CharacterData::getInventoryItem(unsigned short slot) const
-{
- return mInventory[slot];
+ deserializeCharacterData(*this, msg);
}
-void
-CharacterData::addItemToInventory(const InventoryItem& item)
-{
- // Discard items if the inventory is full
- if ((int)mInventory.size() < INVENTORY_SLOTS)
- {
- mInventory.push_back(item);
- }
-}
diff --git a/src/account-server/characterdata.hpp b/src/account-server/characterdata.hpp
index 8d7e2599..76b43da0 100644
--- a/src/account-server/characterdata.hpp
+++ b/src/account-server/characterdata.hpp
@@ -23,18 +23,17 @@
#ifndef _TMWSERV_CHARACTERDATA
#define _TMWSERV_CHARACTERDATA
-#include "abstractcharacterdata.hpp"
-#include "defines.h"
#include <string>
#include <vector>
-#include "utils/countedptr.h"
-
+#include "defines.h"
#include "point.h"
+#include "common/inventorydata.hpp"
+#include "utils/countedptr.h"
class MessageIn;
-class CharacterData: public AbstractCharacterData
+class CharacterData
{
public:
@@ -139,22 +138,6 @@ class CharacterData: public AbstractCharacterData
void
setPosition(const Point &p) { mPos = p; }
- /** Returns the number of inventory items. */
- int
- getNumberOfInventoryItems() const { return mInventory.size(); }
-
- /** Returns a reference to the item in inventory at slot. */
- InventoryItem const &
- getInventoryItem(unsigned short slot) const;
-
- /** Clears the inventory, in preperation for an update. */
- void
- clearInventory() { mInventory.clear(); }
-
- /** Adds an inventory item to the inventory. */
- void
- addItemToInventory(const InventoryItem& item);
-
/** Add a guild to the character */
void addGuild(const std::string &name) { mGuilds.push_back(name); }
@@ -162,6 +145,18 @@ class CharacterData: public AbstractCharacterData
std::vector<std::string>
getGuilds() const { return mGuilds; }
+ /**
+ * Gets a reference on the possessions.
+ */
+ Possessions const &getPossessions() const
+ { return mPossessions; }
+
+ /**
+ * Gets a reference on the possessions.
+ */
+ Possessions &getPossessions()
+ { return mPossessions; }
+
private:
CharacterData(CharacterData const &);
CharacterData &operator=(CharacterData const &);
@@ -180,8 +175,7 @@ class CharacterData: public AbstractCharacterData
//!< character.
unsigned short mMapId; //!< Map the being is on.
Point mPos; //!< Position the being is at.
- std::vector< InventoryItem > mInventory; //!< All the possesions of
- //!< the character.
+ Possessions mPossessions; //!< All the possesions of the character.
std::vector<std::string> mGuilds; //!< All the guilds the player
//!< belongs to.
};
diff --git a/src/account-server/dalstorage.cpp b/src/account-server/dalstorage.cpp
index fd6c8419..ff5684dc 100644
--- a/src/account-server/dalstorage.cpp
+++ b/src/account-server/dalstorage.cpp
@@ -681,6 +681,7 @@ DALStorage::updateCharacter(CharacterPtr character)
* Character's inventory
*/
+ /*
// Delete the old inventory first
try
{
@@ -735,6 +736,7 @@ DALStorage::updateCharacter(CharacterPtr character)
return false;
}
}
+ */
return true;
}
diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp
index 47c23966..3adb7173 100644
--- a/src/account-server/serverhandler.cpp
+++ b/src/account-server/serverhandler.cpp
@@ -34,6 +34,7 @@
#include "net/messagein.hpp"
#include "net/messageout.hpp"
#include "net/netcomputer.hpp"
+#include "serialize/characterdata.hpp"
#include "utils/logger.h"
#include "utils/tokendispenser.hpp"
#include "utils/tokencollector.hpp"
@@ -83,7 +84,7 @@ void ServerHandler::registerGameClient(std::string const &token, CharacterPtr pt
MessageOut msg(AGMSG_PLAYER_ENTER);
msg.writeString(token, MAGIC_TOKEN_LENGTH);
- ptr->serialize(msg); //Characterdata
+ serializeCharacterData(*ptr, msg);
Servers::const_iterator i = servers.find(mapId);
assert(i != servers.end());