diff --git a/libs/common/network_queue.cpp b/libs/common/network_queue.cpp index 463dbad..c873732 100644 --- a/libs/common/network_queue.cpp +++ b/libs/common/network_queue.cpp @@ -13,10 +13,10 @@ static std::deque queue; int networkQueue(void*) { UDPNetworkUtility* netUtil = ServiceLocator::Get(); - Packet p; for(;;) { SDL_SemWait(lock); while(netUtil->Receive()) { + Packet p; memcpy(&p, netUtil->GetInData(), sizeof(Packet)); queue.push_back(p); } diff --git a/libs/common/packet_type.hpp b/libs/common/packet_type.hpp index 54845bd..358fc35 100644 --- a/libs/common/packet_type.hpp +++ b/libs/common/packet_type.hpp @@ -81,8 +81,8 @@ struct PlayerMove { }; union Packet { - Packet() {}; - PacketType type = PacketType::NONE; + Packet() { type = PacketType::NONE; }; + PacketType type; Ping ping; Pong pong; diff --git a/test/main.cpp b/test/main.cpp index cf90d1c..4a86fd0 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,19 +1,11 @@ #include "packet_type.hpp" -#include "service_locator.hpp" -#include "foobar.hpp" - -#include "vector2.hpp" #include + using namespace std; int main() { - ServiceLocator::Set(new int(42)); - ServiceLocator::Set(new Packet()); - - cout << FooBar() << endl; - - ServiceLocator::Set(nullptr); - ServiceLocator::Set(nullptr); + Packet p; + cout << int(p.type) << endl; return 0; } \ No newline at end of file