Fixed the Packet::type bug

In popNetworkPacket(), a second Packet p was being created, which was
destroyed when it went out of scope, and the original Packet p was being
returned.
This commit is contained in:
Kayne Ruse
2013-06-17 11:01:00 +10:00
parent d1aac9ffd8
commit 5b2fd80a61
+1 -8
View File
@@ -7,19 +7,12 @@
#include <deque>
#ifdef DEBUG
#include <iostream>
#endif
static SDL_sem* lock = SDL_CreateSemaphore(1);
static std::deque<Packet> queue;
int networkQueue(void*) {
UDPNetworkUtility* netUtil = ServiceLocator<UDPNetworkUtility>::Get();
#ifdef DEBUG
std::cout << "int networkQueue(void*) active" << std::endl;
#endif
for(;;) {
SDL_SemWait(lock);
while(netUtil->Receive()) {
@@ -46,7 +39,7 @@ Packet popNetworkPacket() {
SDL_SemWait(lock);
Packet p;
if (queue.size() > 0) {
Packet p = queue[0];
p = queue[0];
queue.pop_front();
}
SDL_SemPost(lock);