00001 #ifndef ERIS_PLAYER_H
00002 #define ERIS_PLAYER_H
00003
00004 #include <sigc++/object.h>
00005 #if SIGC_MAJOR_VERSION == 1 && SIGC_MINOR_VERSION == 0
00006 #include <sigc++/basic_signal.h>
00007 #else
00008 #include <sigc++/signal.h>
00009 #endif
00010
00011 #include <Atlas/Objects/Entity/GameEntity.h>
00012 #include <Atlas/Objects/Operation/Error.h>
00013 #include <Atlas/Objects/Operation/Logout.h>
00014 #include <Atlas/Objects/Entity/Player.h>
00015
00016 #include <Eris/Types.h>
00017 #include <Eris/Timeout.h>
00018
00019 namespace Eris
00020 {
00021
00022
00023 class Lobby;
00024 class Connection;
00025 class World;
00026 class Avatar;
00027
00030 typedef enum {
00031 LOGIN_INVALID = 0,
00032 LOGIN_DUPLICATE_ACCOUNT,
00033 LOGIN_BAD_ACCOUNT,
00034 LOGIN_UNKNOWN_ACCOUNT,
00035 LOGIN_BAD_PASSWORD,
00036 LOGIN_DUPLICATE_CONNECT
00037 } LoginFailureType;
00038
00040 typedef std::list<Atlas::Objects::Entity::GameEntity> CharacterList;
00041
00043
00051 class Player : virtual public SigC::Object
00052 {
00053 public:
00056 Player(Connection *con);
00057 ~Player();
00058
00062
00068 void login(const std::string &uname,
00069 const std::string &pwd);
00070
00076
00077
00078
00079
00080 void createAccount(const std::string &uname,
00081 const std::string &name,
00082 const std::string &pwd);
00083
00086 void logout();
00087
00091 CharacterList getCharacters();
00092
00098 void refreshCharacterInfo();
00099
00102 Avatar* takeCharacter(const std::string &id);
00103
00105 Avatar* createCharacter(const Atlas::Objects::Entity::GameEntity &character);
00106
00108 const std::string& getAccountID() const;
00109
00110
00112
00113
00115 SigC::Signal0<void> GotAllCharacters;
00116
00118 SigC::Signal2<void, LoginFailureType, const std::string &> LoginFailure;
00119
00120 SigC::Signal0<void> LoginSuccess;
00121
00125 SigC::Signal1<void, bool> LogoutComplete;
00126 protected:
00127 void recvOpError(const Atlas::Objects::Operation::Error &err);
00128 void recvSightCharacter(const Atlas::Objects::Entity::GameEntity &ge);
00129 void loginComplete(const Atlas::Objects::Entity::Player &p);
00130
00131 void internalLogin(const std::string &unm, const std::string &pwd);
00132
00134 void netConnected();
00135
00137 bool netDisconnecting();
00138 void netFailure(const std::string& msg);
00139
00140 void recvLogoutInfo(const Atlas::Objects::Operation::Logout &lo);
00141 void handleLogoutTimeout();
00142
00143 Connection* _con;
00144 std::string _account;
00145
00146 CharacterList _characters;
00147 StringList _charIds;
00148
00149 std::string _username,
00150 _pass;
00151
00153 std::string _currentAction;
00154 long _currentSerial;
00155
00156 Timeout* _logoutTimeout;
00157
00158 Lobby* _lobby;
00159 };
00160
00161 }
00162
00163 #endif