summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-11-04 22:32:21 +0000
committerrubidium <rubidium@openttd.org>2011-11-04 22:32:21 +0000
commitc8857d467903b9819c82d95a8967f53a55765db0 (patch)
treecab23378ad04fabf9a89716cd79a3d142a4ef1d0 /src
parent707b0f48e6b4d886a7e744802096a56a5a097e3e (diff)
downloadopenttd-c8857d467903b9819c82d95a8967f53a55765db0.tar.xz
(svn r23115) -Fix [FS#4813]: allow accessing the server's client info as well in the admin network (dihedral)
Diffstat (limited to 'src')
-rw-r--r--src/network/network_admin.cpp21
-rw-r--r--src/network/network_admin.h2
2 files changed, 14 insertions, 9 deletions
diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp
index 96f7f2924..ecf94ab0d 100644
--- a/src/network/network_admin.cpp
+++ b/src/network/network_admin.cpp
@@ -226,18 +226,18 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientJoin(ClientID clien
/**
* Send an initial set of data from some client's information.
- * @param cs The information about a client.
+ * @param cs The socket of the client.
+ * @param ci The information about the client.
*/
-NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientInfo(const NetworkClientSocket *cs)
+NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientInfo(const NetworkClientSocket *cs, const NetworkClientInfo *ci)
{
/* Only send data when we're a proper client, not just someone trying to query the server. */
- const NetworkClientInfo *ci = cs->GetInfo();
if (ci == NULL) return NETWORK_RECV_STATUS_OKAY;
Packet *p = new Packet(ADMIN_PACKET_SERVER_CLIENT_INFO);
p->Send_uint32(ci->client_id);
- p->Send_string(const_cast<NetworkAddress &>(cs->client_address).GetHostname());
+ p->Send_string(cs == NULL ? "" : const_cast<NetworkAddress &>(cs->client_address).GetHostname());
p->Send_string(ci->client_name);
p->Send_uint8 (ci->client_lang);
p->Send_uint32(ci->join_date);
@@ -658,12 +658,17 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet *p)
/* The admin is requesting client info. */
const NetworkClientSocket *cs;
if (d1 == UINT32_MAX) {
+ this->SendClientInfo(NULL, NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER));
FOR_ALL_CLIENT_SOCKETS(cs) {
- this->SendClientInfo(cs);
+ this->SendClientInfo(cs, cs->GetInfo());
}
} else {
- cs = NetworkClientSocket::GetByClientID((ClientID)d1);
- if (cs != NULL) this->SendClientInfo(cs);
+ if (d1 == CLIENT_ID_SERVER) {
+ this->SendClientInfo(NULL, NetworkClientInfo::GetByClientID(CLIENT_ID_SERVER));
+ } else {
+ cs = NetworkClientSocket::GetByClientID((ClientID)d1);
+ if (cs != NULL) this->SendClientInfo(cs, cs->GetInfo());
+ }
}
break;
@@ -745,7 +750,7 @@ void NetworkAdminClientInfo(const NetworkClientSocket *cs, bool new_client)
ServerNetworkAdminSocketHandler *as;
FOR_ALL_ACTIVE_ADMIN_SOCKETS(as) {
if (as->update_frequency[ADMIN_UPDATE_CLIENT_INFO] & ADMIN_FREQUENCY_AUTOMATIC) {
- as->SendClientInfo(cs);
+ as->SendClientInfo(cs, cs->GetInfo());
if (new_client) {
as->SendClientJoin(cs->client_id);
}
diff --git a/src/network/network_admin.h b/src/network/network_admin.h
index cbb058655..5a3afc084 100644
--- a/src/network/network_admin.h
+++ b/src/network/network_admin.h
@@ -51,7 +51,7 @@ public:
NetworkRecvStatus SendDate();
NetworkRecvStatus SendClientJoin(ClientID client_id);
- NetworkRecvStatus SendClientInfo(const NetworkClientSocket *cs);
+ NetworkRecvStatus SendClientInfo(const NetworkClientSocket *cs, const NetworkClientInfo *ci);
NetworkRecvStatus SendClientUpdate(const NetworkClientInfo *ci);
NetworkRecvStatus SendClientQuit(ClientID client_id);
NetworkRecvStatus SendClientError(ClientID client_id, NetworkErrorCode error);