From c9cab7ba1967a42b90b44bca865db33c66a20c72 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 17 Jul 2009 20:40:29 +0000 Subject: (svn r16862) -Codechange: make waypoints use the same system of station station spec lists. --- src/saveload/waypoint_sl.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/saveload/waypoint_sl.cpp') diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp index f51a09485..75c687c80 100644 --- a/src/saveload/waypoint_sl.cpp +++ b/src/saveload/waypoint_sl.cpp @@ -21,14 +21,12 @@ void AfterLoadWaypoints() Waypoint *wp; FOR_ALL_WAYPOINTS(wp) { - uint i; + if (wp->num_specs == 0) continue; - if (wp->spec.grfid == 0) continue; - - for (i = 0; i < GetNumCustomStations(STAT_CLASS_WAYP); i++) { + 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->spec.grfid && statspec->localidx == wp->spec.localidx) { - wp->spec.spec = statspec; + if (statspec != NULL && statspec->grffile->grfid == wp->speclist->grfid && statspec->localidx == wp->speclist->localidx) { + wp->speclist->spec = statspec; break; } } @@ -37,6 +35,7 @@ void AfterLoadWaypoints() static uint16 _waypoint_town_index; static StringID _waypoint_string_id; +static StationSpecList _waypoint_spec; static const SaveLoad _waypoint_desc[] = { SLE_CONDVAR(Waypoint, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), @@ -51,8 +50,8 @@ static const SaveLoad _waypoint_desc[] = { 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), + SLEG_CONDVAR(_waypoint_spec.localidx, SLE_UINT8, 3, SL_MAX_VERSION), + SLEG_CONDVAR(_waypoint_spec.grfid, SLE_UINT32, 17, SL_MAX_VERSION), SLE_CONDVAR(Waypoint, owner, SLE_UINT8, 101, SL_MAX_VERSION), SLE_END() @@ -63,6 +62,12 @@ static void Save_WAYP() Waypoint *wp; FOR_ALL_WAYPOINTS(wp) { + if (wp->num_specs == 0) { + _waypoint_spec.grfid = 0; + } else { + _waypoint_spec = *wp->speclist; + } + SlSetArrayIndex(wp->index); SlObject(wp, _waypoint_desc); } @@ -75,10 +80,17 @@ static void Load_WAYP() while ((index = SlIterateArray()) != -1) { _waypoint_string_id = 0; _waypoint_town_index = 0; + _waypoint_spec.grfid = 0; Waypoint *wp = new (index) Waypoint(); SlObject(wp, _waypoint_desc); + if (_waypoint_spec.grfid != 0) { + wp->num_specs = 1; + wp->speclist = MallocT(1); + *wp->speclist = _waypoint_spec; + } + if (CheckSavegameVersion(84)) wp->name = (char *)(size_t)_waypoint_string_id; if (CheckSavegameVersion(122)) wp->town = (Town *)(size_t)_waypoint_town_index; } -- cgit v1.2.3-54-g00ecf