Merge commit 'f1dfa661a1898cde06a38ab4cb230c95912b245b' into jgrpp-beta
# Conflicts: # src/lang/estonian.txt # src/lang/hungarian.txt # src/network/core/game_info.cpp # src/network/core/game_info.h # src/network/core/packet.h # src/network/network.cpp # src/network/network_client.cpp # src/network/network_server.cpp # src/network/network_udp.cpp # src/openttd.cpp # src/string_func.h
This commit is contained in:
@@ -555,7 +555,7 @@ void OpenBrowser(const char *url)
|
||||
struct AfterNewGRFScan : NewGRFScanCallback {
|
||||
Year startyear; ///< The start year.
|
||||
uint32 generation_seed; ///< Seed for the new game.
|
||||
char *dedicated_host; ///< Hostname for the dedicated server.
|
||||
std::string dedicated_host; ///< Hostname for the dedicated server.
|
||||
uint16 dedicated_port; ///< Port for the dedicated server.
|
||||
char *network_conn; ///< Information about the server to connect to, or nullptr.
|
||||
const char *join_server_password; ///< The password to join the server with.
|
||||
@@ -567,7 +567,7 @@ struct AfterNewGRFScan : NewGRFScanCallback {
|
||||
*/
|
||||
AfterNewGRFScan() :
|
||||
startyear(INVALID_YEAR), generation_seed(GENERATE_NEW_SEED),
|
||||
dedicated_host(nullptr), dedicated_port(0), network_conn(nullptr),
|
||||
dedicated_port(0), network_conn(nullptr),
|
||||
join_server_password(nullptr), join_company_password(nullptr),
|
||||
save_config(true)
|
||||
{
|
||||
@@ -608,7 +608,7 @@ struct AfterNewGRFScan : NewGRFScanCallback {
|
||||
if (startyear != INVALID_YEAR) IConsoleSetSetting("game_creation.starting_year", startyear);
|
||||
if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
|
||||
|
||||
if (dedicated_host != nullptr) {
|
||||
if (!dedicated_host.empty()) {
|
||||
_network_bind_list.clear();
|
||||
_network_bind_list.emplace_back(dedicated_host);
|
||||
}
|
||||
@@ -720,10 +720,7 @@ int openttd_main(int argc, char *argv[])
|
||||
dedicated = true;
|
||||
SetDebugString("net=3");
|
||||
if (mgo.opt != nullptr) {
|
||||
const char *port = nullptr;
|
||||
ParseFullConnectionString(nullptr, &port, mgo.opt);
|
||||
if (!StrEmpty(mgo.opt)) scanner->dedicated_host = mgo.opt;
|
||||
if (port != nullptr) scanner->dedicated_port = atoi(port);
|
||||
scanner->dedicated_host = ParseFullConnectionString(mgo.opt, scanner->dedicated_port);
|
||||
}
|
||||
break;
|
||||
case 'f': _dedicated_forks = true; break;
|
||||
@@ -1000,6 +997,28 @@ void HandleExitGameRequest()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers everything that should be triggered when starting a game.
|
||||
* @param dedicated_server Whether this is a dedicated server or not.
|
||||
*/
|
||||
static void OnStartGame(bool dedicated_server)
|
||||
{
|
||||
/* Update the local company for a loaded game. It is either always
|
||||
* a company or in the case of a dedicated server a spectator */
|
||||
if (_network_server && !dedicated_server) {
|
||||
NetworkServerDoMove(CLIENT_ID_SERVER, GetDefaultLocalCompany());
|
||||
} else {
|
||||
SetLocalCompany(dedicated_server ? COMPANY_SPECTATOR : GetDefaultLocalCompany());
|
||||
}
|
||||
if (_ctrl_pressed && !dedicated_server) {
|
||||
DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
|
||||
}
|
||||
/* Update the static game info to set the values from the new game. */
|
||||
NetworkServerUpdateGameInfo();
|
||||
/* Execute the game-start script */
|
||||
IConsoleCmdExec("exec scripts/game_start.scr 0");
|
||||
}
|
||||
|
||||
static void MakeNewGameDone()
|
||||
{
|
||||
SettingsDisableElrail(_settings_game.vehicle.disable_elrails);
|
||||
@@ -1009,9 +1028,8 @@ static void MakeNewGameDone()
|
||||
|
||||
/* In a dedicated server, the server does not play */
|
||||
if (!VideoDriver::GetInstance()->HasGUI()) {
|
||||
SetLocalCompany(COMPANY_SPECTATOR);
|
||||
OnStartGame(true);
|
||||
if (_settings_client.gui.pause_on_newgame) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
|
||||
IConsoleCmdExec("exec scripts/game_start.scr 0");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1030,9 +1048,7 @@ static void MakeNewGameDone()
|
||||
BuildOwnerLegend();
|
||||
}
|
||||
|
||||
IConsoleCmdExec("exec scripts/game_start.scr 0");
|
||||
|
||||
SetLocalCompany(COMPANY_FIRST);
|
||||
OnStartGame(false);
|
||||
|
||||
InitializeRailGUI();
|
||||
InitializeRoadGUI();
|
||||
@@ -1227,18 +1243,7 @@ void SwitchToMode(SwitchMode new_mode)
|
||||
/* Reset engine pool to simplify changing engine NewGRFs in scenario editor. */
|
||||
EngineOverrideManager::ResetToCurrentNewGRFConfig();
|
||||
}
|
||||
/* Update the local company for a loaded game. It is either always
|
||||
* a company or in the case of a dedicated server a spectator */
|
||||
if (_network_server && !_network_dedicated) {
|
||||
NetworkServerDoMove(CLIENT_ID_SERVER, GetDefaultLocalCompany());
|
||||
} else {
|
||||
SetLocalCompany(_network_dedicated ? COMPANY_SPECTATOR : GetDefaultLocalCompany());
|
||||
}
|
||||
if (_ctrl_pressed && !_network_dedicated) {
|
||||
DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
|
||||
}
|
||||
/* Execute the game-start script */
|
||||
IConsoleCmdExec("exec scripts/game_start.scr 0");
|
||||
OnStartGame(_network_dedicated);
|
||||
/* Decrease pause counter (was increased from opening load dialog) */
|
||||
DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user