ManaPlus
Public Member Functions
EAthena::GameHandler Class Reference

#include <gamehandler.h>

Inheritance diagram for EAthena::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()

EAthena::GameHandler::GameHandler ( )

Definition at line 53 of file gamehandler.cpp.

53  :
55 {
56  gameHandler = this;
57 }
Net::GameHandler * gameHandler
Definition: net.cpp:91

References gameHandler.

◆ ~GameHandler()

EAthena::GameHandler::~GameHandler ( )
virtual

Reimplemented from Net::GameHandler.

Definition at line 59 of file gamehandler.cpp.

60 {
61  gameHandler = nullptr;
62 }

References gameHandler.

Member Function Documentation

◆ connect()

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

Implements Net::GameHandler.

Definition at line 69 of file gamehandler.cpp.

70 {
71  if (Network::mInstance == nullptr)
72  return;
73 
75 
76  const Token &token = static_cast<LoginHandler*>(loginHandler)->getToken();
77 
78 
80  {
81  // Change the player's ID to the account ID to match what eAthena uses
82  if (localPlayer != nullptr)
83  {
86  }
87  else
88  {
90  }
91  }
92 
93  // Send login infos
94  createOutPacket(CMSG_MAP_SERVER_CONNECT);
95  outMsg.writeBeingId(token.account_ID, "account id");
96  outMsg.writeBeingId(Ea::GameRecv::mCharID, "char id");
97  outMsg.writeInt32(token.session_ID1, "session key1");
98  outMsg.writeInt32(0, "tick");
99  outMsg.writeInt8(Being::genderToInt(token.sex), "sex");
102 
103  // We get 4 useless bytes before the real answer comes in (what are these?)
104 // Network::mInstance->skip(4);
105 }
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
StateT getState() const
Definition: client.h:69
static Network * mInstance
Definition: network.h:57
bool connect(const ServerInfo &server)
Definition: network.cpp:101
virtual void sendVersion() const =0
virtual bool haveMapServerVersion() const =0
Client * client
Definition: client.cpp:118
LocalPlayer * localPlayer
Net::LoginHandler * loginHandler
Definition: net.cpp:90
#define createOutPacket(name)
Definition: messageout.h:37
ServerInfo mapServer
BeingId mCharID
Definition: gamerecv.cpp:47
@ CONNECT_GAME
Definition: state.h:48
Net::ServerFeatures * serverFeatures
Definition: net.cpp:101
Definition: token.h:31
GenderT sex
Definition: token.h:44
BeingId account_ID
Definition: token.h:41
int session_ID1
Definition: token.h:42

References Token::account_ID, BeingId_zero, client, Ea::Network::connect(), State::CONNECT_GAME, createOutPacket, Being::genderToInt(), ActorSprite::getId(), Client::getState(), Net::ServerFeatures::haveMapServerVersion(), localPlayer, loginHandler, EAthena::mapServer, Ea::GameRecv::mCharID, EAthena::Network::mInstance, Net::LoginHandler::sendVersion(), serverFeatures, Token::session_ID1, ActorSprite::setId(), and Token::sex.

◆ disconnect()

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

Implements Net::GameHandler.

Definition at line 114 of file gamehandler.cpp.

115 {
116  if (Network::mInstance != nullptr)
118 }
void disconnect()
Definition: network.cpp:139

References Ea::Network::disconnect(), and EAthena::Network::mInstance.

◆ disconnect2()

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

Implements Net::GameHandler.

Definition at line 225 of file gamehandler.cpp.

226 {
227  createOutPacket(CMSG_CLIENT_QUIT);
228 }

References createOutPacket.

◆ isConnected()

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

Implements Net::GameHandler.

Definition at line 107 of file gamehandler.cpp.

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

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

◆ mapLoadedEvent()

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

Implements Net::GameHandler.

Definition at line 64 of file gamehandler.cpp.

65 {
66  createOutPacket(CMSG_MAP_LOADED);
67 }

References createOutPacket.

◆ mustPing()

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

Implements Net::GameHandler.

Definition at line 57 of file gamehandler.h.

58  { return true; }

◆ ping()

void EAthena::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  if (packetVersion >= 20101124)
129  {
130  // nothing here
131  }
132  else if (packetVersion >= 20080827)
133  {
134  outMsg.writeInt16(0, "unknown");
135  outMsg.writeInt8(0, "unknown");
136  outMsg.writeInt8(0, "unknown");
137  outMsg.writeInt8(0, "unknown");
138  }
139  else if (packetVersion >= 20070212)
140  {
141  outMsg.writeInt16(0, "unknown");
142  }
143  else if (packetVersion >= 20070108)
144  {
145  outMsg.writeInt16(0, "unknown");
146  outMsg.writeInt16(0, "unknown");
147  outMsg.writeInt8(0, "unknown");
148  }
149  else if (packetVersion >= 20050719)
150  {
151  outMsg.writeInt16(0, "unknown");
152  outMsg.writeInt16(0, "unknown");
153  outMsg.writeInt16(0, "unknown");
154  outMsg.writeInt8(0, "unknown");
155  }
156  else if (packetVersion >= 20050718)
157  {
158  outMsg.writeInt8(0, "unknown");
159  }
160  else if (packetVersion >= 20050628)
161  {
162  outMsg.writeInt16(0, "unknown");
163  outMsg.writeInt16(0, "unknown");
164  outMsg.writeInt16(0, "unknown");
165  outMsg.writeInt8(0, "unknown");
166  }
167  else if (packetVersion >= 20050509)
168  {
169  outMsg.writeInt16(0, "unknown");
170  }
171  else if (packetVersion >= 20050110)
172  {
173  outMsg.writeInt16(0, "unknown");
174  outMsg.writeInt8(0, "unknown");
175  }
176  else if (packetVersion >= 20041129)
177  {
178  outMsg.writeInt8(0, "unknown");
179  }
180  else if (packetVersion >= 20041025)
181  {
182  outMsg.writeInt8(0, "unknown");
183  outMsg.writeInt8(0, "unknown");
184  outMsg.writeInt8(0, "unknown");
185  }
186  else if (packetVersion >= 20041005)
187  {
188  outMsg.writeInt8(0, "unknown");
189  outMsg.writeInt8(0, "unknown");
190  outMsg.writeInt8(0, "unknown");
191  outMsg.writeInt8(0, "unknown");
192  }
193  else if (packetVersion >= 20040920)
194  {
195  outMsg.writeInt16(0, "unknown");
196  outMsg.writeInt16(0, "unknown");
197  outMsg.writeInt8(0, "unknown");
198  outMsg.writeInt8(0, "unknown");
199  outMsg.writeInt8(0, "unknown");
200  outMsg.writeInt8(0, "unknown");
201  }
202  else if (packetVersion >= 20040906)
203  {
204  outMsg.writeInt16(0, "unknown");
205  outMsg.writeInt8(0, "unknown");
206  outMsg.writeInt8(0, "unknown");
207  outMsg.writeInt8(0, "unknown");
208  }
209  else if (packetVersion >= 20040809)
210  {
211  outMsg.writeInt16(0, "unknown");
212  outMsg.writeInt16(0, "unknown");
213  outMsg.writeInt8(0, "unknown");
214  outMsg.writeInt8(0, "unknown");
215  outMsg.writeInt8(0, "unknown");
216  }
217  else if (packetVersion >= 20040726)
218  {
219  outMsg.writeInt16(0, "unknown");
220  outMsg.writeInt16(0, "unknown");
221  }
222  outMsg.writeInt32(tick, "tick");
223 }
int packetVersion
Definition: client.cpp:125

References createOutPacket, and packetVersion.

◆ ping2()

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

Implements Net::GameHandler.

Definition at line 235 of file gamehandler.cpp.

236 {
237  if (packetVersionMain < 20190227 &&
238  packetVersionRe < 20190220 &&
239  packetVersionZero < 20190220)
240  {
241  return;
242  }
243  createOutPacket(CMSG_MAP_PING2);
244 }
int packetVersionRe
Definition: client.cpp:127
int packetVersionMain
Definition: client.cpp:126
int packetVersionZero
Definition: client.cpp:128

References createOutPacket, packetVersionMain, packetVersionRe, and packetVersionZero.

◆ quit()

void EAthena::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 EAthena::GameHandler::reqRemainTime ( ) const
virtual

Implements Net::GameHandler.

Definition at line 230 of file gamehandler.cpp.

231 {
232  createOutPacket(CMSG_REQ_REMAIN_TIME);
233 }

References createOutPacket.


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