6 #include "TransferInfo.h"
8 #include <Atlas/Objects/ObjectsFwd.h>
10 #include <sigc++/signal.h>
29 typedef std::map<std::string, Atlas::Objects::Entity::RootEntity>
CharacterMap;
31 typedef std::map<std::string, std::unique_ptr<Avatar>> ActiveCharacterMap;
42 class Account :
virtual public sigc::trackable {
64 Result login(
const std::string &uname,
const std::string &pwd);
78 const std::string &fullName,
79 const std::string &pwd);
139 Result createCharacterThroughOperation(
const Atlas::Objects::Operation::Create &c);
160 const std::string &
getId()
const;
236 void sightCharacter(
const Atlas::Objects::Operation::RootOperation &op);
238 void loginComplete(
const Atlas::Objects::Entity::Account &p);
240 void loginError(
const Atlas::Objects::Operation::Error &err);
242 Result internalLogin(
const std::string &unm,
const std::string &pwd);
244 void internalLogout(
bool clean);
252 void netFailure(
const std::string &msg);
254 void loginResponse(
const Atlas::Objects::Operation::RootOperation &op);
256 void logoutResponse(
const Atlas::Objects::Operation::RootOperation &op);
258 void possessResponse(
const Atlas::Objects::Operation::RootOperation &op);
260 void avatarCreateResponse(
const Atlas::Objects::Operation::RootOperation &op);
262 void avatarLogoutResponse(
const Atlas::Objects::Operation::RootOperation &op);
274 void handleLogoutTimeout();
277 void handleLoginTimeout();
290 void internalDeactivateCharacter(
const std::string& avatarId);
292 virtual void updateFromObject(
const Atlas::Objects::Entity::Account &p);
296 std::unique_ptr<AccountRouter> m_router;
302 std::string m_parent;
304 std::set<std::string> m_characterIds;
307 ActiveCharacterMap m_activeAvatars;
308 std::unique_ptr<TimedEvent> m_timeout;
322 return m_activeAvatars;
Encapsulates all the state of an Atlas Account, and methods that operation on that state.
CharacterMap _characters
characters belonging to this player
const ActiveCharacterMap & getActiveCharacters() const
Gets a list of active characters, i.e. entities on the server which the account can control.
Result refreshCharacterInfo()
@ LOGGED_IN
Fully logged into a server-side account.
@ CREATED_CHAR
a character was created, we now need to possess it
@ DISCONNECTED
Default state, no server account active.
@ LOGGING_IN
Login sent, waiting for initial INFO response.
@ LOGGING_OUT
Sent a logout op, waiting for the INFO response.
@ CREATING_CHAR
send a character CREATE op, awaiting INFO response
@ TAKING_CHAR
sent a LOOK op for a character, awaiting INFO response
sigc::signal< void, const std::string & > AvatarDeactivated
Result createCharacterThroughEntity(const Atlas::Objects::Entity::RootEntity &character)
enter the game using a new character
Status m_status
what the Player is currently doing
const std::string & getUsername() const
Result takeTransferredCharacter(const std::string &id, const std::string &key)
Transfer all characters to this account and then do all steps in takeCharacter()
std::vector< SpawnPoint > m_spawnPoints
A map of available spawn points. These are points from which a new avatar can be created.
Result logout()
Request logout from the server.
Connection & m_con
underlying connection instance
sigc::signal< void, const std::string & > LoginFailure
Emitted when a server-side error occurs during account creation / login.
sigc::signal< void > GotAllCharacters
emitted when the entire character list had been updated
void destroyAvatar(const std::string &avatarId)
Destroys the avatar with the specified id, if available.
const std::string & getId() const
returns the account ID if logged in
const std::vector< SpawnPoint > & getSpawnPoints() const
Gets the available spawn points from where the client can create new characters.
void avatarLogoutRequested(Avatar *avatar)
Called when a logout of the avatar has been requested by the server.
sigc::signal< void > LoginSuccess
Connection & getConnection() const
Access the underlying Connection for this account.
sigc::signal< void, const std::string & > ErrorMessage
sigc::signal< void, bool > LogoutComplete
Emitted when a logout completes.
Result createAccount(const std::string &uname, const std::string &fullName, const std::string &pwd)
Attempt to create a new account on the server and log into it.
Result takeCharacter(const std::string &id)
Enter the game using an existing character.
sigc::signal< void, const Atlas::Objects::Entity::RootEntity & > GotCharacterInfo
emitted when a character has been retrieved from the server
bool netDisconnecting()
help! the plug is being pulled!
bool canCreateCharacter()
pop up the game's character creation dialog, if present
void netConnected()
Callback for network re-establishment.
bool isLoggedIn() const
Check if the account is logged in.
const std::string & getParent() const
Gets the parent type of the account.
Result login(const std::string &uname, const std::string &pwd)
Login to the server using user-supplied account information.
const CharacterMap & getCharacters()
Get the characters owned by this account.
std::string m_username
The player's username ( != account object's ID)
sigc::signal< void, const std::string & > AvatarFailure
std::string m_accountId
the account ID
bool m_doingCharacterRefresh
set if we're refreshing character data
Account(Connection &con)
Create a new Account associated with a Connection object.
sigc::signal< void, Avatar * > AvatarSuccess
std::map< std::string, Atlas::Objects::Entity::RootEntity > CharacterMap