Packets Refactor

commit 497a601c424e8e728ef0a8e61f049982f2d4af16
Author: Persson-dev <sim16.prib@gmail.com>
Date:   Sat Aug 12 10:32:52 2023 +0200

    fix warning

commit 1bfd019a1ea00dcdb6323d1f285e2cdd3ebb4020
Author: Persson-dev <sim16.prib@gmail.com>
Date:   Tue Jul 25 19:05:13 2023 +0200

    refactor: update cast

commit 5bbc23a7d37e53eb74a885685f18e714f9448fd9
Author: Persson-dev <sim16.prib@gmail.com>
Date:   Tue Jul 25 19:04:15 2023 +0200

    moved GetImguiTeamColor

commit fd0e2d2470ea5cca3553acf280aa371de5c06f4c
Author: Persson-dev <sim16.prib@gmail.com>
Date:   Tue Jul 25 19:03:37 2023 +0200

    packets forward declaration

commit 06eb9b99a96731f4b9a2167c00ed0bcd03702e3b
Author: Persson-dev <sim16.prib@gmail.com>
Date:   Tue Jul 25 18:30:55 2023 +0200

    remove Protocol.h includes

commit 165f63d2e8b468f3e38992baddc221270010f801
Author: Persson-dev <sim16.prib@gmail.com>
Date:   Tue Jul 25 18:30:30 2023 +0200

    split packets into separate source files

commit f247f146c6c1e804a44b86f65cf3059859c07c6c
Author: Persson-dev <sim16.prib@gmail.com>
Date:   Tue Jul 25 17:45:24 2023 +0200

    split packets into separate headers
This commit is contained in:
2023-08-12 10:41:39 +02:00
parent 36f37b6548
commit f941862637
76 changed files with 1734 additions and 1152 deletions

View File

@@ -1,6 +1,8 @@
#include "game/World.h"
#include "protocol/PacketDispatcher.h"
#include "protocol/Protocol.h"
#include "protocol/packets/WorldBeginDataPacket.h"
#include "protocol/packets/WorldDataPacket.h"
#include "game/BaseGame.h"
#include "misc/Random.h"
#include "misc/Compression.h"

View File

@@ -1,6 +1,12 @@
#include "game/client/Client.h"
#include "misc/Format.h"
#include "protocol/packets/DisconnectPacket.h"
#include "protocol/packets/PlaceTowerPacket.h"
#include "protocol/packets/RemoveTowerPacket.h"
#include "protocol/packets/SelectTeamPacket.h"
#include "protocol/packets/UpgradeTowerPacket.h"
namespace td {
namespace client {

View File

@@ -1,6 +1,12 @@
#include "game/client/ClientConnexion.h"
#include "render/WorldRenderer.h"
#include "protocol/packets/ConnectionInfoPacket.h"
#include "protocol/packets/DisconnectPacket.h"
#include "protocol/packets/KeepAlivePacket.h"
#include "protocol/packets/PlayerLoginPacket.h"
#include "protocol/packets/ServerTpsPacket.h"
namespace td {
namespace client {
@@ -32,7 +38,7 @@ void ClientConnexion::HandlePacket(const protocol::ServerTpsPacket* packet) {
}
void ClientConnexion::Login() {
td::protocol::PlayerLoginPacket loginPacket("Persson" + std::to_string(m_ConnectionID));
td::protocol::PlayerLoginPacket loginPacket("Persson" + std::to_string(static_cast<unsigned int>(m_ConnectionID)));
SendPacket(&loginPacket);
}

View File

@@ -2,6 +2,18 @@
#include "protocol/PacketDispatcher.h"
#include "game/client/Client.h"
#include "protocol/packets/ConnectionInfoPacket.h"
#include "protocol/packets/PlayerJoinPacket.h"
#include "protocol/packets/PlayerListPacket.h"
#include "protocol/packets/PlayerLeavePacket.h"
#include "protocol/packets/UpdatePlayerTeamPacket.h"
#include "protocol/packets/UpdateLobbyTimePacket.h"
#include "protocol/packets/UpdateGameStatePacket.h"
#include "protocol/packets/UpdateMoneyPacket.h"
#include "protocol/packets/UpdateExpPacket.h"
#include "protocol/packets/DisconnectPacket.h"
#include "protocol/packets/WorldDataPacket.h"
namespace td {
namespace client {
@@ -43,7 +55,7 @@ void ClientGame::HandlePacket(const protocol::PlayerJoinPacket* packet) {
void ClientGame::HandlePacket(const protocol::PlayerLeavePacket* packet) {
game::Player* player = &m_Players[packet->GetPlayerID()];
if (player->GetTeamColor() != game::TeamColor::None) {
m_Teams[(std::size_t)player->GetTeamColor()].RemovePlayer(player);
m_Teams[static_cast<std::size_t>(player->GetTeamColor())].RemovePlayer(player);
}
m_Players.erase(player->GetID());
}
@@ -57,7 +69,7 @@ void ClientGame::HandlePacket(const protocol::PlayerListPacket* packet) {
player.SetTeamColor(playerInfo.team);
m_Players.insert({ playerID, player });
if (player.GetTeamColor() != game::TeamColor::None) {
m_Teams[(std::size_t)player.GetTeamColor()].AddPlayer(&m_Players[playerID]);
m_Teams[static_cast<std::size_t>(player.GetTeamColor())].AddPlayer(&m_Players[playerID]);
}
}
m_Player = &m_Players[m_ConnexionID];

View File

@@ -3,6 +3,15 @@
#include "game/client/ClientGame.h"
#include "render/WorldRenderer.h"
#include "protocol/packets/WorldAddTowerPacket.h"
#include "protocol/packets/WorldBeginDataPacket.h"
#include "protocol/packets/WorldDataPacket.h"
#include "protocol/packets/SpawnMobPacket.h"
#include "protocol/packets/UpgradeTowerPacket.h"
#include "protocol/packets/RemoveTowerPacket.h"
#include "protocol/packets/UpdateCastleLifePacket.h"
#include "protocol/packets/UpdateMobStatesPacket.h"
namespace td {
namespace client {

View File

@@ -1,6 +1,8 @@
#include "game/server/Lobby.h"
#include "game/server/Server.h"
#include "protocol/packets/UpdateLobbyTimePacket.h"
#include "misc/Time.h"
#ifdef NDEBUG

View File

@@ -1,6 +1,10 @@
#include "game/server/Server.h"
#include "protocol/PacketFactory.h"
#include "protocol/packets/DisconnectPacket.h"
#include "protocol/packets/ServerTpsPacket.h"
#include "protocol/packets/PlayerLeavePacket.h"
#include "misc/Format.h"
namespace td {

View File

@@ -3,6 +3,23 @@
#include "protocol/PacketFactory.h"
#include "game/server/Server.h"
#include "protocol/packets/ConnectionInfoPacket.h"
#include "protocol/packets/DisconnectPacket.h"
#include "protocol/packets/KeepAlivePacket.h"
#include "protocol/packets/PlaceTowerPacket.h"
#include "protocol/packets/PlayerLoginPacket.h"
#include "protocol/packets/PlayerJoinPacket.h"
#include "protocol/packets/PlayerListPacket.h"
#include "protocol/packets/RemoveTowerPacket.h"
#include "protocol/packets/SelectTeamPacket.h"
#include "protocol/packets/SendMobsPacket.h"
#include "protocol/packets/UpdatePlayerTeamPacket.h"
#include "protocol/packets/UpdateGameStatePacket.h"
#include "protocol/packets/UpgradeTowerPacket.h"
#include "protocol/packets/WorldBeginDataPacket.h"
#include "protocol/packets/WorldDataPacket.h"
#include "protocol/packets/WorldAddTowerPacket.h"
#include "misc/Time.h"
#include "misc/Random.h"

View File

@@ -1,6 +1,15 @@
#include "game/server/ServerGame.h"
#include "game/server/Server.h"
#include "protocol/packets/DisconnectPacket.h"
#include "protocol/packets/UpdatePlayerTeamPacket.h"
#include "protocol/packets/UpdateGameStatePacket.h"
#include "protocol/packets/UpdateMoneyPacket.h"
#include "protocol/packets/UpdateExpPacket.h"
#include "protocol/packets/UpdateMobStatesPacket.h"
#include "protocol/packets/WorldDataPacket.h"
#include "protocol/packets/WorldBeginDataPacket.h"
namespace td {
namespace server {

View File

@@ -2,6 +2,9 @@
#include "game/server/Server.h"
#include "misc/Random.h"
#include "protocol/packets/SpawnMobPacket.h"
#include "protocol/packets/UpdateCastleLifePacket.h"
#define MOB_SPAWN_PRECISION 100.0f
namespace td {