Changeset - r12453:ad72006529c2
[Not reviewed]
master
0 6 0
rubidium - 15 years ago 2009-07-21 11:20:34
rubidium@openttd.org
(svn r16897) -Codechange: use the 'generic' station spec to station allocation for waypoints too
6 files changed with 11 insertions and 33 deletions:
0 comments (0 inline, 0 general)
src/newgrf_station.cpp
Show inline comments
 
@@ -954,7 +954,7 @@ const StationSpec *GetStationSpec(TileIn
 

	
 
	if (IsRailWaypointTile(t)) {
 
		const BaseStation *st = BaseStation::GetByTile(t);
 
		return st->num_specs != 0 ? st->speclist[0].spec : NULL;
 
		return st->num_specs != 0 ? st->speclist[1].spec : NULL;
 
	}
 

	
 
	return NULL;
src/saveload/afterload.cpp
Show inline comments
 
@@ -997,7 +997,7 @@ bool AfterLoadGame()
 
		FOR_ALL_WAYPOINTS(wp) {
 
			if (wp->delete_ctr == 0) {
 
				if (HasBit(_m[wp->xy].m3, 4)) {
 
					wp->AssignStationSpec(_m[wp->xy].m4 + 1);
 
					AllocateSpecToStation(GetCustomStationSpec(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1), wp, true);
 
				}
 

	
 
				/* Move ground type bits from m2 to m4. */
src/saveload/waypoint_sl.cpp
Show inline comments
 
@@ -25,8 +25,8 @@ void AfterLoadWaypoints()
 

	
 
		for (uint i = 0; i < GetNumCustomStations(STAT_CLASS_WAYP); i++) {
 
			const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, i);
 
			if (statspec != NULL && statspec->grffile->grfid == wp->speclist->grfid && statspec->localidx == wp->speclist->localidx) {
 
				wp->speclist->spec = statspec;
 
			if (statspec != NULL && statspec->grffile->grfid == wp->speclist[1].grfid && statspec->localidx == wp->speclist[1].localidx) {
 
				wp->speclist[1].spec = statspec;
 
				break;
 
			}
 
		}
 
@@ -65,7 +65,7 @@ static void Save_WAYP()
 
		if (wp->num_specs == 0) {
 
			_waypoint_spec.grfid = 0;
 
		} else {
 
			_waypoint_spec = *wp->speclist;
 
			_waypoint_spec = wp->speclist[1];
 
		}
 

	
 
		SlSetArrayIndex(wp->index);
 
@@ -86,9 +86,9 @@ static void Load_WAYP()
 
		SlObject(wp, _waypoint_desc);
 

	
 
		if (_waypoint_spec.grfid != 0) {
 
			wp->num_specs = 1;
 
			wp->speclist = MallocT<StationSpecList>(1);
 
			*wp->speclist = _waypoint_spec;
 
			wp->num_specs = 2;
 
			wp->speclist = CallocT<StationSpecList>(2);
 
			wp->speclist[1] = _waypoint_spec;
 
		}
 

	
 
		if (CheckSavegameVersion(84)) wp->name = (char *)(size_t)_waypoint_string_id;
src/waypoint.cpp
Show inline comments
 
@@ -68,28 +68,6 @@ Waypoint::~Waypoint()
 
	this->sign.MarkDirty();
 
}
 

	
 
/**
 
 * Assign a station spec to this waypoint.
 
 * @param index the index of the spec from the waypoint specs
 
 */
 
void Waypoint::AssignStationSpec(uint index)
 
{
 
	free(this->speclist);
 

	
 
	const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, index);
 

	
 
	if (statspec != NULL) {
 
		this->speclist = MallocT<StationSpecList>(1);
 
		this->speclist->spec = statspec;
 
		this->speclist->grfid = statspec->grffile->grfid;
 
		this->speclist->localidx = statspec->localidx;
 
		this->num_specs = 1;
 
	} else {
 
		this->speclist = NULL;
 
		this->num_specs = 0;
 
	}
 
}
 

	
 
void InitializeWaypoints()
 
{
 
	_waypoint_pool.CleanPool();
src/waypoint.h
Show inline comments
 
@@ -34,8 +34,6 @@ struct Waypoint : WaypointPool::PoolItem
 

	
 
	/* virtual */ void GetTileArea(TileArea *ta, StationType type) const;
 

	
 
	void AssignStationSpec(uint index);
 

	
 
	/**
 
	 * Fetch a waypoint by tile
 
	 * @param tile Tile of waypoint
src/waypoint_cmd.cpp
Show inline comments
 
@@ -190,7 +190,7 @@ CommandCost CmdBuildTrainWaypoint(TileIn
 
		SetDepotWaypointReservation(tile, reserved);
 
		MarkTileDirtyByTile(tile);
 

	
 
		wp->AssignStationSpec(p1);
 
		AllocateSpecToStation(GetCustomStationSpec(STAT_CLASS_WAYP, p1), wp, true);
 

	
 
		wp->delete_ctr = 0;
 
		wp->build_date = _date;
 
@@ -246,6 +246,8 @@ CommandCost RemoveTrainWaypoint(TileInde
 
		}
 
		YapfNotifyTrackLayoutChange(tile, track);
 
		if (v != NULL) TryPathReserve(v, true);
 

	
 
		DeallocateSpecFromStation(wp, wp->num_specs > 0 ? 1 : 0);
 
	}
 

	
 
	return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_train_depot);
0 comments (0 inline, 0 general)