src/network/network_server.cpp
changeset 6247 7d81e3a5d803
parent 6235 a4ea32acd914
child 6252 691c889970d6
equal deleted inserted replaced
6246:75451000349d 6247:7d81e3a5d803
  1226 
  1226 
  1227 // If this fails, check the array above with network_data.h
  1227 // If this fails, check the array above with network_data.h
  1228 assert_compile(lengthof(_network_server_packet) == PACKET_END);
  1228 assert_compile(lengthof(_network_server_packet) == PACKET_END);
  1229 
  1229 
  1230 // This update the company_info-stuff
  1230 // This update the company_info-stuff
  1231 void NetworkPopulateCompanyInfo(void)
  1231 void NetworkPopulateCompanyInfo()
  1232 {
  1232 {
  1233 	char password[NETWORK_PASSWORD_LENGTH];
  1233 	char password[NETWORK_PASSWORD_LENGTH];
  1234 	const Player *p;
  1234 	const Player *p;
  1235 	const Vehicle *v;
  1235 	const Vehicle *v;
  1236 	const Station *s;
  1236 	const Station *s;
  1353 		SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, ci);
  1353 		SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, ci);
  1354 	}
  1354 	}
  1355 }
  1355 }
  1356 
  1356 
  1357 /* Check if we want to restart the map */
  1357 /* Check if we want to restart the map */
  1358 static void NetworkCheckRestartMap(void)
  1358 static void NetworkCheckRestartMap()
  1359 {
  1359 {
  1360 	if (_network_restart_game_year != 0 && _cur_year >= _network_restart_game_year) {
  1360 	if (_network_restart_game_year != 0 && _cur_year >= _network_restart_game_year) {
  1361 		DEBUG(net, 0, "Auto-restarting map. Year %d reached", _cur_year);
  1361 		DEBUG(net, 0, "Auto-restarting map. Year %d reached", _cur_year);
  1362 
  1362 
  1363 		StartNewGameWithoutGUI(GENERATE_NEW_SEED);
  1363 		StartNewGameWithoutGUI(GENERATE_NEW_SEED);
  1367 /* Check if the server has autoclean_companies activated
  1367 /* Check if the server has autoclean_companies activated
  1368     Two things happen:
  1368     Two things happen:
  1369       1) If a company is not protected, it is closed after 1 year (for example)
  1369       1) If a company is not protected, it is closed after 1 year (for example)
  1370       2) If a company is protected, protection is disabled after 3 years (for example)
  1370       2) If a company is protected, protection is disabled after 3 years (for example)
  1371            (and item 1. happens a year later) */
  1371            (and item 1. happens a year later) */
  1372 static void NetworkAutoCleanCompanies(void)
  1372 static void NetworkAutoCleanCompanies()
  1373 {
  1373 {
  1374 	NetworkTCPSocketHandler *cs;
  1374 	NetworkTCPSocketHandler *cs;
  1375 	const NetworkClientInfo *ci;
  1375 	const NetworkClientInfo *ci;
  1376 	const Player *p;
  1376 	const Player *p;
  1377 	bool clients_in_company[MAX_PLAYERS];
  1377 	bool clients_in_company[MAX_PLAYERS];
  1562 
  1562 
  1563 	/* See if we need to advertise */
  1563 	/* See if we need to advertise */
  1564 	NetworkUDPAdvertise();
  1564 	NetworkUDPAdvertise();
  1565 }
  1565 }
  1566 
  1566 
  1567 void NetworkServerYearlyLoop(void)
  1567 void NetworkServerYearlyLoop()
  1568 {
  1568 {
  1569 	NetworkCheckRestartMap();
  1569 	NetworkCheckRestartMap();
  1570 }
  1570 }
  1571 
  1571 
  1572 void NetworkServerMonthlyLoop(void)
  1572 void NetworkServerMonthlyLoop()
  1573 {
  1573 {
  1574 	NetworkAutoCleanCompanies();
  1574 	NetworkAutoCleanCompanies();
  1575 }
  1575 }
  1576 
  1576 
  1577 #endif /* ENABLE_NETWORK */
  1577 #endif /* ENABLE_NETWORK */