From 8d7576bc1d5cd6a77152f2582991942767a4dcc9 Mon Sep 17 00:00:00 2001 From: Xavier Mitault Date: Sun, 5 Nov 2023 13:14:01 +0000 Subject: [PATCH] NITWORK: Add logger --- src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp | 1 + src/Nitwork/NitworkClient.cpp | 9 +++++++++ src/Nitwork/NitworkServer.cpp | 1 + 3 files changed, 11 insertions(+) diff --git a/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp b/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp index f69926ad..f8843a75 100644 --- a/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp +++ b/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp @@ -157,6 +157,7 @@ namespace Menu { { auto idsButton = Registry::getInstance().getEntitiesByComponents({typeid(Types::Button)}); + Logger::error("!!!!!!!!!!!sendReadyPacket!!!!!!"); Nitwork::NitworkClient::getInstance().addReadyMsg(); for (auto &id : idsButton) { Registry::getInstance().removeEntity(id); diff --git a/src/Nitwork/NitworkClient.cpp b/src/Nitwork/NitworkClient.cpp index 0b7c0e1f..ba710d9b 100644 --- a/src/Nitwork/NitworkClient.cpp +++ b/src/Nitwork/NitworkClient.cpp @@ -152,6 +152,7 @@ namespace Nitwork { }, .msg = {.magick = MAGICK_DISCONNECT_LOBBY}, }; + Logger::error("------------------------------------ Sending disconnect lobby msg: " + std::to_string(DISCONNECT_LOBBY) + " " + std::to_string(MAGICK_DISCONNECT_LOBBY)); Packet packet( packetDisconnectLobby.action.magick, std::make_any(packetDisconnectLobby), @@ -171,6 +172,7 @@ namespace Nitwork { }, .msgInit = {.magick = MAGICK_INIT} }; + Logger::error("------------------------------------ Sending init msg: " + std::to_string(INIT) + " " + std::to_string(MAGICK_INIT)); Packet packet( packetMsgInit.action.magick, std::make_any(packetMsgInit), @@ -186,6 +188,7 @@ namespace Nitwork { .action = {.magick = READY}, .msgReady = {.magick = MAGICK_READY} }; + Logger::error("------------------------------------ Sending ready msg: " + std::to_string(READY) + " " + std::to_string(MAGICK_READY)); Packet packet( packetMsgReady.action.magick, std::make_any(packetMsgReady), @@ -281,6 +284,7 @@ namespace Nitwork { .life = life, }, }; + Logger::error("------------------------------------ Sending life update msg: " + std::to_string(playerId) + " " + std::to_string(MAGICK_LIFE_UPDATE)); Packet packet( packetLifeUpdate.action.magick, std::make_any(packetLifeUpdate), @@ -344,6 +348,7 @@ namespace Nitwork { .missileId = id, }, }; + Logger::error("------------------------------------ Sending missile death msg: " + std::to_string(MISSILE_DEATH) + " " + std::to_string(MAGICK_MISSILE_DEATH)); Packet packet( packetMissileDeath.action.magick, std::make_any(packetMissileDeath), @@ -361,6 +366,7 @@ namespace Nitwork { }, .msg = {.magick = MAGICK_REQUEST_LIST_LOBBY}, }; + Logger::error("------------------------------------ Sending list lobby msg: " + std::to_string(LIST_LOBBY) + " " + std::to_string(MAGICK_REQUEST_LIST_LOBBY)); Packet packet( packetListLobby.action.magick, std::make_any(packetListLobby), @@ -387,6 +393,7 @@ namespace Nitwork { .maxNbPlayer = maxNbPlayer, .ownerInfos = {.ip = "", .port = _mainServerEndpoint.port()}} }; + Logger::error("------------------------------------ Sending create lobby msg: " + std::to_string(CREATE_LOBBY) + " " + std::to_string(MAGICK_CREATE_LOBBY)); std::strcpy(packetCreateLobby.msg.name, (name.size() > 32 ? name.substr(0, 32) : name).c_str()); std::strcpy( packetCreateLobby.msg.ownerInfos.ip, @@ -412,6 +419,7 @@ namespace Nitwork { }, .msg = {.magick = MAGICK_CONNECT_MAIN_SERVER}, }; + Logger::error("------------------------------------ Sending connect main server msg: " + std::to_string(CONNECT_MAIN_SERVER) + " " + std::to_string(MAGICK_CONNECT_MAIN_SERVER)); Packet packet( packetConnectMainServer.action.magick, std::make_any(packetConnectMainServer), @@ -430,6 +438,7 @@ namespace Nitwork { }, .msg = {.magick = MAGICK_CONNECT_LOBBY}, }; + Logger::error("------------------------------------ Sending connect lobby msg: " + std::to_string(CONNECT_LOBBY) + " " + std::to_string(MAGICK_CONNECT_LOBBY)); Packet packet( packetConnectLobby.action.magick, std::make_any(packetConnectLobby), diff --git a/src/Nitwork/NitworkServer.cpp b/src/Nitwork/NitworkServer.cpp index afdec4ea..f9cc9f9e 100644 --- a/src/Nitwork/NitworkServer.cpp +++ b/src/Nitwork/NitworkServer.cpp @@ -210,6 +210,7 @@ namespace Nitwork { Logger::error("Client already connected"); return; } + Logger::error("WTF WTF ICI"); _endpoints.emplace_back(endpoint); auto playerId = static_cast(_endpoints.size() - 1); auto &jsonInstance = Json::getInstance();