File diff r12514:dae232b962a6 → r12515:abd5af2c2638
src/station.cpp
Show inline comments
 
@@ -30,25 +30,24 @@
 

	
 
StationPool _station_pool("Station");
 
INSTANTIATE_POOL_METHODS(Station)
 

	
 
BaseStation::~BaseStation()
 
{
 
	free(this->name);
 
	free(this->speclist);
 
}
 

	
 
Station::Station(TileIndex tile) :
 
	SpecializedStation<Station, false>(tile),
 
	train_station(INVALID_TILE, 0, 0),
 
	airport_tile(INVALID_TILE),
 
	dock_tile(INVALID_TILE),
 
	indtype(IT_INVALID),
 
	time_since_load(255),
 
	time_since_unload(255),
 
	last_vehicle_type(VEH_INVALID)
 
{
 
	/* this->random_bits is set in Station::AddFacility() */
 
}
 

	
 
/**
 
 * Clean up a station by clearing vehicle orders and invalidating windows.
 
@@ -414,25 +413,25 @@ bool StationRect::BeforeAddRect(TileInde
 
{
 
	TileIndex top_left = TileXY(left_a, top_a);
 
	int width = right_a - left_a + 1;
 
	int height = bottom_a - top_a + 1;
 

	
 
	BEGIN_TILE_LOOP(tile, width, height, top_left)
 
		if (IsTileType(tile, MP_STATION) && GetStationIndex(tile) == st_id) return true;
 
	END_TILE_LOOP(tile, width, height, top_left);
 

	
 
	return false;
 
}
 

	
 
bool StationRect::AfterRemoveTile(Station *st, TileIndex tile)
 
bool StationRect::AfterRemoveTile(BaseStation *st, TileIndex tile)
 
{
 
	int x = TileX(tile);
 
	int y = TileY(tile);
 

	
 
	/* look if removed tile was on the bounding rect edge
 
	 * and try to reduce the rect by this edge
 
	 * do it until we have empty rect or nothing to do */
 
	for (;;) {
 
		/* check if removed tile is on rect edge */
 
		bool left_edge = (x == this->left);
 
		bool right_edge = (x == this->right);
 
		bool top_edge = (y == this->top);
 
@@ -464,25 +463,25 @@ bool StationRect::AfterRemoveTile(Statio
 
			}
 
		}
 

	
 
		if (left > right || top > bottom) {
 
			/* can't continue, if the remaining rectangle is empty */
 
			this->MakeEmpty();
 
			return true; // empty remaining rect
 
		}
 
	}
 
	return false; // non-empty remaining rect
 
}
 

	
 
bool StationRect::AfterRemoveRect(Station *st, TileIndex tile, int w, int h)
 
bool StationRect::AfterRemoveRect(BaseStation *st, TileIndex tile, int w, int h)
 
{
 
	assert(PtInExtendedRect(TileX(tile), TileY(tile)));
 
	assert(PtInExtendedRect(TileX(tile) + w - 1, TileY(tile) + h - 1));
 

	
 
	bool empty = this->AfterRemoveTile(st, tile);
 
	if (w != 1 || h != 1) empty = empty || AfterRemoveTile(st, TILE_ADDXY(tile, w - 1, h - 1));
 
	return empty;
 
}
 

	
 
StationRect& StationRect::operator = (Rect src)
 
{
 
	this->left = src.left;