DEADSOFTWARE

more buffer fixes (?)
[d2df-sdl.git] / src / game / g_nethandler.pas
index f505d62ecc848f9d4812fb6fbfcebea405a38149..67b50dd928a87af7ac0e0ac768a39f61e64da93c 100644 (file)
@@ -42,6 +42,8 @@ begin
   while RawPos < P^.dataLength do
   begin
     Len := e_Raw_Read_Word(B);
+    if Len = 0 then break;
+
     MID := e_Raw_Read_Byte(B);
     case MID of
       NET_MSG_CHAT:   MC_RECV_Chat(B);
@@ -103,15 +105,21 @@ begin
   while RawPos < P^.dataLength do
   begin
     Len := e_Raw_Read_Word(B);
+    if Len = 0 then break;
+
     MID := e_Raw_Read_Byte(B);
     case MID of
       NET_MSG_GEVENT: MC_RECV_GameEvent(B);
       NET_MSG_GSET:   MC_RECV_GameSettings(B);
 
-      NET_MSG_PLR:    if NetState <> NET_STATE_AUTH then MC_RECV_PlayerCreate(B);
-      NET_MSG_PLRDEL: if NetState <> NET_STATE_AUTH then MC_RECV_PlayerDelete(B);
+      NET_MSG_PLR:
+        if NetState <> NET_STATE_AUTH then MC_RECV_PlayerCreate(B)
+        else RawPos := RawPos + Len-1;
+      NET_MSG_PLRDEL: 
+        if NetState <> NET_STATE_AUTH then MC_RECV_PlayerDelete(B)
+        else RawPos := RawPos + Len-1;
 
-      else RawPos := RawPos + Len;
+      else RawPos := RawPos + Len-1;
     end;
   end;
 
@@ -132,6 +140,8 @@ begin
   while RawPos < P^.dataLength do
   begin
     Len := e_Raw_Read_Word(B);
+    if Len = 0 then break;
+
     MID := e_Raw_Read_Byte(B);
     case MID of
       NET_MSG_INFO: MH_RECV_Info(S, B);