mirror of https://github.com/OpenTTD/OpenTTD
(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.
parent
be35df3f03
commit
6402d00190
|
@ -395,7 +395,6 @@ void ClientNetworkUDPSocketHandler::HandleIncomingNetworkGameInfoGRFConfig(GRFCo
|
||||||
config->status = GCS_NOT_FOUND;
|
config->status = GCS_NOT_FOUND;
|
||||||
} else {
|
} else {
|
||||||
config->filename = f->filename;
|
config->filename = f->filename;
|
||||||
config->full_path = f->full_path;
|
|
||||||
config->name = f->name;
|
config->name = f->name;
|
||||||
config->info = f->info;
|
config->info = f->info;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4659,7 +4659,7 @@ static void InitNewGRFFile(const GRFConfig *config, int sprite_offset)
|
||||||
|
|
||||||
if (newfile == NULL) error ("Out of memory");
|
if (newfile == NULL) error ("Out of memory");
|
||||||
|
|
||||||
newfile->filename = strdup(config->full_path);
|
newfile->filename = strdup(config->filename);
|
||||||
newfile->sprite_offset = sprite_offset;
|
newfile->sprite_offset = sprite_offset;
|
||||||
|
|
||||||
/* Copy the initial parameter list */
|
/* Copy the initial parameter list */
|
||||||
|
@ -4936,7 +4936,7 @@ static void DecodeSpecialSprite(uint num, GrfLoadingStage stage)
|
||||||
|
|
||||||
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage)
|
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage)
|
||||||
{
|
{
|
||||||
const char *filename = config->full_path;
|
const char *filename = config->filename;
|
||||||
uint16 num;
|
uint16 num;
|
||||||
|
|
||||||
/* A .grf file is activated only if it was active when the game was
|
/* A .grf file is activated only if it was active when the game was
|
||||||
|
@ -5069,7 +5069,7 @@ void LoadNewGRF(uint load_index, uint file_index)
|
||||||
if (stage > GLS_INIT && HASBIT(c->flags, GCF_INIT_ONLY)) continue;
|
if (stage > GLS_INIT && HASBIT(c->flags, GCF_INIT_ONLY)) continue;
|
||||||
|
|
||||||
/* @todo usererror() */
|
/* @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);
|
if (stage == GLS_LABELSCAN) InitNewGRFFile(c, _cur_spriteid);
|
||||||
LoadNewGRFFile(c, slot++, stage);
|
LoadNewGRFFile(c, slot++, stage);
|
||||||
|
|
|
@ -40,7 +40,7 @@ static bool CalcGRFMD5Sum(GRFConfig *config)
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
/* open the file */
|
/* open the file */
|
||||||
f = FioFOpenFile(config->full_path);
|
f = FioFOpenFile(config->filename);
|
||||||
if (f == NULL) return false;
|
if (f == NULL) return false;
|
||||||
|
|
||||||
/* calculate md5sum */
|
/* calculate md5sum */
|
||||||
|
@ -59,16 +59,11 @@ static bool CalcGRFMD5Sum(GRFConfig *config)
|
||||||
/* Find the GRFID and calculate the md5sum */
|
/* Find the GRFID and calculate the md5sum */
|
||||||
bool FillGRFDetails(GRFConfig *config, bool is_static)
|
bool FillGRFDetails(GRFConfig *config, bool is_static)
|
||||||
{
|
{
|
||||||
if (!FioCheckFileExists(config->full_path)) {
|
if (!FioCheckFileExists(config->filename)) {
|
||||||
config->status = GCS_NOT_FOUND;
|
config->status = GCS_NOT_FOUND;
|
||||||
return false;
|
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 */
|
/* Find and load the Action 8 information */
|
||||||
/* 62 is the last file slot before sample.cat.
|
/* 62 is the last file slot before sample.cat.
|
||||||
* Should perhaps be some "don't care" value */
|
* Should perhaps be some "don't care" value */
|
||||||
|
@ -94,7 +89,6 @@ void ClearGRFConfig(GRFConfig **config)
|
||||||
/* GCF_COPY as in NOT strdupped/alloced the filename, name and info */
|
/* GCF_COPY as in NOT strdupped/alloced the filename, name and info */
|
||||||
if (!HASBIT((*config)->flags, GCF_COPY)) {
|
if (!HASBIT((*config)->flags, GCF_COPY)) {
|
||||||
free((*config)->filename);
|
free((*config)->filename);
|
||||||
free((*config)->full_path);
|
|
||||||
free((*config)->name);
|
free((*config)->name);
|
||||||
free((*config)->info);
|
free((*config)->info);
|
||||||
|
|
||||||
|
@ -134,7 +128,6 @@ GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_o
|
||||||
GRFConfig *c = CallocT<GRFConfig>(1);
|
GRFConfig *c = CallocT<GRFConfig>(1);
|
||||||
*c = *src;
|
*c = *src;
|
||||||
if (src->filename != NULL) c->filename = strdup(src->filename);
|
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->name != NULL) c->name = strdup(src->name);
|
||||||
if (src->info != NULL) c->info = strdup(src->info);
|
if (src->info != NULL) c->info = strdup(src->info);
|
||||||
if (src->error != NULL) {
|
if (src->error != NULL) {
|
||||||
|
@ -265,9 +258,7 @@ compatible_grf:
|
||||||
* already a local one, so there is no need to replace it. */
|
* already a local one, so there is no need to replace it. */
|
||||||
if (!HASBIT(c->flags, GCF_COPY)) {
|
if (!HASBIT(c->flags, GCF_COPY)) {
|
||||||
free(c->filename);
|
free(c->filename);
|
||||||
free(c->full_path);
|
|
||||||
c->filename = strdup(f->filename);
|
c->filename = strdup(f->filename);
|
||||||
c->full_path = strdup(f->full_path);
|
|
||||||
memcpy(c->md5sum, f->md5sum, sizeof(c->md5sum));
|
memcpy(c->md5sum, f->md5sum, sizeof(c->md5sum));
|
||||||
if (c->name == NULL && f->name != NULL) c->name = strdup(f->name);
|
if (c->name == NULL && f->name != NULL) c->name = strdup(f->name);
|
||||||
if (c->info == NULL && f->info != NULL) c->info = strdup(f->info);
|
if (c->info == NULL && f->info != NULL) c->info = strdup(f->info);
|
||||||
|
@ -314,7 +305,7 @@ static uint ScanPath(const char *path, int basepath_length)
|
||||||
if (strcasecmp(ext, ".grf") != 0) continue;
|
if (strcasecmp(ext, ".grf") != 0) continue;
|
||||||
|
|
||||||
GRFConfig *c = CallocT<GRFConfig>(1);
|
GRFConfig *c = CallocT<GRFConfig>(1);
|
||||||
c->full_path = strdup(filename + basepath_length);
|
c->filename = strdup(filename + basepath_length);
|
||||||
|
|
||||||
bool added = true;
|
bool added = true;
|
||||||
if (FillGRFDetails(c, false)) {
|
if (FillGRFDetails(c, false)) {
|
||||||
|
@ -341,7 +332,6 @@ static uint ScanPath(const char *path, int basepath_length)
|
||||||
/* File couldn't be opened, or is either not a NewGRF or is a
|
/* 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. */
|
* 'system' NewGRF or it's already known, so forget about it. */
|
||||||
free(c->filename);
|
free(c->filename);
|
||||||
free(c->full_path);
|
|
||||||
free(c->name);
|
free(c->name);
|
||||||
free(c->info);
|
free(c->info);
|
||||||
free(c);
|
free(c);
|
||||||
|
|
|
@ -47,7 +47,6 @@ struct GRFError {
|
||||||
|
|
||||||
struct GRFConfig : public GRFIdentifier {
|
struct GRFConfig : public GRFIdentifier {
|
||||||
char *filename;
|
char *filename;
|
||||||
char *full_path;
|
|
||||||
char *name;
|
char *name;
|
||||||
char *info;
|
char *info;
|
||||||
GRFError *error;
|
GRFError *error;
|
||||||
|
|
|
@ -191,7 +191,6 @@ static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e)
|
||||||
GRFConfig *c = CallocT<GRFConfig>(1);
|
GRFConfig *c = CallocT<GRFConfig>(1);
|
||||||
*c = *src;
|
*c = *src;
|
||||||
c->filename = strdup(src->filename);
|
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->name != NULL) c->name = strdup(src->name);
|
||||||
if (src->info != NULL) c->info = strdup(src->info);
|
if (src->info != NULL) c->info = strdup(src->info);
|
||||||
c->next = NULL;
|
c->next = NULL;
|
||||||
|
|
|
@ -1626,7 +1626,7 @@ static GRFConfig *GRFLoadConfig(IniFile *ini, const char *grpname, bool is_stati
|
||||||
|
|
||||||
for (item = group->item; item != NULL; item = item->next) {
|
for (item = group->item; item != NULL; item = item->next) {
|
||||||
GRFConfig *c = CallocT<GRFConfig>(1);
|
GRFConfig *c = CallocT<GRFConfig>(1);
|
||||||
c->full_path = strdup(item->name);
|
c->filename = strdup(item->name);
|
||||||
|
|
||||||
/* Parse parameters */
|
/* Parse parameters */
|
||||||
if (*item->value != '\0') {
|
if (*item->value != '\0') {
|
||||||
|
@ -1703,7 +1703,7 @@ static void GRFSaveConfig(IniFile *ini, const char *grpname, const GRFConfig *li
|
||||||
char params[512];
|
char params[512];
|
||||||
GRFBuildParamList(params, c, lastof(params));
|
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)->value = (char*)pool_strdup(&ini->pool, params, strlen(params));
|
||||||
item = &(*item)->next;
|
item = &(*item)->next;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue