diff options
author | David Athay <ko2fan@gmail.com> | 2008-10-21 13:11:10 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2008-10-21 13:11:10 +0000 |
commit | faab9e8fd3c312c7651398ce68e2e4e4fa36ac78 (patch) | |
tree | a368a38e6d0dac75b1164396433def1a9405e501 /src/account-server | |
parent | 104be5479d7c1192a73711b932e87c571e434985 (diff) | |
download | manaserv-faab9e8fd3c312c7651398ce68e2e4e4fa36ac78.tar.gz manaserv-faab9e8fd3c312c7651398ce68e2e4e4fa36ac78.tar.bz2 manaserv-faab9e8fd3c312c7651398ce68e2e4e4fa36ac78.tar.xz manaserv-faab9e8fd3c312c7651398ce68e2e4e4fa36ac78.zip |
Game Server now reconnects to Account Server. Some postal system bugs fixed.
Diffstat (limited to 'src/account-server')
-rw-r--r-- | src/account-server/dalstorage.cpp | 6 | ||||
-rw-r--r-- | src/account-server/dalstorage.hpp | 33 | ||||
-rw-r--r-- | src/account-server/dalstoragesql.hpp | 5 | ||||
-rw-r--r-- | src/account-server/serverhandler.cpp | 18 |
4 files changed, 42 insertions, 20 deletions
diff --git a/src/account-server/dalstorage.cpp b/src/account-server/dalstorage.cpp index 2484657d..90f157b0 100644 --- a/src/account-server/dalstorage.cpp +++ b/src/account-server/dalstorage.cpp @@ -30,6 +30,7 @@ #include "account-server/dalstoragesql.hpp" #include "chat-server/chatchannel.hpp" #include "chat-server/guild.hpp" +#include "chat-server/post.hpp" #include "common/configuration.hpp" #include "dal/dalexcept.h" #include "dal/dataproviderfactory.h" @@ -1037,11 +1038,6 @@ std::string DALStorage::getQuestVar(int id, std::string const &name) return std::string(); } -std::string DALStorage::getWorldStateVar(std::string const &name) -{ - return getWorldStateVar(name, -1); -} - std::string DALStorage::getWorldStateVar(std::string const &name, int map_id) { try diff --git a/src/account-server/dalstorage.hpp b/src/account-server/dalstorage.hpp index 970f550b..f67ed264 100644 --- a/src/account-server/dalstorage.hpp +++ b/src/account-server/dalstorage.hpp @@ -33,6 +33,7 @@ class Account; class Character; class ChatChannel; class Guild; +class Letter; /** * A storage class that relies on DAL. @@ -254,19 +255,12 @@ class DALStorage void setQuestVar(int id, std::string const &, std::string const &); /** - * Gets the string value of a world state variable. - * - * @param name Name of the requested world-state variable. - */ - std::string getWorldStateVar(std::string const &name); - - /** * Gets the string value of a map specific world state variable. * * @param name Name of the requested world-state variable. * @param map_id Id of the specific map. */ - std::string getWorldStateVar(std::string const &name, int map_id); + std::string getWorldStateVar(std::string const &name, int map_id = -1); /** * Sets the value of a world state variable. @@ -286,6 +280,29 @@ class DALStorage void setWorldStateVar(std::string const &name, int map_id, std::string const &value); + /** + * Store post + * + * @param letter The letter to store + */ + void storePost(Letter *letter); + + /** + * Retrieve post + * + * @param playerId The id of the player requesting his post + */ + Letter* getStoredPost(int playerId); + + /** + * Add item to auction + * + * @param itemId The id of the item for auction + * @param player The player who put the item up for auction + * @param gold The amount of money to buy it + */ + void addAuctionItem(unsigned int itemId, int playerId, unsigned int gold); + private: /** * Copy constructor. diff --git a/src/account-server/dalstoragesql.hpp b/src/account-server/dalstoragesql.hpp index 95c89c03..b08c895b 100644 --- a/src/account-server/dalstoragesql.hpp +++ b/src/account-server/dalstoragesql.hpp @@ -105,5 +105,8 @@ static char const *QUESTS_TBL_NAME = "tmw_quests"; */ static char const *WORLD_STATES_TBL_NAME = "tmw_world_states"; - +/** + * TABLE: tmw_auctions + */ +static char const *AUCTION_TBL_NAME = "tmw_auctions"; #endif // _TMWSERV_DALSTORAGE_SQL_H_ diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp index db8d2640..5ed771a8 100644 --- a/src/account-server/serverhandler.cpp +++ b/src/account-server/serverhandler.cpp @@ -331,8 +331,13 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) LOG_DEBUG("GCMSG_REQUEST_POST"); result.writeShort(CGMSG_POST_RESPONSE); - // get the character + // get the character id int characterId = msg.readLong(); + + // send the character id of sender + result.writeLong(characterId); + + // get the character based on the id Character *ptr = storage->getCharacter(characterId, NULL); if (!ptr) { @@ -344,18 +349,15 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) // get the post for that character Post *post = postalManager->getPost(ptr); - // send the character id of receiver - result.writeLong(characterId); - // send the post if valid if (post) { for (unsigned int i = 0; i < post->getNumberOfLetters(); ++i) { - // get each letter, send the sender's id, + // get each letter, send the sender's name, // the contents and any attachments Letter *letter = post->getLetter(i); - result.writeLong(letter->getSender()->getDatabaseID()); + result.writeString(letter->getSender()->getName()); result.writeString(letter->getContents()); std::vector<InventoryItem> items = letter->getAttachments(); for (unsigned int j = 0; j < items.size(); ++j) @@ -381,6 +383,9 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) int senderId = msg.readLong(); std::string receiverName = msg.readString(); + // for sending it back + result.writeLong(senderId); + // get their characters Character *sender = storage->getCharacter(senderId, NULL); Character *receiver = storage->getCharacter(receiverName); @@ -402,6 +407,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) } // save the letter + LOG_INFO("Creating letter"); Letter *letter = new Letter(0, sender, receiver); letter->addText(contents); for (unsigned int i = 0; i < items.size(); ++i) |