Fixed a bug in deserializePacket()

This commit is contained in:
Kayne Ruse
2014-11-26 07:51:24 +11:00
parent 01461deaa5
commit 584b6ea303
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -95,7 +95,7 @@ void deserializePacket(void* buffer, SerialPacketBase* packet) {
SerialPacketType type;
memcpy(&type, buffer, sizeof(SerialPacketType));
switch(packet->type) {
switch(type) {
case SerialPacketType::PING:
case SerialPacketType::PONG:
case SerialPacketType::BROADCAST_REQUEST:
+8
View File
@@ -163,11 +163,19 @@ void ServerApplication::Init(int argc, char* argv[]) {
void ServerApplication::Proc() {
SerialPacket* packetBuffer = reinterpret_cast<SerialPacket*>(new char[MAX_PACKET_SIZE]);
memset(packetBuffer, 0, MAX_PACKET_SIZE); //zero the buffer
while(running) {
//suck in the waiting packets & process them
while(UDPNetworkUtility::GetSingleton().Receive(packetBuffer)) {
try {
HandlePacket(packetBuffer);
}
catch(std::exception& e) {
std::cerr << "HandlePacket Error: " << e.what() << std::endl;
}
memset(packetBuffer, 0, MAX_PACKET_SIZE); //reset the buffer
}
//update the internals
//...