src/newgrf.cpp
changeset 9488 963e9e278125
parent 9483 cdefc44b5f60
child 9490 01c07bde5e84
equal deleted inserted replaced
9487:4b8dae4806bf 9488:963e9e278125
  2944 			last_engines = ReallocT(last_engines, idcount);
  2944 			last_engines = ReallocT(last_engines, idcount);
  2945 			last_engines_count = idcount;
  2945 			last_engines_count = idcount;
  2946 		}
  2946 		}
  2947 	}
  2947 	}
  2948 
  2948 
  2949 	EngineID *engines = (EngineID*)alloca(idcount * sizeof(*engines));
  2949 	EngineID *engines = AllocaM(EngineID, idcount);
  2950 	for (uint i = 0; i < idcount; i++) {
  2950 	for (uint i = 0; i < idcount; i++) {
  2951 		engines[i] = GetNewEngine(_cur_grffile, (VehicleType)feature, grf_load_byte(&buf))->index;
  2951 		engines[i] = GetNewEngine(_cur_grffile, (VehicleType)feature, grf_load_byte(&buf))->index;
  2952 		if (!wagover) last_engines[i] = engines[i];
  2952 		if (!wagover) last_engines[i] = engines[i];
  2953 	}
  2953 	}
  2954 
  2954 
  2994 }
  2994 }
  2995 
  2995 
  2996 
  2996 
  2997 static void CanalMapSpriteGroup(byte *buf, uint8 idcount)
  2997 static void CanalMapSpriteGroup(byte *buf, uint8 idcount)
  2998 {
  2998 {
  2999 	CanalFeature *cfs = (CanalFeature*)alloca(idcount * sizeof(*cfs));
  2999 	CanalFeature *cfs = AllocaM(CanalFeature, idcount);
  3000 	for (uint i = 0; i < idcount; i++) {
  3000 	for (uint i = 0; i < idcount; i++) {
  3001 		cfs[i] = (CanalFeature)grf_load_byte(&buf);
  3001 		cfs[i] = (CanalFeature)grf_load_byte(&buf);
  3002 	}
  3002 	}
  3003 
  3003 
  3004 	uint8 cidcount = grf_load_byte(&buf);
  3004 	uint8 cidcount = grf_load_byte(&buf);
  3020 }
  3020 }
  3021 
  3021 
  3022 
  3022 
  3023 static void StationMapSpriteGroup(byte *buf, uint8 idcount)
  3023 static void StationMapSpriteGroup(byte *buf, uint8 idcount)
  3024 {
  3024 {
  3025 	uint8 *stations = (uint8*)alloca(idcount * sizeof(*stations));
  3025 	uint8 *stations = AllocaM(uint8, idcount);
  3026 	for (uint i = 0; i < idcount; i++) {
  3026 	for (uint i = 0; i < idcount; i++) {
  3027 		stations[i] = grf_load_byte(&buf);
  3027 		stations[i] = grf_load_byte(&buf);
  3028 	}
  3028 	}
  3029 
  3029 
  3030 	uint8 cidcount = grf_load_byte(&buf);
  3030 	uint8 cidcount = grf_load_byte(&buf);
  3067 }
  3067 }
  3068 
  3068 
  3069 
  3069 
  3070 static void TownHouseMapSpriteGroup(byte *buf, uint8 idcount)
  3070 static void TownHouseMapSpriteGroup(byte *buf, uint8 idcount)
  3071 {
  3071 {
  3072 	uint8 *houses = (uint8*)alloca(idcount * sizeof(*houses));
  3072 	uint8 *houses = AllocaM(uint8, idcount);
  3073 	for (uint i = 0; i < idcount; i++) {
  3073 	for (uint i = 0; i < idcount; i++) {
  3074 		houses[i] = grf_load_byte(&buf);
  3074 		houses[i] = grf_load_byte(&buf);
  3075 	}
  3075 	}
  3076 
  3076 
  3077 	/* Skip the cargo type section, we only care about the default group */
  3077 	/* Skip the cargo type section, we only care about the default group */
  3093 	}
  3093 	}
  3094 }
  3094 }
  3095 
  3095 
  3096 static void IndustryMapSpriteGroup(byte *buf, uint8 idcount)
  3096 static void IndustryMapSpriteGroup(byte *buf, uint8 idcount)
  3097 {
  3097 {
  3098 	uint8 *industries = (uint8*)alloca(idcount * sizeof(*industries));
  3098 	uint8 *industries = AllocaM(uint8, idcount);
  3099 	for (uint i = 0; i < idcount; i++) {
  3099 	for (uint i = 0; i < idcount; i++) {
  3100 		industries[i] = grf_load_byte(&buf);
  3100 		industries[i] = grf_load_byte(&buf);
  3101 	}
  3101 	}
  3102 
  3102 
  3103 	/* Skip the cargo type section, we only care about the default group */
  3103 	/* Skip the cargo type section, we only care about the default group */
  3119 	}
  3119 	}
  3120 }
  3120 }
  3121 
  3121 
  3122 static void IndustrytileMapSpriteGroup(byte *buf, uint8 idcount)
  3122 static void IndustrytileMapSpriteGroup(byte *buf, uint8 idcount)
  3123 {
  3123 {
  3124 	uint8 *indtiles = (uint8*)alloca(idcount * sizeof(*indtiles));
  3124 	uint8 *indtiles = AllocaM(uint8, idcount);
  3125 	for (uint i = 0; i < idcount; i++) {
  3125 	for (uint i = 0; i < idcount; i++) {
  3126 		indtiles[i] = grf_load_byte(&buf);
  3126 		indtiles[i] = grf_load_byte(&buf);
  3127 	}
  3127 	}
  3128 
  3128 
  3129 	/* Skip the cargo type section, we only care about the default group */
  3129 	/* Skip the cargo type section, we only care about the default group */
  3145 	}
  3145 	}
  3146 }
  3146 }
  3147 
  3147 
  3148 static void CargoMapSpriteGroup(byte *buf, uint8 idcount)
  3148 static void CargoMapSpriteGroup(byte *buf, uint8 idcount)
  3149 {
  3149 {
  3150 	CargoID *cargos = (CargoID*)alloca(idcount * sizeof(*cargos));
  3150 	CargoID *cargos = AllocaM(CargoID, idcount);
  3151 	for (uint i = 0; i < idcount; i++) {
  3151 	for (uint i = 0; i < idcount; i++) {
  3152 		cargos[i] = grf_load_byte(&buf);
  3152 		cargos[i] = grf_load_byte(&buf);
  3153 	}
  3153 	}
  3154 
  3154 
  3155 	/* Skip the cargo type section, we only care about the default group */
  3155 	/* Skip the cargo type section, we only care about the default group */