#include <gamehandler.hpp>
Public Member Functions | |
GameHandler () | |
Constructor. | |
bool | startListen (enet_uint16 port) |
Starts the handler. | |
void | sendTo (Character *, MessageOut &msg) |
Sends message to the given character. | |
void | kill (Character *) |
Kills connection with given character. | |
void | prepareServerChange (Character *) |
Prepares a server change for given character. | |
void | completeServerChange (int id, const std::string &token, const std::string &address, int port) |
Completes a server change for given character ID. | |
void | updateCharacter (int charid, int partyid) |
Updates the party id of the character. | |
void | addPendingCharacter (const std::string &token, Character *) |
Registers a character that should soon be claimed by a client. | |
void | tokenMatched (GameClient *computer, Character *character) |
Combines a client with its character. | |
void | deletePendingClient (GameClient *computer) |
Deletes a pending client's data. | |
void | deletePendingConnect (Character *character) |
Deletes a pending connection's data. | |
GameClient * | getClientByNameSlow (const std::string &) |
Gets the client associated to a character name. | |
Protected Member Functions | |
NetComputer * | computerConnected (ENetPeer *) |
Called when a computer connects to the server. | |
void | computerDisconnected (NetComputer *) |
Called when a computer reconnects to the server. | |
void | sendError (NetComputer *computer, int id, std::string errorMsg) |
Send error message back to player. | |
void | processMessage (NetComputer *computer, MessageIn &message) |
Processes messages related to core game events. | |
void | handleWalk (GameClient *client, MessageIn &message) |
Set the position a player wants to move to. | |
void | handleSendPost (GameClient *client, MessageIn &message) |
Send a letter. | |
void | handleGetPost (GameClient *client, MessageIn &message) |
Retrieve a letter. |
Definition at line 49 of file gamehandler.hpp.
void GameHandler::addPendingCharacter | ( | const std::string & | token, | |
Character * | ch | |||
) |
Registers a character that should soon be claimed by a client.
token | token used by the client when connecting. |
Definition at line 580 of file gamehandler.cpp.
References TokenCollector< Handler, Client, ServerData >::addPendingConnect(), ConnectionHandler::clients, Character::getDatabaseID(), and kill().
Referenced by AccountConnection::processMessage().
void GameHandler::tokenMatched | ( | GameClient * | computer, | |
Character * | character | |||
) |
Combines a client with its character.
(Needed for TokenCollector)
Definition at line 618 of file gamehandler.cpp.
References kill(), Character::modifiedAttribute(), Character::setClient(), and MessageOut::writeByte().
void GameHandler::deletePendingClient | ( | GameClient * | computer | ) |
Deletes a pending client's data.
(Needed for TokenCollector)
Definition at line 647 of file gamehandler.cpp.
References MessageOut::writeByte().
void GameHandler::deletePendingConnect | ( | Character * | character | ) |
Deletes a pending connection's data.
(Needed for TokenCollector)
Definition at line 659 of file gamehandler.cpp.
GameClient * GameHandler::getClientByNameSlow | ( | const std::string & | name | ) |
Gets the client associated to a character name.
This method is slow, so it should never be called for regular operations.
Definition at line 664 of file gamehandler.cpp.
References ConnectionHandler::clients, and Character::getName().
NetComputer * GameHandler::computerConnected | ( | ENetPeer * | peer | ) | [protected, virtual] |
Called when a computer connects to the server.
Initialize an object derived of NetComputer.
Implements ConnectionHandler.
Definition at line 59 of file gamehandler.cpp.
void GameHandler::computerDisconnected | ( | NetComputer * | ) | [protected, virtual] |
Called when a computer reconnects to the server.
Called when a computer disconnects from the server.
Note: After returning from this method the NetComputer reference is no longer guaranteed to be valid.
Implements ConnectionHandler.
Definition at line 64 of file gamehandler.cpp.
References TokenCollector< Handler, Client, ServerData >::deletePendingClient(), and AccountConnection::sendCharacterData().