src/newgrf.cpp
branchNewGRF_ports
changeset 10994 cd9968b6f96b
parent 10991 d8811e327d12
equal deleted inserted replaced
10991:d8811e327d12 10994:cd9968b6f96b
  1546 				byte count = grf_load_byte(&buf);
  1546 				byte count = grf_load_byte(&buf);
  1547 				for (byte j = 0; j < count; j++) grf_load_byte(&buf);
  1547 				for (byte j = 0; j < count; j++) grf_load_byte(&buf);
  1548 				ret = true;
  1548 				ret = true;
  1549 			} break;
  1549 			} break;
  1550 
  1550 
       
  1551 			case 0x21: // long introduction year
       
  1552 				housespec->min_year = grf_load_word(&buf);
       
  1553 				break;
       
  1554 
       
  1555 			case 0x22: // long maximum year
       
  1556 				housespec->max_year = grf_load_word(&buf);
       
  1557 				break;
       
  1558 
  1551 			default:
  1559 			default:
  1552 				ret = true;
  1560 				ret = true;
  1553 				break;
  1561 				break;
  1554 		}
  1562 		}
  1555 	}
  1563 	}
  3290 			last_engines = ReallocT(last_engines, idcount);
  3298 			last_engines = ReallocT(last_engines, idcount);
  3291 			last_engines_count = idcount;
  3299 			last_engines_count = idcount;
  3292 		}
  3300 		}
  3293 	}
  3301 	}
  3294 
  3302 
  3295 	EngineID *engines = (EngineID*)alloca(idcount * sizeof(*engines));
  3303 	EngineID *engines = AllocaM(EngineID, idcount);
  3296 	for (uint i = 0; i < idcount; i++) {
  3304 	for (uint i = 0; i < idcount; i++) {
  3297 		engines[i] = GetNewEngine(_cur_grffile, (VehicleType)feature, grf_load_byte(&buf))->index;
  3305 		engines[i] = GetNewEngine(_cur_grffile, (VehicleType)feature, grf_load_extended(&buf))->index;
  3298 		if (!wagover) last_engines[i] = engines[i];
  3306 		if (!wagover) last_engines[i] = engines[i];
  3299 	}
  3307 	}
  3300 
  3308 
  3301 	uint8 cidcount = grf_load_byte(&buf);
  3309 	uint8 cidcount = grf_load_byte(&buf);
  3302 	for (uint c = 0; c < cidcount; c++) {
  3310 	for (uint c = 0; c < cidcount; c++) {
  3340 }
  3348 }
  3341 
  3349 
  3342 
  3350 
  3343 static void CanalMapSpriteGroup(byte *buf, uint8 idcount)
  3351 static void CanalMapSpriteGroup(byte *buf, uint8 idcount)
  3344 {
  3352 {
  3345 	CanalFeature *cfs = (CanalFeature*)alloca(idcount * sizeof(*cfs));
  3353 	CanalFeature *cfs = AllocaM(CanalFeature, idcount);
  3346 	for (uint i = 0; i < idcount; i++) {
  3354 	for (uint i = 0; i < idcount; i++) {
  3347 		cfs[i] = (CanalFeature)grf_load_byte(&buf);
  3355 		cfs[i] = (CanalFeature)grf_load_byte(&buf);
  3348 	}
  3356 	}
  3349 
  3357 
  3350 	uint8 cidcount = grf_load_byte(&buf);
  3358 	uint8 cidcount = grf_load_byte(&buf);
  3366 }
  3374 }
  3367 
  3375 
  3368 
  3376 
  3369 static void StationMapSpriteGroup(byte *buf, uint8 idcount)
  3377 static void StationMapSpriteGroup(byte *buf, uint8 idcount)
  3370 {
  3378 {
  3371 	uint8 *stations = (uint8*)alloca(idcount * sizeof(*stations));
  3379 	uint8 *stations = AllocaM(uint8, idcount);
  3372 	for (uint i = 0; i < idcount; i++) {
  3380 	for (uint i = 0; i < idcount; i++) {
  3373 		stations[i] = grf_load_byte(&buf);
  3381 		stations[i] = grf_load_byte(&buf);
  3374 	}
  3382 	}
  3375 
  3383 
  3376 	uint8 cidcount = grf_load_byte(&buf);
  3384 	uint8 cidcount = grf_load_byte(&buf);
  3413 }
  3421 }
  3414 
  3422 
  3415 
  3423 
  3416 static void TownHouseMapSpriteGroup(byte *buf, uint8 idcount)
  3424 static void TownHouseMapSpriteGroup(byte *buf, uint8 idcount)
  3417 {
  3425 {
  3418 	uint8 *houses = (uint8*)alloca(idcount * sizeof(*houses));
  3426 	uint8 *houses = AllocaM(uint8, idcount);
  3419 	for (uint i = 0; i < idcount; i++) {
  3427 	for (uint i = 0; i < idcount; i++) {
  3420 		houses[i] = grf_load_byte(&buf);
  3428 		houses[i] = grf_load_byte(&buf);
  3421 	}
  3429 	}
  3422 
  3430 
  3423 	/* Skip the cargo type section, we only care about the default group */
  3431 	/* Skip the cargo type section, we only care about the default group */
  3439 	}
  3447 	}
  3440 }
  3448 }
  3441 
  3449 
  3442 static void IndustryMapSpriteGroup(byte *buf, uint8 idcount)
  3450 static void IndustryMapSpriteGroup(byte *buf, uint8 idcount)
  3443 {
  3451 {
  3444 	uint8 *industries = (uint8*)alloca(idcount * sizeof(*industries));
  3452 	uint8 *industries = AllocaM(uint8, idcount);
  3445 	for (uint i = 0; i < idcount; i++) {
  3453 	for (uint i = 0; i < idcount; i++) {
  3446 		industries[i] = grf_load_byte(&buf);
  3454 		industries[i] = grf_load_byte(&buf);
  3447 	}
  3455 	}
  3448 
  3456 
  3449 	/* Skip the cargo type section, we only care about the default group */
  3457 	/* Skip the cargo type section, we only care about the default group */
  3465 	}
  3473 	}
  3466 }
  3474 }
  3467 
  3475 
  3468 static void IndustrytileMapSpriteGroup(byte *buf, uint8 idcount)
  3476 static void IndustrytileMapSpriteGroup(byte *buf, uint8 idcount)
  3469 {
  3477 {
  3470 	uint8 *indtiles = (uint8*)alloca(idcount * sizeof(*indtiles));
  3478 	uint8 *indtiles = AllocaM(uint8, idcount);
  3471 	for (uint i = 0; i < idcount; i++) {
  3479 	for (uint i = 0; i < idcount; i++) {
  3472 		indtiles[i] = grf_load_byte(&buf);
  3480 		indtiles[i] = grf_load_byte(&buf);
  3473 	}
  3481 	}
  3474 
  3482 
  3475 	/* Skip the cargo type section, we only care about the default group */
  3483 	/* Skip the cargo type section, we only care about the default group */
  3491 	}
  3499 	}
  3492 }
  3500 }
  3493 
  3501 
  3494 static void CargoMapSpriteGroup(byte *buf, uint8 idcount)
  3502 static void CargoMapSpriteGroup(byte *buf, uint8 idcount)
  3495 {
  3503 {
  3496 	CargoID *cargos = (CargoID*)alloca(idcount * sizeof(*cargos));
  3504 	CargoID *cargos = AllocaM(CargoID, idcount);
  3497 	for (uint i = 0; i < idcount; i++) {
  3505 	for (uint i = 0; i < idcount; i++) {
  3498 		cargos[i] = grf_load_byte(&buf);
  3506 		cargos[i] = grf_load_byte(&buf);
  3499 	}
  3507 	}
  3500 
  3508 
  3501 	/* Skip the cargo type section, we only care about the default group */
  3509 	/* Skip the cargo type section, we only care about the default group */
  3676 	buf++;
  3684 	buf++;
  3677 	uint8 feature  = grf_load_byte(&buf);
  3685 	uint8 feature  = grf_load_byte(&buf);
  3678 	uint8 lang     = grf_load_byte(&buf);
  3686 	uint8 lang     = grf_load_byte(&buf);
  3679 	uint8 num      = grf_load_byte(&buf);
  3687 	uint8 num      = grf_load_byte(&buf);
  3680 	bool generic   = HasBit(lang, 7);
  3688 	bool generic   = HasBit(lang, 7);
  3681 	uint16 id      = generic ? grf_load_word(&buf) : grf_load_byte(&buf);
  3689 	uint16 id;
       
  3690 	if (generic) {
       
  3691 		id = grf_load_word(&buf);
       
  3692 	} else if (feature <= GSF_AIRCRAFT) {
       
  3693 		id = grf_load_extended(&buf);
       
  3694 	} else {
       
  3695 		id = grf_load_byte(&buf);
       
  3696 	}
  3682 
  3697 
  3683 	ClrBit(lang, 7);
  3698 	ClrBit(lang, 7);
  3684 
  3699 
  3685 	uint16 endid = id + num;
  3700 	uint16 endid = id + num;
  3686 
  3701 
  3854 		const char *name;             ///< Name for error messages.
  3869 		const char *name;             ///< Name for error messages.
  3855 	};
  3870 	};
  3856 
  3871 
  3857 	static const Action5Type action5_types[] = {
  3872 	static const Action5Type action5_types[] = {
  3858 		/* Note: min_sprites should not be changed. Therefore these constants are directly here and not in sprites.h */
  3873 		/* Note: min_sprites should not be changed. Therefore these constants are directly here and not in sprites.h */
  3859 		/* 0x00 */ { A5BLOCK_INVALID,      0,                   0, 0,                                           "Type 0x00"             },
  3874 		/* 0x00 */ { A5BLOCK_INVALID,      0,                            0, 0,                                           "Type 0x00"             },
  3860 		/* 0x01 */ { A5BLOCK_INVALID,      0,                   0, 0,                                           "Type 0x01"             },
  3875 		/* 0x01 */ { A5BLOCK_INVALID,      0,                            0, 0,                                           "Type 0x01"             },
  3861 		/* 0x02 */ { A5BLOCK_INVALID,      0,                   0, 0,                                           "Type 0x02"             },
  3876 		/* 0x02 */ { A5BLOCK_INVALID,      0,                            0, 0,                                           "Type 0x02"             },
  3862 		/* 0x03 */ { A5BLOCK_INVALID,      0,                   0, 0,                                           "Type 0x03"             },
  3877 		/* 0x03 */ { A5BLOCK_INVALID,      0,                            0, 0,                                           "Type 0x03"             },
  3863 		/* 0x04 */ { A5BLOCK_FIXED,        SPR_SIGNALS_BASE,   48, PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT,    "Signal graphics"       },
  3878 		/* 0x04 */ { A5BLOCK_FIXED,        SPR_SIGNALS_BASE,            48, PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT,    "Signal graphics"       },
  3864 		/* 0x05 */ { A5BLOCK_FIXED,        SPR_ELRAIL_BASE,    48, ELRAIL_SPRITE_COUNT,                         "Catenary graphics"     },
  3879 		/* 0x05 */ { A5BLOCK_FIXED,        SPR_ELRAIL_BASE,             48, ELRAIL_SPRITE_COUNT,                         "Catenary graphics"     },
  3865 		/* 0x06 */ { A5BLOCK_FIXED,        SPR_SLOPES_BASE,    74, NORMAL_AND_HALFTILE_FOUNDATION_SPRITE_COUNT, "Foundation graphics"   },
  3880 		/* 0x06 */ { A5BLOCK_FIXED,        SPR_SLOPES_BASE,             74, NORMAL_AND_HALFTILE_FOUNDATION_SPRITE_COUNT, "Foundation graphics"   },
  3866 		/* 0x07 */ { A5BLOCK_INVALID,      0,                  75, 0,                                           "TTDP GUI graphics"     }, // Not used by OTTD.
  3881 		/* 0x07 */ { A5BLOCK_INVALID,      0,                           75, 0,                                           "TTDP GUI graphics"     }, // Not used by OTTD.
  3867 		/* 0x08 */ { A5BLOCK_FIXED,        SPR_CANALS_BASE,    65, CANALS_SPRITE_COUNT,                         "Canal graphics"        },
  3882 		/* 0x08 */ { A5BLOCK_FIXED,        SPR_CANALS_BASE,             65, CANALS_SPRITE_COUNT,                         "Canal graphics"        },
  3868 		/* 0x09 */ { A5BLOCK_FIXED,        SPR_ONEWAY_BASE,     6, ONEWAY_SPRITE_COUNT,                         "One way road graphics" },
  3883 		/* 0x09 */ { A5BLOCK_FIXED,        SPR_ONEWAY_BASE,              6, ONEWAY_SPRITE_COUNT,                         "One way road graphics" },
  3869 		/* 0x0A */ { A5BLOCK_FIXED,        SPR_2CCMAP_BASE,   256, TWOCCMAP_SPRITE_COUNT,                       "2CC colour maps"       },
  3884 		/* 0x0A */ { A5BLOCK_FIXED,        SPR_2CCMAP_BASE,            256, TWOCCMAP_SPRITE_COUNT,                       "2CC colour maps"       },
  3870 		/* 0x0B */ { A5BLOCK_FIXED,        SPR_TRAMWAY_BASE,  113, TRAMWAY_SPRITE_COUNT,                        "Tramway graphics"      },
  3885 		/* 0x0B */ { A5BLOCK_FIXED,        SPR_TRAMWAY_BASE,           113, TRAMWAY_SPRITE_COUNT,                        "Tramway graphics"      },
  3871 		/* 0x0C */ { A5BLOCK_INVALID,      0,                 133, 0,                                           "Snowy temperate tree"  }, // Not yet used by OTTD.
  3886 		/* 0x0C */ { A5BLOCK_INVALID,      0,                          133, 0,                                           "Snowy temperate tree"  }, // Not yet used by OTTD.
  3872 		/* 0x0D */ { A5BLOCK_FIXED,        SPR_SHORE_BASE,     16, SPR_SHORE_SPRITE_COUNT,                      "Shore graphics"        },
  3887 		/* 0x0D */ { A5BLOCK_FIXED,        SPR_SHORE_BASE,              16, SPR_SHORE_SPRITE_COUNT,                      "Shore graphics"        },
  3873 		/* 0x0E */ { A5BLOCK_INVALID,      0,                   0, 0,                                           "New Signals graphics"  }, // Not yet used by OTTD.
  3888 		/* 0x0E */ { A5BLOCK_INVALID,      0,                            0, 0,                                           "New Signals graphics"  }, // Not yet used by OTTD.
  3874 		/* 0x0F */ { A5BLOCK_INVALID,      0,                  12, 0,                                           "Sloped rail track"     }, // Not yet used by OTTD.
  3889 		/* 0x0F */ { A5BLOCK_FIXED,        SPR_TRACKS_FOR_SLOPES_BASE,  12, TRACKS_FOR_SLOPES_SPRITE_COUNT,              "Sloped rail track"     },
  3875 		/* 0x10 */ { A5BLOCK_FIXED,        SPR_AIRPORTX_BASE,  15, AIRPORTX_SPRITE_COUNT,                       "Airport graphics"      },
  3890 		/* 0x10 */ { A5BLOCK_FIXED,        SPR_AIRPORTX_BASE,           15, AIRPORTX_SPRITE_COUNT,                       "Airport graphics"      },
  3876 		/* 0x11 */ { A5BLOCK_FIXED,        SPR_ROADSTOP_BASE,   8, ROADSTOP_SPRITE_COUNT,                       "Road stop graphics"    },
  3891 		/* 0x11 */ { A5BLOCK_FIXED,        SPR_ROADSTOP_BASE,            8, ROADSTOP_SPRITE_COUNT,                       "Road stop graphics"    },
  3877 		/* 0x12 */ { A5BLOCK_INVALID,      0,                   8, 0,                                           "Aqueduct graphics"     }, // Not yet used by OTTD.
  3892 		/* 0x12 */ { A5BLOCK_FIXED,        SPR_AQUEDUCT_BASE,            8, AQUEDUCT_SPRITE_COUNT,                       "Aqueduct graphics"     },
  3878 		/* 0x13 */ { A5BLOCK_FIXED,        SPR_AUTORAIL_BASE,  55, AUTORAIL_SPRITE_COUNT,                       "Autorail graphics"     },
  3893 		/* 0x13 */ { A5BLOCK_FIXED,        SPR_AUTORAIL_BASE,           55, AUTORAIL_SPRITE_COUNT,                       "Autorail graphics"     },
  3879 		/* 0x14 */ { A5BLOCK_ALLOW_OFFSET, SPR_FLAGS_BASE,      1, FLAGS_SPRITE_COUNT,                          "Flag graphics"         },
  3894 		/* 0x14 */ { A5BLOCK_ALLOW_OFFSET, SPR_FLAGS_BASE,               1, FLAGS_SPRITE_COUNT,                          "Flag graphics"         },
  3880 		/* 0x15 */ { A5BLOCK_ALLOW_OFFSET, SPR_OPENTTD_BASE,    1, OPENTTD_SPRITE_COUNT,                        "OpenTTD GUI graphics"  },
  3895 		/* 0x15 */ { A5BLOCK_ALLOW_OFFSET, SPR_OPENTTD_BASE,             1, OPENTTD_SPRITE_COUNT,                        "OpenTTD GUI graphics"  },
  3881 	};
  3896 	};
  3882 
  3897 
  3883 	if (!check_length(len, 2, "GraphicsNew")) return;
  3898 	if (!check_length(len, 2, "GraphicsNew")) return;
  3884 	buf++;
  3899 	buf++;
  3885 	uint8 type = grf_load_byte(&buf);
  3900 	uint8 type = grf_load_byte(&buf);