diff options
author | Andreas Habel <mail@exceptionfault.de> | 2008-11-30 12:08:57 +0100 |
---|---|---|
committer | Andreas Habel <mail@exceptionfault.de> | 2008-11-30 12:08:57 +0100 |
commit | 4abae69f1180ffe6a4dbd2db60dfa76b6ef41ebb (patch) | |
tree | 4b2e3eb8e5c35e65ec18996060a5daac9bff1938 /src/account-server/serverhandler.cpp | |
parent | 6d263b7550468306018934ad1dc9928b57b8f129 (diff) | |
download | manaserv-4abae69f1180ffe6a4dbd2db60dfa76b6ef41ebb.tar.gz manaserv-4abae69f1180ffe6a4dbd2db60dfa76b6ef41ebb.tar.bz2 manaserv-4abae69f1180ffe6a4dbd2db60dfa76b6ef41ebb.tar.xz manaserv-4abae69f1180ffe6a4dbd2db60dfa76b6ef41ebb.zip |
Add sync Buffer according to mantis #550
The game server buffers all changes made to a character in a sync buffer.
The buffer is sent to the account server if the buffer contains more then
20 message, reaches size of 1kb or at least every 10 seconds.
ATM Character attributes, corr points and attribute points and skills are
synchronized. TODO: items, location, money...
Diffstat (limited to 'src/account-server/serverhandler.cpp')
-rw-r--r-- | src/account-server/serverhandler.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp index bdbdb1f6..1c4a5219 100644 --- a/src/account-server/serverhandler.cpp +++ b/src/account-server/serverhandler.cpp @@ -31,7 +31,6 @@ #include "account-server/dalstorage.hpp" #include "chat-server/post.hpp" #include "net/connectionhandler.hpp" -#include "net/messagein.hpp" #include "net/messageout.hpp" #include "net/netcomputer.hpp" #include "serialize/characterdata.hpp" @@ -241,6 +240,12 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg) } } break; + case GAMSG_PLAYER_SYNC: + { + LOG_DEBUG("GAMSG_PLAYER_SYNC"); + GameServerHandler::syncDatabase(msg); + } break; + case GAMSG_REDIRECT: { LOG_DEBUG("GAMSG_REDIRECT"); @@ -511,3 +516,37 @@ void GameServerHandler::sendPartyChange(Character *ptr, int partyId) s->send(msg); } } + +void GameServerHandler::syncDatabase(MessageIn &msg) +{ + int msgType = msg.readByte(); + while( msgType != SYNC_END_OF_BUFFER ) + { + switch (msgType) + { + case SYNC_CHARACTER_POINTS: + { + LOG_DEBUG("received SYNC_CHARACTER_POINTS"); + int CharId = msg.readLong(); + int CharPoints = msg.readLong(); + int CorrPoints = msg.readLong(); + int AttribId = msg.readByte(); + int AttribValue = msg.readLong(); + storage->updateCharacterPoints(CharId, CharPoints, CorrPoints, + AttribId, AttribValue); + } break; + + case SYNC_CHARACTER_SKILL: + { + LOG_DEBUG("received SYNC_CHARACTER_SKILL"); + int CharId = msg.readLong(); + int SkillId = msg.readByte(); + int SkillValue = msg.readLong(); + storage->updateExperience(CharId, SkillId, SkillValue); + } break; + } + + // read next message type from buffer + msgType = msg.readByte(); + } +} |