|
@@ -280,13 +280,13 @@ NetworkRecvStatus ServerNetworkGameSocke
|
|
|
this->savegame = nullptr;
|
|
|
|
|
|
this->CheckNextClientToSendMap(this);
|
|
|
}
|
|
|
|
|
|
NetworkAdminClientError(this->client_id, NETWORK_ERROR_CONNECTION_LOST);
|
|
|
DEBUG(net, 3, "Closed client connection %d", this->client_id);
|
|
|
Debug(net, 3, "Closed client connection {}", this->client_id);
|
|
|
|
|
|
/* We just lost one client :( */
|
|
|
if (this->status >= STATUS_AUTHORIZED) _network_game_info.clients_on--;
|
|
|
extern byte _network_clients_connected;
|
|
|
_network_clients_connected--;
|
|
|
|
|
@@ -442,13 +442,13 @@ NetworkRecvStatus ServerNetworkGameSocke
|
|
|
/* Only send when the current client was in game */
|
|
|
if (this->status > STATUS_AUTHORIZED) {
|
|
|
char client_name[NETWORK_CLIENT_NAME_LENGTH];
|
|
|
|
|
|
this->GetClientName(client_name, lastof(client_name));
|
|
|
|
|
|
DEBUG(net, 1, "'%s' made an error and has been disconnected: %s", client_name, GetString(strid).c_str());
|
|
|
Debug(net, 1, "'{}' made an error and has been disconnected: {}", client_name, GetString(strid));
|
|
|
|
|
|
if (error == NETWORK_ERROR_KICKED && !reason.empty()) {
|
|
|
NetworkTextMessage(NETWORK_ACTION_KICKED, CC_DEFAULT, false, client_name, reason, strid);
|
|
|
} else {
|
|
|
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "", strid);
|
|
|
}
|
|
@@ -463,13 +463,13 @@ NetworkRecvStatus ServerNetworkGameSocke
|
|
|
new_cs->SendErrorQuit(this->client_id, error);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
NetworkAdminClientError(this->client_id, error);
|
|
|
} else {
|
|
|
DEBUG(net, 1, "Client %d made an error and has been disconnected: %s", this->client_id, GetString(strid).c_str());
|
|
|
Debug(net, 1, "Client {} made an error and has been disconnected: {}", this->client_id, GetString(strid));
|
|
|
}
|
|
|
|
|
|
/* The client made a mistake, so drop the connection now! */
|
|
|
return this->CloseConnection(NETWORK_RECV_STATUS_SERVER_ERROR);
|
|
|
}
|
|
|
|
|
@@ -922,13 +922,13 @@ NetworkRecvStatus ServerNetworkGameSocke
|
|
|
assert(NetworkClientInfo::CanAllocateItem());
|
|
|
NetworkClientInfo *ci = new NetworkClientInfo(this->client_id);
|
|
|
this->SetInfo(ci);
|
|
|
ci->join_date = _date;
|
|
|
ci->client_name = client_name;
|
|
|
ci->client_playas = playas;
|
|
|
DEBUG(desync, 1, "client: %08x; %02x; %02x; %02x", _date, _date_fract, (int)ci->client_playas, (int)ci->index);
|
|
|
Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:02x}", _date, _date_fract, (int)ci->client_playas, (int)ci->index);
|
|
|
|
|
|
/* Make sure companies to which people try to join are not autocleaned */
|
|
|
if (Company::IsValidID(playas)) _network_company_states[playas].months_empty = 0;
|
|
|
|
|
|
this->status = STATUS_NEWGRFS_CHECK;
|
|
|
|
|
@@ -1130,13 +1130,13 @@ NetworkRecvStatus ServerNetworkGameSocke
|
|
|
}
|
|
|
|
|
|
this->GetClientName(client_name, lastof(client_name));
|
|
|
|
|
|
StringID strid = GetNetworkErrorMsg(errorno);
|
|
|
|
|
|
DEBUG(net, 1, "'%s' reported an error and is closing its connection: %s", client_name, GetString(strid).c_str());
|
|
|
Debug(net, 1, "'{}' reported an error and is closing its connection: {}", client_name, GetString(strid));
|
|
|
|
|
|
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "", strid);
|
|
|
|
|
|
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
|
|
|
if (new_cs->status >= STATUS_AUTHORIZED) {
|
|
|
new_cs->SendErrorQuit(this->client_id, errorno);
|
|
@@ -1320,13 +1320,13 @@ void NetworkServerSendChat(NetworkAction
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
default:
|
|
|
DEBUG(net, 1, "Received unknown chat destination type %d; doing broadcast instead", desttype);
|
|
|
Debug(net, 1, "Received unknown chat destination type {}; doing broadcast instead", desttype);
|
|
|
FALLTHROUGH;
|
|
|
|
|
|
case DESTTYPE_BROADCAST:
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
cs->SendChat(action, from_id, false, msg, data);
|
|
|
}
|
|
@@ -1422,17 +1422,17 @@ NetworkRecvStatus ServerNetworkGameSocke
|
|
|
if (_settings_client.network.rcon_password.empty()) return NETWORK_RECV_STATUS_OKAY;
|
|
|
|
|
|
std::string password = p->Recv_string(NETWORK_PASSWORD_LENGTH);
|
|
|
std::string command = p->Recv_string(NETWORK_RCONCOMMAND_LENGTH);
|
|
|
|
|
|
if (_settings_client.network.rcon_password.compare(password) != 0) {
|
|
|
DEBUG(net, 1, "[rcon] Wrong password from client-id %d", this->client_id);
|
|
|
Debug(net, 1, "[rcon] Wrong password from client-id {}", this->client_id);
|
|
|
return NETWORK_RECV_STATUS_OKAY;
|
|
|
}
|
|
|
|
|
|
DEBUG(net, 3, "[rcon] Client-id %d executed: %s", this->client_id, command.c_str());
|
|
|
Debug(net, 3, "[rcon] Client-id {} executed: {}", this->client_id, command);
|
|
|
|
|
|
_redirect_console_to_client = this->client_id;
|
|
|
IConsoleCmdExec(command.c_str());
|
|
|
_redirect_console_to_client = INVALID_CLIENT_ID;
|
|
|
return NETWORK_RECV_STATUS_OKAY;
|
|
|
}
|
|
@@ -1450,13 +1450,13 @@ NetworkRecvStatus ServerNetworkGameSocke
|
|
|
if (company_id != COMPANY_SPECTATOR && !_network_company_states[company_id].password.empty()) {
|
|
|
/* we need a password from the client - should be in this packet */
|
|
|
std::string password = p->Recv_string(NETWORK_PASSWORD_LENGTH);
|
|
|
|
|
|
/* Incorrect password sent, return! */
|
|
|
if (_network_company_states[company_id].password.compare(password) != 0) {
|
|
|
DEBUG(net, 2, "Wrong password from client-id #%d for company #%d", this->client_id, company_id + 1);
|
|
|
Debug(net, 2, "Wrong password from client-id #{} for company #{}", this->client_id, company_id + 1);
|
|
|
return NETWORK_RECV_STATUS_OKAY;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* if we get here we can move the client */
|
|
|
NetworkServerDoMove(this->client_id, company_id);
|
|
@@ -1558,13 +1558,13 @@ void NetworkPopulateCompanyStats(Network
|
|
|
void NetworkUpdateClientInfo(ClientID client_id)
|
|
|
{
|
|
|
NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id);
|
|
|
|
|
|
if (ci == nullptr) return;
|
|
|
|
|
|
DEBUG(desync, 1, "client: %08x; %02x; %02x; %04x", _date, _date_fract, (int)ci->client_playas, client_id);
|
|
|
Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:04x}", _date, _date_fract, (int)ci->client_playas, client_id);
|
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
if (cs->status >= ServerNetworkGameSocketHandler::STATUS_AUTHORIZED) {
|
|
|
cs->SendClientInfo(ci);
|
|
|
}
|
|
|
}
|
|
@@ -1573,13 +1573,13 @@ void NetworkUpdateClientInfo(ClientID cl
|
|
|
}
|
|
|
|
|
|
/** Check if we want to restart the map */
|
|
|
static void NetworkCheckRestartMap()
|
|
|
{
|
|
|
if (_settings_client.network.restart_game_year != 0 && _cur_year >= _settings_client.network.restart_game_year) {
|
|
|
DEBUG(net, 3, "Auto-restarting map: year %d reached", _cur_year);
|
|
|
Debug(net, 3, "Auto-restarting map: year {} reached", _cur_year);
|
|
|
|
|
|
_settings_newgame.game_creation.generation_seed = GENERATE_NEW_SEED;
|
|
|
switch(_file_to_saveload.abstract_ftype) {
|
|
|
case FT_SAVEGAME:
|
|
|
case FT_SCENARIO:
|
|
|
_switch_mode = SM_LOAD_GAME;
|