core/GameDataFetcher.cpp
changeset 2247 da4a6d013772
parent 2186 c991c043022d
child 2367 0a45bbad3bde
     1.1 --- a/core/GameDataFetcher.cpp	Tue Sep 02 06:01:12 2008 +0000
     1.2 +++ b/core/GameDataFetcher.cpp	Tue Sep 02 06:29:50 2008 +0000
     1.3 @@ -60,6 +60,7 @@
     1.4  #include "time.h"
     1.5  #include "TimerSys.h"
     1.6  #include "compat_wrappers.h"
     1.7 +#include "sm_stringutil.h"
     1.8  
     1.9  #define QUERY_MAX_LENGTH 1024
    1.10  
    1.11 @@ -71,6 +72,9 @@
    1.12  bool g_disableGameDataUpdate = false;
    1.13  bool g_restartAfterUpdate = false;
    1.14  
    1.15 +int g_serverPort = 6500;
    1.16 +char g_serverAddress[100] = "hayate.alliedmods.net";
    1.17 +
    1.18  void FetcherThread::RunThread( IThreadHandle *pHandle )
    1.19  {
    1.20  	char lock_path[PLATFORM_MAX_PATH];
    1.21 @@ -269,13 +273,13 @@
    1.22  	struct sockaddr_in local_addr;
    1.23  
    1.24  	local_addr.sin_family = AF_INET;
    1.25 -	local_addr.sin_port = htons((u_short)6500);
    1.26 +	local_addr.sin_port = htons((u_short)g_serverPort);
    1.27  
    1.28 -	he = gethostbyname("hayate.alliedmods.net");
    1.29 +	he = gethostbyname(g_serverAddress);
    1.30  
    1.31  	if (!he)
    1.32  	{
    1.33 -		if ((local_addr.sin_addr.s_addr = inet_addr("hayate.alliedmods.net")) == INADDR_NONE)
    1.34 +		if ((local_addr.sin_addr.s_addr = inet_addr(g_serverAddress)) == INADDR_NONE)
    1.35  		{
    1.36  			g_Logger.LogToOpenFile(logfile, "Couldnt locate address");
    1.37  			closesocket(socketDescriptor);
    1.38 @@ -645,6 +649,27 @@
    1.39  			return ConfigResult_Reject;
    1.40  		}
    1.41  
    1.42 +		if (strcmp(key, "AutoUpdateServer") == 0)
    1.43 +		{
    1.44 +			UTIL_Format(g_serverAddress, sizeof(g_serverAddress), "%s", value);
    1.45 +
    1.46 +			return ConfigResult_Accept;
    1.47 +		}
    1.48 +
    1.49 +		if (strcmp(key, "AutoUpdatePort") == 0)
    1.50 +		{
    1.51 +			int port = atoi(value);
    1.52 +
    1.53 +			if (!port)
    1.54 +			{
    1.55 +				return ConfigResult_Reject;
    1.56 +			}
    1.57 +
    1.58 +			g_serverPort = port;
    1.59 +
    1.60 +			return ConfigResult_Accept;
    1.61 +		}
    1.62 +
    1.63  		return ConfigResult_Ignore;
    1.64  	}
    1.65  } g_InitFetch;