Changeset - r12406:d60713d1c3ad
[Not reviewed]
master
0 6 0
rubidium - 15 years ago 2009-07-16 20:15:28
rubidium@openttd.org
(svn r16850) -Codechange: unify some naming of variables between waypoints and stations.
6 files changed with 15 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/saveload/afterload.cpp
Show inline comments
 
@@ -444,14 +444,14 @@ bool AfterLoadGame()
 
			t->name = CopyFromOldName(t->townnametype);
 
			if (t->name != NULL) t->townnametype = SPECSTR_TOWNNAME_START + _settings_game.game_creation.town_name;
 
		}
 

	
 
		Waypoint *wp;
 
		FOR_ALL_WAYPOINTS(wp) {
 
			wp->name = CopyFromOldName(wp->string);
 
			wp->string = STR_EMPTY;
 
			wp->name = CopyFromOldName(wp->string_id);
 
			wp->string_id = STR_NULL;
 
		}
 
	}
 

	
 
	/* From this point the old names array is cleared. */
 
	ResetOldNames();
 

	
 
@@ -1002,13 +1002,13 @@ bool AfterLoadGame()
 
	 * id which was stored in m4 is now saved as a grf/id reference in the
 
	 * waypoint struct. */
 
	if (CheckSavegameVersion(17)) {
 
		Waypoint *wp;
 

	
 
		FOR_ALL_WAYPOINTS(wp) {
 
			if (wp->deleted == 0) {
 
			if (wp->delete_ctr == 0) {
 
				const StationSpec *statspec = NULL;
 

	
 
				if (HasBit(_m[wp->xy].m3, 4))
 
					statspec = GetCustomStationSpec(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1);
 

	
 
				if (statspec != NULL) {
src/saveload/waypoint_sl.cpp
Show inline comments
 
@@ -42,28 +42,28 @@ void FixOldWaypoints()
 
	Waypoint *wp;
 

	
 
	/* Convert the old 'town_or_string', to 'string' / 'town' / 'town_cn' */
 
	FOR_ALL_WAYPOINTS(wp) {
 
		wp->town_index = ClosestTownFromTile(wp->xy, UINT_MAX)->index;
 
		wp->town_cn = 0;
 
		if (wp->string & 0xC000) {
 
			wp->town_cn = wp->string & 0x3F;
 
			wp->string = STR_NULL;
 
		if (wp->string_id & 0xC000) {
 
			wp->town_cn = wp->string_id & 0x3F;
 
			wp->string_id = STR_NULL;
 
		}
 
	}
 
}
 

	
 
static const SaveLoad _waypoint_desc[] = {
 
	SLE_CONDVAR(Waypoint, xy,         SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
	SLE_CONDVAR(Waypoint, xy,         SLE_UINT32,                  6, SL_MAX_VERSION),
 
	SLE_CONDVAR(Waypoint, town_index, SLE_UINT16,                 12, SL_MAX_VERSION),
 
	SLE_CONDVAR(Waypoint, town_cn,    SLE_FILE_U8 | SLE_VAR_U16,  12, 88),
 
	SLE_CONDVAR(Waypoint, town_cn,    SLE_UINT16,                 89, SL_MAX_VERSION),
 
	SLE_CONDVAR(Waypoint, string,     SLE_STRINGID,                0, 83),
 
	SLE_CONDVAR(Waypoint, string_id,  SLE_STRINGID,                0, 83),
 
	SLE_CONDSTR(Waypoint, name,       SLE_STR, 0,                 84, SL_MAX_VERSION),
 
	    SLE_VAR(Waypoint, deleted,    SLE_UINT8),
 
	    SLE_VAR(Waypoint, delete_ctr, SLE_UINT8),
 

	
 
	SLE_CONDVAR(Waypoint, build_date, SLE_FILE_U16 | SLE_VAR_I32,  3, 30),
 
	SLE_CONDVAR(Waypoint, build_date, SLE_INT32,                  31, SL_MAX_VERSION),
 
	SLE_CONDVAR(Waypoint, localidx,   SLE_UINT8,                   3, SL_MAX_VERSION),
 
	SLE_CONDVAR(Waypoint, grfid,      SLE_UINT32,                 17, SL_MAX_VERSION),
 
	SLE_CONDVAR(Waypoint, owner,      SLE_UINT8,                 101, SL_MAX_VERSION),
src/viewport.cpp
Show inline comments
 
@@ -1215,13 +1215,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->deleted ? 0xE : _company_colours[wp->owner]), width);
 
	AddStringToDraw(wp->sign.left + 1, wp->sign.top + 1, str, wp->index, 0, (wp->delete_ctr != 0 ? 0xE : _company_colours[wp->owner]), width);
 
}
 

	
 

	
 
static void ViewportAddWaypoints(DrawPixelInfo *dpi)
 
{
 
	const Waypoint *wp;
src/waypoint.cpp
Show inline comments
 
@@ -35,13 +35,13 @@ void UpdateAllWaypointVirtCoords()
 
void WaypointsDailyLoop()
 
{
 
	Waypoint *wp;
 

	
 
	/* Check if we need to delete a waypoint */
 
	FOR_ALL_WAYPOINTS(wp) {
 
		if (wp->deleted != 0 && --wp->deleted == 0) delete wp;
 
		if (wp->delete_ctr != 0 && --wp->delete_ctr == 0) delete wp;
 
	}
 
}
 

	
 
/**
 
 * This hacks together some dummy one-shot Station structure for a waypoint.
 
 * @param tile on which to work
src/waypoint.h
Show inline comments
 
@@ -19,24 +19,24 @@ extern WaypointPool _waypoint_pool;
 

	
 
struct Waypoint : WaypointPool::PoolItem<&_waypoint_pool> {
 
	TileIndex xy;      ///< Tile of waypoint
 

	
 
	TownID town_index; ///< Town associated with the waypoint
 
	uint16 town_cn;    ///< The Nth waypoint for this town (consecutive number)
 
	StringID string;   ///< C000-C03F have special meaning in old games
 
	StringID string_id;///< C000-C03F have special meaning in old games
 
	char *name;        ///< Custom name. If not set, town + town_cn is used for naming
 

	
 
	ViewportSign sign; ///< Dimensions of sign (not saved)
 
	Date build_date;   ///< Date of construction
 
	OwnerByte owner;   ///< Whom this waypoint belongs to
 

	
 
	byte stat_id;      ///< ID of waypoint within the waypoint class (not saved)
 
	uint32 grfid;      ///< ID of GRF file
 
	byte localidx;     ///< Index of station within GRF file
 

	
 
	byte deleted;      ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
 
	byte delete_ctr;   ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
 

	
 
	Waypoint(TileIndex tile = INVALID_TILE) : xy(tile) { }
 
	~Waypoint();
 

	
 
	void UpdateVirtCoord();
 
};
src/waypoint_cmd.cpp
Show inline comments
 
@@ -101,13 +101,13 @@ static void MakeDefaultWaypointName(Wayp
 
static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile)
 
{
 
	Waypoint *wp, *best = NULL;
 
	uint thres = 8;
 

	
 
	FOR_ALL_WAYPOINTS(wp) {
 
		if (wp->deleted && wp->owner == _current_company) {
 
		if (wp->delete_ctr != 0 && wp->owner == _current_company) {
 
			uint cur_dist = DistanceManhattan(tile, wp->xy);
 

	
 
			if (cur_dist < thres) {
 
				thres = cur_dist;
 
				best = wp;
 
			}
 
@@ -202,13 +202,13 @@ CommandCost CmdBuildTrainWaypoint(TileIn
 
			/* Specified custom graphics do not exist, so use default. */
 
			wp->stat_id = 0;
 
			wp->grfid = 0;
 
			wp->localidx = 0;
 
		}
 

	
 
		wp->deleted = 0;
 
		wp->delete_ctr = 0;
 
		wp->build_date = _date;
 

	
 
		if (wp->town_index == INVALID_TOWN) MakeDefaultWaypointName(wp);
 

	
 
		wp->UpdateVirtCoord();
 
		YapfNotifyTrackLayoutChange(tile, AxisToTrack(axis));
 
@@ -236,13 +236,13 @@ CommandCost RemoveTrainWaypoint(TileInde
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		Track track = GetRailWaypointTrack(tile);
 
		wp = GetWaypointByTile(tile);
 

	
 
		wp->deleted = 30; // let it live for this many days before we do the actual deletion.
 
		wp->delete_ctr = 30; // let it live for this many days before we do the actual deletion.
 
		wp->sign.MarkDirty();
 

	
 
		Train *v = NULL;
 
		if (justremove) {
 
			TrackBits tracks = GetRailWaypointBits(tile);
 
			bool reserved = GetDepotWaypointReservation(tile);
0 comments (0 inline, 0 general)