1
0
Fork 0

(svn r14710) -Change: simplify sending company information from the server to the client.

release/0.7
rubidium 2008-12-22 15:17:14 +00:00
parent 782b80eff7
commit 887869c771
2 changed files with 11 additions and 33 deletions

View File

@ -352,21 +352,13 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_BANNED)
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO) DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO)
{ {
byte company_info_version; byte company_info_version = p->Recv_uint8();
int i;
company_info_version = p->Recv_uint8();
if (!MY_CLIENT->has_quit && company_info_version == NETWORK_COMPANY_INFO_VERSION) { if (!MY_CLIENT->has_quit && company_info_version == NETWORK_COMPANY_INFO_VERSION) {
byte total; /* We have received all data... (there are no more packets coming) */
CompanyID current; if (!p->Recv_bool()) return NETWORK_RECV_STATUS_CLOSE_QUERY;
total = p->Recv_uint8(); CompanyID current = (Owner)p->Recv_uint8();
// There is no data at all..
if (total == 0) return NETWORK_RECV_STATUS_CLOSE_QUERY;
current = (Owner)p->Recv_uint8();
if (current >= MAX_COMPANIES) return NETWORK_RECV_STATUS_CLOSE_QUERY; if (current >= MAX_COMPANIES) return NETWORK_RECV_STATUS_CLOSE_QUERY;
p->Recv_string(_network_company_info[current].company_name, sizeof(_network_company_info[current].company_name)); p->Recv_string(_network_company_info[current].company_name, sizeof(_network_company_info[current].company_name));
@ -376,9 +368,9 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO)
_network_company_info[current].income = p->Recv_uint64(); _network_company_info[current].income = p->Recv_uint64();
_network_company_info[current].performance = p->Recv_uint16(); _network_company_info[current].performance = p->Recv_uint16();
_network_company_info[current].use_password = p->Recv_bool(); _network_company_info[current].use_password = p->Recv_bool();
for (i = 0; i < NETWORK_VEHICLE_TYPES; i++) for (int i = 0; i < NETWORK_VEHICLE_TYPES; i++)
_network_company_info[current].num_vehicle[i] = p->Recv_uint16(); _network_company_info[current].num_vehicle[i] = p->Recv_uint16();
for (i = 0; i < NETWORK_STATION_TYPES; i++) for (int i = 0; i < NETWORK_STATION_TYPES; i++)
_network_company_info[current].num_station[i] = p->Recv_uint16(); _network_company_info[current].num_station[i] = p->Recv_uint16();
p->Recv_string(_network_company_info[current].clients, sizeof(_network_company_info[current].clients)); p->Recv_string(_network_company_info[current].clients, sizeof(_network_company_info[current].clients));

View File

@ -69,30 +69,16 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
// Data: // Data:
// //
int i;
Company *company; Company *company;
Packet *p; Packet *p;
byte active = ActiveCompanyCount();
if (active == 0) {
p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO);
p->Send_uint8 (NETWORK_COMPANY_INFO_VERSION);
p->Send_uint8 (active);
cs->Send_Packet(p);
return;
}
NetworkPopulateCompanyInfo(); NetworkPopulateCompanyInfo();
FOR_ALL_COMPANIES(company) { FOR_ALL_COMPANIES(company) {
p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO); p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO);
p->Send_uint8 (NETWORK_COMPANY_INFO_VERSION); p->Send_uint8 (NETWORK_COMPANY_INFO_VERSION);
p->Send_uint8 (active); p->Send_bool (true);
p->Send_uint8 (company->index); p->Send_uint8 (company->index);
p->Send_string(_network_company_info[company->index].company_name); p->Send_string(_network_company_info[company->index].company_name);
@ -105,11 +91,11 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
/* Send 1 if there is a passord for the company else send 0 */ /* Send 1 if there is a passord for the company else send 0 */
p->Send_bool(!StrEmpty(_network_company_info[company->index].password)); p->Send_bool(!StrEmpty(_network_company_info[company->index].password));
for (i = 0; i < NETWORK_VEHICLE_TYPES; i++) { for (int i = 0; i < NETWORK_VEHICLE_TYPES; i++) {
p->Send_uint16(_network_company_info[company->index].num_vehicle[i]); p->Send_uint16(_network_company_info[company->index].num_vehicle[i]);
} }
for (i = 0; i < NETWORK_STATION_TYPES; i++) { for (int i = 0; i < NETWORK_STATION_TYPES; i++) {
p->Send_uint16(_network_company_info[company->index].num_station[i]); p->Send_uint16(_network_company_info[company->index].num_station[i]);
} }
@ -125,7 +111,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO); p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO);
p->Send_uint8 (NETWORK_COMPANY_INFO_VERSION); p->Send_uint8 (NETWORK_COMPANY_INFO_VERSION);
p->Send_uint8 (0); p->Send_bool (false);
cs->Send_Packet(p); cs->Send_Packet(p);
} }