diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-14 19:19:35 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-14 19:19:35 +0000 |
commit | d33140baf3e05bd6c814eb57cffdb62505f7861e (patch) | |
tree | 2b35fca2f6d5c68741af7a366bfa8a0df648d279 /src/net/charserverhandler.cpp | |
parent | c79bf8c82f0a38b574b83be2484eb347852cd833 (diff) | |
download | mana-d33140baf3e05bd6c814eb57cffdb62505f7861e.tar.gz mana-d33140baf3e05bd6c814eb57cffdb62505f7861e.tar.bz2 mana-d33140baf3e05bd6c814eb57cffdb62505f7861e.tar.xz mana-d33140baf3e05bd6c814eb57cffdb62505f7861e.zip |
Fix warning about jump to case label crossing an initialization.
Diffstat (limited to 'src/net/charserverhandler.cpp')
-rw-r--r-- | src/net/charserverhandler.cpp | 113 |
1 files changed, 61 insertions, 52 deletions
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index e41ca0f3..b4715315 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -46,7 +46,8 @@ CharServerHandler::CharServerHandler() handledMessages = _messages; } -void CharServerHandler::handleMessage(MessageIn *msg) +void +CharServerHandler::handleMessage(MessageIn *msg) { int slot; LocalPlayer *tempPlayer; @@ -54,56 +55,7 @@ void CharServerHandler::handleMessage(MessageIn *msg) switch (msg->getId()) { case APMSG_CHAR_CREATE_RESPONSE: - int errMsg = msg->readByte(); - // Character creation successful - if (errMsg == ERRMSG_OK) - { - } - // Character creation failed - else - { - std::string message = ""; - switch (errMsg) - { - case ERRMSG_NO_LOGIN: - message = "Not logged in"; - break; - case CREATE_TOO_MUCH_CHARACTERS: - message = "No empty slot"; - break; - case ERRMSG_INVALID_ARGUMENT: - message = "Invalid name"; - break; - case CREATE_EXISTS_NAME: - message = "Character's name already exists"; - break; - case CREATE_INVALID_HAIRSTYLE: - message = "Invalid hairstyle"; - break; - case CREATE_INVALID_HAIRCOLOR: - message = "Invalid hair color"; - break; - case CREATE_INVALID_GENDER: - message = "Invalid gender"; - break; - case CREATE_RAW_STATS_TOO_HIGH: - message = "Character's stats are too high"; - break; - case CREATE_RAW_STATS_TOO_LOW: - message = "Character's stats are too low"; - break; - case CREATE_RAW_STATS_INVALID_DIFF: - message = "Character's stats difference is too high"; - break; - case CREATE_RAW_STATS_EQUAL_TO_ZERO: - message = "One stat is zero"; - break; - default: - message = "Unknown error"; - break; - } - new OkDialog("Error", message); - } + handleCharCreateResponse(*msg); break; case APMSG_CHAR_DELETE_RESPONSE: { @@ -147,7 +99,64 @@ void CharServerHandler::handleMessage(MessageIn *msg) } } -LocalPlayer* CharServerHandler::readPlayerData(MessageIn *msg, int &slot) +void +CharServerHandler::handleCharCreateResponse(MessageIn &msg) +{ + int errMsg = msg.readByte(); + + // Character creation successful + if (errMsg == ERRMSG_OK) + { + } + // Character creation failed + else + { + std::string message = ""; + switch (errMsg) + { + case ERRMSG_NO_LOGIN: + message = "Not logged in"; + break; + case CREATE_TOO_MUCH_CHARACTERS: + message = "No empty slot"; + break; + case ERRMSG_INVALID_ARGUMENT: + message = "Invalid name"; + break; + case CREATE_EXISTS_NAME: + message = "Character's name already exists"; + break; + case CREATE_INVALID_HAIRSTYLE: + message = "Invalid hairstyle"; + break; + case CREATE_INVALID_HAIRCOLOR: + message = "Invalid hair color"; + break; + case CREATE_INVALID_GENDER: + message = "Invalid gender"; + break; + case CREATE_RAW_STATS_TOO_HIGH: + message = "Character's stats are too high"; + break; + case CREATE_RAW_STATS_TOO_LOW: + message = "Character's stats are too low"; + break; + case CREATE_RAW_STATS_INVALID_DIFF: + message = "Character's stats difference is too high"; + break; + case CREATE_RAW_STATS_EQUAL_TO_ZERO: + message = "One stat is zero"; + break; + default: + message = "Unknown error"; + break; + } + new OkDialog("Error", message); + } +} + +LocalPlayer* +CharServerHandler::readPlayerData(MessageIn *msg, int &slot) { LocalPlayer *tempPlayer = new LocalPlayer(mLoginData->account_ID, 0, NULL); slot = msg->readByte(); // character slot |