Merge branch 'master' into jgrpp

# Conflicts:
#	src/lang/simplified_chinese.txt
#	src/network/core/tcp_content.cpp
#	src/network/core/udp.cpp
#	src/network/network_server.cpp
#	src/saveload/linkgraph_sl.cpp
#	src/table/gameopt_settings.ini
This commit is contained in:
Jonathan G Rennison
2021-04-25 01:23:38 +01:00
96 changed files with 250 additions and 2653 deletions

View File

@@ -60,8 +60,6 @@ static const uint NETWORK_GRF_NAME_LENGTH = 80; ///< Maximum l
static const uint NETWORK_MAX_GRF_COUNT = 62;
static const uint NETWORK_MAX_GRF_COUNT_SHORT = 59;
static const uint NETWORK_NUM_LANGUAGES = 36; ///< Number of known languages (to the network protocol) + 1 for 'any'.
/**
* The number of landscapes in OpenTTD.
* This number must be equal to NUM_LANDSCAPE, but as this number is used

View File

@@ -22,7 +22,6 @@
* be sent to the clients.
*/
struct NetworkServerGameInfo {
char map_name[NETWORK_NAME_LENGTH]; ///< Map which is played ["random" for a randomized map]
byte clients_on; ///< Current count of clients on server
};
@@ -44,7 +43,6 @@ struct NetworkGameInfo : NetworkServerGameInfo {
bool compatible; ///< Can we connect to this server or not? (based on server_revision _and_ grf_match
bool use_password; ///< Is this server passworded?
byte game_info_version; ///< Version of the game info
byte server_lang; ///< Language of the server (we should make a nice table for this)
byte clients_max; ///< Max clients allowed on server
byte companies_on; ///< How many started companies do we have
byte companies_max; ///< Max companies allowed on server

View File

@@ -222,7 +222,7 @@ protected:
/**
* Welcome a connected admin to the game:
* string Name of the Server (e.g. as advertised to master server).
* string Name of the Server.
* string OpenTTD version string.
* bool Server is dedicated.
* string Name of the Map.

View File

@@ -171,9 +171,9 @@ bool NetworkContentSocketHandler::HandlePacket(Packet *p)
default:
if (this->HasClientQuit()) {
DEBUG(net, 0, "[tcp/content] received invalid packet type %d from %s", type, NetworkAddressDumper().GetAddressAsString(&(this->client_addr)));
DEBUG(net, 0, "[tcp/content] received invalid packet type %d", type);
} else {
DEBUG(net, 0, "[tcp/content] received illegal packet from %s", NetworkAddressDumper().GetAddressAsString(&(this->client_addr)));
DEBUG(net, 0, "[tcp/content] received illegal packet");
}
return false;
}
@@ -223,7 +223,7 @@ bool NetworkContentSocketHandler::ReceivePackets()
*/
bool NetworkContentSocketHandler::ReceiveInvalidPacket(PacketContentType type)
{
DEBUG(net, 0, "[tcp/content] received illegal packet type %d from %s", type, NetworkAddressDumper().GetAddressAsString(&(this->client_addr)));
DEBUG(net, 0, "[tcp/content] received illegal packet type %d", type);
return false;
}

View File

@@ -95,7 +95,6 @@ struct ContentInfo {
/** Base socket handler for all Content TCP sockets */
class NetworkContentSocketHandler : public NetworkTCPSocketHandler {
protected:
NetworkAddress client_addr; ///< The address we're connected to.
void Close() override;
bool ReceiveInvalidPacket(PacketContentType type);
@@ -193,9 +192,8 @@ public:
* @param s the socket we are connected with
* @param address IP etc. of the client
*/
NetworkContentSocketHandler(SOCKET s = INVALID_SOCKET, const NetworkAddress &address = NetworkAddress()) :
NetworkTCPSocketHandler(s),
client_addr(address)
NetworkContentSocketHandler(SOCKET s = INVALID_SOCKET) :
NetworkTCPSocketHandler(s)
{
}

View File

@@ -203,10 +203,8 @@ int NetworkHTTPSocketHandler::HandleHeader()
*url = '\0';
/* Fetch the hostname, and possible port number. */
const char *company = nullptr;
const char *port = nullptr;
ParseConnectionString(&company, &port, hname);
if (company != nullptr) return_error("[tcp/http] invalid hostname");
ParseConnectionString(&port, hname);
NetworkAddress address(hname, port == nullptr ? 80 : atoi(port));

View File

@@ -248,12 +248,12 @@ void NetworkUDPSocketHandler::SendNetworkGameInfo(Packet *p, const NetworkGameIn
/* NETWORK_GAME_INFO_VERSION = 1 */
p->Send_string(info->server_name);
p->Send_string(info->short_server_revision);
p->Send_uint8 (info->server_lang);
p->Send_uint8 (0); // Used to be server-lang.
p->Send_bool (info->use_password);
p->Send_uint8 (info->clients_max);
p->Send_uint8 (info->clients_on);
p->Send_uint8 (info->spectators_on);
p->Send_string(info->map_name);
p->Send_string(""); // Used to be map-name.
p->Send_uint16(info->map_width);
p->Send_uint16(info->map_height);
p->Send_uint8 (info->map_set);
@@ -276,12 +276,12 @@ void NetworkUDPSocketHandler::SendNetworkGameInfoExtended(Packet *p, const Netwo
p->Send_uint8 (info->spectators_max);
p->Send_string(info->server_name);
p->Send_string(info->server_revision);
p->Send_uint8 (info->server_lang);
p->Send_uint8 (0); // Used to be server-lang.
p->Send_bool (info->use_password);
p->Send_uint8 (info->clients_max);
p->Send_uint8 (info->clients_on);
p->Send_uint8 (info->spectators_on);
p->Send_string(info->map_name);
p->Send_string(""); // Used to be map-name.
p->Send_uint32(info->map_width);
p->Send_uint32(info->map_height);
p->Send_uint8 (info->map_set);
@@ -364,7 +364,7 @@ void NetworkUDPSocketHandler::ReceiveNetworkGameInfo(Packet *p, NetworkGameInfo
case 1:
p->Recv_string(info->server_name, sizeof(info->server_name));
p->Recv_string(info->server_revision, sizeof(info->server_revision));
info->server_lang = p->Recv_uint8 ();
p->Recv_uint8 (); // Used to contain server-lang.
info->use_password = p->Recv_bool ();
info->clients_max = p->Recv_uint8 ();
info->clients_on = p->Recv_uint8 ();
@@ -373,14 +373,13 @@ void NetworkUDPSocketHandler::ReceiveNetworkGameInfo(Packet *p, NetworkGameInfo
info->game_date = p->Recv_uint16() + DAYS_TILL_ORIGINAL_BASE_YEAR;
info->start_date = p->Recv_uint16() + DAYS_TILL_ORIGINAL_BASE_YEAR;
}
p->Recv_string(info->map_name, sizeof(info->map_name));
while (p->Recv_uint8() != 0) {} // Used to contain the map-name.
info->map_width = p->Recv_uint16();
info->map_height = p->Recv_uint16();
info->map_set = p->Recv_uint8 ();
info->dedicated = p->Recv_bool ();
if (info->server_lang >= NETWORK_NUM_LANGUAGES) info->server_lang = 0;
if (info->map_set >= NETWORK_NUM_LANDSCAPES) info->map_set = 0;
if (info->map_set >= NETWORK_NUM_LANDSCAPES) info->map_set = 0;
}
}
/**
@@ -404,12 +403,12 @@ void NetworkUDPSocketHandler::ReceiveNetworkGameInfoExtended(Packet *p, NetworkG
info->spectators_max = p->Recv_uint8 ();
p->Recv_string(info->server_name, sizeof(info->server_name));
p->Recv_string(info->server_revision, sizeof(info->server_revision));
info->server_lang = p->Recv_uint8 ();
p->Recv_uint8 (); // Used to contain server-lang.
info->use_password = p->Recv_bool ();
info->clients_max = p->Recv_uint8 ();
info->clients_on = p->Recv_uint8 ();
info->spectators_on = p->Recv_uint8 ();
p->Recv_string(info->map_name, sizeof(info->map_name));
while (p->Recv_uint8() != 0) {} // Used to contain the map-name.
info->map_width = p->Recv_uint32();
info->map_height = p->Recv_uint32();
info->map_set = p->Recv_uint8 ();
@@ -434,8 +433,7 @@ void NetworkUDPSocketHandler::ReceiveNetworkGameInfoExtended(Packet *p, NetworkG
}
}
if (info->server_lang >= NETWORK_NUM_LANGUAGES) info->server_lang = 0;
if (info->map_set >= NETWORK_NUM_LANDSCAPES) info->map_set = 0;
if (info->map_set >= NETWORK_NUM_LANDSCAPES) info->map_set = 0;
}
/**