# HG changeset patch
# User Adam Kaminski <kaminskiadam9@gmail.com>
# Date 1630928351 14400
#      Mon Sep 06 07:39:11 2021 -0400
# Node ID 05f4bfcd25062015acb60a6ac408d0eecb46fb12
# Parent  af0ad1affaf8fc12129e588eda5fac98cff626e1
Removed some duplicate code.

diff -r af0ad1affaf8 -r 05f4bfcd2506 src/cl_main.cpp
--- a/src/cl_main.cpp	Sun Sep 05 21:12:34 2021 -0400
+++ b/src/cl_main.cpp	Mon Sep 06 07:39:11 2021 -0400
@@ -421,13 +421,30 @@
 
 //*****************************************************************************
 //
+static void client_ResetValuesOnConnection( void )
+{
+	UCVarValue Val;
+
+	// [AK] Reset the map rotation before we connect to the server.
+	MAPROTATION_Construct( );
+
+	// Make sure cheats are off.
+	Val.Bool = false;
+	sv_cheats.ForceSet( Val, CVAR_Bool );
+	am_cheat = 0;
+
+	// Make sure our visibility is normal.
+	R_SetVisibility( 8.0f );
+}
+
+//*****************************************************************************
+//
 void CLIENT_Construct( void )
 {
 	const char	*pszPort;
 	const char	*pszIPAddress;
 	const char	*pszDemoName;
 	USHORT		usPort;
-	UCVarValue	Val;
 
 	// Start off as being disconnected.
 	g_ConnectionState = CTS_DISCONNECTED;
@@ -473,16 +490,7 @@
 		// Put the game in client mode.
 		NETWORK_SetState( NETSTATE_CLIENT );
 
-		// [AK] Reset the map rotation before we connect to the server.
-		MAPROTATION_Construct( );
-
-		// Make sure cheats are off.
-		Val.Bool = false;
-		sv_cheats.ForceSet( Val, CVAR_Bool );
-		am_cheat = 0;
-
-		// Make sure our visibility is normal.
-		R_SetVisibility( 8.0f );
+		client_ResetValuesOnConnection();
 
 		CLIENT_ClearAllPlayers();
 
@@ -9317,7 +9325,6 @@
 CCMD( connect )
 {
 	const char	*pszDemoName;
-	UCVarValue	Val;
 
 	// Servers can't connect to other servers!
 	if ( NETWORK_GetState( ) == NETSTATE_SERVER )
@@ -9342,16 +9349,7 @@
 	if ( M_InServerSetupMenu( ))
 		M_SetMenu( NAME_ZA_RconLoginMenu );
 
-	// [AK] Reset the map rotation before we connect to the server.
-	MAPROTATION_Construct( );
-
-	// Make sure cheats are off.
-	Val.Bool = false;
-	sv_cheats.ForceSet( Val, CVAR_Bool );
-	am_cheat = 0;
-
-	// Make sure our visibility is normal.
-	R_SetVisibility( 8.0f );
+	client_ResetValuesOnConnection( );
 
 	// Create a server IP from the given string.
 	g_AddressServer.LoadFromString( argv[1] );
@@ -9412,8 +9410,6 @@
 //
 CCMD( reconnect )
 {
-	UCVarValue	Val;
-
 	// If we're in the middle of a game, we first need to disconnect from the server.
 	if ( g_ConnectionState != CTS_DISCONNECTED )
 		CLIENT_QuitNetworkGame( NULL );
@@ -9432,16 +9428,7 @@
 	if ( M_InServerSetupMenu( ))
 		M_SetMenu( NAME_ZA_RconLoginMenu );
 
-	// [AK] Reset the map rotation before we reconnect to the server.
-	MAPROTATION_Construct( );
-
-	// Make sure cheats are off.
-	Val.Bool = false;
-	sv_cheats.ForceSet( Val, CVAR_Bool );
-	am_cheat = 0;
-
-	// Make sure our visibility is normal.
-	R_SetVisibility( 8.0f );
+	client_ResetValuesOnConnection( );
 
 	// Set the address of the server we're trying to connect to to the previously connected to server.
 	g_AddressServer = g_AddressLastConnected;