mirror of https://github.com/OpenTTD/OpenTTD
(svn r8844) -Revert partly (r8820, r8806): Change AppendToGRFConfigList to add the allocated GRFConfig to its list and not copy it.
parent
c834320611
commit
31be3c6fac
|
@ -178,13 +178,13 @@ void AppendStaticGRFConfigs(GRFConfig **dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Appends an element to a list of GRFs
|
/** Appends an element to a list of GRFs
|
||||||
* @param dst the head of the list to add to
|
* @param dst the head of the list to add to */
|
||||||
* @param el the element that is being added (as a copy) */
|
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el)
|
||||||
void AppendToGRFConfigList(GRFConfig **dst, const GRFConfig *el)
|
|
||||||
{
|
{
|
||||||
GRFConfig **tail = dst;
|
GRFConfig **tail = dst;
|
||||||
while (*tail != NULL) tail = &(*tail)->next;
|
while (*tail != NULL) tail = &(*tail)->next;
|
||||||
CopyGRFConfigList(tail, el);
|
*tail = el;
|
||||||
|
|
||||||
RemoveDuplicatesFromGRFConfigList(*dst);
|
RemoveDuplicatesFromGRFConfigList(*dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,10 +451,9 @@ static const SaveLoad _grfconfig_desc[] = {
|
||||||
|
|
||||||
static void Save_NGRF(void)
|
static void Save_NGRF(void)
|
||||||
{
|
{
|
||||||
GRFConfig *c;
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
for (c = _grfconfig; c != NULL; c = c->next) {
|
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
|
||||||
if (HASBIT(c->flags, GCF_STATIC)) continue;
|
if (HASBIT(c->flags, GCF_STATIC)) continue;
|
||||||
SlSetArrayIndex(index++);
|
SlSetArrayIndex(index++);
|
||||||
SlObject(c, _grfconfig_desc);
|
SlObject(c, _grfconfig_desc);
|
||||||
|
@ -464,12 +463,11 @@ static void Save_NGRF(void)
|
||||||
|
|
||||||
static void Load_NGRF(void)
|
static void Load_NGRF(void)
|
||||||
{
|
{
|
||||||
GRFConfig c;
|
ClearGRFConfigList(&_grfconfig);
|
||||||
memset(&c, 0, sizeof(GRFConfig));
|
|
||||||
|
|
||||||
while (SlIterateArray() != -1) {
|
while (SlIterateArray() != -1) {
|
||||||
SlObject(&c, _grfconfig_desc);
|
GRFConfig *c = CallocT<GRFConfig>(1);
|
||||||
AppendToGRFConfigList(&_grfconfig, &c);
|
SlObject(c, _grfconfig_desc);
|
||||||
|
AppendToGRFConfigList(&_grfconfig, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append static NewGRF configuration */
|
/* Append static NewGRF configuration */
|
||||||
|
|
|
@ -50,7 +50,7 @@ const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL);
|
||||||
GRFConfig *GetGRFConfig(uint32 grfid);
|
GRFConfig *GetGRFConfig(uint32 grfid);
|
||||||
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src);
|
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src);
|
||||||
void AppendStaticGRFConfigs(GRFConfig **dst);
|
void AppendStaticGRFConfigs(GRFConfig **dst);
|
||||||
void AppendToGRFConfigList(GRFConfig **dst, const GRFConfig *el);
|
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el);
|
||||||
void ClearGRFConfig(GRFConfig **config);
|
void ClearGRFConfig(GRFConfig **config);
|
||||||
void ClearGRFConfigList(GRFConfig **config);
|
void ClearGRFConfigList(GRFConfig **config);
|
||||||
void ResetGRFConfig(bool defaults);
|
void ResetGRFConfig(bool defaults);
|
||||||
|
|
|
@ -1367,18 +1367,16 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num)
|
||||||
ReadUint32(ls); ReadByte(ls); len -= 5;
|
ReadUint32(ls); ReadByte(ls); len -= 5;
|
||||||
|
|
||||||
ClearGRFConfigList(&_grfconfig);
|
ClearGRFConfigList(&_grfconfig);
|
||||||
GRFConfig c;
|
|
||||||
memset(&c, 0, sizeof(GRFConfig));
|
|
||||||
|
|
||||||
while (len != 0) {
|
while (len != 0) {
|
||||||
uint32 grfid = ReadUint32(ls);
|
uint32 grfid = ReadUint32(ls);
|
||||||
|
|
||||||
if (ReadByte(ls) == 1) {
|
if (ReadByte(ls) == 1) {
|
||||||
c.grfid = grfid;
|
GRFConfig *c = CallocT<GRFConfig>(1);
|
||||||
c.filename = "TTDP game, no information";
|
c->grfid = grfid;
|
||||||
|
c->filename = strdup("TTDP game, no information");
|
||||||
|
|
||||||
AppendToGRFConfigList(&_grfconfig, &c);
|
AppendToGRFConfigList(&_grfconfig, c);
|
||||||
DEBUG(oldloader, 3, "TTDPatch game using GRF file with GRFID %0X", BSWAP32(c.grfid));
|
DEBUG(oldloader, 3, "TTDPatch game using GRF file with GRFID %0X", BSWAP32(c->grfid));
|
||||||
}
|
}
|
||||||
len -= 5;
|
len -= 5;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue