From 353ad97413cb7bf5859e1a5c829c7b31966e89a8 Mon Sep 17 00:00:00 2001
From: Yukita Mayako <catgirl@goddess.moe>
Date: Mon, 22 Feb 2016 21:58:04 -0500
Subject: [PATCH] Removed BACKUPTICS and packettype_t.

---
 src/d_clisrv.c | 52 ++++++++++----------------------------------------
 src/d_clisrv.h | 28 ---------------------------
 src/d_enet.c   | 14 +-------------
 src/d_enet.h   |  5 -----
 src/d_netfil.c |  2 +-
 src/doomstat.h |  2 +-
 src/g_game.c   |  4 +---
 src/p_setup.c  |  3 +--
 8 files changed, 15 insertions(+), 95 deletions(-)

diff --git a/src/d_clisrv.c b/src/d_clisrv.c
index 06ee96689b..1b9f756250 100644
--- a/src/d_clisrv.c
+++ b/src/d_clisrv.c
@@ -113,7 +113,7 @@ typedef struct textcmdtic_s
 	struct textcmdtic_s *next;
 } textcmdtic_t;
 
-ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS];
+ticcmd_t netcmds[MAXPLAYERS];
 static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL};
 
 
@@ -210,40 +210,9 @@ UINT8 GetFreeXCmdSize(void)
 }
 
 // Frees all textcmd memory for the specified tic
-static void D_FreeTextcmd(tic_t tic)
+static void D_FreeTextcmd(void)
 {
-	textcmdtic_t **tctprev = &textcmds[tic & (TEXTCMD_HASH_SIZE - 1)];
-	textcmdtic_t *textcmdtic = *tctprev;
-
-	while (textcmdtic && textcmdtic->tic != tic)
-	{
-		tctprev = &textcmdtic->next;
-		textcmdtic = textcmdtic->next;
-	}
-
-	if (textcmdtic)
-	{
-		INT32 i;
-
-		// Remove this tic from the list.
-		*tctprev = textcmdtic->next;
-
-		// Free all players.
-		for (i = 0; i < TEXTCMD_HASH_SIZE; i++)
-		{
-			textcmdplayer_t *textcmdplayer = textcmdtic->playercmds[i];
-
-			while (textcmdplayer)
-			{
-				textcmdplayer_t *tcpnext = textcmdplayer->next;
-				Z_Free(textcmdplayer);
-				textcmdplayer = tcpnext;
-			}
-		}
-
-		// Free this tic's own memory.
-		Z_Free(textcmdtic);
-	}
+	// NET TODO
 }
 
 // Gets the buffer for the specified ticcmd, or NULL if there isn't one
@@ -342,26 +311,26 @@ static void ExtraDataTicker(void)
 							DEBFILE(va("player %d kicked [gametic=%u] reason as follows:\n", i, gametic));
 						}
 						CONS_Alert(CONS_WARNING, M_GetText("Got unknown net command [%s]=%d (max %d)\n"), sizeu1(curpos - bufferstart), *curpos, bufferstart[0]);
-						D_FreeTextcmd(gametic);
+						D_FreeTextcmd();
 						return;
 					}
 				}
 			}
 		}
 
-	D_FreeTextcmd(gametic);
+	D_FreeTextcmd();
 }
 
-static void D_Clearticcmd(tic_t tic)
+static void D_Clearticcmd(void)
 {
 	INT32 i;
 
-	D_FreeTextcmd(tic);
+	D_FreeTextcmd();
 
 	for (i = 0; i < MAXPLAYERS; i++)
-		netcmds[tic%BACKUPTICS][i].angleturn = 0;
+		netcmds[i].angleturn = 0;
 
-	DEBFILE(va("clear tic %5u (%2u)\n", tic, tic%BACKUPTICS));
+	DEBFILE(va("clear tic\n"));
 }
 
 // -----------------------------------------------------------------
@@ -1986,8 +1955,7 @@ void SV_StopServer(void)
 	gamestate = wipegamestate = GS_NULL;
 
 
-	for (i = 0; i < BACKUPTICS; i++)
-		D_Clearticcmd(i);
+	D_Clearticcmd();
 
 	consoleplayer = 0;
 	cl_mode = cl_searching;
diff --git a/src/d_clisrv.h b/src/d_clisrv.h
index f14271aff6..d762108645 100644
--- a/src/d_clisrv.h
+++ b/src/d_clisrv.h
@@ -25,35 +25,7 @@
 //  be transmitted.
 
 // Networking and tick handling related.
-#define BACKUPTICS 32
 #define MAXTEXTCMD 256
-//
-// Packet structure
-//
-typedef enum {
-	PT_NOTHING,       // To send a nop through the network. ^_~
-	PT_SERVERCFG,     // Server config used in start game
-	                  // This is a positive response to a CLIENTJOIN request.
-	PT_SERVERREFUSE,  // Server refuses joiner (reason inside).
-	PT_SERVERSHUTDOWN,// Server is exiting.
-	PT_CLIENTQUIT,    // Client closes the connection.
-
-	PT_ASKINFO,       // Anyone can ask info of the server.
-	PT_SERVERINFO,    // Send game & server info (gamespy).
-	PT_PLAYERINFO,    // Send information for players in game (gamespy).
-	PT_REQUESTFILE,   // Client requests a file transfer
-	PT_ASKINFOVIAMS,  // Packet from the MS requesting info be sent to new client.
-	                  // If this ID changes, update masterserver definition.
-
-	PT_CANFAIL = 0x40, // This is kind of a priority. Anything >= PT_CANFAIL
-	                   // allows HSendPacket(,true,,) to return false.
-	                   // In addition, this packet can't occupy all the available slots.
-
-	PT_FILEFRAGMENT = PT_CANFAIL, // A part of a file.
-
-	PT_CLIENTJOIN,    // Client wants to join; used in start game.
-	PT_NODETIMEOUT,   // Packet sent to self if the connection times out.
-} packettype_t;
 
 #if defined(_MSC_VER)
 #pragma pack(1)
diff --git a/src/d_enet.c b/src/d_enet.c
index 65ef0fecdd..8bfdf22eb9 100644
--- a/src/d_enet.c
+++ b/src/d_enet.c
@@ -4,6 +4,7 @@
 
 boolean Net_GetNetStat(void)
 {
+	// set getbps, sendbps, gamelostpercent, lostpercent, etc.
 	return false;
 }
 
@@ -16,19 +17,6 @@ boolean Net_AllAckReceived(void)
 	return true;
 }
 
-// if reliable return true if packet sent, 0 else
-boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum,
-	size_t packetlength)
-{
-	return false;
-}
-
-boolean HGetPacket(void)
-{
-	return false;
-}
-
-
 void D_SetDoomcom(void)
 {
 	//net_nodecount = net_playercount = 0;
diff --git a/src/d_enet.h b/src/d_enet.h
index b84ab8ada0..dd340ec7e4 100644
--- a/src/d_enet.h
+++ b/src/d_enet.h
@@ -4,11 +4,6 @@
 boolean Net_GetNetStat(void);
 void Net_AckTicker(void);
 boolean Net_AllAckReceived(void);
-
-// if reliable return true if packet sent, 0 else
-boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum,
-	size_t packetlength);
-boolean HGetPacket(void);
 void D_SetDoomcom(void);
 void D_SaveBan(void);
 boolean D_CheckNetGame(void);
diff --git a/src/d_netfil.c b/src/d_netfil.c
index 1358b84c23..6c7be73140 100644
--- a/src/d_netfil.c
+++ b/src/d_netfil.c
@@ -478,7 +478,7 @@ void CloseNetFile(void)
 		}
 
 	// remove FILEFRAGMENT from acknledge list
-	Net_AbortPacketType(PT_FILEFRAGMENT);
+	//Net_AbortPacketType(PT_FILEFRAGMENT);
 }
 
 // functions cut and pasted from doomatic :)
diff --git a/src/doomstat.h b/src/doomstat.h
index 44cf6feaab..a842f69c3c 100644
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -482,7 +482,7 @@ extern boolean singletics;
 extern consvar_t cv_timetic; // display high resolution timer
 extern consvar_t cv_forceskin; // force clients to use the server's skin
 extern consvar_t cv_downloading; // allow clients to downloading WADs.
-extern ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS];
+extern ticcmd_t netcmds[MAXPLAYERS];
 extern INT32 adminplayer, serverplayer;
 
 /// \note put these in d_clisrv outright?
diff --git a/src/g_game.c b/src/g_game.c
index 423be93389..a7b957d6f1 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -1875,13 +1875,11 @@ void G_Ticker(boolean run)
 			default: I_Error("gameaction = %d\n", gameaction);
 		}
 
-	buf = gametic % BACKUPTICS;
-
 	// read/write demo and check turbo cheat
 	for (i = 0; i < MAXPLAYERS; i++)
 	{
 		if (playeringame[i])
-			G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1);
+			G_CopyTiccmd(&players[i].cmd, &netcmds[i], 1);
 	}
 
 	// do main actions
diff --git a/src/p_setup.c b/src/p_setup.c
index 3491669c7d..c2b8b875c1 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -2803,11 +2803,10 @@ boolean P_SetupLevel(boolean skipprecip)
 	skyVisible = true; // assume the skybox is visible on level load.
 	if (loadprecip) // uglier hack
 	{ // to make a newly loaded level start on the second frame.
-		INT32 buf = gametic % BACKUPTICS;
 		for (i = 0; i < MAXPLAYERS; i++)
 		{
 			if (playeringame[i])
-				G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1);
+				G_CopyTiccmd(&players[i].cmd, &netcmds[i], 1);
 		}
 		P_PreTicker(2);
 #ifdef HAVE_BLUA
-- 
GitLab