Fixed segfault in common, changed casting of packets to static_cast

This required that I switch from using a char array for the packet buffers
to using malloc() and free(). They make more sense anyway, and I've
learned (or relearned) something about casting.
This commit is contained in:
Kayne Ruse
2014-06-12 03:47:49 +10:00
parent 13332bf3fc
commit a11867126c
7 changed files with 85 additions and 82 deletions
+4 -3
View File
@@ -86,10 +86,11 @@ void InCombat::FrameStart() {
void InCombat::Update(double delta) {
//suck in and process all waiting packets
char packetBuffer[MAX_PACKET_SIZE];
while(network.Receive(reinterpret_cast<SerialPacket*>(packetBuffer))) {
HandlePacket(reinterpret_cast<SerialPacket*>(packetBuffer));
SerialPacket* packetBuffer = static_cast<SerialPacket*>(malloc(MAX_PACKET_SIZE));
while(network.Receive(packetBuffer)) {
HandlePacket(packetBuffer);
}
free(static_cast<void*>(packetBuffer));
//TODO: more
}