summaryrefslogtreecommitdiff
path: root/src/net/tmwa/charserverhandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-10-08 02:04:33 +0300
committerAndrei Karas <akaras@inbox.ru>2011-10-08 02:04:33 +0300
commit96d877fa2b9bbec546b83cbbc6d16664116e1fb9 (patch)
tree5b75c3f10217c8515a8e2809892f7526e6efd66f /src/net/tmwa/charserverhandler.cpp
parent29187a2582c04e3ede63f9c58f09dbbe34834a30 (diff)
downloadmanaverse-96d877fa2b9bbec546b83cbbc6d16664116e1fb9.tar.gz
manaverse-96d877fa2b9bbec546b83cbbc6d16664116e1fb9.tar.bz2
manaverse-96d877fa2b9bbec546b83cbbc6d16664116e1fb9.tar.xz
manaverse-96d877fa2b9bbec546b83cbbc6d16664116e1fb9.zip
Add checks and fix code style.
Diffstat (limited to 'src/net/tmwa/charserverhandler.cpp')
-rw-r--r--src/net/tmwa/charserverhandler.cpp16
1 files changed, 10 insertions, 6 deletions
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<LoginHandler*>(Net::getLoginHandler())->getToken();
+ static_cast<LoginHandler*>(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<short unsigned int>(slots);
- }
+ loginData.characterSlots = static_cast<short unsigned int>(slots);
+
bool version = msg.readInt8() == 1 && serverVersion > 0;
msg.skip(17); // Unused