mirror of https://github.com/OpenTTD/OpenTTD.git
(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)
This commit is contained in:
parent
3672ae1118
commit
c9645885d0
|
@ -837,6 +837,23 @@ DEF_CONSOLE_CMD(ConSet) {
|
||||||
return NULL;
|
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 */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
||||||
// Patch-options
|
// Patch-options
|
||||||
|
@ -868,6 +885,7 @@ DEF_CONSOLE_CMD(ConSet) {
|
||||||
IConsolePrint(_iconsole_color_error, " - server_bind_ip <ip>");
|
IConsolePrint(_iconsole_color_error, " - server_bind_ip <ip>");
|
||||||
IConsolePrint(_iconsole_color_error, " - server_port <port>");
|
IConsolePrint(_iconsole_color_error, " - server_port <port>");
|
||||||
IConsolePrint(_iconsole_color_error, " - server_pw \"<password>\"");
|
IConsolePrint(_iconsole_color_error, " - server_pw \"<password>\"");
|
||||||
|
IConsolePrint(_iconsole_color_error, " - restart_game_date \"<year>\"");
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
IConsolePrint(_iconsole_color_error, " - patch <patch_name> [<value>]");
|
IConsolePrint(_iconsole_color_error, " - patch <patch_name> [<value>]");
|
||||||
|
|
||||||
|
|
8
misc.c
8
misc.c
|
@ -129,7 +129,7 @@ void CSleep(int milliseconds)
|
||||||
#ifdef __BEOS__
|
#ifdef __BEOS__
|
||||||
snooze(milliseconds * 1000);
|
snooze(milliseconds * 1000);
|
||||||
#endif
|
#endif
|
||||||
#if defined(__AMIGA__)
|
#if defined(__AMIGA__)
|
||||||
{
|
{
|
||||||
ULONG signals;
|
ULONG signals;
|
||||||
ULONG TimerSigBit = 1 << TimerPort->mp_SigBit;
|
ULONG TimerSigBit = 1 << TimerPort->mp_SigBit;
|
||||||
|
@ -145,7 +145,7 @@ void CSleep(int milliseconds)
|
||||||
}
|
}
|
||||||
WaitIO((struct IORequest *)TimerRequest);
|
WaitIO((struct IORequest *)TimerRequest);
|
||||||
}
|
}
|
||||||
#endif // __AMIGA__
|
#endif // __AMIGA__
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -690,6 +690,10 @@ void IncreaseDate()
|
||||||
RoadVehiclesYearlyLoop();
|
RoadVehiclesYearlyLoop();
|
||||||
AircraftYearlyLoop();
|
AircraftYearlyLoop();
|
||||||
ShipsYearlyLoop();
|
ShipsYearlyLoop();
|
||||||
|
#ifdef ENABLE_NETWORK
|
||||||
|
if (_network_server)
|
||||||
|
NetworkServerYearlyLoop();
|
||||||
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
||||||
/* check if we reached 2090, that's the maximum year. */
|
/* check if we reached 2090, that's the maximum year. */
|
||||||
if (_cur_year == 171) {
|
if (_cur_year == 171) {
|
||||||
|
|
|
@ -184,6 +184,8 @@ VARDEF bool _network_autoclean_companies;
|
||||||
VARDEF uint8 _network_autoclean_unprotected; // Remove a company after X months
|
VARDEF uint8 _network_autoclean_unprotected; // Remove a company after X months
|
||||||
VARDEF uint8 _network_autoclean_protected; // Unprotect 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);
|
NetworkGameList *NetworkQueryServer(const byte* host, unsigned short port, bool game_info);
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
|
@ -1259,6 +1259,23 @@ void NetworkUpdateClientInfo(uint16 client_index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
/* Check if the server has autoclean_companies activated
|
||||||
Two things happen:
|
Two things happen:
|
||||||
1) If a company is not protected, it is closed after 1 year (for example)
|
1) If a company is not protected, it is closed after 1 year (for example)
|
||||||
|
@ -1477,6 +1494,11 @@ void NetworkServer_Tick(void)
|
||||||
NetworkUDPAdvertise();
|
NetworkUDPAdvertise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkServerYearlyLoop(void)
|
||||||
|
{
|
||||||
|
NetworkCheckRestartMap();
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkServerMonthlyLoop(void)
|
void NetworkServerMonthlyLoop(void)
|
||||||
{
|
{
|
||||||
NetworkAutoCleanCompanies();
|
NetworkAutoCleanCompanies();
|
||||||
|
|
|
@ -15,6 +15,7 @@ void NetworkServer_HandleChat(NetworkAction action, DestType desttype, int dest,
|
||||||
bool NetworkServer_ReadPackets(NetworkClientState *cs);
|
bool NetworkServer_ReadPackets(NetworkClientState *cs);
|
||||||
void NetworkServer_Tick(void);
|
void NetworkServer_Tick(void);
|
||||||
void NetworkServerMonthlyLoop(void);
|
void NetworkServerMonthlyLoop(void);
|
||||||
|
void NetworkServerYearlyLoop(void);
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
||||||
|
|
|
@ -766,6 +766,7 @@ static const SettingDesc network_settings[] = {
|
||||||
{"autoclean_companies", SDT_BOOL, (void*)false, &_network_autoclean_companies, NULL},
|
{"autoclean_companies", SDT_BOOL, (void*)false, &_network_autoclean_companies, NULL},
|
||||||
{"autoclean_unprotected", SDT_UINT8, (void*)12, &_network_autoclean_unprotected, NULL},
|
{"autoclean_unprotected", SDT_UINT8, (void*)12, &_network_autoclean_unprotected, NULL},
|
||||||
{"autoclean_protected", SDT_UINT8, (void*)36, &_network_autoclean_protected, 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}
|
{NULL, 0, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
Loading…
Reference in New Issue