1er commit

This commit is contained in:
2021-08-21 10:14:47 +02:00
commit a99ecf7c2d
99 changed files with 66605 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
#include "game/client/ClientConnexion.h"
#include "render/WorldRenderer.h"
namespace td {
namespace client {
ClientConnexion::ClientConnexion(): Connexion(&m_Dispatcher){
registerHandlers();
}
void ClientConnexion::registerHandlers(){
GetDispatcher()->RegisterHandler(protocol::PacketType::KeepAlive, this);
GetDispatcher()->RegisterHandler(protocol::PacketType::ConnectionInfo, this);
GetDispatcher()->RegisterHandler(protocol::PacketType::Disconnect, this);
GetDispatcher()->RegisterHandler(protocol::PacketType::ServerTps, this);
}
void ClientConnexion::HandlePacket(protocol::KeepAlivePacket* packet){
protocol::KeepAlivePacket keepAlivePacket(packet->getAliveID());
sendPacket(&keepAlivePacket);
}
void ClientConnexion::HandlePacket(protocol::ConnexionInfoPacket* packet){
m_ConnectionID = packet->getConnectionID();
login();
}
void ClientConnexion::HandlePacket(protocol::ServerTpsPacket* packet){
m_ServerTPS = packet->getTPS();
m_Ping = utils::getTime() - packet->getPacketSendTime();
}
void ClientConnexion::login(){
td::protocol::PlayerLoginPacket loginPacket("Persson" + std::to_string(m_ConnectionID));
sendPacket(&loginPacket);
}
bool ClientConnexion::updateSocket(){
return Connexion::updateSocket();
}
void ClientConnexion::HandlePacket(protocol::DisconnectPacket* packet){
m_DisconnectReason = packet->getReason();
closeConnection();
render::WorldRenderer::destroy();
}
} // namespace client
} // namespace td