mirror of https://github.com/OpenTTD/OpenTTD
(svn r8820) -Codechange (r8807, r8806): Remove the unneeded calloc/free allocation of GRFConfig and turn it into a simple variable (it's supposed to be data-only). Thanks Tron.
parent
f79618118f
commit
5b237758aa
|
@ -465,12 +465,13 @@ static void Save_NGRF(void)
|
||||||
|
|
||||||
static void Load_NGRF(void)
|
static void Load_NGRF(void)
|
||||||
{
|
{
|
||||||
GRFConfig *c = CallocT<GRFConfig>(1);
|
GRFConfig c;
|
||||||
|
memset(&c, 0, sizeof(GRFConfig));
|
||||||
|
|
||||||
while (SlIterateArray() != -1) {
|
while (SlIterateArray() != -1) {
|
||||||
SlObject(c, _grfconfig_desc);
|
SlObject(&c, _grfconfig_desc);
|
||||||
AppendToGRFConfigList(&_grfconfig, c);
|
AppendToGRFConfigList(&_grfconfig, &c);
|
||||||
}
|
}
|
||||||
free(c);
|
|
||||||
|
|
||||||
/* Append static NewGRF configuration */
|
/* Append static NewGRF configuration */
|
||||||
AppendStaticGRFConfigs(&_grfconfig);
|
AppendStaticGRFConfigs(&_grfconfig);
|
||||||
|
|
|
@ -1359,38 +1359,41 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num)
|
||||||
uint32 len = ReadUint32(ls);
|
uint32 len = ReadUint32(ls);
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
/* List of GRFIDs, used in the savegame
|
/* List of GRFIDs, used in the savegame. 0x8004 is the new ID
|
||||||
* They are saved in a 'GRFID:4 active:1' format, 5 bytes for each entry */
|
* They are saved in a 'GRFID:4 active:1' format, 5 bytes for each entry */
|
||||||
case 0x2:
|
case 0x2:
|
||||||
case 0x8004: {
|
case 0x8004: {
|
||||||
/* Skip the first element: TTDP hack for the Action D special variables FFFF0000 01 */
|
/* Skip the first element: TTDP hack for the Action D special variables (FFFF0000 01) */
|
||||||
ReadUint32(ls); ReadByte(ls); len -= 5;
|
ReadUint32(ls); ReadByte(ls); len -= 5;
|
||||||
|
|
||||||
ClearGRFConfigList(&_grfconfig);
|
ClearGRFConfigList(&_grfconfig);
|
||||||
GRFConfig *c = CallocT<GRFConfig>(1);
|
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;
|
c.grfid = grfid;
|
||||||
c->filename = "TTDP game, no information";
|
c.filename = "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;
|
||||||
};
|
};
|
||||||
free(c);
|
|
||||||
|
|
||||||
/* Append static NewGRF configuration */
|
/* Append static NewGRF configuration */
|
||||||
AppendStaticGRFConfigs(&_grfconfig);
|
AppendStaticGRFConfigs(&_grfconfig);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 0x3: { /* TTDPatch version and configuration */
|
case 0x3: { /* TTDPatch version and configuration */
|
||||||
uint32 ttdpv = ReadUint32(ls);
|
uint32 ttdpv = ReadUint32(ls);
|
||||||
DEBUG(oldloader, 3, "Game saved with TTDPatch version %d.%d.%d r%d", GB(ttdpv, 24, 8), GB(ttdpv, 20, 4), GB(ttdpv, 16, 4), GB(ttdpv, 0, 16));
|
DEBUG(oldloader, 3, "Game saved with TTDPatch version %d.%d.%d r%d", GB(ttdpv, 24, 8), GB(ttdpv, 20, 4), GB(ttdpv, 16, 4), GB(ttdpv, 0, 16));
|
||||||
len -= 4;
|
len -= 4;
|
||||||
while (len-- != 0) ReadByte(ls); // skip the configuration
|
while (len-- != 0) ReadByte(ls); // skip the configuration
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG(oldloader, 4, "Skipping unknown extra chunk %X", id);
|
DEBUG(oldloader, 4, "Skipping unknown extra chunk %X", id);
|
||||||
while (len-- != 0) ReadByte(ls);
|
while (len-- != 0) ReadByte(ls);
|
||||||
|
|
Loading…
Reference in New Issue