Added amb1978 - Core.cfg now has parameters to set the gamedata auto-updater server and port.
authorMatt Woodrow <pred@alliedmods.net>
Tue Sep 02 06:29:50 2008 +0000 (2008-09-02)
changeset 2247da4a6d013772
parent 2246 b9bb53f4343f
child 2248 d433aa792147
Added amb1978 - Core.cfg now has parameters to set the gamedata auto-updater server and port.
configs/core.cfg
core/GameDataFetcher.cpp
     1.1 --- a/configs/core.cfg	Tue Sep 02 06:01:12 2008 +0000
     1.2 +++ b/configs/core.cfg	Tue Sep 02 06:29:50 2008 +0000
     1.3 @@ -102,4 +102,14 @@
     1.4  	 * The default value is "no". A value of "yes" will let the server automatically restart.
     1.5  	 */
     1.6  	"ForceRestartAfterUpdate"		"no"
     1.7 +
     1.8 +	/**
     1.9 +	 * Sets the server to connect to for auotmatic gamedata updates.
    1.10 +	 */
    1.11 +	"AutoUpdateServer"		"hayate.alliedmods.net"
    1.12 +
    1.13 +	/**
    1.14 +	 * Sets the port to connect to on the AutoUpdateServer server
    1.15 +	 */
    1.16 +	"AutoUpdatePort"			"6500"
    1.17  }
     2.1 --- a/core/GameDataFetcher.cpp	Tue Sep 02 06:01:12 2008 +0000
     2.2 +++ b/core/GameDataFetcher.cpp	Tue Sep 02 06:29:50 2008 +0000
     2.3 @@ -60,6 +60,7 @@
     2.4  #include "time.h"
     2.5  #include "TimerSys.h"
     2.6  #include "compat_wrappers.h"
     2.7 +#include "sm_stringutil.h"
     2.8  
     2.9  #define QUERY_MAX_LENGTH 1024
    2.10  
    2.11 @@ -71,6 +72,9 @@
    2.12  bool g_disableGameDataUpdate = false;
    2.13  bool g_restartAfterUpdate = false;
    2.14  
    2.15 +int g_serverPort = 6500;
    2.16 +char g_serverAddress[100] = "hayate.alliedmods.net";
    2.17 +
    2.18  void FetcherThread::RunThread( IThreadHandle *pHandle )
    2.19  {
    2.20  	char lock_path[PLATFORM_MAX_PATH];
    2.21 @@ -269,13 +273,13 @@
    2.22  	struct sockaddr_in local_addr;
    2.23  
    2.24  	local_addr.sin_family = AF_INET;
    2.25 -	local_addr.sin_port = htons((u_short)6500);
    2.26 +	local_addr.sin_port = htons((u_short)g_serverPort);
    2.27  
    2.28 -	he = gethostbyname("hayate.alliedmods.net");
    2.29 +	he = gethostbyname(g_serverAddress);
    2.30  
    2.31  	if (!he)
    2.32  	{
    2.33 -		if ((local_addr.sin_addr.s_addr = inet_addr("hayate.alliedmods.net")) == INADDR_NONE)
    2.34 +		if ((local_addr.sin_addr.s_addr = inet_addr(g_serverAddress)) == INADDR_NONE)
    2.35  		{
    2.36  			g_Logger.LogToOpenFile(logfile, "Couldnt locate address");
    2.37  			closesocket(socketDescriptor);
    2.38 @@ -645,6 +649,27 @@
    2.39  			return ConfigResult_Reject;
    2.40  		}
    2.41  
    2.42 +		if (strcmp(key, "AutoUpdateServer") == 0)
    2.43 +		{
    2.44 +			UTIL_Format(g_serverAddress, sizeof(g_serverAddress), "%s", value);
    2.45 +
    2.46 +			return ConfigResult_Accept;
    2.47 +		}
    2.48 +
    2.49 +		if (strcmp(key, "AutoUpdatePort") == 0)
    2.50 +		{
    2.51 +			int port = atoi(value);
    2.52 +
    2.53 +			if (!port)
    2.54 +			{
    2.55 +				return ConfigResult_Reject;
    2.56 +			}
    2.57 +
    2.58 +			g_serverPort = port;
    2.59 +
    2.60 +			return ConfigResult_Accept;
    2.61 +		}
    2.62 +
    2.63  		return ConfigResult_Ignore;
    2.64  	}
    2.65  } g_InitFetch;