Changeset - r7420:9706ae234622
[Not reviewed]
master
0 2 0
rubidium - 17 years ago 2007-08-06 14:08:25
rubidium@openttd.org
(svn r10813) -Fix (r10799): some destructors were performing too much during the pool cleanups, which could cause crashes as already removed pool items could then be dereferenced by other destructors.
2 files changed with 4 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -121,24 +121,26 @@ const IndustrySpec *GetIndustrySpec(Indu
 
const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx, bool full_check)
 
{
 
	assert(gfx < INVALID_INDUSTRYTILE);
 
	const IndustryTileSpec *its = &_industry_tile_specs[gfx];
 
	if (full_check && its->grf_prop.override != INVALID_INDUSTRYTILE) {
 
		its = &_industry_tile_specs[its->grf_prop.override];
 
	}
 
	return its;
 
}
 

	
 
Industry::~Industry()
 
{
 
	if (CleaningPool()) return;
 

	
 
	/* Industry can also be destroyed when not fully initialized.
 
	 * This means that we do not have to clear tiles either. */
 
	if (this->width == 0) {
 
		this->xy = 0;
 
		return;
 
	}
 

	
 
	BEGIN_TILE_LOOP(tile_cur, this->width, this->height, this->xy);
 
		if (IsTileType(tile_cur, MP_INDUSTRY)) {
 
			if (GetIndustryIndex(tile_cur) == this->index) {
 
				DoClearSquare(tile_cur);
 
			}
src/station.cpp
Show inline comments
 
@@ -382,24 +382,26 @@ RoadStop::RoadStop(TileIndex tile) :
 
	status(3), // stop is free
 
	num_vehicles(0),
 
	next(NULL)
 
{
 
	DEBUG(ms, cDebugCtorLevel,  "I+ at %d[0x%x]", tile, tile);
 
}
 

	
 
/** De-Initializes a RoadStops. This includes clearing all slots that vehicles might
 
  * have and unlinks it from the linked list of road stops at the given station
 
  */
 
RoadStop::~RoadStop()
 
{
 
	if (CleaningPool()) return;
 

	
 
	/* Clear the slot assignment of all vehicles heading for this road stop */
 
	if (num_vehicles != 0) {
 
		Vehicle *v;
 

	
 
		FOR_ALL_VEHICLES(v) {
 
			if (v->type == VEH_ROAD && v->u.road.slot == this) ClearSlot(v);
 
		}
 
	}
 
	assert(num_vehicles == 0);
 

	
 
	DEBUG(ms, cDebugCtorLevel , "I- at %d[0x%x]", xy, xy);
 

	
0 comments (0 inline, 0 general)