diff options
Diffstat (limited to 'src/game-server')
-rw-r--r-- | src/game-server/accountconnection.cpp | 11 | ||||
-rw-r--r-- | src/game-server/main-game.cpp | 20 |
2 files changed, 25 insertions, 6 deletions
diff --git a/src/game-server/accountconnection.cpp b/src/game-server/accountconnection.cpp index 80e65730..c5da8e2a 100644 --- a/src/game-server/accountconnection.cpp +++ b/src/game-server/accountconnection.cpp @@ -131,7 +131,7 @@ void AccountConnection::processMessage(MessageIn &msg) while (msg.getUnreadLength()) { // write the sender - out.writeLong(msg.readLong()); + out.writeString(msg.readString()); // write the contents out.writeString(msg.readString()); @@ -155,6 +155,12 @@ void AccountConnection::processMessage(MessageIn &msg) // get character Character *character = postMan->getCharacter(msg.readLong()); + // check character is valid + if (!character) + { + break; + } + // create message and put error inside MessageOut out(GPMSG_SEND_POST_RESPONSE); out.writeByte(msg.readByte()); @@ -251,6 +257,7 @@ void AccountConnection::sendPost(Character *c, MessageIn &msg) { // send message to account server with id of sending player, // the id of receiving player, the letter contents, and attachments + LOG_DEBUG("Sending GCMSG_STORE_POST."); MessageOut out(GCMSG_STORE_POST); out.writeLong(c->getDatabaseID()); out.writeString(msg.readString()); @@ -261,11 +268,13 @@ void AccountConnection::sendPost(Character *c, MessageIn &msg) out.writeLong(msg.readShort()); out.writeLong(msg.readShort()); } + send(out); } void AccountConnection::getPost(Character *c) { // send message to account server with id of retrieving player + LOG_DEBUG("Sending GCMSG_REQUEST_POST"); MessageOut out(GCMSG_REQUEST_POST); out.writeLong(c->getDatabaseID()); send(out); diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp index b1c454e4..898bcb8d 100644 --- a/src/game-server/main-game.cpp +++ b/src/game-server/main-game.cpp @@ -276,8 +276,7 @@ int main(int argc, char *argv[]) initialize(); if (!accountHandler->start()) { - LOG_FATAL("Unable to create a connection to an account server."); - return 3; + LOG_INFO("Unable to create a connection to an account server."); } int gameServerPort = @@ -308,11 +307,22 @@ int main(int argc, char *argv[]) // Print world time at 10 second intervals to show we're alive if (worldTime % 100 == 0) { LOG_INFO("World time: " << worldTime); - accountHandler->sendStatistics(); } - // Handle all messages that are in the message queues - accountHandler->process(); + if (accountHandler->isConnected()) + { + // Handle all messages that are in the message queues + accountHandler->process(); + + if (worldTime % 100 == 0) + { + accountHandler->sendStatistics(); + } + } + else + { + accountHandler->start(); + } gameHandler->process(); // Update all active objects/beings GameState::update(); |