Changeset - r13054:319ef5c8a6c7
[Not reviewed]
master
0 3 0
rubidium - 15 years ago 2009-09-17 21:14:16
rubidium@openttd.org
(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
3 files changed with 40 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/network/network_func.h
Show inline comments
 
@@ -85,5 +85,7 @@ void CDECL NetworkAddChatMessage(TextCol
 
void NetworkUndrawChatMessage();
 
void NetworkChatMessageDailyLoop();
 

	
 
void NetworkAfterNewGRFScan();
 

	
 
#endif /* ENABLE_NETWORK */
 
#endif /* NETWORK_FUNC_H */
src/network/network_gamelist.cpp
Show inline comments
 
@@ -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 */
src/newgrf_config.cpp
Show inline comments
 
@@ -17,6 +17,7 @@
 
#include "string_func.h"
 
#include "gamelog.h"
 
#include "network/network_type.h"
 
#include "network/network_func.h"
 
#include "gfx_func.h"
 

	
 
#include "fileio_func.h"
 
@@ -391,6 +392,10 @@ void ScanNewGRFFiles()
 
	_all_grfs = to_sort[0];
 

	
 
	free(to_sort);
 

	
 
#ifdef ENABLE_NETWORK
 
	NetworkAfterNewGRFScan();
 
#endif
 
}
 

	
 

	
0 comments (0 inline, 0 general)