mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-19 15:25:39 +00:00
Fix: server's client is shown incorrectly in some cases
This commit is contained in:
parent
4740eeaa43
commit
455e202e03
@ -884,7 +884,7 @@ static void NetworkInitGameInfo()
|
|||||||
/* There should be always space for the server. */
|
/* There should be always space for the server. */
|
||||||
assert(NetworkClientInfo::CanAllocateItem());
|
assert(NetworkClientInfo::CanAllocateItem());
|
||||||
NetworkClientInfo *ci = new NetworkClientInfo(CLIENT_ID_SERVER);
|
NetworkClientInfo *ci = new NetworkClientInfo(CLIENT_ID_SERVER);
|
||||||
ci->client_playas = _network_dedicated ? COMPANY_SPECTATOR : COMPANY_FIRST;
|
ci->client_playas = COMPANY_SPECTATOR;
|
||||||
|
|
||||||
ci->client_name = _settings_client.network.client_name;
|
ci->client_name = _settings_client.network.client_name;
|
||||||
}
|
}
|
||||||
@ -987,6 +987,30 @@ bool NetworkServerStart()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform tasks when the server is started. This consists of things
|
||||||
|
* like putting the server's client in a valid company and resetting the restart time.
|
||||||
|
*/
|
||||||
|
void NetworkOnGameStart()
|
||||||
|
{
|
||||||
|
if (!_network_server) return;
|
||||||
|
|
||||||
|
/* Update the static game info to set the values from the new game. */
|
||||||
|
NetworkServerUpdateGameInfo();
|
||||||
|
|
||||||
|
ChangeNetworkRestartTime(true);
|
||||||
|
|
||||||
|
if (!_network_dedicated) {
|
||||||
|
Company *c = Company::GetIfValid(GetFirstPlayableCompanyID());
|
||||||
|
NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER);
|
||||||
|
if (c != nullptr && ci != nullptr) {
|
||||||
|
ci->client_playas = c->index;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowClientList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* The server is rebooting...
|
/* The server is rebooting...
|
||||||
* The only difference with NetworkDisconnect, is the packets that is sent */
|
* The only difference with NetworkDisconnect, is the packets that is sent */
|
||||||
void NetworkReboot()
|
void NetworkReboot()
|
||||||
|
@ -64,6 +64,8 @@ void NetworkPrintClients();
|
|||||||
std::string_view NetworkGetPublicKeyOfClient(ClientID client_id);
|
std::string_view NetworkGetPublicKeyOfClient(ClientID client_id);
|
||||||
void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode);
|
void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode);
|
||||||
|
|
||||||
|
void NetworkOnGameStart();
|
||||||
|
|
||||||
/*** Commands ran by the server ***/
|
/*** Commands ran by the server ***/
|
||||||
void NetworkServerSendConfigUpdate();
|
void NetworkServerSendConfigUpdate();
|
||||||
void NetworkServerUpdateGameInfo();
|
void NetworkServerUpdateGameInfo();
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include "console_func.h"
|
#include "console_func.h"
|
||||||
#include "screenshot.h"
|
#include "screenshot.h"
|
||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
#include "network/network_server.h"
|
|
||||||
#include "network/network_func.h"
|
#include "network/network_func.h"
|
||||||
#include "ai/ai.hpp"
|
#include "ai/ai.hpp"
|
||||||
#include "ai/ai_config.hpp"
|
#include "ai/ai_config.hpp"
|
||||||
@ -859,8 +858,8 @@ static void OnStartGame(bool dedicated_server)
|
|||||||
* or in the case of a dedicated server, a spectator */
|
* or in the case of a dedicated server, a spectator */
|
||||||
SetLocalCompany(dedicated_server ? COMPANY_SPECTATOR : GetFirstPlayableCompanyID());
|
SetLocalCompany(dedicated_server ? COMPANY_SPECTATOR : GetFirstPlayableCompanyID());
|
||||||
|
|
||||||
/* Update the static game info to set the values from the new game. */
|
NetworkOnGameStart();
|
||||||
NetworkServerUpdateGameInfo();
|
|
||||||
/* Execute the game-start script */
|
/* Execute the game-start script */
|
||||||
IConsoleCmdExec("exec scripts/game_start.scr 0");
|
IConsoleCmdExec("exec scripts/game_start.scr 0");
|
||||||
}
|
}
|
||||||
@ -911,12 +910,6 @@ static void MakeNewGameDone()
|
|||||||
CheckEngines();
|
CheckEngines();
|
||||||
CheckIndustries();
|
CheckIndustries();
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
|
|
||||||
if (_network_server) {
|
|
||||||
ChangeNetworkRestartTime(true);
|
|
||||||
|
|
||||||
if (!_network_dedicated) ShowClientList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MakeNewGame(bool from_heightmap, bool reset_settings)
|
static void MakeNewGame(bool from_heightmap, bool reset_settings)
|
||||||
|
Loading…
Reference in New Issue
Block a user