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>
|
#include <deque>
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#include <iostream>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static SDL_sem* lock = SDL_CreateSemaphore(1);
|
static SDL_sem* lock = SDL_CreateSemaphore(1);
|
||||||
|
|
||||||
static std::deque<Packet> queue;
|
static std::deque<Packet> queue;
|
||||||
|
|
||||||
int networkQueue(void*) {
|
int networkQueue(void*) {
|
||||||
UDPNetworkUtility* netUtil = ServiceLocator<UDPNetworkUtility>::Get();
|
UDPNetworkUtility* netUtil = ServiceLocator<UDPNetworkUtility>::Get();
|
||||||
#ifdef DEBUG
|
|
||||||
std::cout << "int networkQueue(void*) active" << std::endl;
|
|
||||||
#endif
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
SDL_SemWait(lock);
|
SDL_SemWait(lock);
|
||||||
while(netUtil->Receive()) {
|
while(netUtil->Receive()) {
|
||||||
@@ -46,7 +39,7 @@ Packet popNetworkPacket() {
|
|||||||
SDL_SemWait(lock);
|
SDL_SemWait(lock);
|
||||||
Packet p;
|
Packet p;
|
||||||
if (queue.size() > 0) {
|
if (queue.size() > 0) {
|
||||||
Packet p = queue[0];
|
p = queue[0];
|
||||||
queue.pop_front();
|
queue.pop_front();
|
||||||
}
|
}
|
||||||
SDL_SemPost(lock);
|
SDL_SemPost(lock);
|
||||||
|
|||||||
Reference in New Issue
Block a user