summaryrefslogtreecommitdiff
path: root/src/oldloader.cpp
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2007-02-20 00:01:54 +0000
committerDarkvater <darkvater@openttd.org>2007-02-20 00:01:54 +0000
commit5b237758aaf4ba5d646ccfad2129312f30bfcfb2 (patch)
treebe7d6f569de5d6510195c2554c952e12683ed72b /src/oldloader.cpp
parentf79618118f7f6d06b001c40eb83ee5f0fbbfa8e7 (diff)
downloadopenttd-5b237758aaf4ba5d646ccfad2129312f30bfcfb2.tar.xz
(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.
Diffstat (limited to 'src/oldloader.cpp')
-rw-r--r--src/oldloader.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index 75dc8e5db..82c7d8493 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -1359,38 +1359,41 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num)
uint32 len = ReadUint32(ls);
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 */
case 0x2:
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;
ClearGRFConfigList(&_grfconfig);
- GRFConfig *c = CallocT<GRFConfig>(1);
+ GRFConfig c;
+ memset(&c, 0, sizeof(GRFConfig));
+
while (len != 0) {
uint32 grfid = ReadUint32(ls);
if (ReadByte(ls) == 1) {
- c->grfid = grfid;
- c->filename = "TTDP game, no information";
+ c.grfid = grfid;
+ c.filename = "TTDP game, no information";
- AppendToGRFConfigList(&_grfconfig, c);
- DEBUG(oldloader, 3, "TTDPatch game using GRF file with GRFID %0X", BSWAP32(c->grfid));
+ AppendToGRFConfigList(&_grfconfig, &c);
+ DEBUG(oldloader, 3, "TTDPatch game using GRF file with GRFID %0X", BSWAP32(c.grfid));
}
len -= 5;
};
- free(c);
/* Append static NewGRF configuration */
AppendStaticGRFConfigs(&_grfconfig);
} break;
+
case 0x3: { /* TTDPatch version and configuration */
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));
len -= 4;
while (len-- != 0) ReadByte(ls); // skip the configuration
} break;
+
default:
DEBUG(oldloader, 4, "Skipping unknown extra chunk %X", id);
while (len-- != 0) ReadByte(ls);