summaryrefslogtreecommitdiff
path: root/src/network/network_gamelist.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-09-17 21:14:16 +0000
committerrubidium <rubidium@openttd.org>2009-09-17 21:14:16 +0000
commit55c0109ee0053d224236ec536629d03d7b6ec13c (patch)
tree54cd778bcc859dfbf1a0b94a4f0f96b595f298bf /src/network/network_gamelist.cpp
parent1858fef92f53651915cffa12c820fc68272379ce (diff)
downloadopenttd-55c0109ee0053d224236ec536629d03d7b6ec13c.tar.xz
(svn r17562) -Fix [FS#2972]: the NewGRF settings of (remote) network games did not get properly updated when the NewGRFs were rescanned causing reading of freed data
Diffstat (limited to 'src/network/network_gamelist.cpp')
-rw-r--r--src/network/network_gamelist.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/network/network_gamelist.cpp b/src/network/network_gamelist.cpp
index b751fba34..5ac4ad1df 100644
--- a/src/network/network_gamelist.cpp
+++ b/src/network/network_gamelist.cpp
@@ -161,4 +161,37 @@ void NetworkGameListRequery()
}
}
+/**
+ * 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->grfid, c->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->status = GCS_NOT_FOUND;
+
+ /* If we miss a file, we're obviously incompatible */
+ item->info.compatible = false;
+ } else {
+ c->filename = f->filename;
+ c->name = f->name;
+ c->info = f->info;
+ c->status = GCS_UNKNOWN;
+ }
+ }
+ }
+}
+
#endif /* ENABLE_NETWORK */