Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members

Player.h

00001 #ifndef ERIS_PLAYER_H
00002 #define ERIS_PLAYER_H
00003 
00004 #include <Eris/Types.h>
00005 #include <Eris/Timeout.h>
00006 
00007 #include <sigc++/object.h>
00008 
00009 namespace Atlas {
00010   namespace Objects {
00011     namespace Operation {
00012       class Error;
00013       class Logout;
00014     }
00015     namespace Entity {
00016       class GameEntity;
00017       class Player;
00018     }
00019   }
00020 }
00021 
00022 namespace Eris
00023 {
00024         
00025 // Forward Declerations
00026 class Lobby;
00027 class Connection;
00028 class World;
00029 class Avatar;
00030 
00033 typedef enum {
00034         LOGIN_INVALID = 0,
00035         LOGIN_DUPLICATE_ACCOUNT,        
00036         LOGIN_BAD_ACCOUNT,              
00037         LOGIN_UNKNOWN_ACCOUNT,  
00038         LOGIN_BAD_PASSWORD,             
00039         LOGIN_DUPLICATE_CONNECT 
00040 } LoginFailureType;
00041 
00043 typedef std::map<std::string, Atlas::Objects::Entity::GameEntity> CharacterMap;
00044 
00046 
00054 class Player : virtual public SigC::Object
00055 {
00056 public:
00059         Player(Connection *con);
00060         ~Player();
00061 
00065         
00071         void login(const std::string &uname,
00072                 const std::string &pwd);
00073 
00079 
00080 
00081 
00082 
00083         void createAccount(const std::string &uname,
00084                 const std::string &name,
00085                 const std::string &pwd);
00086         
00089         void logout();
00090 
00094         const CharacterMap& getCharacters();
00095 
00101         void refreshCharacterInfo();
00102 
00105         Avatar* takeCharacter(const std::string &id);
00106 
00108         Avatar* createCharacter(const Atlas::Objects::Entity::GameEntity &character);
00109 
00111         void createCharacter();
00112 
00114         bool canCreateCharacter() {return false;}
00115 
00117         const std::string& getAccountID() const;
00118 
00119         Connection* getConnection() const {return _con;}
00120 
00121 // signals
00123         SigC::Signal1<void, const Atlas::Objects::Entity::GameEntity&> GotCharacterInfo;
00124         
00126         SigC::Signal0<void> GotAllCharacters;
00127         
00129         SigC::Signal2<void, LoginFailureType, const std::string &> LoginFailure;
00130         
00131         SigC::Signal0<void> LoginSuccess;
00132         
00136         SigC::Signal1<void, bool> LogoutComplete;
00137 
00139         SigC::Signal1<void, Avatar*> NewCharacter;
00140 protected:
00141         void recvOpError(const Atlas::Objects::Operation::Error &err);  
00142         void recvSightCharacter(const Atlas::Objects::Entity::GameEntity &ge);
00143         void loginComplete(const Atlas::Objects::Entity::Player &p);
00144 
00145         void internalLogin(const std::string &unm, const std::string &pwd);
00146         void internalLogout(bool clean);
00147 
00149         void netConnected();
00150         
00152         bool netDisconnecting();
00153         void netFailure(const std::string& msg);
00154 
00155         void recvLogoutInfo(const Atlas::Objects::Operation::Logout &lo);
00156         void handleLogoutTimeout();
00157         void recvRemoteLogout(const Atlas::Objects::Operation::Logout &lo);
00158 
00159         void createCharacterHandler(long serialno);
00160 
00161         Connection* _con;       
00162         std::string _account;   
00163 
00164         CharacterMap _characters;       
00165     StringSet m_characterIds;
00166     bool m_doingCharacterRefresh; 
00167     
00168         std::string _username,  
00169                 _pass;          
00170 
00172         std::string _currentAction;
00173         long _currentSerial;    
00174 
00175         Timeout* _logoutTimeout;
00176 
00177         Lobby* _lobby;
00178 };
00179         
00180 } // of namespace Eris
00181 
00182 #endif

Generated on Sun Sep 4 14:14:04 2005 for Eris by  doxygen 1.4.4