diff options
Diffstat (limited to 'src/net/manaserv/charhandler.h')
-rw-r--r-- | src/net/manaserv/charhandler.h | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/src/net/manaserv/charhandler.h b/src/net/manaserv/charhandler.h index 74f68f55..4a1af307 100644 --- a/src/net/manaserv/charhandler.h +++ b/src/net/manaserv/charhandler.h @@ -42,11 +42,6 @@ class CharHandler : public MessageHandler, public Net::CharHandler void handleMessage(Net::MessageIn &msg); - void setCharInfo(LockedArray<LocalPlayer*> *charInfo) - { - mCharInfo = charInfo; - } - void setCharSelectDialog(CharSelectDialog *window); /** @@ -56,32 +51,52 @@ class CharHandler : public MessageHandler, public Net::CharHandler */ void setCharCreateDialog(CharCreateDialog *window); - void getCharacters(); + void requestCharacters(); - void chooseCharacter(int slot, LocalPlayer* character); + void chooseCharacter(Net::Character *character); void newCharacter(const std::string &name, int slot, - bool gender, int hairstyle, int hairColor, - std::vector<int> stats); + bool gender, int hairstyle, int hairColor, + const std::vector<int> &stats); - void deleteCharacter(int slot, LocalPlayer* character); + void deleteCharacter(Net::Character *character); void switchCharacter(); - unsigned int baseSprite() const; - - unsigned int hairSprite() const; - - unsigned int maxSprite() const; + int baseSprite() const; - protected: - void handleCharCreateResponse(Net::MessageIn &msg); + int hairSprite() const; - void handleCharSelectResponse(Net::MessageIn &msg); + int maxSprite() const; - LockedArray<LocalPlayer*> *mCharInfo; - CharSelectDialog *mCharSelectDialog; - CharCreateDialog *mCharCreateDialog; + private: + /** + * Character information needs to be cached since we receive it before + * we have loaded the dynamic data, so we can't resolve load any + * sprites yet. + */ + struct CachedCharacterInfo { + int slot; + std::string name; + Gender gender; + int hairStyle; + int hairColor; + int level; + int characterPoints; + int correctionPoints; + int money; + int attribute[7]; + }; + + void handleCharacterInfo(Net::MessageIn &msg); + void handleCharacterCreateResponse(Net::MessageIn &msg); + void handleCharacterDeleteResponse(Net::MessageIn &msg); + void handleCharacterSelectResponse(Net::MessageIn &msg); + + void updateCharacters(); + + /** Cached character information */ + std::vector<CachedCharacterInfo> mCachedCharacterInfos; }; } // namespace ManaServ |