src/oldloader.cpp
changeset 6085 f6f90fd20181
parent 6074 5d7d0c753d49
child 6108 c0929232db31
equal deleted inserted replaced
6084:1bf4040cd72e 6085:f6f90fd20181
  1357 	for (int i = 0; i != _old_extra_chunk_nums; i++) {
  1357 	for (int i = 0; i != _old_extra_chunk_nums; i++) {
  1358 		uint16 id = ReadUint16(ls);
  1358 		uint16 id = ReadUint16(ls);
  1359 		uint32 len = ReadUint32(ls);
  1359 		uint32 len = ReadUint32(ls);
  1360 
  1360 
  1361 		switch (id) {
  1361 		switch (id) {
  1362 			/* List of GRFIDs, used in the savegame
  1362 			/* List of GRFIDs, used in the savegame. 0x8004 is the new ID
  1363 			 * They are saved in a 'GRFID:4 active:1' format, 5 bytes for each entry */
  1363 			 * They are saved in a 'GRFID:4 active:1' format, 5 bytes for each entry */
  1364 			case 0x2:
  1364 			case 0x2:
  1365 			case 0x8004: {
  1365 			case 0x8004: {
  1366 				/* Skip the first element: TTDP hack for the Action D special variables FFFF0000 01 */
  1366 				/* Skip the first element: TTDP hack for the Action D special variables (FFFF0000 01) */
  1367 				ReadUint32(ls); ReadByte(ls); len -= 5;
  1367 				ReadUint32(ls); ReadByte(ls); len -= 5;
  1368 
  1368 
  1369 				ClearGRFConfigList(&_grfconfig);
  1369 				ClearGRFConfigList(&_grfconfig);
  1370 				GRFConfig *c = CallocT<GRFConfig>(1);
  1370 				GRFConfig c;
       
  1371 				memset(&c, 0, sizeof(GRFConfig));
       
  1372 
  1371 				while (len != 0) {
  1373 				while (len != 0) {
  1372 					uint32 grfid = ReadUint32(ls);
  1374 					uint32 grfid = ReadUint32(ls);
  1373 
  1375 
  1374 					if (ReadByte(ls) == 1) {
  1376 					if (ReadByte(ls) == 1) {
  1375 						c->grfid = grfid;
  1377 						c.grfid = grfid;
  1376 						c->filename = "TTDP game, no information";
  1378 						c.filename = "TTDP game, no information";
  1377 
  1379 
  1378 						AppendToGRFConfigList(&_grfconfig, c);
  1380 						AppendToGRFConfigList(&_grfconfig, &c);
  1379 						DEBUG(oldloader, 3, "TTDPatch game using GRF file with GRFID %0X", BSWAP32(c->grfid));
  1381 						DEBUG(oldloader, 3, "TTDPatch game using GRF file with GRFID %0X", BSWAP32(c.grfid));
  1380 					}
  1382 					}
  1381 					len -= 5;
  1383 					len -= 5;
  1382 				};
  1384 				};
  1383 				free(c);
       
  1384 
  1385 
  1385 				/* Append static NewGRF configuration */
  1386 				/* Append static NewGRF configuration */
  1386 				AppendStaticGRFConfigs(&_grfconfig);
  1387 				AppendStaticGRFConfigs(&_grfconfig);
  1387 			} break;
  1388 			} break;
       
  1389 
  1388 			case 0x3: { /* TTDPatch version and configuration */
  1390 			case 0x3: { /* TTDPatch version and configuration */
  1389 				uint32 ttdpv = ReadUint32(ls);
  1391 				uint32 ttdpv = ReadUint32(ls);
  1390 				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));
  1392 				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));
  1391 				len -= 4;
  1393 				len -= 4;
  1392 				while (len-- != 0) ReadByte(ls); // skip the configuration
  1394 				while (len-- != 0) ReadByte(ls); // skip the configuration
  1393 			} break;
  1395 			} break;
       
  1396 
  1394 			default:
  1397 			default:
  1395 				DEBUG(oldloader, 4, "Skipping unknown extra chunk %X", id);
  1398 				DEBUG(oldloader, 4, "Skipping unknown extra chunk %X", id);
  1396 				while (len-- != 0) ReadByte(ls);
  1399 				while (len-- != 0) ReadByte(ls);
  1397 				break;
  1400 				break;
  1398 		}
  1401 		}