mirror of https://github.com/OpenTTD/OpenTTD
(svn r16860) -Codechange: introduce a helper to assign a station spec to Waypoints
parent
84df3ba2b4
commit
06ea681b5f
|
@ -997,21 +997,8 @@ bool AfterLoadGame()
|
||||||
|
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
if (wp->delete_ctr == 0) {
|
if (wp->delete_ctr == 0) {
|
||||||
const StationSpec *statspec = NULL;
|
|
||||||
|
|
||||||
if (HasBit(_m[wp->xy].m3, 4)) {
|
if (HasBit(_m[wp->xy].m3, 4)) {
|
||||||
statspec = GetCustomStationSpec(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1);
|
wp->AssignStationSpec(_m[wp->xy].m4 + 1);
|
||||||
}
|
|
||||||
|
|
||||||
if (statspec != NULL) {
|
|
||||||
wp->spec.spec = statspec;
|
|
||||||
wp->spec.grfid = statspec->grffile->grfid;
|
|
||||||
wp->spec.localidx = statspec->localidx;
|
|
||||||
} else {
|
|
||||||
/* No custom graphics set, so set to default. */
|
|
||||||
wp->spec.spec = NULL;
|
|
||||||
wp->spec.grfid = 0;
|
|
||||||
wp->spec.localidx = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move ground type bits from m2 to m4. */
|
/* Move ground type bits from m2 to m4. */
|
||||||
|
|
|
@ -91,6 +91,25 @@ Waypoint::~Waypoint()
|
||||||
this->sign.MarkDirty();
|
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)
|
||||||
|
{
|
||||||
|
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, index);
|
||||||
|
|
||||||
|
if (statspec != NULL) {
|
||||||
|
this->spec.spec = statspec;
|
||||||
|
this->spec.grfid = statspec->grffile->grfid;
|
||||||
|
this->spec.localidx = statspec->localidx;
|
||||||
|
} else {
|
||||||
|
this->spec.spec = NULL;
|
||||||
|
this->spec.grfid = 0;
|
||||||
|
this->spec.localidx = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InitializeWaypoints()
|
void InitializeWaypoints()
|
||||||
{
|
{
|
||||||
_waypoint_pool.CleanPool();
|
_waypoint_pool.CleanPool();
|
||||||
|
|
|
@ -36,6 +36,8 @@ struct Waypoint : WaypointPool::PoolItem<&_waypoint_pool> {
|
||||||
~Waypoint();
|
~Waypoint();
|
||||||
|
|
||||||
void UpdateVirtCoord();
|
void UpdateVirtCoord();
|
||||||
|
|
||||||
|
void AssignStationSpec(uint index);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FOR_ALL_WAYPOINTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Waypoint, waypoint_index, var, start)
|
#define FOR_ALL_WAYPOINTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Waypoint, waypoint_index, var, start)
|
||||||
|
|
|
@ -190,18 +190,7 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1
|
||||||
SetDepotWaypointReservation(tile, reserved);
|
SetDepotWaypointReservation(tile, reserved);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
|
|
||||||
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, p1);
|
wp->AssignStationSpec(p1);
|
||||||
|
|
||||||
if (statspec != NULL) {
|
|
||||||
wp->spec.spec = statspec;
|
|
||||||
wp->spec.grfid = statspec->grffile->grfid;
|
|
||||||
wp->spec.localidx = statspec->localidx;
|
|
||||||
} else {
|
|
||||||
/* Specified custom graphics do not exist, so use default. */
|
|
||||||
wp->spec.spec = NULL;
|
|
||||||
wp->spec.grfid = 0;
|
|
||||||
wp->spec.localidx = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
wp->delete_ctr = 0;
|
wp->delete_ctr = 0;
|
||||||
wp->build_date = _date;
|
wp->build_date = _date;
|
||||||
|
|
Loading…
Reference in New Issue