summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-10-04 12:27:07 -0600
committerJared Adams <jaxad0127@gmail.com>2009-10-04 12:27:07 -0600
commitcff9f1947bac8fa49aaf6f846a6e4335a439ac2e (patch)
treea1b2272c9541bb1ee40323948970787459187ae6 /src/net
parent95b54aee1b20e6fd2bf8f99766d810e0ab2e5477 (diff)
downloadmana-cff9f1947bac8fa49aaf6f846a6e4335a439ac2e.tar.gz
mana-cff9f1947bac8fa49aaf6f846a6e4335a439ac2e.tar.bz2
mana-cff9f1947bac8fa49aaf6f846a6e4335a439ac2e.tar.xz
mana-cff9f1947bac8fa49aaf6f846a6e4335a439ac2e.zip
Add ability to delect characters from account
Diffstat (limited to 'src/net')
-rw-r--r--src/net/charhandler.h3
-rw-r--r--src/net/ea/charserverhandler.cpp19
-rw-r--r--src/net/ea/charserverhandler.h3
-rw-r--r--src/net/tmwserv/charhandler.cpp11
-rw-r--r--src/net/tmwserv/charhandler.h2
5 files changed, 30 insertions, 8 deletions
diff --git a/src/net/charhandler.h b/src/net/charhandler.h
index ac235df5..f3d7a6bc 100644
--- a/src/net/charhandler.h
+++ b/src/net/charhandler.h
@@ -30,6 +30,7 @@
#include <vector>
class CharCreateDialog;
+class CharSelectDialog;
class LocalPlayer;
namespace Net {
@@ -39,6 +40,8 @@ class CharHandler
public:
virtual void setCharInfo(LockedArray<LocalPlayer*> *charInfo) = 0;
+ virtual void setCharSelectDialog(CharSelectDialog *window) = 0;
+
virtual void setCharCreateDialog(CharCreateDialog *window) = 0;
virtual void getCharacters() = 0;
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
index 83f8f9fc..e538eeaf 100644
--- a/src/net/ea/charserverhandler.cpp
+++ b/src/net/ea/charserverhandler.cpp
@@ -49,6 +49,7 @@ extern ServerInfo charServer;
extern ServerInfo mapServer;
CharServerHandler::CharServerHandler():
+ mCharSelectDialog(0),
mCharCreateDialog(0)
{
static const Uint16 _messages[] = {
@@ -67,7 +68,7 @@ CharServerHandler::CharServerHandler():
void CharServerHandler::handleMessage(MessageIn &msg)
{
- int slot;
+ int count, slot;
LocalPlayer *tempPlayer;
logger->log("CharServerHandler: Packet ID: %x, Length: %d",
@@ -79,9 +80,9 @@ void CharServerHandler::handleMessage(MessageIn &msg)
msg.skip(20); // Unused
// Derive number of characters from message length
- n_character = (msg.getLength() - 24) / 106;
+ count = (msg.getLength() - 24) / 106;
- for (int i = 0; i < n_character; i++)
+ for (int i = 0; i < count; i++)
{
tempPlayer = readPlayerData(msg, slot);
mCharInfo->select(slot);
@@ -113,7 +114,6 @@ void CharServerHandler::handleMessage(MessageIn &msg)
mCharInfo->unlock();
mCharInfo->select(slot);
mCharInfo->setEntry(tempPlayer);
- n_character++;
// Close the character create dialog
if (mCharCreateDialog)
@@ -133,11 +133,13 @@ void CharServerHandler::handleMessage(MessageIn &msg)
break;
case SMSG_CHAR_DELETE_SUCCEEDED:
- delete mCharInfo->getEntry();
+ tempPlayer = mCharInfo->getEntry();
mCharInfo->setEntry(0);
mCharInfo->unlock();
- n_character--;
+ if (mCharSelectDialog)
+ mCharSelectDialog->update(mCharInfo->getPos());
new OkDialog(_("Info"), _("Character deleted."));
+ delete tempPlayer;
break;
case SMSG_CHAR_DELETE_FAILED:
@@ -219,6 +221,11 @@ LocalPlayer *CharServerHandler::readPlayerData(MessageIn &msg, int &slot)
return tempPlayer;
}
+void CharServerHandler::setCharSelectDialog(CharSelectDialog *window)
+{
+ mCharSelectDialog = window;
+}
+
void CharServerHandler::setCharCreateDialog(CharCreateDialog *window)
{
mCharCreateDialog = window;
diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h
index aa36f873..90e7372c 100644
--- a/src/net/ea/charserverhandler.h
+++ b/src/net/ea/charserverhandler.h
@@ -45,6 +45,8 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler
void setCharInfo(LockedArray<LocalPlayer*> *charInfo)
{ mCharInfo = charInfo; }
+ void setCharSelectDialog(CharSelectDialog *window);
+
/**
* Sets the character create dialog. The handler will clean up this
* dialog when a new character is succesfully created, and will unlock
@@ -65,6 +67,7 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler
protected:
LockedArray<LocalPlayer*> *mCharInfo;
+ CharSelectDialog *mCharSelectDialog;
CharCreateDialog *mCharCreateDialog;
LocalPlayer *readPlayerData(MessageIn &msg, int &slot);
diff --git a/src/net/tmwserv/charhandler.cpp b/src/net/tmwserv/charhandler.cpp
index 841c9a2d..03a6dff0 100644
--- a/src/net/tmwserv/charhandler.cpp
+++ b/src/net/tmwserv/charhandler.cpp
@@ -100,10 +100,13 @@ void CharHandler::handleMessage(MessageIn &msg)
// Character deletion successful
if (errMsg == ERRMSG_OK)
{
- delete mCharInfo->getEntry();
+ LocalPlayer *tempPlayer = mCharInfo->getEntry();
mCharInfo->setEntry(0);
mCharInfo->unlock();
+ if (mCharSelectDialog)
+ mCharSelectDialog->update(mCharInfo->getPos());
new OkDialog(_("Info"), _("Player deleted."));
+ delete tempPlayer;
}
// Character deletion failed
else
@@ -291,9 +294,13 @@ void CharHandler::handleCharSelectResponse(MessageIn &msg)
}
}
+void CharHandler::setCharSelectDialog(CharSelectDialog *window)
+{
+ mCharSelectDialog = window;
+}
+
void CharHandler::setCharCreateDialog(CharCreateDialog *window)
{
- mCharSelectDialog = window ? window->getSelectDialog() : NULL;
mCharCreateDialog = window;
if (!mCharCreateDialog) return;
diff --git a/src/net/tmwserv/charhandler.h b/src/net/tmwserv/charhandler.h
index 5517bd17..03ea51dc 100644
--- a/src/net/tmwserv/charhandler.h
+++ b/src/net/tmwserv/charhandler.h
@@ -47,6 +47,8 @@ class CharHandler : public MessageHandler, public Net::CharHandler
mCharInfo = charInfo;
}
+ void setCharSelectDialog(CharSelectDialog *window);
+
/**
* Sets the character create dialog. The handler will clean up this
* dialog when a new character is succesfully created, and will unlock