ManaPlus
Public Member Functions
TmwAthena::GameHandler Class Reference

#include <gamehandler.h>

Inheritance diagram for TmwAthena::GameHandler:
Ea::GameHandler Net::GameHandler

Public Member Functions

 GameHandler ()
 
 ~GameHandler ()
 
void connect () const
 
bool isConnected () const
 
void disconnect () const
 
void quit () const
 
void ping (const int tick) const
 
void disconnect2 () const
 
void mapLoadedEvent () const
 
void reqRemainTime () const
 
bool mustPing () const
 
void ping2 () const
 
- Public Member Functions inherited from Ea::GameHandler
 GameHandler ()
 
void who () const
 
bool removeDeadBeings () const
 
void clear () const
 
void initEngines () const
 
- Public Member Functions inherited from Net::GameHandler
 GameHandler ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Ea::GameHandler
static void setMap (const std::string &map)
 

Detailed Description

Definition at line 32 of file gamehandler.h.

Constructor & Destructor Documentation

◆ GameHandler()

TmwAthena::GameHandler::GameHandler ( )

Definition at line 46 of file gamehandler.cpp.

46  :
48 {
49  gameHandler = this;
50 }
Net::GameHandler * gameHandler
Definition: net.cpp:91

References gameHandler.

◆ ~GameHandler()

TmwAthena::GameHandler::~GameHandler ( )
virtual

Reimplemented from Net::GameHandler.

Definition at line 52 of file gamehandler.cpp.

53 {
54  gameHandler = nullptr;
55 }

References gameHandler.

Member Function Documentation

◆ connect()

void TmwAthena::GameHandler::connect ( ) const
virtual

Implements Net::GameHandler.

Definition at line 62 of file gamehandler.cpp.

63 {
64  if (Network::mInstance == nullptr)
65  return;
66 
67  BLOCK_START("GameHandler::connect")
68  Network::mInstance->connect(mapServer);
69  const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
70 
71  if (client->getState() == State::CONNECT_GAME)
72  {
73  // Change the player's ID to the account ID to match what eAthena uses
74  if (localPlayer != nullptr)
75  {
77  localPlayer->setId(token.account_ID);
78  }
79  else
80  {
82  }
83  }
84 
85  // Send login infos
86  createOutPacket(CMSG_MAP_SERVER_CONNECT);
87  outMsg.writeBeingId(token.account_ID, "account id");
88  outMsg.writeBeingId(Ea::GameRecv::mCharID, "char id");
89  outMsg.writeInt32(token.session_ID1, "session id1");
90  outMsg.writeInt32(token.session_ID2, "session id2");
91  outMsg.writeInt8(Being::genderToInt(token.sex), "gender");
92 
93 /*
94  if (localPlayer)
95  {
96  // Change the player's ID to the account ID to match what eAthena uses
97  localPlayer->setId(token.account_ID);
98  }
99 */
100  // We get 4 useless bytes before the real answer comes in (what are these?)
102  BLOCK_END("GameHandler::connect")
103 }
const BeingId BeingId_zero
Definition: beingid.h:30
void setId(const BeingId id)
Definition: actorsprite.h:67
BeingId getId() const
Definition: actorsprite.h:64
static uint8_t genderToInt(const GenderT sex) A_CONST
Definition: being.h:927
void skip(const int len)
Definition: network.cpp:181
static Network * mInstance
Definition: network.h:54
Client * client
Definition: client.cpp:118
if(!vert) return
LocalPlayer * localPlayer
Net::LoginHandler * loginHandler
Definition: net.cpp:90
#define createOutPacket(name)
Definition: messageout.h:37
BeingId mCharID
Definition: gamerecv.cpp:47
Definition: state.h:33
@ CONNECT_GAME
Definition: state.h:48
ServerInfo mapServer
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79
Definition: token.h:31

References Token::account_ID, BeingId_zero, BLOCK_END, BLOCK_START, client, Ea::Network::connect(), State::CONNECT_GAME, createOutPacket, Being::genderToInt(), ActorSprite::getId(), Client::getState(), localPlayer, loginHandler, TmwAthena::mapServer, Ea::GameRecv::mCharID, TmwAthena::Network::mInstance, Token::session_ID1, Token::session_ID2, ActorSprite::setId(), Token::sex, and Ea::Network::skip().

◆ disconnect()

void TmwAthena::GameHandler::disconnect ( ) const
virtual

Implements Net::GameHandler.

Definition at line 112 of file gamehandler.cpp.

113 {
114  BLOCK_START("GameHandler::disconnect")
115  if (Network::mInstance != nullptr)
116  Network::mInstance->disconnect();
118 }

References BLOCK_END, BLOCK_START, Ea::Network::disconnect(), and TmwAthena::Network::mInstance.

◆ disconnect2()

void TmwAthena::GameHandler::disconnect2 ( ) const
virtual

Implements Net::GameHandler.

Definition at line 131 of file gamehandler.cpp.

132 {
133  createOutPacket(CMSG_CLIENT_DISCONNECT);
134 }

References createOutPacket.

◆ isConnected()

bool TmwAthena::GameHandler::isConnected ( ) const
virtual

Implements Net::GameHandler.

Definition at line 105 of file gamehandler.cpp.

106 {
107  if (Network::mInstance == nullptr)
108  return false;
110 }
bool isConnected() const
Definition: network.h:61

References Ea::Network::isConnected(), and TmwAthena::Network::mInstance.

◆ mapLoadedEvent()

void TmwAthena::GameHandler::mapLoadedEvent ( ) const
virtual

Implements Net::GameHandler.

Definition at line 57 of file gamehandler.cpp.

58 {
59  createOutPacket(CMSG_MAP_LOADED);
60 }

References createOutPacket.

◆ mustPing()

bool TmwAthena::GameHandler::mustPing ( ) const
inlinevirtual

Implements Net::GameHandler.

Definition at line 57 of file gamehandler.h.

58  { return false; }

◆ ping()

void TmwAthena::GameHandler::ping ( const int  tick) const
virtual

Implements Net::GameHandler.

Definition at line 125 of file gamehandler.cpp.

126 {
127  createOutPacket(CMSG_MAP_PING);
128  outMsg.writeInt32(tick, "tick");
129 }

References createOutPacket.

◆ ping2()

void TmwAthena::GameHandler::ping2 ( ) const
virtual

Implements Net::GameHandler.

Definition at line 140 of file gamehandler.cpp.

141 {
142 }

◆ quit()

void TmwAthena::GameHandler::quit ( ) const
virtual

Implements Net::GameHandler.

Definition at line 120 of file gamehandler.cpp.

121 {
122  createOutPacket(CMSG_CLIENT_QUIT);
123 }

References createOutPacket.

◆ reqRemainTime()

void TmwAthena::GameHandler::reqRemainTime ( ) const
virtual

Implements Net::GameHandler.

Definition at line 136 of file gamehandler.cpp.

137 {
138 }

The documentation for this class was generated from the following files: