Changeset - r785:98d70fb62afe
[Not reviewed]
master
0 6 0
truelight - 19 years ago 2004-12-23 17:37:26
truelight@openttd.org
(svn r1252) -Add: [Network] With 'set restart_game_date' you can set the date for in
which year the server must restart hisself. (0 = disabled, default value)
6 files changed with 50 insertions and 2 deletions:
0 comments (0 inline, 0 general)
console_cmds.c
Show inline comments
 
@@ -834,12 +834,29 @@ DEF_CONSOLE_CMD(ConSet) {
 
			IConsolePrintF(_iconsole_color_default, "Current autoclean-unprotected is '%d'", _network_autoclean_unprotected);
 
			IConsolePrint(_iconsole_color_warning, "Usage: set autoclean_unprotected <months>.");
 
		}
 
		return NULL;
 
	}
 

	
 
	// setting the server auto restart date
 
	if (strcmp(argv[1],"restart_game_date") == 0) {
 
		if (!_network_server) {
 
			IConsolePrintF(_iconsole_color_error, "You are not the server");
 
			return NULL;
 
		}
 
		if (argc == 3) {
 
			_network_restart_game_date = atoi(argv[2]);
 
			IConsolePrintF(_iconsole_color_warning, "Restart Game Date changed to '%d'", _network_restart_game_date);
 
		} else {
 
			IConsolePrintF(_iconsole_color_default, "Current Restart Game Date is '%d'", _network_restart_game_date);
 
			IConsolePrint(_iconsole_color_warning, "Usage: set restart_game_date <year>. '0' means disabled.");
 
			IConsolePrint(_iconsole_color_warning, " Auto-restart the server when 1 jan of this year is reached (e.g.: 2030).");
 
		}
 
		return NULL;
 
	}
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
	// Patch-options
 
	if (strcmp(argv[1],"patch") == 0) {
 
		if (_networking && !_network_server) {
 
			IConsolePrintF(_iconsole_color_error, "You are not the server");
 
@@ -865,12 +882,13 @@ DEF_CONSOLE_CMD(ConSet) {
 
	IConsolePrint(_iconsole_color_error, " - name \"<playername>\"");
 
	IConsolePrint(_iconsole_color_error, " - server_name \"<name>\"");
 
	IConsolePrint(_iconsole_color_error, " - server_advertise on/off");
 
	IConsolePrint(_iconsole_color_error, " - server_bind_ip <ip>");
 
	IConsolePrint(_iconsole_color_error, " - server_port <port>");
 
	IConsolePrint(_iconsole_color_error, " - server_pw \"<password>\"");
 
	IConsolePrint(_iconsole_color_error, " - restart_game_date \"<year>\"");
 
#endif /* ENABLE_NETWORK */
 
	IConsolePrint(_iconsole_color_error, " - patch <patch_name> [<value>]");
 

	
 
	return NULL;
 
}
 

	
misc.c
Show inline comments
 
@@ -126,13 +126,13 @@ void CSleep(int milliseconds)
 
		#if !defined(__BEOS__) && !defined(__AMIGA__)
 
			usleep(milliseconds * 1000);
 
		#endif
 
		#ifdef __BEOS__
 
			snooze(milliseconds * 1000);
 
		#endif
 
		#if defined(__AMIGA__) 
 
		#if defined(__AMIGA__)
 
		{
 
			ULONG signals;
 
			ULONG TimerSigBit = 1 << TimerPort->mp_SigBit;
 

	
 
			// send IORequest
 
			TimerRequest->tr_node.io_Command = TR_ADDREQUEST;
 
@@ -142,13 +142,13 @@ void CSleep(int milliseconds)
 

	
 
			if (!((signals = Wait(TimerSigBit | SIGBREAKF_CTRL_C)) & TimerSigBit) ) {
 
				AbortIO((struct IORequest *)TimerRequest);
 
			}
 
			WaitIO((struct IORequest *)TimerRequest);
 
		}
 
		#endif // __AMIGA__ 
 
		#endif // __AMIGA__
 
	#endif
 
}
 

	
 
void InitializeClearLand();
 
void InitializeRail();
 
void InitializeRailGui();
 
@@ -687,12 +687,16 @@ void IncreaseDate()
 

	
 
	PlayersYearlyLoop();
 
	TrainsYearlyLoop();
 
	RoadVehiclesYearlyLoop();
 
	AircraftYearlyLoop();
 
	ShipsYearlyLoop();
 
#ifdef ENABLE_NETWORK
 
	if (_network_server)
 
		NetworkServerYearlyLoop();
 
#endif /* ENABLE_NETWORK */
 

	
 
	/* check if we reached 2090, that's the maximum year. */
 
	if (_cur_year == 171) {
 
		Vehicle *v;
 
		_cur_year = 170;
 
		_date = 62093;
network.h
Show inline comments
 
@@ -181,12 +181,14 @@ VARDEF uint16 _network_last_advertise_da
 
VARDEF uint8 _network_advertise_retries;
 

	
 
VARDEF bool _network_autoclean_companies;
 
VARDEF uint8 _network_autoclean_unprotected; // Remove a company after X months
 
VARDEF uint8 _network_autoclean_protected;   // Unprotect a company after X months
 

	
 
VARDEF uint16 _network_restart_game_date;    // If this year is reached, the server automaticly restarts
 

	
 
NetworkGameList *NetworkQueryServer(const byte* host, unsigned short port, bool game_info);
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
// Those variables must always be registered!
 
#define MAX_SAVED_SERVERS 10
network_server.c
Show inline comments
 
@@ -1256,12 +1256,29 @@ void NetworkUpdateClientInfo(uint16 clie
 

	
 
	FOR_ALL_CLIENTS(cs) {
 
		SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, ci);
 
	}
 
}
 

	
 
extern void SwitchMode(int new_mode);
 

	
 
/* Check if we want to restart the map */
 
static void NetworkCheckRestartMap()
 
{
 
	if (_network_restart_game_date != 0 && _cur_year + 1920 >= _network_restart_game_date) {
 
		_docommand_recursive = 0;
 

	
 
		DEBUG(net, 0)("Auto-restarting map. Year %d reached.", _cur_year + 1920);
 

	
 
		_random_seeds[0][0] = Random();
 
		_random_seeds[0][1] = InteractiveRandom();
 

	
 
		SwitchMode(SM_NEWGAME);
 
	}
 
}
 

	
 
/* Check if the server has autoclean_companies activated
 
    Two things happen:
 
      1) If a company is not protected, it is closed after 1 year (for example)
 
      2) If a company is protected, protection is disabled after 3 years (for example)
 
           (and item 1. happens a year later) */
 
static void NetworkAutoCleanCompanies()
 
@@ -1474,12 +1491,17 @@ void NetworkServer_Tick(void)
 
#endif
 

	
 
	/* See if we need to advertise */
 
	NetworkUDPAdvertise();
 
}
 

	
 
void NetworkServerYearlyLoop(void)
 
{
 
	NetworkCheckRestartMap();
 
}
 

	
 
void NetworkServerMonthlyLoop(void)
 
{
 
	NetworkAutoCleanCompanies();
 
}
 

	
 
#endif /* ENABLE_NETWORK */
network_server.h
Show inline comments
 
@@ -12,10 +12,11 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_NE
 
bool NetworkFindName(char new_name[NETWORK_NAME_LENGTH]);
 
void NetworkServer_HandleChat(NetworkAction action, DestType desttype, int dest, const char *msg, byte from_index);
 

	
 
bool NetworkServer_ReadPackets(NetworkClientState *cs);
 
void NetworkServer_Tick(void);
 
void NetworkServerMonthlyLoop(void);
 
void NetworkServerYearlyLoop(void);
 

	
 
#endif /* ENABLE_NETWORK */
 

	
 
#endif // NETWORK_SERVER_H
settings.c
Show inline comments
 
@@ -763,12 +763,13 @@ static const SettingDesc network_setting
 
	{"server_name",			SDT_STRINGBUF | (lengthof(_network_server_name) << 16), NULL, &_network_server_name, NULL},
 
	{"connect_to_ip",		SDT_STRINGBUF | (lengthof(_network_default_ip) << 16), NULL, &_network_default_ip, NULL},
 
	{"network_id",			SDT_STRINGBUF | (lengthof(_network_unique_id) << 16), NULL, &_network_unique_id, NULL},
 
	{"autoclean_companies", SDT_BOOL, (void*)false, &_network_autoclean_companies, NULL},
 
	{"autoclean_unprotected", SDT_UINT8, (void*)12, &_network_autoclean_unprotected, NULL},
 
	{"autoclean_protected", SDT_UINT8, (void*)36, &_network_autoclean_protected, NULL},
 
	{"restart_game_date", SDT_UINT16, (void*)0, &_network_restart_game_date, NULL},
 
	{NULL,							0,											NULL,					NULL,										NULL}
 
};
 
#endif /* ENABLE_NETWORK */
 

	
 
static const SettingDesc debug_settings[] = {
 
	{"savedump_path",		SDT_STRINGBUF | (lengthof(_savedump_path)<<16) | SDT_NOSAVE, NULL, _savedump_path, NULL},
0 comments (0 inline, 0 general)