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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user