Changeset - r9488:2873382f8f4a
[Not reviewed]
master
0 6 0
smatz - 16 years ago 2008-06-10 21:59:22
smatz@openttd.org
(svn r13456) -Codechange: use AllocaM() macro instead of alloca() at most places
6 files changed with 15 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/core/alloc_func.hpp
Show inline comments
 
@@ -69,25 +69,28 @@ template <typename T> FORCEINLINE T* Cal
 
 * @note throws an error when there is no memory anymore.
 
 * @note the memory contains all zero values.
 
 * @param T the type of the variable(s) to allocation.
 
 * @param t_ptr the previous allocation to extend/shrink.
 
 * @param num_elements the number of elements to allocate of the given type.
 
 * @return NULL when num_elements == 0, non-NULL otherwise.
 
 */
 
template <typename T> FORCEINLINE T* ReallocT(T *t_ptr, size_t num_elements)
 
{
 
	/*
 
	 * MorphOS cannot handle 0 elements allocations, or rather that always
 
	 * returns NULL. So we do that for *all* allocations, thus causing it
 
	 * to behave the same on all OSes.
 
	 */
 
	if (num_elements == 0) {
 
		free(t_ptr);
 
		return NULL;
 
	}
 

	
 
	t_ptr = (T*)realloc(t_ptr, num_elements * sizeof(T));
 
	if (t_ptr == NULL) ReallocError(num_elements * sizeof(T));
 
	return t_ptr;
 
}
 

	
 
/** alloca() has to be called in the parent function, so define AllocaM() as a macro */
 
#define AllocaM(T, num_elements) ((T*)alloca((num_elements) * sizeof(T)))
 

	
 
#endif /* ALLOC_FUNC_HPP */
src/newgrf.cpp
Show inline comments
 
@@ -2925,49 +2925,49 @@ static void VehicleMapSpriteGroup(byte *
 
	static EngineID *last_engines;
 
	static uint last_engines_count;
 
	bool wagover = false;
 

	
 
	/* Test for 'wagon override' flag */
 
	if (HasBit(idcount, 7)) {
 
		wagover = true;
 
		/* Strip off the flag */
 
		idcount = GB(idcount, 0, 7);
 

	
 
		if (last_engines_count == 0) {
 
			grfmsg(0, "VehicleMapSpriteGroup: WagonOverride: No engine to do override with");
 
			return;
 
		}
 

	
 
		grfmsg(6, "VehicleMapSpriteGroup: WagonOverride: %u engines, %u wagons",
 
				last_engines_count, idcount);
 
	} else {
 
		if (last_engines_count != idcount) {
 
			last_engines = ReallocT(last_engines, idcount);
 
			last_engines_count = idcount;
 
		}
 
	}
 

	
 
	EngineID *engines = (EngineID*)alloca(idcount * sizeof(*engines));
 
	EngineID *engines = AllocaM(EngineID, idcount);
 
	for (uint i = 0; i < idcount; i++) {
 
		engines[i] = GetNewEngine(_cur_grffile, (VehicleType)feature, grf_load_byte(&buf))->index;
 
		if (!wagover) last_engines[i] = engines[i];
 
	}
 

	
 
	uint8 cidcount = grf_load_byte(&buf);
 
	for (uint c = 0; c < cidcount; c++) {
 
		uint8 ctype = grf_load_byte(&buf);
 
		uint16 groupid = grf_load_word(&buf);
 
		if (!IsValidGroupID(groupid, "VehicleMapSpriteGroup")) continue;
 

	
 
		grfmsg(8, "VehicleMapSpriteGroup: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid);
 

	
 
		ctype = TranslateCargo(feature, ctype);
 
		if (ctype == CT_INVALID) continue;
 

	
 
		for (uint i = 0; i < idcount; i++) {
 
			EngineID engine = engines[i];
 

	
 
			grfmsg(7, "VehicleMapSpriteGroup: [%d] Engine %d...", i, engine);
 

	
 
			if (wagover) {
 
				SetWagonOverrideSprites(engine, ctype, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count);
 
			} else {
 
@@ -2975,200 +2975,200 @@ static void VehicleMapSpriteGroup(byte *
 
			}
 
		}
 
	}
 

	
 
	uint16 groupid = grf_load_word(&buf);
 
	if (!IsValidGroupID(groupid, "VehicleMapSpriteGroup")) return;
 

	
 
	grfmsg(8, "-- Default group id 0x%04X", groupid);
 

	
 
	for (uint i = 0; i < idcount; i++) {
 
		EngineID engine = engines[i];
 

	
 
		if (wagover) {
 
			SetWagonOverrideSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count);
 
		} else {
 
			SetCustomEngineSprites(engine, CT_DEFAULT, _cur_grffile->spritegroups[groupid]);
 
			SetEngineGRF(engine, _cur_grffile);
 
		}
 
	}
 
}
 

	
 

	
 
static void CanalMapSpriteGroup(byte *buf, uint8 idcount)
 
{
 
	CanalFeature *cfs = (CanalFeature*)alloca(idcount * sizeof(*cfs));
 
	CanalFeature *cfs = AllocaM(CanalFeature, idcount);
 
	for (uint i = 0; i < idcount; i++) {
 
		cfs[i] = (CanalFeature)grf_load_byte(&buf);
 
	}
 

	
 
	uint8 cidcount = grf_load_byte(&buf);
 
	buf += cidcount * 3;
 

	
 
	uint16 groupid = grf_load_word(&buf);
 
	if (!IsValidGroupID(groupid, "CanalMapSpriteGroup")) return;
 

	
 
	for (uint i = 0; i < idcount; i++) {
 
		CanalFeature cf = cfs[i];
 

	
 
		if (cf >= CF_END) {
 
			grfmsg(1, "CanalMapSpriteGroup: Canal subset %d out of range, skipping", cf);
 
			continue;
 
		}
 

	
 
		_water_feature[cf].group = _cur_grffile->spritegroups[groupid];
 
	}
 
}
 

	
 

	
 
static void StationMapSpriteGroup(byte *buf, uint8 idcount)
 
{
 
	uint8 *stations = (uint8*)alloca(idcount * sizeof(*stations));
 
	uint8 *stations = AllocaM(uint8, idcount);
 
	for (uint i = 0; i < idcount; i++) {
 
		stations[i] = grf_load_byte(&buf);
 
	}
 

	
 
	uint8 cidcount = grf_load_byte(&buf);
 
	for (uint c = 0; c < cidcount; c++) {
 
		uint8 ctype = grf_load_byte(&buf);
 
		uint16 groupid = grf_load_word(&buf);
 
		if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) continue;
 

	
 
		ctype = TranslateCargo(GSF_STATION, ctype);
 
		if (ctype == CT_INVALID) continue;
 

	
 
		for (uint i = 0; i < idcount; i++) {
 
			StationSpec *statspec = _cur_grffile->stations[stations[i]];
 

	
 
			if (statspec == NULL) {
 
				grfmsg(1, "StationMapSpriteGroup: Station with ID 0x%02X does not exist, skipping", stations[i]);
 
				return;
 
			}
 

	
 
			statspec->spritegroup[ctype] = _cur_grffile->spritegroups[groupid];
 
		}
 
	}
 

	
 
	uint16 groupid = grf_load_word(&buf);
 
	if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) return;
 

	
 
	for (uint i = 0; i < idcount; i++) {
 
		StationSpec *statspec = _cur_grffile->stations[stations[i]];
 

	
 
		if (statspec == NULL) {
 
			grfmsg(1, "StationMapSpriteGroup: Station with ID 0x%02X does not exist, skipping", stations[i]);
 
			continue;
 
		}
 

	
 
		statspec->spritegroup[CT_DEFAULT] = _cur_grffile->spritegroups[groupid];
 
		statspec->grffile = _cur_grffile;
 
		statspec->localidx = stations[i];
 
		SetCustomStationSpec(statspec);
 
	}
 
}
 

	
 

	
 
static void TownHouseMapSpriteGroup(byte *buf, uint8 idcount)
 
{
 
	uint8 *houses = (uint8*)alloca(idcount * sizeof(*houses));
 
	uint8 *houses = AllocaM(uint8, idcount);
 
	for (uint i = 0; i < idcount; i++) {
 
		houses[i] = grf_load_byte(&buf);
 
	}
 

	
 
	/* Skip the cargo type section, we only care about the default group */
 
	uint8 cidcount = grf_load_byte(&buf);
 
	buf += cidcount * 3;
 

	
 
	uint16 groupid = grf_load_word(&buf);
 
	if (!IsValidGroupID(groupid, "TownHouseMapSpriteGroup")) return;
 

	
 
	for (uint i = 0; i < idcount; i++) {
 
		HouseSpec *hs = _cur_grffile->housespec[houses[i]];
 

	
 
		if (hs == NULL) {
 
			grfmsg(1, "TownHouseMapSpriteGroup: Too many houses defined, skipping");
 
			return;
 
		}
 

	
 
		hs->spritegroup = _cur_grffile->spritegroups[groupid];
 
	}
 
}
 

	
 
static void IndustryMapSpriteGroup(byte *buf, uint8 idcount)
 
{
 
	uint8 *industries = (uint8*)alloca(idcount * sizeof(*industries));
 
	uint8 *industries = AllocaM(uint8, idcount);
 
	for (uint i = 0; i < idcount; i++) {
 
		industries[i] = grf_load_byte(&buf);
 
	}
 

	
 
	/* Skip the cargo type section, we only care about the default group */
 
	uint8 cidcount = grf_load_byte(&buf);
 
	buf += cidcount * 3;
 

	
 
	uint16 groupid = grf_load_word(&buf);
 
	if (!IsValidGroupID(groupid, "IndustryMapSpriteGroup")) return;
 

	
 
	for (uint i = 0; i < idcount; i++) {
 
		IndustrySpec *indsp = _cur_grffile->industryspec[industries[i]];
 

	
 
		if (indsp == NULL) {
 
			grfmsg(1, "IndustryMapSpriteGroup: Too many industries defined, skipping");
 
			return;
 
		}
 

	
 
		indsp->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid];
 
	}
 
}
 

	
 
static void IndustrytileMapSpriteGroup(byte *buf, uint8 idcount)
 
{
 
	uint8 *indtiles = (uint8*)alloca(idcount * sizeof(*indtiles));
 
	uint8 *indtiles = AllocaM(uint8, idcount);
 
	for (uint i = 0; i < idcount; i++) {
 
		indtiles[i] = grf_load_byte(&buf);
 
	}
 

	
 
	/* Skip the cargo type section, we only care about the default group */
 
	uint8 cidcount = grf_load_byte(&buf);
 
	buf += cidcount * 3;
 

	
 
	uint16 groupid = grf_load_word(&buf);
 
	if (!IsValidGroupID(groupid, "IndustrytileMapSpriteGroup")) return;
 

	
 
	for (uint i = 0; i < idcount; i++) {
 
		IndustryTileSpec *indtsp = _cur_grffile->indtspec[indtiles[i]];
 

	
 
		if (indtsp == NULL) {
 
			grfmsg(1, "IndustrytileMapSpriteGroup: Too many industry tiles defined, skipping");
 
			return;
 
		}
 

	
 
		indtsp->grf_prop.spritegroup = _cur_grffile->spritegroups[groupid];
 
	}
 
}
 

	
 
static void CargoMapSpriteGroup(byte *buf, uint8 idcount)
 
{
 
	CargoID *cargos = (CargoID*)alloca(idcount * sizeof(*cargos));
 
	CargoID *cargos = AllocaM(CargoID, idcount);
 
	for (uint i = 0; i < idcount; i++) {
 
		cargos[i] = grf_load_byte(&buf);
 
	}
 

	
 
	/* Skip the cargo type section, we only care about the default group */
 
	uint8 cidcount = grf_load_byte(&buf);
 
	buf += cidcount * 3;
 

	
 
	uint16 groupid = grf_load_word(&buf);
 
	if (!IsValidGroupID(groupid, "CargoMapSpriteGroup")) return;
 

	
 
	for (uint i = 0; i < idcount; i++) {
 
		CargoID cid = cargos[i];
 

	
 
		if (cid >= NUM_CARGO) {
 
			grfmsg(1, "CargoMapSpriteGroup: Cargo ID %d out of range, skipping", cid);
 
			continue;
 
		}
 

	
 
		CargoSpec *cs = &_cargo[cid];
 
		cs->grfid = _cur_grffile->grfid;
 
		cs->group = _cur_grffile->spritegroups[groupid];
 
	}
 
}
src/roadveh_cmd.cpp
Show inline comments
 
@@ -173,49 +173,49 @@ void RoadVehUpdateCache(Vehicle *v)
 
 * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number
 
 */
 
CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	CommandCost cost;
 
	Vehicle *v;
 
	UnitID unit_num;
 
	Engine *e;
 

	
 
	if (!IsEngineBuildable(p1, VEH_ROAD, _current_player)) return_cmd_error(STR_ROAD_VEHICLE_NOT_AVAILABLE);
 

	
 
	cost = EstimateRoadVehCost(p1);
 
	if (flags & DC_QUERY_COST) return cost;
 

	
 
	/* The ai_new queries the vehicle cost before building the route,
 
	 * so we must check against cheaters no sooner than now. --pasky */
 
	if (!IsRoadDepotTile(tile)) return CMD_ERROR;
 
	if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
 

	
 
	if (HasTileRoadType(tile, ROADTYPE_TRAM) != HasBit(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE);
 

	
 
	uint num_vehicles = 1 + CountArticulatedParts(p1, false);
 

	
 
	/* Allow for the front and the articulated parts, plus one to "terminate" the list. */
 
	Vehicle **vl = (Vehicle**)alloca(sizeof(*vl) * (num_vehicles + 1));
 
	Vehicle **vl = AllocaM(Vehicle*, num_vehicles + 1);
 
	memset(vl, 0, sizeof(*vl) * (num_vehicles + 1));
 

	
 
	if (!Vehicle::AllocateList(vl, num_vehicles)) {
 
		return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 
	}
 

	
 
	v = vl[0];
 

	
 
	/* find the first free roadveh id */
 
	unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_ROAD);
 
	if (unit_num > _settings_game.vehicle.max_roadveh)
 
		return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 

	
 
	if (flags & DC_EXEC) {
 
		int x;
 
		int y;
 

	
 
		const RoadVehicleInfo *rvi = RoadVehInfo(p1);
 

	
 
		v = new (v) RoadVehicle();
 
		v->unitnumber = unit_num;
 
		v->direction = DiagDirToDir(GetRoadDepotDirection(tile));
 
		v->owner = _current_player;
 

	
src/station_cmd.cpp
Show inline comments
 
@@ -992,49 +992,49 @@ CommandCost CmdBuildRailroadStation(Tile
 

	
 
		/* Now really clear the land below the station
 
		 * It should never return CMD_ERROR.. but you never know ;)
 
		 * (a bit strange function name for it, but it really does clear the land, when DC_EXEC is in flags) */
 
		ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _settings_game.station.nonuniform_stations ? &est : NULL);
 
		if (CmdFailed(ret)) return ret;
 

	
 
		st->train_tile = finalvalues[0];
 
		st->AddFacility(FACIL_TRAIN, finalvalues[0]);
 

	
 
		st->trainst_w = finalvalues[1];
 
		st->trainst_h = finalvalues[2];
 

	
 
		st->rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TRY);
 

	
 
		if (statspec != NULL) {
 
			/* Include this station spec's animation trigger bitmask
 
			 * in the station's cached copy. */
 
			st->cached_anim_triggers |= statspec->anim_triggers;
 
		}
 

	
 
		tile_delta = (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
 
		track = AxisToTrack(axis);
 

	
 
		layout_ptr = (byte*)alloca(numtracks * plat_len);
 
		layout_ptr = AllocaM(byte, numtracks * plat_len);
 
		GetStationLayout(layout_ptr, numtracks, plat_len, statspec);
 

	
 
		numtracks_orig = numtracks;
 

	
 
		do {
 
			TileIndex tile = tile_org;
 
			int w = plat_len;
 
			do {
 
				byte layout = *layout_ptr++;
 
				MakeRailStation(tile, st->owner, st->index, axis, layout & ~1, (RailType)GB(p2, 0, 4));
 
				SetCustomStationSpecIndex(tile, specindex);
 
				SetStationTileRandomBits(tile, GB(Random(), 0, 4));
 
				SetStationAnimationFrame(tile, 0);
 

	
 
				if (statspec != NULL) {
 
					/* Use a fixed axis for GetPlatformInfo as our platforms / numtracks are always the right way around */
 
					uint32 platinfo = GetPlatformInfo(AXIS_X, 0, plat_len, numtracks_orig, plat_len - w, numtracks_orig - numtracks, false);
 

	
 
					/* As the station is not yet completely finished, the station does not yet exist. */
 
					uint16 callback = GetStationCallback(CBID_STATION_TILE_LAYOUT, platinfo, 0, statspec, NULL, tile);
 
					if (callback != CALLBACK_FAILED && callback < 8) SetStationGfx(tile, (callback & ~1) + axis);
 

	
 
					/* Trigger station animation -- after building? */
 
					StationAnimationTrigger(st, tile, STAT_ANIM_BUILT);
src/train_cmd.cpp
Show inline comments
 
@@ -528,49 +528,49 @@ void DrawTrainEngine(int x, int y, Engin
 
		int yr = y;
 

	
 
		SpriteID spritef = GetRailIcon(engine, false, yf);
 
		SpriteID spriter = GetRailIcon(engine, true, yr);
 
		DrawSprite(spritef, pal, x - 14, yf);
 
		DrawSprite(spriter, pal, x + 15, yr);
 
	} else {
 
		SpriteID sprite = GetRailIcon(engine, false, y);
 
		DrawSprite(sprite, pal, x, y);
 
	}
 
}
 

	
 
static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags)
 
{
 
	const RailVehicleInfo *rvi = RailVehInfo(engine);
 
	CommandCost value(EXPENSES_NEW_VEHICLES, (GetEngineProperty(engine, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8);
 

	
 
	uint num_vehicles = 1 + CountArticulatedParts(engine, false);
 

	
 
	if (!(flags & DC_QUERY_COST)) {
 
		/* Check that the wagon can drive on the track in question */
 
		if (!IsCompatibleRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR;
 

	
 
		/* Allow for the wagon and the articulated parts, plus one to "terminate" the list. */
 
		Vehicle **vl = (Vehicle**)alloca(sizeof(*vl) * (num_vehicles + 1));
 
		Vehicle **vl = AllocaM(Vehicle*, num_vehicles + 1);
 
		memset(vl, 0, sizeof(*vl) * (num_vehicles + 1));
 

	
 
		if (!Vehicle::AllocateList(vl, num_vehicles))
 
			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 

	
 
		if (flags & DC_EXEC) {
 
			Vehicle *v = vl[0];
 
			v->spritenum = rvi->image_index;
 

	
 
			Vehicle *u = NULL;
 

	
 
			Vehicle *w;
 
			FOR_ALL_VEHICLES(w) {
 
				if (w->type == VEH_TRAIN && w->tile == tile &&
 
				    IsFreeWagon(w) && w->engine_type == engine &&
 
				    !HASBITS(w->vehstatus, VS_CRASHED)) {          /// do not connect new wagon with crashed/flooded consists
 
					u = GetLastVehicleInChain(w);
 
					break;
 
				}
 
			}
 

	
 
			v = new (v) Train();
 
			v->engine_type = engine;
 

	
 
@@ -695,49 +695,49 @@ CommandCost CmdBuildRailVehicle(TileInde
 

	
 
	/* Check if the train is actually being built in a depot belonging
 
	 * to the player. Doesn't matter if only the cost is queried */
 
	if (!(flags & DC_QUERY_COST)) {
 
		if (!IsRailDepotTile(tile)) return CMD_ERROR;
 
		if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
 
	}
 

	
 
	const RailVehicleInfo *rvi = RailVehInfo(p1);
 

	
 
	if (rvi->railveh_type == RAILVEH_WAGON) return CmdBuildRailWagon(p1, tile, flags);
 

	
 
	CommandCost value = EstimateTrainCost(p1, rvi);
 

	
 
	uint num_vehicles =
 
		(rvi->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1) +
 
		CountArticulatedParts(p1, false);
 

	
 
	if (!(flags & DC_QUERY_COST)) {
 
		/* Check if depot and new engine uses the same kind of tracks *
 
		 * We need to see if the engine got power on the tile to avoid eletric engines in non-electric depots */
 
		if (!HasPowerOnRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR;
 

	
 
		/* Allow for the dual-heads and the articulated parts, plus one to "terminate" the list. */
 
		Vehicle **vl = (Vehicle**)alloca(sizeof(*vl) * (num_vehicles + 1));
 
		Vehicle **vl = AllocaM(Vehicle*, num_vehicles + 1);
 
		memset(vl, 0, sizeof(*vl) * (num_vehicles + 1));
 

	
 
		if (!Vehicle::AllocateList(vl, num_vehicles)) {
 
			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 
		}
 

	
 
		Vehicle *v = vl[0];
 

	
 
		UnitID unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_TRAIN);
 
		if (unit_num > _settings_game.vehicle.max_trains)
 
			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 

	
 
		if (flags & DC_EXEC) {
 
			DiagDirection dir = GetRailDepotDirection(tile);
 
			int x = TileX(tile) * TILE_SIZE + _vehicle_initial_x_fract[dir];
 
			int y = TileY(tile) * TILE_SIZE + _vehicle_initial_y_fract[dir];
 

	
 
			v = new (v) Train();
 
			v->unitnumber = unit_num;
 
			v->direction = DiagDirToDir(dir);
 
			v->tile = tile;
 
			v->owner = _current_player;
 
			v->x_pos = x;
 
			v->y_pos = y;
src/win32.cpp
Show inline comments
 
@@ -453,49 +453,49 @@ static void Handler2()
 
	DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(100), NULL, CrashDialogFunc);
 
}
 

	
 
extern bool CloseConsoleLogIfActive();
 

	
 
static HANDLE _file_crash_log;
 

	
 
static void GamelogPrintCrashLogProc(const char *s)
 
{
 
	DWORD num_written;
 
	WriteFile(_file_crash_log, s, strlen(s), &num_written, NULL);
 
	WriteFile(_file_crash_log, "\r\n", strlen("\r\n"), &num_written, NULL);
 
}
 

	
 
static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
 
{
 
	char *output;
 
	static bool had_exception = false;
 

	
 
	if (had_exception) ExitProcess(0);
 
	had_exception = true;
 

	
 
	_ident = GetTickCount(); // something pretty unique
 

	
 
	MakeCRCTable((uint32*)alloca(256 * sizeof(uint32)));
 
	MakeCRCTable(AllocaM(uint32, 256));
 
	_crash_msg = output = (char*)LocalAlloc(LMEM_FIXED, 8192);
 

	
 
	{
 
		SYSTEMTIME time;
 
		GetLocalTime(&time);
 
		output += sprintf(output,
 
			"*** OpenTTD Crash Report ***\r\n"
 
			"Date: %d-%.2d-%.2d %.2d:%.2d:%.2d\r\n"
 
			"Build: %s built on " __DATE__ " " __TIME__ "\r\n",
 
			time.wYear,
 
			time.wMonth,
 
			time.wDay,
 
			time.wHour,
 
			time.wMinute,
 
			time.wSecond,
 
			_openttd_revision
 
		);
 
	}
 

	
 
	if (_exception_string)
 
		output += sprintf(output, "Reason: %s\r\n", _exception_string);
 

	
 
#ifdef _M_AMD64
 
	output += sprintf(output, "Exception %.8X at %.16IX\r\n"
0 comments (0 inline, 0 general)