Changeset - r12487:7b0d87481daf
[Not reviewed]
master
0 6 0
rubidium - 15 years ago 2009-07-24 07:38:10
rubidium@openttd.org
(svn r16934) -Codechange: introduce a simple helper function to check whether a station is pending deletion or not
6 files changed with 19 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/base_station_base.h
Show inline comments
 
@@ -91,12 +91,23 @@ struct BaseStation : StationPool::PoolIt
 
	 * @return the station associated with that tile.
 
	 */
 
	static FORCEINLINE BaseStation *GetByTile(TileIndex tile)
 
	{
 
		return BaseStation::Get(GetStationIndex(tile));
 
	}
 

	
 
	/**
 
	 * Check whether the base station currently is in use; in use means
 
	 * that it is not scheduled for deletion and that it still has some
 
	 * facilities left.
 
	 * @return true if still in use
 
	 */
 
	FORCEINLINE bool IsInUse() const
 
	{
 
		return (this->facilities & ~FACIL_WAYPOINT) != 0;
 
	}
 
};
 

	
 
#define FOR_ALL_BASE_STATIONS(var) FOR_ALL_ITEMS_FROM(BaseStation, station_index, var, 0)
 

	
 
/**
 
 * Class defining several overloaded accessors so we don't
src/station_cmd.cpp
Show inline comments
 
@@ -2567,13 +2567,13 @@ static VehicleEnterTileStatus VehicleEnt
 
 * Not all stations will get the tick at the same time.
 
 * @param st the station receiving the tick.
 
 * @return true if the station is still valid (wasn't deleted)
 
 */
 
static bool StationHandleBigTick(BaseStation *st)
 
{
 
	if ((st->facilities & ~FACIL_WAYPOINT) == 0 && ++st->delete_ctr >= 8) {
 
	if (!st->IsInUse() && ++st->delete_ctr >= 8) {
 
		delete st;
 
		return false;
 
	}
 

	
 
	if ((st->facilities & FACIL_WAYPOINT) == 0) UpdateStationAcceptance(Station::From(st), true);
 

	
 
@@ -2695,13 +2695,13 @@ static void UpdateStationRating(Station 
 
	}
 
}
 

	
 
/* called for every station each tick */
 
static void StationHandleSmallTick(BaseStation *st)
 
{
 
	if ((st->facilities & FACIL_WAYPOINT) != 0 || st->facilities == 0) return;
 
	if ((st->facilities & FACIL_WAYPOINT) != 0 || !st->IsInUse()) return;
 

	
 
	byte b = st->delete_ctr + 1;
 
	if (b >= 185) b = 0;
 
	st->delete_ctr = b;
 

	
 
	if (b == 0) UpdateStationRating(Station::From(st));
src/terraform_gui.cpp
Show inline comments
 
@@ -635,13 +635,13 @@ static void ResetLandscapeConfirmationCa
 

	
 
		/* Delete all station signs */
 
		BaseStation *st;
 
		FOR_ALL_BASE_STATIONS(st) {
 
			/* There can be buoys, remove them */
 
			if (IsBuoyTile(st->xy)) DoCommand(st->xy, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
 
			if ((st->facilities & ~FACIL_WAYPOINT) == 0) delete st;
 
			if (!st->IsInUse()) delete st;
 
		}
 

	
 
		MarkWholeScreenDirty();
 
	}
 
}
 

	
src/viewport.cpp
Show inline comments
 
@@ -1217,13 +1217,13 @@ static void ViewportAddSigns(DrawPixelIn
 
	}
 
}
 

	
 

	
 
static void AddWaypoint(const Waypoint *wp, StringID str, uint16 width)
 
{
 
	AddStringToDraw(wp->sign.left + 1, wp->sign.top + 1, str, wp->index, 0, (wp->owner == OWNER_NONE || (wp->facilities & ~FACIL_WAYPOINT) == 0) ? 0xE : _company_colours[wp->owner], width);
 
	AddStringToDraw(wp->sign.left + 1, wp->sign.top + 1, str, wp->index, 0, (wp->owner == OWNER_NONE || !wp->IsInUse()) ? 0xE : _company_colours[wp->owner], width);
 
}
 

	
 

	
 
static void ViewportAddWaypoints(DrawPixelInfo *dpi)
 
{
 
	const Waypoint *wp;
src/waypoint_cmd.cpp
Show inline comments
 
@@ -104,13 +104,13 @@ void MakeDefaultWaypointName(Waypoint *w
 
static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile, StringID str)
 
{
 
	Waypoint *wp, *best = NULL;
 
	uint thres = 8;
 

	
 
	FOR_ALL_WAYPOINTS(wp) {
 
		if ((wp->facilities & ~FACIL_WAYPOINT) == 0 && wp->string_id == str && (wp->owner == _current_company || wp->owner == OWNER_NONE)) {
 
		if (!wp->IsInUse() && wp->string_id == str && (wp->owner == _current_company || wp->owner == OWNER_NONE)) {
 
			uint cur_dist = DistanceManhattan(tile, wp->xy);
 

	
 
			if (cur_dist < thres) {
 
				thres = cur_dist;
 
				best = wp;
 
			}
src/waypoint_gui.cpp
Show inline comments
 
@@ -56,15 +56,15 @@ public:
 
		DeleteWindowById(WC_TRAINS_LIST, (this->window_number << 16) | (this->vt << 11) | VLW_WAYPOINT_LIST | this->wp->owner);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		/* You can only change your own waypoints */
 
		this->SetWidgetDisabledState(WAYPVW_RENAME, (this->wp->facilities & ~FACIL_WAYPOINT) == 0 || (this->wp->owner != _local_company && this->wp->owner != OWNER_NONE));
 
		/* Disable the widget for waypoints with no owner (after company bankrupt) */
 
		this->SetWidgetDisabledState(WAYPVW_SHOW_VEHICLES, (this->wp->facilities & ~FACIL_WAYPOINT) == 0);
 
		this->SetWidgetDisabledState(WAYPVW_RENAME, !this->wp->IsInUse() || (this->wp->owner != _local_company && this->wp->owner != OWNER_NONE));
 
		/* Disable the widget for waypoints with no use */
 
		this->SetWidgetDisabledState(WAYPVW_SHOW_VEHICLES, !this->wp->IsInUse());
 

	
 
		SetDParam(0, this->wp->index);
 
		this->DrawWidgets();
 

	
 
		this->DrawViewport();
 
	}
0 comments (0 inline, 0 general)