/** The return of the client's request of the names of some NewGRFs */ DEF_UDP_RECEIVE_COMMAND(Client, PACKET_UDP_SERVER_NEWGRFS) { uint8 num_grfs; uint i; DEBUG(net, 6, "[udp] newgrf data reply from %s", client_addr->GetAddressAsString()); num_grfs = p->Recv_uint8 (); if (num_grfs > NETWORK_MAX_GRF_COUNT) return; for (i = 0; i < num_grfs; i++) { char *unknown_name; char name[NETWORK_GRF_NAME_LENGTH]; GRFConfig c; this->Recv_GRFIdentifier(p, &c); p->Recv_string(name, sizeof(name)); /* An empty name is not possible under normal circumstances * and causes problems when showing the NewGRF list. */ if (StrEmpty(name)) continue; /* 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); if (unknown_name != NULL && strcmp(unknown_name, UNKNOWN_GRF_NAME_PLACEHOLDER) == 0) { ttd_strlcpy(unknown_name, name, NETWORK_GRF_NAME_LENGTH); } } }
void ClientNetworkUDPSocketHandler::HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config) { /* Find the matching GRF file */ const GRFConfig *f = FindGRFConfig(config->grfid, config->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->status = GCS_NOT_FOUND; } else { config->filename = f->filename; config->name = f->name; config->info = f->info; } SetBit(config->flags, GCF_COPY); }
/** * Rebuild the GRFConfig's of the servers in the game list as we did * a rescan and might have found new NewGRFs. */ void NetworkAfterNewGRFScan() { for (NetworkGameList *item = _network_game_list; item != NULL; item = item->next) { /* Reset compatability state */ item->info.compatible = item->info.version_compatible; for (GRFConfig *c = item->info.grfconfig; c != NULL; c = c->next) { assert(HasBit(c->flags, GCF_COPY)); const GRFConfig *f = FindGRFConfig(c->ident.grfid, FGCM_EXACT, 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->Release(); c->name = FindUnknownGRFName(c->ident.grfid, c->ident.md5sum, true); c->name->AddRef(); c->status = GCS_NOT_FOUND; /* If we miss a file, we're obviously incompatible */ item->info.compatible = false; } else { c->filename = f->filename; c->name->Release(); c->name = f->name; c->name->AddRef(); c->info->Release(); c->info = f->info; c->info->AddRef(); c->status = GCS_UNKNOWN; } } } InvalidateWindowClassesData(WC_NETWORK_WINDOW); }