From a9c8dbc0a0e1f1fc4434cf0c83ff658ab8d9e3d9 Mon Sep 17 00:00:00 2001 From: yexo Date: Thu, 25 Feb 2010 20:05:31 +0000 Subject: (svn r19255) -Codechange: encapsulate GRFIdentifier in GRFConfig instead of subclassing it --- src/network/core/udp.cpp | 4 ++-- src/network/network_client.cpp | 10 +++++----- src/network/network_gamelist.cpp | 4 ++-- src/network/network_gui.cpp | 2 +- src/network/network_server.cpp | 2 +- src/network/network_udp.cpp | 18 +++++++++--------- 6 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/network') diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp index e855bdfcf..4bf0c1e30 100644 --- a/src/network/core/udp.cpp +++ b/src/network/core/udp.cpp @@ -181,7 +181,7 @@ void NetworkUDPSocketHandler::Send_NetworkGameInfo(Packet *p, const NetworkGameI /* Send actual GRF Identifications */ for (c = info->grfconfig; c != NULL; c = c->next) { - if (!HasBit(c->flags, GCF_STATIC)) this->Send_GRFIdentifier(p, c); + if (!HasBit(c->flags, GCF_STATIC)) this->Send_GRFIdentifier(p, &c->ident); } } @@ -239,7 +239,7 @@ void NetworkUDPSocketHandler::Recv_NetworkGameInfo(Packet *p, NetworkGameInfo *i for (i = 0; i < num_grfs; i++) { GRFConfig *c = CallocT(1); - this->Recv_GRFIdentifier(p, c); + this->Recv_GRFIdentifier(p, &c->ident); this->HandleIncomingNetworkGameInfoGRFConfig(c); /* Append GRFConfig to the list */ diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index f20bafab7..d5007ef9a 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -512,15 +512,15 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CHECK_NEWGRFS) /* Check all GRFs */ for (; grf_count > 0; grf_count--) { GRFConfig c; - MY_CLIENT->Recv_GRFIdentifier(p, &c); + MY_CLIENT->Recv_GRFIdentifier(p, &c.ident); /* Check whether we know this GRF */ - const GRFConfig *f = FindGRFConfig(c.grfid, c.md5sum); + const GRFConfig *f = FindGRFConfig(c.ident.grfid, c.ident.md5sum); if (f == NULL) { /* We do not know this GRF, bail out of initialization */ - char buf[sizeof(c.md5sum) * 2 + 1]; - md5sumToString(buf, lastof(buf), c.md5sum); - DEBUG(grf, 0, "NewGRF %08X not found; checksum %s", BSWAP32(c.grfid), buf); + char buf[sizeof(c.ident.md5sum) * 2 + 1]; + md5sumToString(buf, lastof(buf), c.ident.md5sum); + DEBUG(grf, 0, "NewGRF %08X not found; checksum %s", BSWAP32(c.ident.grfid), buf); ret = NETWORK_RECV_STATUS_NEWGRF_MISMATCH; } } diff --git a/src/network/network_gamelist.cpp b/src/network/network_gamelist.cpp index 62fbc822b..61efe3b79 100644 --- a/src/network/network_gamelist.cpp +++ b/src/network/network_gamelist.cpp @@ -172,12 +172,12 @@ void NetworkAfterNewGRFScan() for (GRFConfig *c = item->info.grfconfig; c != NULL; c = c->next) { assert(HasBit(c->flags, GCF_COPY)); - const GRFConfig *f = FindGRFConfig(c->grfid, c->md5sum); + const GRFConfig *f = FindGRFConfig(c->ident.grfid, c->ident.md5sum); if (f == NULL) { /* Don't know the GRF, so mark game incompatible and the (possibly) * already resolved name for this GRF (another server has sent the * name of the GRF already */ - c->name = FindUnknownGRFName(c->grfid, c->md5sum, true); + c->name = FindUnknownGRFName(c->ident.grfid, c->ident.md5sum, true); c->status = GCS_NOT_FOUND; /* If we miss a file, we're obviously incompatible */ diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index b15113243..d9f4b7184 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -797,7 +797,7 @@ public: for (GRFConfig *c = item->info.grfconfig; c != NULL; c = c->next) { if (c->status != GCS_NOT_FOUND) continue; - const GRFConfig *f = FindGRFConfig(c->grfid, c->md5sum); + const GRFConfig *f = FindGRFConfig(c->ident.grfid, c->ident.md5sum); if (f == NULL) { missing_grfs = true; continue; diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index c090d176d..94c2911f2 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -202,7 +202,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CHECK_NEWGRFS)(NetworkClientSocket * p->Send_uint8 (grf_count); for (c = _grfconfig; c != NULL; c = c->next) { - if (!HasBit(c->flags, GCF_STATIC)) cs->Send_GRFIdentifier(p, c); + if (!HasBit(c->flags, GCF_STATIC)) cs->Send_GRFIdentifier(p, &c->ident); } cs->Send_Packet(p); diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index 2197da8d4..2f613fade 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -180,16 +180,16 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_GET_NEWGRFS) GRFConfig c; const GRFConfig *f; - this->Recv_GRFIdentifier(p, &c); + this->Recv_GRFIdentifier(p, &c.ident); /* Find the matching GRF file */ - f = FindGRFConfig(c.grfid, c.md5sum); + f = FindGRFConfig(c.ident.grfid, c.ident.md5sum); if (f == NULL) continue; // The GRF is unknown to this server /* If the reply might exceed the size of the packet, only reply * the current list and do not send the other data. * The name could be an empty string, if so take the filename. */ - packet_len += sizeof(c.grfid) + sizeof(c.md5sum) + + packet_len += sizeof(c.ident.grfid) + sizeof(c.ident.md5sum) + min(strlen((!StrEmpty(f->name)) ? f->name : f->filename) + 1, (size_t)NETWORK_GRF_NAME_LENGTH); if (packet_len > SEND_MTU - 4) { // 4 is 3 byte header + grf count in reply break; @@ -207,7 +207,7 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_GET_NEWGRFS) /* The name could be an empty string, if so take the filename */ strecpy(name, (!StrEmpty(in_reply[i]->name)) ? in_reply[i]->name : in_reply[i]->filename, lastof(name)); - this->Send_GRFIdentifier(&packet, in_reply[i]); + this->Send_GRFIdentifier(&packet, &in_reply[i]->ident); packet.Send_string(name); } @@ -268,7 +268,7 @@ DEF_UDP_RECEIVE_COMMAND(Client, PACKET_UDP_SERVER_RESPONSE) packet.Send_uint8(in_request_count); for (i = 0; i < in_request_count; i++) { - this->Send_GRFIdentifier(&packet, in_request[i]); + this->Send_GRFIdentifier(&packet, &in_request[i]->ident); } this->SendPacket(&packet, &item->address); @@ -343,7 +343,7 @@ DEF_UDP_RECEIVE_COMMAND(Client, PACKET_UDP_SERVER_NEWGRFS) char name[NETWORK_GRF_NAME_LENGTH]; GRFConfig c; - this->Recv_GRFIdentifier(p, &c); + this->Recv_GRFIdentifier(p, &c.ident); p->Recv_string(name, sizeof(name)); /* An empty name is not possible under normal circumstances @@ -353,7 +353,7 @@ DEF_UDP_RECEIVE_COMMAND(Client, PACKET_UDP_SERVER_NEWGRFS) /* Finds the fake GRFConfig for the just read GRF ID and MD5sum tuple. * If it exists and not resolved yet, then name of the fake GRF is * overwritten with the name from the reply. */ - unknown_name = FindUnknownGRFName(c.grfid, c.md5sum, false); + unknown_name = FindUnknownGRFName(c.ident.grfid, c.ident.md5sum, false); if (unknown_name != NULL && strcmp(unknown_name, UNKNOWN_GRF_NAME_PLACEHOLDER) == 0) { ttd_strlcpy(unknown_name, name, NETWORK_GRF_NAME_LENGTH); } @@ -363,12 +363,12 @@ DEF_UDP_RECEIVE_COMMAND(Client, PACKET_UDP_SERVER_NEWGRFS) void ClientNetworkUDPSocketHandler::HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config) { /* Find the matching GRF file */ - const GRFConfig *f = FindGRFConfig(config->grfid, config->md5sum); + const GRFConfig *f = FindGRFConfig(config->ident.grfid, config->ident.md5sum); if (f == NULL) { /* Don't know the GRF, so mark game incompatible and the (possibly) * already resolved name for this GRF (another server has sent the * name of the GRF already */ - config->name = FindUnknownGRFName(config->grfid, config->md5sum, true); + config->name = FindUnknownGRFName(config->ident.grfid, config->ident.md5sum, true); config->status = GCS_NOT_FOUND; } else { config->filename = f->filename; -- cgit v1.2.3-70-g09d2