From 96d877fa2b9bbec546b83cbbc6d16664116e1fb9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 8 Oct 2011 02:04:33 +0300 Subject: Add checks and fix code style. --- src/net/tmwa/charserverhandler.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/net/tmwa/charserverhandler.cpp') diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 7aa68e617..03b63aa16 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -157,7 +157,7 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) break; default: - break; + break; } } @@ -165,8 +165,11 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, Net::Character *character, bool withColors) { + if (!character) + return; + const Token &token = - static_cast(Net::getLoginHandler())->getToken(); + static_cast(Net::getLoginHandler())->getToken(); LocalPlayer *tempPlayer = new LocalPlayer(msg.readInt32(), 0); tempPlayer->setGender(token.sex); @@ -264,6 +267,9 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, void CharServerHandler::chooseCharacter(Net::Character *character) { + if (!character) + return; + mSelectedCharacter = character; mCharSelectDialog = 0; @@ -338,10 +344,8 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg) msg.skip(2); // Length word int slots = msg.readInt16(); if (slots > 0 && slots < 30) - { - loginData.characterSlots - = static_cast(slots); - } + loginData.characterSlots = static_cast(slots); + bool version = msg.readInt8() == 1 && serverVersion > 0; msg.skip(17); // Unused -- cgit v1.2.3-70-g09d2