Changeset - r7034:02d83c0816e7
[Not reviewed]
master
0 6 0
rubidium - 17 years ago 2007-06-23 21:12:09
rubidium@openttd.org
(svn r10298) -Fix [FS#903]: show the subdirectory below the default data directory in this filename in the newgrf list. The directory was removed in r9560 because then it used to full path instead of the path relative to the data directory, but since the inclusion of "search paths" that is not necessary anymore.
6 files changed with 8 insertions and 21 deletions:
0 comments (0 inline, 0 general)
src/network/network_udp.cpp
Show inline comments
 
@@ -392,13 +392,12 @@ void ClientNetworkUDPSocketHandler::Hand
 
		 * 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->full_path = f->full_path;
 
		config->name      = f->name;
 
		config->info      = f->info;
 
	}
 
	SETBIT(config->flags, GCF_COPY);
 
}
 

	
src/newgrf.cpp
Show inline comments
 
@@ -4656,13 +4656,13 @@ static void InitNewGRFFile(const GRFConf
 
	}
 

	
 
	newfile = CallocT<GRFFile>(1);
 

	
 
	if (newfile == NULL) error ("Out of memory");
 

	
 
	newfile->filename = strdup(config->full_path);
 
	newfile->filename = strdup(config->filename);
 
	newfile->sprite_offset = sprite_offset;
 

	
 
	/* Copy the initial parameter list */
 
	assert(lengthof(newfile->param) == lengthof(config->param) && lengthof(config->param) == 0x80);
 
	newfile->param_end = config->num_params;
 
	memcpy(newfile->param, config->param, sizeof(newfile->param));
 
@@ -4933,13 +4933,13 @@ static void DecodeSpecialSprite(uint num
 
	free(buf);
 
}
 

	
 

	
 
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage)
 
{
 
	const char *filename = config->full_path;
 
	const char *filename = config->filename;
 
	uint16 num;
 

	
 
	/* A .grf file is activated only if it was active when the game was
 
	 * started.  If a game is loaded, only its active .grfs will be
 
	 * reactivated, unless "loadallgraphics on" is used.  A .grf file is
 
	 * considered active if its action 8 has been processed, i.e. its
 
@@ -5066,13 +5066,13 @@ void LoadNewGRF(uint load_index, uint fi
 
		_cur_spriteid = load_index;
 
		for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
 
			if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND) continue;
 
			if (stage > GLS_INIT && HASBIT(c->flags, GCF_INIT_ONLY)) continue;
 

	
 
			/* @todo usererror() */
 
			if (!FioCheckFileExists(c->full_path)) error("NewGRF file is missing '%s'", c->filename);
 
			if (!FioCheckFileExists(c->filename)) error("NewGRF file is missing '%s'", c->filename);
 

	
 
			if (stage == GLS_LABELSCAN) InitNewGRFFile(c, _cur_spriteid);
 
			LoadNewGRFFile(c, slot++, stage);
 
			if (stage == GLS_RESERVE) {
 
				if (c->status == GCS_ACTIVATED) c->status = GCS_INITIALISED;
 
			} else if (stage == GLS_ACTIVATION) {
src/newgrf_config.cpp
Show inline comments
 
@@ -37,13 +37,13 @@ static bool CalcGRFMD5Sum(GRFConfig *con
 
	FILE *f;
 
	md5_state_t md5state;
 
	md5_byte_t buffer[1024];
 
	size_t len;
 

	
 
	/* open the file */
 
	f = FioFOpenFile(config->full_path);
 
	f = FioFOpenFile(config->filename);
 
	if (f == NULL) return false;
 

	
 
	/* calculate md5sum */
 
	md5_init(&md5state);
 
	while ((len = fread(buffer, 1, sizeof(buffer), f)) != 0) {
 
		md5_append(&md5state, buffer, len);
 
@@ -56,22 +56,17 @@ static bool CalcGRFMD5Sum(GRFConfig *con
 
}
 

	
 

	
 
/* Find the GRFID and calculate the md5sum */
 
bool FillGRFDetails(GRFConfig *config, bool is_static)
 
{
 
	if (!FioCheckFileExists(config->full_path)) {
 
	if (!FioCheckFileExists(config->filename)) {
 
		config->status = GCS_NOT_FOUND;
 
		return false;
 
	}
 

	
 
	if (config->filename == NULL) {
 
		const char *t = strrchr(config->full_path, PATHSEPCHAR);
 
		config->filename = strdup(t != NULL ? t + 1 : config->full_path);
 
	}
 

	
 
	/* Find and load the Action 8 information */
 
	/* 62 is the last file slot before sample.cat.
 
	 * Should perhaps be some "don't care" value */
 
	LoadNewGRFFile(config, 62, GLS_FILESCAN);
 

	
 
	/* Skip if the grfid is 0 (not read) or 0xFFFFFFFF (ttdp system grf) */
 
@@ -91,13 +86,12 @@ bool FillGRFDetails(GRFConfig *config, b
 

	
 
void ClearGRFConfig(GRFConfig **config)
 
{
 
	/* GCF_COPY as in NOT strdupped/alloced the filename, name and info */
 
	if (!HASBIT((*config)->flags, GCF_COPY)) {
 
		free((*config)->filename);
 
		free((*config)->full_path);
 
		free((*config)->name);
 
		free((*config)->info);
 

	
 
		if ((*config)->error != NULL) {
 
			free((*config)->error->custom_message);
 
			free((*config)->error->data);
 
@@ -131,13 +125,12 @@ GRFConfig **CopyGRFConfigList(GRFConfig 
 
	/* Clear destination as it will be overwritten */
 
	ClearGRFConfigList(dst);
 
	for (; src != NULL; src = src->next) {
 
		GRFConfig *c = CallocT<GRFConfig>(1);
 
		*c = *src;
 
		if (src->filename  != NULL) c->filename  = strdup(src->filename);
 
		if (src->full_path != NULL) c->full_path = strdup(src->full_path);
 
		if (src->name      != NULL) c->name      = strdup(src->name);
 
		if (src->info      != NULL) c->info      = strdup(src->info);
 
		if (src->error     != NULL) {
 
			c->error = CallocT<GRFError>(1);
 
			memcpy(c->error, src->error, sizeof(GRFError));
 
			if (src->error->data != NULL) c->error->data = strdup(src->error->data);
 
@@ -262,15 +255,13 @@ compatible_grf:
 
			 * to load the GRF here, we need the correct filename, so overwrite that
 
			 * in any case and set the name and info when it is not set already.
 
			 * When the GCF_COPY flag is set, it is certain that the filename is
 
			 * already a local one, so there is no need to replace it. */
 
			if (!HASBIT(c->flags, GCF_COPY)) {
 
				free(c->filename);
 
				free(c->full_path);
 
				c->filename = strdup(f->filename);
 
				c->full_path = strdup(f->full_path);
 
				memcpy(c->md5sum, f->md5sum, sizeof(c->md5sum));
 
				if (c->name == NULL && f->name != NULL) c->name = strdup(f->name);
 
				if (c->info == NULL && f->info != NULL) c->info = strdup(f->info);
 
				c->error = NULL;
 
			}
 
		}
 
@@ -311,13 +302,13 @@ static uint ScanPath(const char *path, i
 

	
 
			/* If no extension or extension isn't .grf, skip the file */
 
			if (ext == NULL) continue;
 
			if (strcasecmp(ext, ".grf") != 0) continue;
 

	
 
			GRFConfig *c = CallocT<GRFConfig>(1);
 
			c->full_path = strdup(filename + basepath_length);
 
			c->filename = strdup(filename + basepath_length);
 

	
 
			bool added = true;
 
			if (FillGRFDetails(c, false)) {
 
				if (_all_grfs == NULL) {
 
					_all_grfs = c;
 
				} else {
 
@@ -338,13 +329,12 @@ static uint ScanPath(const char *path, i
 
			}
 

	
 
			if (!added) {
 
				/* File couldn't be opened, or is either not a NewGRF or is a
 
				 * 'system' NewGRF or it's already known, so forget about it. */
 
				free(c->filename);
 
				free(c->full_path);
 
				free(c->name);
 
				free(c->info);
 
				free(c);
 
			} else {
 
				num++;
 
			}
src/newgrf_config.h
Show inline comments
 
@@ -44,13 +44,12 @@ struct GRFError {
 
	uint8 num_params;
 
	uint8 param_number[2];
 
};
 

	
 
struct GRFConfig : public GRFIdentifier {
 
	char *filename;
 
	char *full_path;
 
	char *name;
 
	char *info;
 
	GRFError *error;
 

	
 
	uint8 flags;
 
	GRFStatus status;
src/newgrf_gui.cpp
Show inline comments
 
@@ -188,13 +188,12 @@ static void NewGRFAddDlgWndProc(Window *
 
						}
 

	
 
						/* Copy GRF details from scanned list */
 
						GRFConfig *c = CallocT<GRFConfig>(1);
 
						*c = *src;
 
						c->filename = strdup(src->filename);
 
						if (src->full_path != NULL) c->full_path = strdup(src->full_path);
 
						if (src->name      != NULL) c->name      = strdup(src->name);
 
						if (src->info      != NULL) c->info      = strdup(src->info);
 
						c->next = NULL;
 

	
 
						/* Append GRF config to configuration list */
 
						*list = c;
src/settings.cpp
Show inline comments
 
@@ -1623,13 +1623,13 @@ static GRFConfig *GRFLoadConfig(IniFile 
 
	GRFConfig **curr = &first;
 

	
 
	if (group == NULL) return NULL;
 

	
 
	for (item = group->item; item != NULL; item = item->next) {
 
		GRFConfig *c = CallocT<GRFConfig>(1);
 
		c->full_path = strdup(item->name);
 
		c->filename = strdup(item->name);
 

	
 
		/* Parse parameters */
 
		if (*item->value != '\0') {
 
			c->num_params = parse_intlist(item->value, (int*)c->param, lengthof(c->param));
 
			if (c->num_params == (byte)-1) {
 
				ShowInfoF("ini: error in array '%s'", item->name);
 
@@ -1700,13 +1700,13 @@ static void GRFSaveConfig(IniFile *ini, 
 
	item = &group->item;
 

	
 
	for (c = list; c != NULL; c = c->next) {
 
		char params[512];
 
		GRFBuildParamList(params, c, lastof(params));
 

	
 
		*item = ini_item_alloc(group, c->full_path, strlen(c->full_path));
 
		*item = ini_item_alloc(group, c->filename, strlen(c->filename));
 
		(*item)->value = (char*)pool_strdup(&ini->pool, params, strlen(params));
 
		item = &(*item)->next;
 
	}
 
}
 

	
 
/* Common handler for saving/loading variables to the configuration file */
0 comments (0 inline, 0 general)