|
|
|
@ -258,14 +258,13 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::CloseConnection(NetworkRecvSta
|
|
|
|
|
if (status != NETWORK_RECV_STATUS_CONN_LOST && !this->HasClientQuit() && this->status >= STATUS_AUTHORIZED) {
|
|
|
|
|
/* We did not receive a leave message from this client... */
|
|
|
|
|
char client_name[NETWORK_CLIENT_NAME_LENGTH];
|
|
|
|
|
NetworkClientSocket *new_cs;
|
|
|
|
|
|
|
|
|
|
this->GetClientName(client_name, lastof(client_name));
|
|
|
|
|
|
|
|
|
|
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, nullptr, STR_NETWORK_ERROR_CLIENT_CONNECTION_LOST);
|
|
|
|
|
|
|
|
|
|
/* Inform other clients of this... strange leaving ;) */
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(new_cs) {
|
|
|
|
|
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (new_cs->status > STATUS_AUTHORIZED && this != new_cs) {
|
|
|
|
|
new_cs->SendErrorQuit(this->client_id, NETWORK_ERROR_CONNECTION_LOST);
|
|
|
|
|
}
|
|
|
|
@ -310,8 +309,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::CloseConnection(NetworkRecvSta
|
|
|
|
|
/** Send the packets for the server sockets. */
|
|
|
|
|
/* static */ void ServerNetworkGameSocketHandler::Send()
|
|
|
|
|
{
|
|
|
|
|
NetworkClientSocket *cs;
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (cs->writable) {
|
|
|
|
|
if (cs->SendPackets() != SPS_CLOSED && cs->status == STATUS_MAP) {
|
|
|
|
|
/* This client is in the middle of a map-send, call the function for that */
|
|
|
|
@ -354,7 +352,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCompanyInfo()
|
|
|
|
|
|
|
|
|
|
/* Make a list of all clients per company */
|
|
|
|
|
char clients[MAX_COMPANIES][NETWORK_CLIENTS_LENGTH];
|
|
|
|
|
NetworkClientSocket *csi;
|
|
|
|
|
memset(clients, 0, sizeof(clients));
|
|
|
|
|
|
|
|
|
|
/* Add the local player (if not dedicated) */
|
|
|
|
@ -363,7 +360,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCompanyInfo()
|
|
|
|
|
strecpy(clients[ci->client_playas], ci->client_name, lastof(clients[ci->client_playas]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(csi) {
|
|
|
|
|
for (NetworkClientSocket *csi : NetworkClientSocket::Iterate()) {
|
|
|
|
|
char client_name[NETWORK_CLIENT_NAME_LENGTH];
|
|
|
|
|
|
|
|
|
|
((ServerNetworkGameSocketHandler*)csi)->GetClientName(client_name, lastof(client_name));
|
|
|
|
@ -424,7 +421,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode err
|
|
|
|
|
|
|
|
|
|
/* Only send when the current client was in game */
|
|
|
|
|
if (this->status > STATUS_AUTHORIZED) {
|
|
|
|
|
NetworkClientSocket *new_cs;
|
|
|
|
|
char client_name[NETWORK_CLIENT_NAME_LENGTH];
|
|
|
|
|
|
|
|
|
|
this->GetClientName(client_name, lastof(client_name));
|
|
|
|
@ -433,7 +429,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode err
|
|
|
|
|
|
|
|
|
|
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, nullptr, strid);
|
|
|
|
|
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(new_cs) {
|
|
|
|
|
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (new_cs->status > STATUS_AUTHORIZED && new_cs != this) {
|
|
|
|
|
/* Some errors we filter to a more general error. Clients don't have to know the real
|
|
|
|
|
* reason a joining failed. */
|
|
|
|
@ -509,7 +505,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedCompanyPassword()
|
|
|
|
|
NetworkRecvStatus ServerNetworkGameSocketHandler::SendWelcome()
|
|
|
|
|
{
|
|
|
|
|
Packet *p;
|
|
|
|
|
NetworkClientSocket *new_cs;
|
|
|
|
|
|
|
|
|
|
/* Invalid packet when status is AUTH or higher */
|
|
|
|
|
if (this->status >= STATUS_AUTHORIZED) return this->CloseConnection(NETWORK_RECV_STATUS_MALFORMED_PACKET);
|
|
|
|
@ -527,7 +522,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendWelcome()
|
|
|
|
|
this->SendPacket(p);
|
|
|
|
|
|
|
|
|
|
/* Transmit info about all the active clients */
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(new_cs) {
|
|
|
|
|
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (new_cs != this && new_cs->status > STATUS_AUTHORIZED) {
|
|
|
|
|
this->SendClientInfo(new_cs->GetInfo());
|
|
|
|
|
}
|
|
|
|
@ -540,11 +535,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendWelcome()
|
|
|
|
|
NetworkRecvStatus ServerNetworkGameSocketHandler::SendWait()
|
|
|
|
|
{
|
|
|
|
|
int waiting = 0;
|
|
|
|
|
NetworkClientSocket *new_cs;
|
|
|
|
|
Packet *p;
|
|
|
|
|
|
|
|
|
|
/* Count how many clients are waiting in the queue, in front of you! */
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(new_cs) {
|
|
|
|
|
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (new_cs->status != STATUS_MAP_WAIT) continue;
|
|
|
|
|
if (new_cs->GetInfo()->join_date < this->GetInfo()->join_date || (new_cs->GetInfo()->join_date == this->GetInfo()->join_date && new_cs->client_id < this->client_id)) waiting++;
|
|
|
|
|
}
|
|
|
|
@ -611,9 +605,8 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendMap()
|
|
|
|
|
this->status = STATUS_DONE_MAP;
|
|
|
|
|
|
|
|
|
|
/* Find the best candidate for joining, i.e. the first joiner. */
|
|
|
|
|
NetworkClientSocket *new_cs;
|
|
|
|
|
NetworkClientSocket *best = nullptr;
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(new_cs) {
|
|
|
|
|
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (new_cs->status == STATUS_MAP_WAIT) {
|
|
|
|
|
if (best == nullptr || best->GetInfo()->join_date > new_cs->GetInfo()->join_date || (best->GetInfo()->join_date == new_cs->GetInfo()->join_date && best->client_id > new_cs->client_id)) {
|
|
|
|
|
best = new_cs;
|
|
|
|
@ -628,7 +621,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendMap()
|
|
|
|
|
best->SendMap();
|
|
|
|
|
|
|
|
|
|
/* And update the rest. */
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(new_cs) {
|
|
|
|
|
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (new_cs->status == STATUS_MAP_WAIT) new_cs->SendWait();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1000,7 +993,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_COMPANY_PASSWOR
|
|
|
|
|
|
|
|
|
|
NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_GETMAP(Packet *p)
|
|
|
|
|
{
|
|
|
|
|
NetworkClientSocket *new_cs;
|
|
|
|
|
/* The client was never joined.. so this is impossible, right?
|
|
|
|
|
* Ignore the packet, give the client a warning, and close his connection */
|
|
|
|
|
if (this->status < STATUS_AUTHORIZED || this->HasClientQuit()) {
|
|
|
|
@ -1008,7 +1000,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_GETMAP(Packet *
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check if someone else is receiving the map */
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(new_cs) {
|
|
|
|
|
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (new_cs->status == STATUS_MAP) {
|
|
|
|
|
/* Tell the new client to wait */
|
|
|
|
|
this->status = STATUS_MAP_WAIT;
|
|
|
|
@ -1025,7 +1017,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_MAP_OK(Packet *
|
|
|
|
|
/* Client has the map, now start syncing */
|
|
|
|
|
if (this->status == STATUS_DONE_MAP && !this->HasClientQuit()) {
|
|
|
|
|
char client_name[NETWORK_CLIENT_NAME_LENGTH];
|
|
|
|
|
NetworkClientSocket *new_cs;
|
|
|
|
|
|
|
|
|
|
this->GetClientName(client_name, lastof(client_name));
|
|
|
|
|
|
|
|
|
@ -1043,7 +1034,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_MAP_OK(Packet *
|
|
|
|
|
this->last_frame = _frame_counter;
|
|
|
|
|
this->last_frame_server = _frame_counter;
|
|
|
|
|
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(new_cs) {
|
|
|
|
|
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (new_cs->status > STATUS_AUTHORIZED) {
|
|
|
|
|
new_cs->SendClientInfo(this->GetInfo());
|
|
|
|
|
new_cs->SendJoin(this->client_id);
|
|
|
|
@ -1135,7 +1126,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p
|
|
|
|
|
{
|
|
|
|
|
/* This packets means a client noticed an error and is reporting this
|
|
|
|
|
* to us. Display the error and report it to the other clients */
|
|
|
|
|
NetworkClientSocket *new_cs;
|
|
|
|
|
char str[100];
|
|
|
|
|
char client_name[NETWORK_CLIENT_NAME_LENGTH];
|
|
|
|
|
NetworkErrorCode errorno = (NetworkErrorCode)p->Recv_uint8();
|
|
|
|
@ -1154,7 +1144,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p
|
|
|
|
|
|
|
|
|
|
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, nullptr, strid);
|
|
|
|
|
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(new_cs) {
|
|
|
|
|
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (new_cs->status > STATUS_AUTHORIZED) {
|
|
|
|
|
new_cs->SendErrorQuit(this->client_id, errorno);
|
|
|
|
|
}
|
|
|
|
@ -1169,7 +1159,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_QUIT(Packet *p)
|
|
|
|
|
{
|
|
|
|
|
/* The client wants to leave. Display this and report it to the other
|
|
|
|
|
* clients. */
|
|
|
|
|
NetworkClientSocket *new_cs;
|
|
|
|
|
char client_name[NETWORK_CLIENT_NAME_LENGTH];
|
|
|
|
|
|
|
|
|
|
/* The client was never joined.. thank the client for the packet, but ignore it */
|
|
|
|
@ -1181,7 +1170,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_QUIT(Packet *p)
|
|
|
|
|
|
|
|
|
|
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, nullptr, STR_NETWORK_MESSAGE_CLIENT_LEAVING);
|
|
|
|
|
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(new_cs) {
|
|
|
|
|
for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (new_cs->status > STATUS_AUTHORIZED && new_cs != this) {
|
|
|
|
|
new_cs->SendQuit(this->client_id);
|
|
|
|
|
}
|
|
|
|
@ -1250,7 +1239,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ACK(Packet *p)
|
|
|
|
|
*/
|
|
|
|
|
void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, const char *msg, ClientID from_id, int64 data, bool from_admin)
|
|
|
|
|
{
|
|
|
|
|
NetworkClientSocket *cs;
|
|
|
|
|
const NetworkClientInfo *ci, *ci_own, *ci_to;
|
|
|
|
|
|
|
|
|
|
switch (desttype) {
|
|
|
|
@ -1268,7 +1256,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* Else find the client to send the message to */
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (cs->client_id == (ClientID)dest) {
|
|
|
|
|
cs->SendChat(action, from_id, false, msg, data);
|
|
|
|
|
break;
|
|
|
|
@ -1285,7 +1273,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
|
|
|
|
NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), true, ci_to->client_name, msg, data);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (cs->client_id == from_id) {
|
|
|
|
|
cs->SendChat(action, (ClientID)dest, true, msg, data);
|
|
|
|
|
break;
|
|
|
|
@ -1299,7 +1287,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
|
|
|
|
bool show_local = true;
|
|
|
|
|
/* Find all clients that belong to this company */
|
|
|
|
|
ci_to = nullptr;
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
ci = cs->GetInfo();
|
|
|
|
|
if (ci != nullptr && ci->client_playas == (CompanyID)dest) {
|
|
|
|
|
cs->SendChat(action, from_id, false, msg, data);
|
|
|
|
@ -1333,7 +1321,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
|
|
|
|
GetString(name, str, lastof(name));
|
|
|
|
|
NetworkTextMessage(action, GetDrawStringCompanyColour(ci_own->client_playas), true, name, msg, data);
|
|
|
|
|
} else {
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (cs->client_id == from_id) {
|
|
|
|
|
cs->SendChat(action, ci_to->client_id, true, msg, data);
|
|
|
|
|
}
|
|
|
|
@ -1347,7 +1335,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
|
|
|
|
FALLTHROUGH;
|
|
|
|
|
|
|
|
|
|
case DESTTYPE_BROADCAST:
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
cs->SendChat(action, from_id, false, msg, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1584,14 +1572,13 @@ void NetworkPopulateCompanyStats(NetworkCompanyStats *stats)
|
|
|
|
|
*/
|
|
|
|
|
void NetworkUpdateClientInfo(ClientID client_id)
|
|
|
|
|
{
|
|
|
|
|
NetworkClientSocket *cs;
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
cs->SendClientInfo(ci);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1616,7 +1603,6 @@ static void NetworkCheckRestartMap()
|
|
|
|
|
*/
|
|
|
|
|
static void NetworkAutoCleanCompanies()
|
|
|
|
|
{
|
|
|
|
|
const NetworkClientInfo *ci;
|
|
|
|
|
bool clients_in_company[MAX_COMPANIES];
|
|
|
|
|
int vehicles_in_company[MAX_COMPANIES];
|
|
|
|
|
|
|
|
|
@ -1625,12 +1611,12 @@ static void NetworkAutoCleanCompanies()
|
|
|
|
|
memset(clients_in_company, 0, sizeof(clients_in_company));
|
|
|
|
|
|
|
|
|
|
/* Detect the active companies */
|
|
|
|
|
FOR_ALL_CLIENT_INFOS(ci) {
|
|
|
|
|
for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
|
|
|
|
|
if (Company::IsValidID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_network_dedicated) {
|
|
|
|
|
ci = NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER);
|
|
|
|
|
const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER);
|
|
|
|
|
if (Company::IsValidID(ci->client_playas)) clients_in_company[ci->client_playas] = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1695,10 +1681,8 @@ bool NetworkFindName(char *new_name, const char *last)
|
|
|
|
|
strecpy(original_name, new_name, lastof(original_name));
|
|
|
|
|
|
|
|
|
|
while (!found_name) {
|
|
|
|
|
const NetworkClientInfo *ci;
|
|
|
|
|
|
|
|
|
|
found_name = true;
|
|
|
|
|
FOR_ALL_CLIENT_INFOS(ci) {
|
|
|
|
|
for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
|
|
|
|
|
if (strcmp(ci->client_name, new_name) == 0) {
|
|
|
|
|
/* Name already in use */
|
|
|
|
|
found_name = false;
|
|
|
|
@ -1706,7 +1690,7 @@ bool NetworkFindName(char *new_name, const char *last)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* Check if it is the same as the server-name */
|
|
|
|
|
ci = NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER);
|
|
|
|
|
const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER);
|
|
|
|
|
if (ci != nullptr) {
|
|
|
|
|
if (strcmp(ci->client_name, new_name) == 0) found_name = false; // name already in use
|
|
|
|
|
}
|
|
|
|
@ -1731,13 +1715,12 @@ bool NetworkFindName(char *new_name, const char *last)
|
|
|
|
|
*/
|
|
|
|
|
bool NetworkServerChangeClientName(ClientID client_id, const char *new_name)
|
|
|
|
|
{
|
|
|
|
|
NetworkClientInfo *ci;
|
|
|
|
|
/* Check if the name's already in use */
|
|
|
|
|
FOR_ALL_CLIENT_INFOS(ci) {
|
|
|
|
|
for (NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
|
|
|
|
|
if (strcmp(ci->client_name, new_name) == 0) return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ci = NetworkClientInfo::GetByClientID(client_id);
|
|
|
|
|
NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id);
|
|
|
|
|
if (ci == nullptr) return false;
|
|
|
|
|
|
|
|
|
|
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, true, ci->client_name, new_name);
|
|
|
|
@ -1785,7 +1768,6 @@ static void NetworkHandleCommandQueue(NetworkClientSocket *cs)
|
|
|
|
|
*/
|
|
|
|
|
void NetworkServer_Tick(bool send_frame)
|
|
|
|
|
{
|
|
|
|
|
NetworkClientSocket *cs;
|
|
|
|
|
#ifndef ENABLE_NETWORK_SYNC_EVERY_FRAME
|
|
|
|
|
bool send_sync = false;
|
|
|
|
|
#endif
|
|
|
|
@ -1799,7 +1781,7 @@ void NetworkServer_Tick(bool send_frame)
|
|
|
|
|
|
|
|
|
|
/* Now we are done with the frame, inform the clients that they can
|
|
|
|
|
* do their frame! */
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
/* We allow a number of bytes per frame, but only to the burst amount
|
|
|
|
|
* to be available for packet receiving at any particular time. */
|
|
|
|
|
cs->receive_limit = min(cs->receive_limit + _settings_client.network.bytes_per_frame,
|
|
|
|
@ -1956,8 +1938,7 @@ void NetworkServerShowStatusToConsole()
|
|
|
|
|
};
|
|
|
|
|
assert_compile(lengthof(stat_str) == NetworkClientSocket::STATUS_END);
|
|
|
|
|
|
|
|
|
|
NetworkClientSocket *cs;
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
NetworkClientInfo *ci = cs->GetInfo();
|
|
|
|
|
if (ci == nullptr) continue;
|
|
|
|
|
uint lag = NetworkCalculateLag(cs);
|
|
|
|
@ -1976,9 +1957,7 @@ void NetworkServerShowStatusToConsole()
|
|
|
|
|
*/
|
|
|
|
|
void NetworkServerSendConfigUpdate()
|
|
|
|
|
{
|
|
|
|
|
NetworkClientSocket *cs;
|
|
|
|
|
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (cs->status >= NetworkClientSocket::STATUS_PRE_ACTIVE) cs->SendConfigUpdate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1995,8 +1974,7 @@ void NetworkServerUpdateCompanyPassworded(CompanyID company_id, bool passworded)
|
|
|
|
|
SB(_network_company_passworded, company_id, 1, !!passworded);
|
|
|
|
|
SetWindowClassesDirty(WC_COMPANY);
|
|
|
|
|
|
|
|
|
|
NetworkClientSocket *cs;
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (cs->status >= NetworkClientSocket::STATUS_PRE_ACTIVE) cs->SendCompanyUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2090,8 +2068,7 @@ uint NetworkServerKickOrBanIP(const char *ip, bool ban)
|
|
|
|
|
uint n = 0;
|
|
|
|
|
|
|
|
|
|
/* There can be multiple clients with the same IP, kick them all */
|
|
|
|
|
NetworkClientSocket *cs;
|
|
|
|
|
FOR_ALL_CLIENT_SOCKETS(cs) {
|
|
|
|
|
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
|
|
|
|
if (cs->client_id == CLIENT_ID_SERVER) continue;
|
|
|
|
|
if (cs->client_address.IsInNetmask(ip)) {
|
|
|
|
|
NetworkServerKickClient(cs->client_id);
|
|
|
|
@ -2109,8 +2086,7 @@ uint NetworkServerKickOrBanIP(const char *ip, bool ban)
|
|
|
|
|
*/
|
|
|
|
|
bool NetworkCompanyHasClients(CompanyID company)
|
|
|
|
|
{
|
|
|
|
|
const NetworkClientInfo *ci;
|
|
|
|
|
FOR_ALL_CLIENT_INFOS(ci) {
|
|
|
|
|
for (const NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
|
|
|
|
|
if (ci->client_playas == company) return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
@ -2138,8 +2114,7 @@ void ServerNetworkGameSocketHandler::GetClientName(char *client_name, const char
|
|
|
|
|
*/
|
|
|
|
|
void NetworkPrintClients()
|
|
|
|
|
{
|
|
|
|
|
NetworkClientInfo *ci;
|
|
|
|
|
FOR_ALL_CLIENT_INFOS(ci) {
|
|
|
|
|
for (NetworkClientInfo *ci : NetworkClientInfo::Iterate()) {
|
|
|
|
|
if (_network_server) {
|
|
|
|
|
IConsolePrintF(CC_INFO, "Client #%1d name: '%s' company: %1d IP: %s",
|
|
|
|
|
ci->client_id,
|
|
|
|
|