@@ -865,12 +865,14 @@ NetworkRecvStatus ClientNetworkGameSocke
/* If the savegame has successfully loaded, ALL windows have been removed,
* only toolbar/statusbar and gamefield are visible */
/* Say we received the map and loaded it correctly! */
SendMapOk();
ShowClientList();
/* New company/spectator (invalid company) or company we want to join is not active
* Switch local company to spectator and await the server's judgement */
if (_network_join.company == COMPANY_NEW_COMPANY || !Company::IsValidID(_network_join.company)) {
SetLocalCompany(COMPANY_SPECTATOR);
if (_network_join.company != COMPANY_SPECTATOR) {
@@ -1576,21 +1576,21 @@ private:
ShowNetworkChatQueryWindow(DESTTYPE_CLIENT, client_id);
}
/**
* Part of RebuildList() to create the information for a single company.
* @param company_id The company to build the list for.
* @param own_ci The NetworkClientInfo of the client itself.
* @param client_playas The company the client is joined as.
*/
void RebuildListCompany(CompanyID company_id, const NetworkClientInfo *own_ci)
void RebuildListCompany(CompanyID company_id, CompanyID client_playas)
{
ButtonCommon *chat_button = new CompanyButton(SPR_CHAT, company_id == COMPANY_SPECTATOR ? STR_NETWORK_CLIENT_LIST_CHAT_SPECTATOR_TOOLTIP : STR_NETWORK_CLIENT_LIST_CHAT_COMPANY_TOOLTIP, COLOUR_ORANGE, company_id, &NetworkClientListWindow::OnClickCompanyChat);
if (_network_server) this->buttons[line_count].emplace_back(new CompanyButton(SPR_ADMIN, STR_NETWORK_CLIENT_LIST_ADMIN_COMPANY_TOOLTIP, COLOUR_RED, company_id, &NetworkClientListWindow::OnClickCompanyAdmin, company_id == COMPANY_SPECTATOR));
this->buttons[line_count].emplace_back(chat_button);
if (own_ci->client_playas != company_id) this->buttons[line_count].emplace_back(new CompanyButton(SPR_JOIN, STR_NETWORK_CLIENT_LIST_JOIN_TOOLTIP, COLOUR_ORANGE, company_id, &NetworkClientListWindow::OnClickCompanyJoin, company_id != COMPANY_SPECTATOR && Company::Get(company_id)->is_ai));
if (client_playas != company_id) this->buttons[line_count].emplace_back(new CompanyButton(SPR_JOIN, STR_NETWORK_CLIENT_LIST_JOIN_TOOLTIP, COLOUR_ORANGE, company_id, &NetworkClientListWindow::OnClickCompanyJoin, company_id != COMPANY_SPECTATOR && Company::Get(company_id)->is_ai));
this->line_count += 1;
bool has_players = false;
for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
if (ci->client_playas != company_id) continue;
@@ -1615,37 +1615,38 @@ private:
* Rebuild the list, meaning: calculate the lines needed and what buttons go on which line.
void RebuildList()
const NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
CompanyID client_playas = own_ci == nullptr ? COMPANY_SPECTATOR : own_ci->client_playas;
this->buttons.clear();
this->line_count = 0;
this->player_host_index = -1;
this->player_self_index = -1;
/* As spectator, show a line to create a new company. */
if (own_ci->client_playas == COMPANY_SPECTATOR && !NetworkMaxCompaniesReached()) {
if (client_playas == COMPANY_SPECTATOR && !NetworkMaxCompaniesReached()) {
this->buttons[line_count].emplace_back(new CompanyButton(SPR_JOIN, STR_NETWORK_CLIENT_LIST_NEW_COMPANY_TOOLTIP, COLOUR_ORANGE, COMPANY_SPECTATOR, &NetworkClientListWindow::OnClickCompanyNew));
if (own_ci->client_playas != COMPANY_SPECTATOR) {
this->RebuildListCompany(own_ci->client_playas, own_ci);
if (client_playas != COMPANY_SPECTATOR) {
this->RebuildListCompany(client_playas, client_playas);
/* Companies */
for (const Company *c : Company::Iterate()) {
if (c->index == own_ci->client_playas) continue;
if (c->index == client_playas) continue;
this->RebuildListCompany(c->index, own_ci);
this->RebuildListCompany(c->index, client_playas);
/* Spectators */
this->RebuildListCompany(COMPANY_SPECTATOR, own_ci);
this->RebuildListCompany(COMPANY_SPECTATOR, client_playas);
this->vscroll->SetCount(this->line_count);
* Get the button at a specific point on the WID_CL_MATRIX.
@@ -2060,22 +2061,24 @@ public:
if (this->hover_index >= 0) {
uint offset = this->hover_index * this->line_height;
GfxFillRect(r.left + 2, r.top + offset, r.right - 1, r.top + offset + this->line_height - 2, GREY_SCALE(9));
NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
this->DrawCompany(COMPANY_NEW_COMPANY, r.left, r.right, r.top, line);
this->DrawCompany(own_ci->client_playas, r.left, r.right, r.top, line);
this->DrawCompany(client_playas, r.left, r.right, r.top, line);
if (own_ci->client_playas == c->index) continue;
if (client_playas == c->index) continue;
this->DrawCompany(c->index, r.left, r.right, r.top, line);
/* Specators */
this->DrawCompany(COMPANY_SPECTATOR, r.left, r.right, r.top, line);
@@ -62,12 +62,13 @@
#include "subsidy_func.h"
#include "gfx_layout.h"
#include "viewport_func.h"
#include "viewport_sprite_sorter.h"
#include "framerate_type.h"
#include "industry.h"
#include "network/network_gui.h"
#include "linkgraph/linkgraphschedule.h"
#include <stdarg.h>
#include <system_error>
@@ -881,12 +882,14 @@ static void MakeNewGameDone()
if (_settings_client.gui.pause_on_newgame) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
CheckEngines();
CheckIndustries();
MarkWholeScreenDirty();
if (_network_server && !_network_dedicated) ShowClientList();
static void MakeNewGame(bool from_heightmap, bool reset_settings)
_game_mode = GM_NORMAL;
if (!from_heightmap) {
Status change: