summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-14 19:19:35 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-14 19:19:35 +0000
commitd33140baf3e05bd6c814eb57cffdb62505f7861e (patch)
tree2b35fca2f6d5c68741af7a366bfa8a0df648d279 /src
parentc79bf8c82f0a38b574b83be2484eb347852cd833 (diff)
downloadmana-client-d33140baf3e05bd6c814eb57cffdb62505f7861e.tar.gz
mana-client-d33140baf3e05bd6c814eb57cffdb62505f7861e.tar.bz2
mana-client-d33140baf3e05bd6c814eb57cffdb62505f7861e.tar.xz
mana-client-d33140baf3e05bd6c814eb57cffdb62505f7861e.zip
Fix warning about jump to case label crossing an initialization.
Diffstat (limited to 'src')
-rw-r--r--src/gui/vbox.cpp2
-rw-r--r--src/net/charserverhandler.cpp113
-rw-r--r--src/net/charserverhandler.h15
3 files changed, 74 insertions, 56 deletions
diff --git a/src/gui/vbox.cpp b/src/gui/vbox.cpp
index eb838ead..b503508e 100644
--- a/src/gui/vbox.cpp
+++ b/src/gui/vbox.cpp
@@ -25,7 +25,7 @@
void VBox::draw(gcn::Graphics *graphics)
{
- if (mWidgets.size() == 0)
+ if (mWidgets.empty())
{
return;
}
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
diff --git a/src/net/charserverhandler.h b/src/net/charserverhandler.h
index 16d2c361..ec5df3f8 100644
--- a/src/net/charserverhandler.h
+++ b/src/net/charserverhandler.h
@@ -36,13 +36,22 @@ class CharServerHandler : public MessageHandler
public:
CharServerHandler();
- void handleMessage(MessageIn *msg);
+ void
+ handleMessage(MessageIn *msg);
- void setCharInfo(LockedArray<LocalPlayer*> *charInfo) { mCharInfo = charInfo; };
+ void
+ setCharInfo(LockedArray<LocalPlayer*> *charInfo)
+ {
+ mCharInfo = charInfo;
+ }
- void setLoginData(LoginData *loginData) { mLoginData = loginData; };
+ void
+ setLoginData(LoginData *loginData) { mLoginData = loginData; };
protected:
+ void
+ handleCharCreateResponse(MessageIn &msg);
+
LoginData *mLoginData;
LockedArray<LocalPlayer*> *mCharInfo;