Merge tag '12.0-beta1' into jgrpp-beta
# Conflicts: # CMakeLists.txt # bin/ai/CMakeLists.txt # bin/game/CMakeLists.txt # src/build_vehicle_gui.cpp # src/console_cmds.cpp # src/core/overflowsafe_type.hpp # src/fios.cpp # src/lang/english.txt # src/lang/german.txt # src/lang/korean.txt # src/lang/polish.txt # src/network/core/game_info.cpp # src/network/core/game_info.h # src/network/core/tcp_game.cpp # src/network/core/tcp_game.h # src/network/network.cpp # src/network/network_client.cpp # src/network/network_client.h # src/network/network_coordinator.cpp # src/network/network_gui.cpp # src/network/network_server.cpp # src/network/network_server.h # src/newgrf_engine.cpp # src/openttd.cpp # src/rev.cpp.in # src/settings_type.h # src/train.h # src/train_cmd.cpp
This commit is contained in:
@@ -378,66 +378,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendGameInfoExtended(PacketGam
|
||||
return NETWORK_RECV_STATUS_OKAY;
|
||||
}
|
||||
|
||||
/** Send the client information about the companies. */
|
||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendCompanyInfo()
|
||||
{
|
||||
/* Fetch the latest version of the stats */
|
||||
NetworkCompanyStats company_stats[MAX_COMPANIES];
|
||||
NetworkPopulateCompanyStats(company_stats);
|
||||
|
||||
/* Make a list of all clients per company */
|
||||
std::string clients[MAX_COMPANIES];
|
||||
|
||||
/* Add the local player (if not dedicated) */
|
||||
const NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER);
|
||||
if (ci != nullptr && Company::IsValidID(ci->client_playas)) {
|
||||
clients[ci->client_playas] = ci->client_name;
|
||||
}
|
||||
|
||||
for (NetworkClientSocket *csi : NetworkClientSocket::Iterate()) {
|
||||
char client_name[NETWORK_CLIENT_NAME_LENGTH];
|
||||
|
||||
((ServerNetworkGameSocketHandler*)csi)->GetClientName(client_name, lastof(client_name));
|
||||
|
||||
ci = csi->GetInfo();
|
||||
if (ci != nullptr && Company::IsValidID(ci->client_playas)) {
|
||||
if (!clients[ci->client_playas].empty()) {
|
||||
clients[ci->client_playas] += ", ";
|
||||
}
|
||||
|
||||
clients[ci->client_playas] += client_name;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now send the data */
|
||||
|
||||
Packet *p;
|
||||
|
||||
for (const Company *company : Company::Iterate()) {
|
||||
p = new Packet(PACKET_SERVER_COMPANY_INFO, SHRT_MAX);
|
||||
|
||||
p->Send_uint8 (NETWORK_COMPANY_INFO_VERSION);
|
||||
p->Send_bool (true);
|
||||
this->SendCompanyInformation(p, company, &company_stats[company->index]);
|
||||
|
||||
if (clients[company->index].empty()) {
|
||||
p->Send_string("<none>");
|
||||
} else {
|
||||
p->Send_string(clients[company->index]);
|
||||
}
|
||||
|
||||
this->SendPacket(p);
|
||||
}
|
||||
|
||||
p = new Packet(PACKET_SERVER_COMPANY_INFO, SHRT_MAX);
|
||||
|
||||
p->Send_uint8 (NETWORK_COMPANY_INFO_VERSION);
|
||||
p->Send_bool (false);
|
||||
|
||||
this->SendPacket(p);
|
||||
return NETWORK_RECV_STATUS_OKAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an error to the client, and close its connection.
|
||||
* @param error The error to disconnect for.
|
||||
@@ -864,7 +804,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendConfigUpdate()
|
||||
Packet *p = new Packet(PACKET_SERVER_CONFIG_UPDATE, SHRT_MAX);
|
||||
|
||||
p->Send_uint8(_settings_client.network.max_companies);
|
||||
p->Send_uint8(_settings_client.network.max_spectators);
|
||||
p->Send_string(_settings_client.network.server_name);
|
||||
this->SendPacket(p);
|
||||
return NETWORK_RECV_STATUS_OKAY;
|
||||
}
|
||||
@@ -895,11 +835,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_GAME_INFO(Packe
|
||||
}
|
||||
}
|
||||
|
||||
NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_COMPANY_INFO(Packet *p)
|
||||
{
|
||||
return this->SendCompanyInfo();
|
||||
}
|
||||
|
||||
NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_NEWGRFS_CHECKED(Packet *p)
|
||||
{
|
||||
if (this->status != STATUS_NEWGRFS_CHECK) {
|
||||
@@ -950,9 +885,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
|
||||
}
|
||||
break;
|
||||
case COMPANY_SPECTATOR: // Spectator
|
||||
if (NetworkSpectatorCount() >= _settings_client.network.max_spectators) {
|
||||
return this->SendError(NETWORK_ERROR_FULL);
|
||||
}
|
||||
break;
|
||||
default: // Join another company (companies 1-8 (index 0-7))
|
||||
if (!Company::IsValidHumanID(playas)) {
|
||||
@@ -1624,58 +1556,6 @@ std::string ServerNetworkGameSocketHandler::GetDebugInfo() const
|
||||
return stdstr_fmt("status: %d (%s)", this->status, GetClientStatusName(this->status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Package some generic company information into a packet.
|
||||
* @param p The packet that will contain the data.
|
||||
* @param c The company to put the of into the packet.
|
||||
* @param stats The statistics to put in the packet.
|
||||
* @param max_len The maximum length of the company name.
|
||||
*/
|
||||
void NetworkSocketHandler::SendCompanyInformation(Packet *p, const Company *c, const NetworkCompanyStats *stats, uint max_len)
|
||||
{
|
||||
/* Grab the company name */
|
||||
char company_name[NETWORK_COMPANY_NAME_LENGTH];
|
||||
SetDParam(0, c->index);
|
||||
|
||||
assert(max_len <= lengthof(company_name));
|
||||
GetString(company_name, STR_COMPANY_NAME, company_name + max_len - 1);
|
||||
|
||||
/* Get the income */
|
||||
Money income = 0;
|
||||
if (_cur_year - 1 == c->inaugurated_year) {
|
||||
/* The company is here just 1 year, so display [2], else display[1] */
|
||||
for (uint i = 0; i < lengthof(c->yearly_expenses[2]); i++) {
|
||||
income -= c->yearly_expenses[2][i];
|
||||
}
|
||||
} else {
|
||||
for (uint i = 0; i < lengthof(c->yearly_expenses[1]); i++) {
|
||||
income -= c->yearly_expenses[1][i];
|
||||
}
|
||||
}
|
||||
|
||||
/* Send the information */
|
||||
p->Send_uint8 (c->index);
|
||||
p->Send_string(company_name);
|
||||
p->Send_uint32(c->inaugurated_year);
|
||||
p->Send_uint64(c->old_economy[0].company_value);
|
||||
p->Send_uint64(c->money);
|
||||
p->Send_uint64(income);
|
||||
p->Send_uint16(c->old_economy[0].performance_history);
|
||||
|
||||
/* Send 1 if there is a password for the company else send 0 */
|
||||
p->Send_bool (!_network_company_states[c->index].password.empty());
|
||||
|
||||
for (uint i = 0; i < NETWORK_VEH_END; i++) {
|
||||
p->Send_uint16(stats->num_vehicle[i]);
|
||||
}
|
||||
|
||||
for (uint i = 0; i < NETWORK_VEH_END; i++) {
|
||||
p->Send_uint16(stats->num_station[i]);
|
||||
}
|
||||
|
||||
p->Send_bool(c->is_ai);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the company stats.
|
||||
* @param stats the stats to update
|
||||
|
||||
Reference in New Issue
Block a user