diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-02-19 22:38:59 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-02-19 23:37:36 +0100 |
commit | 363527d0f95963ba3f4a6d25c8eabc1bb3ad4efe (patch) | |
tree | 117ce95d3587f913a64b71fe4dcdee716b8aea7e /src/gui/charselectdialog.h | |
parent | 432d16435774cafd630e287321e882f3e8510d16 (diff) | |
download | mana-363527d0f95963ba3f4a6d25c8eabc1bb3ad4efe.tar.gz mana-363527d0f95963ba3f4a6d25c8eabc1bb3ad4efe.tar.bz2 mana-363527d0f95963ba3f4a6d25c8eabc1bb3ad4efe.tar.xz mana-363527d0f95963ba3f4a6d25c8eabc1bb3ad4efe.zip |
Fixed a crash when trying to switch servers
Ownership of the charInfo global variable wasn't well defined. It was
being locked, unlocked and generally modified from a lot of places, and
somewhere in this mess it ended up crashing when switching servers.
Now the CharHandler instances, for eAthena and manaserv respectively,
own this list of characters. A new class, Net::Character wraps up the
slot index in combination with the player dummy. The list is passed on
to the CharSelectDialog each time it changes.
Both related and unrelated cleanups were made as well.
Reviewed-by: Jared Adams
Diffstat (limited to 'src/gui/charselectdialog.h')
-rw-r--r-- | src/gui/charselectdialog.h | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index fa9591bf..9e455462 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -23,16 +23,17 @@ #define CHAR_SELECT_H #include "guichanfwd.h" -#include "lockedarray.h" #include "main.h" #include "player.h" #include "gui/widgets/window.h" +#include "net/charhandler.h" + #include <guichan/actionlistener.hpp> #include <guichan/keylistener.hpp> -class CharEntry; +class CharacterDisplay; class LocalPlayer; class LoginData; class PlayerBox; @@ -51,49 +52,55 @@ class CharSelectDialog : public Window, public gcn::ActionListener, { public: friend class CharDeleteConfirm; + friend class Net::CharHandler; /** * Constructor. */ - CharSelectDialog(LockedArray<LocalPlayer*> *charInfo, - LoginData *loginData); + CharSelectDialog(LoginData *loginData); - ~CharSelectDialog() { mCharInfo->clear(); }; + ~CharSelectDialog(); void action(const gcn::ActionEvent &event); void keyPressed(gcn::KeyEvent &keyEvent); - bool selectByName(const std::string &name); + enum SelectAction { + Focus, + Choose + }; /** - * Send selection to character server - * @return false if the selection or the number of existing character - * is empty. - */ - bool chooseSelected(); - - void update(int slot = -1); + * Attempt to select the character with the given name. Returns whether + * a character with the given name was found. + * + * \param action determines what to do when a character with the given + * name was found (just focus or also try to choose this + * character). + */ + bool selectByName(const std::string &name, + SelectAction action = Focus); private: - /** - * Communicate character deletion to the server. - */ - void attemptCharDelete(); + void attemptCharacterDelete(int index); + void attemptCharacterSelect(int index); - /** - * Communicate character selection to the server. - */ - void attemptCharSelect(); + void setCharacters(const Net::Characters &characters); + + void lock(); + void unlock(); + void setLocked(bool locked); - LockedArray<LocalPlayer*> *mCharInfo; + bool mLocked; gcn::Label *mAccountNameLabel; gcn::Button *mSwitchLoginButton; gcn::Button *mChangePasswordButton; + gcn::Button *mUnregisterButton; + gcn::Button *mChangeEmailButton; - CharEntry *mCharEntries[MAX_CHARACTER_COUNT]; + CharacterDisplay *mCharacterEntries[MAX_CHARACTER_COUNT]; LoginData *mLoginData; |