summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-01-13 11:46:29 +0000
committerrubidium <rubidium@openttd.org>2009-01-13 11:46:29 +0000
commitfc696a7e29625d9a8e5ee5c6677a0acf52b19619 (patch)
tree5a26666ea573d89e16fd5c4abc8d675336e8d8a7
parentf0e6eeb57d13d70e220a2886564bb4ce95afe52a (diff)
downloadopenttd-fc696a7e29625d9a8e5ee5c6677a0acf52b19619.tar.xz
(svn r15052) -Codechange: move the implementation of Send_CompanyInformation to network_server.cpp as the server's the one that sends that information
-rw-r--r--src/network/core/core.cpp44
-rw-r--r--src/network/network_server.cpp42
2 files changed, 42 insertions, 44 deletions
diff --git a/src/network/core/core.cpp b/src/network/core/core.cpp
index e989d0a50..d49a2f174 100644
--- a/src/network/core/core.cpp
+++ b/src/network/core/core.cpp
@@ -8,8 +8,6 @@
#include "../../stdafx.h"
#include "../../debug.h"
-#include "../../company_base.h"
-#include "../../strings_func.h"
#include "../../string_func.h"
#include "../../date_func.h"
#include "os_abstraction.h"
@@ -17,7 +15,6 @@
#include "packet.h"
#include "../network_func.h"
-#include "table/strings.h"
#ifdef __MORPHOS__
/* the library base is required here */
@@ -126,45 +123,4 @@ void NetworkSocketHandler::Recv_GRFIdentifier(Packet *p, GRFIdentifier *grf)
}
}
-void NetworkSocketHandler::Send_CompanyInformation(Packet *p, const Company *c, const NetworkCompanyStats *stats)
-{
- /* Grab the company name */
- char company_name[NETWORK_COMPANY_NAME_LENGTH];
- SetDParam(0, c->index);
- GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
-
- /* 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 passord for the company else send 0 */
- p->Send_bool (!StrEmpty(_network_company_states[c->index].password));
-
- for (int i = 0; i < NETWORK_VEHICLE_TYPES; i++) {
- p->Send_uint16(stats->num_vehicle[i]);
- }
-
- for (int i = 0; i < NETWORK_STATION_TYPES; i++) {
- p->Send_uint16(stats->num_station[i]);
- }
-}
-
#endif /* ENABLE_NETWORK */
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index d7ed77ba0..a81ba049e 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -1245,6 +1245,47 @@ static NetworkServerPacket * const _network_server_packet[] = {
// If this fails, check the array above with network_data.h
assert_compile(lengthof(_network_server_packet) == PACKET_END);
+void NetworkSocketHandler::Send_CompanyInformation(Packet *p, const Company *c, const NetworkCompanyStats *stats)
+{
+ /* Grab the company name */
+ char company_name[NETWORK_COMPANY_NAME_LENGTH];
+ SetDParam(0, c->index);
+ GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
+
+ /* 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 passord for the company else send 0 */
+ p->Send_bool (!StrEmpty(_network_company_states[c->index].password));
+
+ for (int i = 0; i < NETWORK_VEHICLE_TYPES; i++) {
+ p->Send_uint16(stats->num_vehicle[i]);
+ }
+
+ for (int i = 0; i < NETWORK_STATION_TYPES; i++) {
+ p->Send_uint16(stats->num_station[i]);
+ }
+}
+
/**
* Populate the company stats.
* @param stats the stats to update
@@ -1587,4 +1628,5 @@ bool NetworkCompanyHasClients(CompanyID company)
}
return false;
}
+
#endif /* ENABLE_NETWORK */