foxygit / doom Log in
commit 19b8c7428afd6a42485a76bdf938e686e8450543
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Thu Feb 23 18:20:29 2006 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Thu Feb 23 18:20:29 2006 +0000

    Fix bugs in resend code for server->client data

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 377
---
 src/net_client.c | 15 +++++++++++----
 src/net_server.c | 11 ++++++++---
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/net_client.c b/src/net_client.c
index 2d0622a5..c8b08fb6 100644
--- a/src/net_client.c
+++ b/src/net_client.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*-
 //-----------------------------------------------------------------------------
 //
-// $Id: net_client.c 375 2006-02-22 18:35:55Z fraggle $
+// $Id: net_client.c 377 2006-02-23 18:20:29Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.28  2006/02/23 18:20:29  fraggle
+// Fix bugs in resend code for server->client data
+//
 // Revision 1.27  2006/02/22 18:35:55  fraggle
 // Packet resends for server->client gamedata
 //
@@ -552,12 +555,15 @@ static void NET_CL_SendResendRequest(int start, int end)
     net_packet_t *packet;
     unsigned int nowtime;
     int i;
+
+    //printf("CL: Send resend %i-%i\n", start, end);

     packet = NET_NewPacket(64);
     NET_WriteInt16(packet, NET_PACKET_TYPE_GAMEDATA_RESEND);
     NET_WriteInt32(packet, start);
-    NET_WriteInt8(packet, end - start - 1);
+    NET_WriteInt8(packet, end - start + 1);
     NET_Conn_SendPacket(&client_connection, packet);
+    NET_FreePacket(packet);

     nowtime = I_GetTimeMS();

@@ -567,7 +573,7 @@ static void NET_CL_SendResendRequest(int start, int end)
     {
         int index;

-        index = start - recvwindow_start;
+        index = i - recvwindow_start;

         if (index < 0 || index >= BACKUPTICS)
             continue;
@@ -631,6 +637,7 @@ static void NET_CL_CheckResends(void)

     if (resend_start >= 0)
     {
+        //printf("CL: resend request timed out: %i-%i\n", resend_start, resend_end);
         NET_CL_SendResendRequest(recvwindow_start + resend_start,
                                  recvwindow_start + resend_end);
     }
@@ -669,7 +676,7 @@ static void NET_CL_ParseGameData(net_packet_t *packet)

         index = seq - recvwindow_start + i;

-        if (!NET_ReadFullTiccmd(packet, &cmd))
+        if (!NET_ReadFullTiccmd(packet, &cmd, false))
         {
             return;
         }
diff --git a/src/net_server.c b/src/net_server.c
index 6cc35350..aedd5f19 100644
--- a/src/net_server.c
+++ b/src/net_server.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*-
 //-----------------------------------------------------------------------------
 //
-// $Id: net_server.c 375 2006-02-22 18:35:55Z fraggle $
+// $Id: net_server.c 377 2006-02-23 18:20:29Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.30  2006/02/23 18:20:29  fraggle
+// Fix bugs in resend code for server->client data
+//
 // Revision 1.29  2006/02/22 18:35:55  fraggle
 // Packet resends for server->client gamedata
 //
@@ -920,7 +923,7 @@ static void NET_SV_SendTics(net_client_t *client, int start, int end)

         // Add command

-        NET_WriteFullTiccmd(packet, cmd);
+        NET_WriteFullTiccmd(packet, cmd, false);
     }

     // Send packet
@@ -945,6 +948,8 @@ static void NET_SV_ParseResendRequest(net_packet_t *packet, net_client_t *client
         return;
     }

+    //printf("SV: %p: resend %i-%i\n", client, start, start+num_tics-1);
+
     // Resend those tics

     NET_SV_SendTics(client, start, start + num_tics - 1);
@@ -1124,7 +1129,7 @@ static void NET_SV_PumpSendQueue(net_client_t *client)
         }
     }

-    //printf("have complete ticcmd for %i\n", client->sendseq);
+    //printf("SV: have complete ticcmd for %i\n", client->sendseq);

     // We have all data we need to generate a command for this tic.