mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-08 23:19:40 +00:00
(svn r16851) -Codechange: use StationSpecList in waypoint too
This commit is contained in:
parent
dea1144bcb
commit
665fa7f9c1
@ -1938,8 +1938,7 @@ static void DrawTile_Track(TileInfo *ti)
|
||||
}
|
||||
} else {
|
||||
/* look for customization */
|
||||
byte stat_id = GetWaypointByTile(ti->tile)->stat_id;
|
||||
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, stat_id);
|
||||
const StationSpec *statspec = GetWaypointByTile(ti->tile)->spec.spec;
|
||||
|
||||
if (statspec != NULL) {
|
||||
/* emulate station tile - open with building */
|
||||
|
@ -1008,18 +1008,19 @@ bool AfterLoadGame()
|
||||
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);
|
||||
}
|
||||
|
||||
if (statspec != NULL) {
|
||||
wp->stat_id = _m[wp->xy].m4 + 1;
|
||||
wp->grfid = statspec->grffile->grfid;
|
||||
wp->localidx = statspec->localidx;
|
||||
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->stat_id = 0;
|
||||
wp->grfid = 0;
|
||||
wp->localidx = 0;
|
||||
wp->spec.spec = NULL;
|
||||
wp->spec.grfid = 0;
|
||||
wp->spec.localidx = 0;
|
||||
}
|
||||
|
||||
/* Move ground type bits from m2 to m4. */
|
||||
|
@ -22,12 +22,12 @@ void AfterLoadWaypoints()
|
||||
FOR_ALL_WAYPOINTS(wp) {
|
||||
uint i;
|
||||
|
||||
if (wp->grfid == 0) continue;
|
||||
if (wp->spec.grfid == 0) continue;
|
||||
|
||||
for (i = 0; i < GetNumCustomStations(STAT_CLASS_WAYP); i++) {
|
||||
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, i);
|
||||
if (statspec != NULL && statspec->grffile->grfid == wp->grfid && statspec->localidx == wp->localidx) {
|
||||
wp->stat_id = i;
|
||||
if (statspec != NULL && statspec->grffile->grfid == wp->spec.grfid && statspec->localidx == wp->spec.localidx) {
|
||||
wp->spec.spec = statspec;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -53,20 +53,20 @@ void FixOldWaypoints()
|
||||
}
|
||||
|
||||
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_id, SLE_STRINGID, 0, 83),
|
||||
SLE_CONDSTR(Waypoint, name, SLE_STR, 0, 84, SL_MAX_VERSION),
|
||||
SLE_VAR(Waypoint, delete_ctr, SLE_UINT8),
|
||||
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_id, SLE_STRINGID, 0, 83),
|
||||
SLE_CONDSTR(Waypoint, name, SLE_STR, 0, 84, SL_MAX_VERSION),
|
||||
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),
|
||||
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, spec.localidx, SLE_UINT8, 3, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Waypoint, spec.grfid, SLE_UINT32, 17, SL_MAX_VERSION),
|
||||
SLE_CONDVAR(Waypoint, owner, SLE_UINT8, 101, SL_MAX_VERSION),
|
||||
|
||||
SLE_END()
|
||||
};
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "waypoint_type.h"
|
||||
#include "rail_map.h"
|
||||
#include "command_type.h"
|
||||
#include "station_type.h"
|
||||
#include "station_base.h"
|
||||
#include "town_type.h"
|
||||
#include "viewport_type.h"
|
||||
#include "date_type.h"
|
||||
@ -29,9 +29,7 @@ struct Waypoint : WaypointPool::PoolItem<&_waypoint_pool> {
|
||||
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
|
||||
StationSpecList spec; ///< NewGRF specification of the station
|
||||
|
||||
byte delete_ctr; ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
|
||||
|
||||
|
@ -185,24 +185,22 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1
|
||||
}
|
||||
wp->owner = owner;
|
||||
|
||||
const StationSpec *statspec;
|
||||
|
||||
bool reserved = HasBit(GetTrackReservation(tile), AxisToTrack(axis));
|
||||
MakeRailWaypoint(tile, owner, axis, GetRailType(tile), wp->index);
|
||||
SetDepotWaypointReservation(tile, reserved);
|
||||
MarkTileDirtyByTile(tile);
|
||||
|
||||
statspec = GetCustomStationSpec(STAT_CLASS_WAYP, p1);
|
||||
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, p1);
|
||||
|
||||
if (statspec != NULL) {
|
||||
wp->stat_id = p1;
|
||||
wp->grfid = statspec->grffile->grfid;
|
||||
wp->localidx = statspec->localidx;
|
||||
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->stat_id = 0;
|
||||
wp->grfid = 0;
|
||||
wp->localidx = 0;
|
||||
wp->spec.spec = NULL;
|
||||
wp->spec.grfid = 0;
|
||||
wp->spec.localidx = 0;
|
||||
}
|
||||
|
||||
wp->delete_ctr = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user