From c013d7ba8cb97262d318fe30e1ef4da1aea19b82 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sun, 27 Mar 2011 19:44:53 +0200 Subject: Some cleanups related to syncing from game to account server * Remove SYNC_END_OF_BUFFER since the end of a message can already be identified by no more data being available. * Consistently prefix ++ rather than postfix ++ when incrementing mSyncMessages. * Made SYNC_BUFFER_SIZE into constants rather than defines, and moved them into the .cpp file since they're not used anywhere else. * Just use 1 and 0 to indicate online status. No point in writing it like 0x01 and 0x00. * Merged some duplicated documentation for AccountConnection::syncChanges. Reviewed-by: Jared Adams --- src/account-server/serverhandler.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/account-server/serverhandler.cpp') diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp index f228e043..1d2f9e0d 100644 --- a/src/account-server/serverhandler.cpp +++ b/src/account-server/serverhandler.cpp @@ -603,9 +603,9 @@ void GameServerHandler::syncDatabase(MessageIn &msg) // It is safe to perform the following updates in a transaction dal::PerformTransaction transaction(storage->database()); - int msgType = msg.readInt8(); - while (msgType != SYNC_END_OF_BUFFER && msg.getUnreadLength() > 0) + while (msg.getUnreadLength() > 0) { + int msgType = msg.readInt8(); switch (msgType) { case SYNC_CHARACTER_POINTS: @@ -640,14 +640,10 @@ void GameServerHandler::syncDatabase(MessageIn &msg) { LOG_DEBUG("received SYNC_ONLINE_STATUS"); int charId = msg.readInt32(); - bool online; - msg.readInt8() == 0x00 ? online = false : online = true; + bool online = (msg.readInt8() == 1); storage->setOnlineStatus(charId, online); } } - - // read next message type from buffer - msgType = msg.readInt8(); } transaction.commit(); -- cgit v1.2.3-60-g2f50