summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/charserverhandler.cpp24
-rw-r--r--src/net/charserverhandler.h13
-rw-r--r--src/net/equipmenthandler.cpp5
-rw-r--r--src/net/loginhandler.cpp2
-rw-r--r--src/net/protocol.h1
5 files changed, 42 insertions, 3 deletions
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp
index 34fc188d..820aaea4 100644
--- a/src/net/charserverhandler.cpp
+++ b/src/net/charserverhandler.cpp
@@ -34,11 +34,13 @@
#include "../main.h"
#include "../gui/ok_dialog.h"
+#include "../gui/char_select.h"
extern Net::Connection *gameServerConnection;
extern Net::Connection *chatServerConnection;
-CharServerHandler::CharServerHandler()
+CharServerHandler::CharServerHandler():
+ mCharCreateDialog(0)
{
static const Uint16 _messages[] = {
APMSG_CHAR_CREATE_RESPONSE,
@@ -99,6 +101,13 @@ CharServerHandler::handleMessage(MessageIn &msg)
mCharInfo->unlock();
mCharInfo->select(slot);
mCharInfo->setEntry(tempPlayer);
+
+ // Close the character create dialog
+ if (mCharCreateDialog)
+ {
+ mCharCreateDialog->scheduleDelete();
+ mCharCreateDialog = 0;
+ }
break;
case APMSG_CHAR_SELECT_RESPONSE:
@@ -154,6 +163,9 @@ CharServerHandler::handleCharCreateResponse(MessageIn &msg)
}
new OkDialog("Error", message);
}
+
+ if (mCharCreateDialog)
+ mCharCreateDialog->unlock();
}
void
@@ -177,15 +189,20 @@ CharServerHandler::handleCharSelectResponse(MessageIn &msg)
// Keep the selected character and delete the others
player_node = mCharInfo->getEntry();
+ int slot = mCharInfo->getPos();
mCharInfo->unlock();
mCharInfo->select(0);
do {
LocalPlayer *tmp = mCharInfo->getEntry();
if (tmp != player_node)
+ {
delete tmp;
+ mCharInfo->setEntry(0);
+ }
mCharInfo->next();
} while (mCharInfo->getPos());
+ mCharInfo->select(slot);
mCharInfo->clear(); //player_node will be deleted by ~Game
@@ -204,8 +221,11 @@ CharServerHandler::readPlayerData(MessageIn &msg, int &slot)
tempPlayer->setHairColor(msg.readByte());
tempPlayer->setLevel(msg.readByte());
tempPlayer->setMoney(msg.readLong());
- for (int i = 0; i < 7; i++) {
+
+ for (int i = 0; i < 7; i++)
+ {
tempPlayer->setAttributeBase(i, msg.readByte());
}
+
return tempPlayer;
}
diff --git a/src/net/charserverhandler.h b/src/net/charserverhandler.h
index 342641d7..4a4fe0c3 100644
--- a/src/net/charserverhandler.h
+++ b/src/net/charserverhandler.h
@@ -28,9 +28,13 @@
#include "../lockedarray.h"
+class CharCreateDialog;
class LocalPlayer;
class LoginData;
+/**
+ * Deals with incoming messages related to character selection.
+ */
class CharServerHandler : public MessageHandler
{
public:
@@ -45,6 +49,14 @@ class CharServerHandler : public MessageHandler
mCharInfo = charInfo;
}
+ /**
+ * Sets the character create dialog. The handler will clean up this
+ * dialog when a new character is succesfully created, and will unlock
+ * the dialog when a new character failed to be created.
+ */
+ void setCharCreateDialog(CharCreateDialog *window)
+ { mCharCreateDialog = window; }
+
protected:
void
handleCharCreateResponse(MessageIn &msg);
@@ -53,6 +65,7 @@ class CharServerHandler : public MessageHandler
handleCharSelectResponse(MessageIn &msg);
LockedArray<LocalPlayer*> *mCharInfo;
+ CharCreateDialog *mCharCreateDialog;
LocalPlayer*
readPlayerData(MessageIn &msg, int &slot);
diff --git a/src/net/equipmenthandler.cpp b/src/net/equipmenthandler.cpp
index 1c0fd4ca..c0072a45 100644
--- a/src/net/equipmenthandler.cpp
+++ b/src/net/equipmenthandler.cpp
@@ -43,6 +43,7 @@ EquipmentHandler::EquipmentHandler()
0x01d7,
SMSG_PLAYER_UNEQUIP,
SMSG_PLAYER_ARROW_EQUIP,
+ SMSG_PLAYER_ATTACK_RANGE,
0
};
handledMessages = _messages;
@@ -191,6 +192,10 @@ void EquipmentHandler::handleMessage(MessageIn &msg)
index, equipPoint, type, position);
break;
+ case SMSG_PLAYER_ATTACK_RANGE:
+ player_node->setAttackRange(msg.readShort());
+ break;
+
case SMSG_PLAYER_ARROW_EQUIP:
itemId = msg.readShort();
diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp
index c68a620a..90f2dbd5 100644
--- a/src/net/loginhandler.cpp
+++ b/src/net/loginhandler.cpp
@@ -88,7 +88,7 @@ void LoginHandler::handleMessage(MessageIn &msg)
{
switch (errMsg) {
case REGISTER_INVALID_VERSION:
- errorMessage = "Client has an insufficient version number to login.";
+ errorMessage = "Client has an insufficient version number to login.";
break;
case ERRMSG_INVALID_ARGUMENT:
errorMessage = "Wrong username, password or email address";
diff --git a/src/net/protocol.h b/src/net/protocol.h
index a9ee0e5b..b5dc2996 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -44,6 +44,7 @@
#define SMSG_PLAYER_EQUIPMENT 0x00a4
#define SMSG_PLAYER_EQUIP 0x00aa
#define SMSG_PLAYER_UNEQUIP 0x00ac
+#define SMSG_PLAYER_ATTACK_RANGE 0x013a
#define SMSG_PLAYER_ARROW_EQUIP 0x013c
#define SMSG_PLAYER_ARROW_MESSAGE 0x013b
#define SMSG_PLAYER_SKILLS 0x010f