tron@2186: /* $Id$ */ tron@2186: rubidium@9111: /** @file waypoint.cpp Handling of waypoints. */ belugas@6432: truelight@1542: #include "stdafx.h" Darkvater@1891: #include "openttd.h" truelight@1542: rubidium@8116: #include "command_func.h" maedhros@6453: #include "landscape.h" rubidium@8784: #include "order_func.h" tron@3101: #include "rail_map.h" rubidium@8138: #include "rail.h" celestar@5385: #include "bridge_map.h" truelight@1542: #include "saveload.h" rubidium@8785: #include "station_base.h" truelight@1542: #include "town.h" truelight@1542: #include "waypoint.h" tron@2159: #include "variables.h" KUDr@3900: #include "yapf/yapf.h" peter1138@6451: #include "newgrf.h" rubidium@8114: #include "strings_func.h" rubidium@8225: #include "gfx_func.h" rubidium@8131: #include "functions.h" rubidium@8131: #include "window_func.h" rubidium@8138: #include "economy_func.h" rubidium@8140: #include "date_func.h" rubidium@8144: #include "vehicle_func.h" rubidium@8144: #include "vehicle_base.h" rubidium@8214: #include "string_func.h" smatz@8238: #include "signal_func.h" rubidium@10208: #include "company_func.h" rubidium@8270: #include "settings_type.h" rubidium@8787: #include "newgrf_station.h" smatz@8847: #include "oldpool_func.h" rubidium@9129: #include "viewport_func.h" rubidium@9815: #include "pbs.h" rubidium@9815: #include "train.h" truelight@1542: rubidium@8264: #include "table/strings.h" smatz@8238: rubidium@7381: DEFINE_OLD_POOL_GENERIC(Waypoint, Waypoint) truelight@1542: truelight@1542: belugas@6432: /** belugas@6432: * Update the sign for the waypoint belugas@6432: * @param wp Waypoint to update sign */ tron@2817: static void UpdateWaypointSign(Waypoint* wp) truelight@1542: { celestar@3422: Point pt = RemapCoords2(TileX(wp->xy) * TILE_SIZE, TileY(wp->xy) * TILE_SIZE); truelight@1542: SetDParam(0, wp->index); truelight@1542: UpdateViewportSignPos(&wp->sign, pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT); truelight@1542: } truelight@1542: belugas@6432: /** belugas@6432: * Redraw the sign of a waypoint belugas@6432: * @param wp Waypoint to redraw sign */ tron@2752: static void RedrawWaypointSign(const Waypoint* wp) truelight@1542: { truelight@1542: MarkAllViewportsDirty( truelight@1542: wp->sign.left - 6, truelight@1542: wp->sign.top, truelight@1542: wp->sign.left + (wp->sign.width_1 << 2) + 12, truelight@1542: wp->sign.top + 48); truelight@1542: } truelight@1542: belugas@6432: /** belugas@6432: * Update all signs belugas@6432: */ rubidium@6247: void UpdateAllWaypointSigns() truelight@1542: { truelight@1542: Waypoint *wp; truelight@1542: truelight@1542: FOR_ALL_WAYPOINTS(wp) { truelight@4346: UpdateWaypointSign(wp); truelight@1542: } truelight@1542: } truelight@1542: belugas@6432: /** belugas@6432: * Set the default name for a waypoint belugas@6432: * @param wp Waypoint to work on belugas@6432: */ tron@2752: static void MakeDefaultWaypointName(Waypoint* wp) truelight@1542: { smatz@8579: uint32 used = 0; // bitmap of used waypoint numbers, sliding window with 'next' as base smatz@8579: uint32 next = 0; // first waypoint number in the bitmap smatz@8579: WaypointID idx = 0; // index where we will stop truelight@1542: rubidium@10236: wp->town_index = ClosestTownFromTile(wp->xy, UINT_MAX)->index; truelight@1542: smatz@8579: /* Find first unused waypoint number belonging to this town. This can never fail, smatz@8579: * as long as there can be at most 65535 waypoints in total. smatz@8579: * smatz@8579: * This does 'n * m' search, but with 32bit 'used' bitmap, it needs at most 'n * (1 + ceil(m / 32))' smatz@8579: * steps (n - number of waypoints in pool, m - number of waypoints near this town). smatz@8579: * Usually, it needs only 'n' steps. smatz@8579: * smatz@8579: * If it wasn't using 'used' and 'idx', it would just search for increasing 'next', smatz@8579: * but this way it is faster */ truelight@1542: smatz@8579: WaypointID cid = 0; // current index, goes to GetWaypointPoolSize()-1, then wraps to 0 smatz@8579: do { smatz@8579: Waypoint *lwp = GetWaypoint(cid); truelight@1542: smatz@8579: /* check only valid waypoints... */ rubidium@8970: if (lwp->IsValid() && wp != lwp) { smatz@8579: /* only waypoints with 'generic' name within the same city */ smatz@8579: if (lwp->name == NULL && lwp->town_index == wp->town_index) { smatz@8579: /* if lwp->town_cn < next, uint will overflow to '+inf' */ smatz@8579: uint i = (uint)lwp->town_cn - next; truelight@1542: smatz@8579: if (i < 32) { smatz@8579: SetBit(used, i); // update bitmap smatz@8579: if (i == 0) { smatz@8579: /* shift bitmap while the lowest bit is '1'; smatz@8579: * increase the base of the bitmap too */ smatz@8579: do { smatz@8579: used >>= 1; smatz@8579: next++; smatz@8579: } while (HasBit(used, 0)); smatz@8579: /* when we are at 'idx' again at end of the loop and smatz@8579: * 'next' hasn't changed, then no waypoint had town_cn == next, smatz@8579: * so we can safely use it */ smatz@8579: idx = cid; smatz@8579: } smatz@8579: } smatz@8579: } smatz@8579: } smatz@8579: smatz@8579: cid++; smatz@8579: if (cid == GetWaypointPoolSize()) cid = 0; // wrap to zero... smatz@8579: } while (cid != idx); smatz@8579: smatz@8579: wp->town_cn = (uint16)next; // set index... smatz@8579: wp->name = NULL; // ... and use generic name truelight@1542: } truelight@1542: belugas@6432: /** belugas@6432: * Find a deleted waypoint close to a tile. belugas@6432: * @param tile to search from belugas@6432: */ tron@1977: static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile) truelight@1542: { truelight@1542: Waypoint *wp, *best = NULL; tron@4077: uint thres = 8; truelight@1542: truelight@1542: FOR_ALL_WAYPOINTS(wp) { rubidium@10207: if (wp->deleted && (wp->owner == OWNER_NONE || wp->owner == _current_company)) { tron@4077: uint cur_dist = DistanceManhattan(tile, wp->xy); tron@4077: truelight@1542: if (cur_dist < thres) { truelight@1542: thres = cur_dist; truelight@1542: best = wp; truelight@1542: } truelight@1542: } truelight@1542: } truelight@1542: truelight@1542: return best; truelight@1542: } truelight@1542: peter1138@2670: /** peter1138@2670: * Update waypoint graphics id against saved GRFID/localidx. peter1138@2670: * This is to ensure the chosen graphics are correct if GRF files are changed. peter1138@2670: */ rubidium@6247: void AfterLoadWaypoints() peter1138@2670: { peter1138@2670: Waypoint *wp; peter1138@2670: peter1138@2670: FOR_ALL_WAYPOINTS(wp) { peter1138@2670: uint i; peter1138@2670: peter1138@2670: if (wp->grfid == 0) continue; peter1138@2670: peter1138@2670: for (i = 0; i < GetNumCustomStations(STAT_CLASS_WAYP); i++) { belugas@3676: const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, i); peter1138@6451: if (statspec != NULL && statspec->grffile->grfid == wp->grfid && statspec->localidx == wp->localidx) { peter1138@2670: wp->stat_id = i; peter1138@2670: break; peter1138@2670: } peter1138@2670: } peter1138@2670: } peter1138@2670: } peter1138@2670: Darkvater@1782: /** Convert existing rail to waypoint. Eg build a waypoint station over Darkvater@1782: * piece of rail tron@3491: * @param tile tile where waypoint will be built belugas@6432: * @param flags type of operation peter1138@2625: * @param p1 graphics for waypoint type, 0 indicates standard graphics Darkvater@1782: * @param p2 unused celestar@2085: * celestar@2085: * @todo When checking for the tile slope, celestar@2085: * distingush between "Flat land required" and "land sloped in wrong direction" Darkvater@1782: */ rubidium@6943: CommandCost CmdBuildTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) truelight@1542: { truelight@1542: Waypoint *wp; tron@3636: Slope tileh; tron@3101: Axis axis; truelight@1542: Darkvater@1782: /* if custom gfx are used, make sure it is within bounds */ peter1138@2625: if (p1 >= GetNumCustomStations(STAT_CLASS_WAYP)) return CMD_ERROR; Darkvater@1782: tron@3267: if (!IsTileType(tile, MP_RAILWAY) || rubidium@3792: GetRailTileType(tile) != RAIL_TILE_NORMAL || ( tron@3267: (axis = AXIS_X, GetTrackBits(tile) != TRACK_BIT_X) && tron@3267: (axis = AXIS_Y, GetTrackBits(tile) != TRACK_BIT_Y) tron@3101: )) { truelight@1542: return_cmd_error(STR_1005_NO_SUITABLE_RAILROAD_TRACK); tron@3101: } truelight@1542: belugas@9978: Owner owner = GetTileOwner(tile); belugas@9978: if (!CheckOwnership(owner)) return CMD_ERROR; rubidium@7758: if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; truelight@1542: truelight@1542: tileh = GetTileSlope(tile, NULL); tron@4077: if (tileh != SLOPE_FLAT && rubidium@9413: (!_settings_game.construction.build_on_slopes || IsSteepSlope(tileh) || !(tileh & (0x3 << axis)) || !(tileh & ~(0x3 << axis)))) { tron@4077: return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); truelight@1542: } truelight@1542: celestar@5385: if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); celestar@5385: truelight@1542: /* Check if there is an already existing, deleted, waypoint close to us that we can reuse. */ truelight@1542: wp = FindDeletedWaypointCloseTo(tile); rubidium@9036: if (wp == NULL && !Waypoint::CanAllocateItem()) return CMD_ERROR; rubidium@7381: rubidium@9036: if (flags & DC_EXEC) { rubidium@9036: if (wp == NULL) { rubidium@9036: wp = new Waypoint(tile); rubidium@7704: rubidium@9036: wp->town_index = INVALID_TOWN; rubidium@9036: wp->name = NULL; rubidium@9036: wp->town_cn = 0; rubidium@9036: } else { rubidium@9036: /* Move existing (recently deleted) waypoint to the new location */ rubidium@9036: rubidium@9036: /* First we update the destination for all vehicles that rubidium@9036: * have the old waypoint in their orders. */ rubidium@9036: Vehicle *v; rubidium@9036: FOR_ALL_VEHICLES(v) { rubidium@9036: if (v->type == VEH_TRAIN && rubidium@9036: v->First() == v && rubidium@9036: v->current_order.IsType(OT_GOTO_WAYPOINT) && rubidium@9036: v->dest_tile == wp->xy) { rubidium@9036: v->dest_tile = tile; rubidium@9036: } rubidium@7704: } rubidium@9036: rubidium@9036: RedrawWaypointSign(wp); rubidium@9036: wp->xy = tile; frosch@9986: InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index); rubidium@7704: } frosch@9988: wp->owner = owner; rubidium@7704: tron@4051: const StationSpec* statspec; tron@4051: rubidium@9789: bool reserved = HasBit(GetTrackReservation(tile), AxisToTrack(axis)); belugas@9978: MakeRailWaypoint(tile, owner, axis, GetRailType(tile), wp->index); rubidium@9789: SetDepotWaypointReservation(tile, reserved); tron@3101: MarkTileDirtyByTile(tile); peter1138@2670: tron@4051: statspec = GetCustomStationSpec(STAT_CLASS_WAYP, p1); peter1138@2670: belugas@3676: if (statspec != NULL) { tron@4051: wp->stat_id = p1; peter1138@6451: wp->grfid = statspec->grffile->grfid; belugas@3676: wp->localidx = statspec->localidx; peter1138@2670: } else { belugas@6432: /* Specified custom graphics do not exist, so use default. */ peter1138@2670: wp->stat_id = 0; peter1138@2670: wp->grfid = 0; peter1138@2670: wp->localidx = 0; truelight@1542: } peter1138@2670: truelight@1542: wp->deleted = 0; truelight@1542: wp->build_date = _date; truelight@1542: glx@8501: if (wp->town_index == INVALID_TOWN) MakeDefaultWaypointName(wp); truelight@1542: truelight@1542: UpdateWaypointSign(wp); truelight@1542: RedrawWaypointSign(wp); KUDr@5348: YapfNotifyTrackLayoutChange(tile, AxisToTrack(axis)); truelight@1542: } truelight@1542: rubidium@8230: return CommandCost(EXPENSES_CONSTRUCTION, _price.build_train_depot); truelight@1542: } truelight@1542: belugas@6432: /** belugas@6432: * Daily loop for waypoints belugas@6432: */ rubidium@6247: void WaypointsDailyLoop() truelight@1542: { truelight@1542: Waypoint *wp; truelight@1542: truelight@1542: /* Check if we need to delete a waypoint */ truelight@1542: FOR_ALL_WAYPOINTS(wp) { smatz@10089: if (wp->deleted != 0 && --wp->deleted == 0) delete wp; truelight@1542: } truelight@1542: } truelight@1542: belugas@6432: /** belugas@6432: * Remove a waypoint belugas@6432: * @param tile from which to remove waypoint belugas@6432: * @param flags type of operation belugas@6432: * @param justremove will indicate if it is removed from rail or if rails are removed too belugas@6432: * @return cost of operation or error belugas@6432: */ rubidium@6943: CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove) truelight@1542: { truelight@1542: Waypoint *wp; truelight@1542: truelight@1542: /* Make sure it's a waypoint */ smatz@10099: if (!IsRailWaypointTile(tile) || rubidium@10207: (!CheckTileOwnership(tile) && _current_company != OWNER_WATER) || rubidium@7758: !EnsureNoVehicleOnGround(tile)) { truelight@1542: return CMD_ERROR; tron@4077: } truelight@1542: truelight@1542: if (flags & DC_EXEC) { KUDr@5348: Track track = GetRailWaypointTrack(tile); truelight@1542: wp = GetWaypointByTile(tile); truelight@1542: truelight@1542: wp->deleted = 30; // let it live for this many days before we do the actual deletion. truelight@1542: RedrawWaypointSign(wp); truelight@1542: rubidium@9815: Vehicle *v = NULL; truelight@1542: if (justremove) { rubidium@9789: TrackBits tracks = GetRailWaypointBits(tile); rubidium@9789: bool reserved = GetDepotWaypointReservation(tile); belugas@9978: MakeRailNormal(tile, wp->owner, tracks, GetRailType(tile)); rubidium@9789: if (reserved) SetTrackReservation(tile, tracks); tron@3101: MarkTileDirtyByTile(tile); truelight@1542: } else { rubidium@9815: if (GetDepotWaypointReservation(tile)) { rubidium@9815: v = GetTrainForReservation(tile, track); rubidium@9815: if (v != NULL) FreeTrainTrackReservation(v); rubidium@9815: } truelight@1542: DoClearSquare(tile); belugas@9978: AddTrackToSignalBuffer(tile, track, wp->owner); truelight@1542: } KUDr@5348: YapfNotifyTrackLayoutChange(tile, track); rubidium@9815: if (v != NULL) TryPathReserve(v, true); truelight@1542: } truelight@1542: rubidium@8230: return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_train_depot); truelight@1542: } truelight@1542: belugas@6432: /** belugas@6432: * Delete a waypoint tron@3491: * @param tile tile where waypoint is to be deleted belugas@6432: * @param flags type of operation Darkvater@1782: * @param p1 unused Darkvater@1782: * @param p2 unused belugas@6432: * @return cost of operation or error Darkvater@1782: */ rubidium@6943: CommandCost CmdRemoveTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) truelight@1542: { truelight@1542: return RemoveTrainWaypoint(tile, flags, true); truelight@1542: } truelight@1542: peter1138@7097: static bool IsUniqueWaypointName(const char *name) peter1138@7097: { peter1138@7097: const Waypoint *wp; peter1138@7097: char buf[512]; peter1138@7097: peter1138@7097: FOR_ALL_WAYPOINTS(wp) { peter1138@7097: SetDParam(0, wp->index); peter1138@7097: GetString(buf, STR_WAYPOINT_RAW, lastof(buf)); peter1138@7097: if (strcmp(buf, name) == 0) return false; peter1138@7097: } peter1138@7097: peter1138@7097: return true; peter1138@7097: } peter1138@7097: belugas@6432: /** belugas@6432: * Rename a waypoint. tron@3491: * @param tile unused belugas@6432: * @param flags type of operation Darkvater@1782: * @param p1 id of waypoint Darkvater@1782: * @param p2 unused belugas@6432: * @return cost of operation or error Darkvater@1782: */ rubidium@6943: CommandCost CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) truelight@1542: { truelight@4352: if (!IsValidWaypointID(p1)) return CMD_ERROR; Darkvater@1782: smatz@10136: Waypoint *wp = GetWaypoint(p1); smatz@10136: if (!CheckOwnership(wp->owner)) return CMD_ERROR; peter1138@7101: smatz@10148: bool reset = StrEmpty(_cmd_text); smatz@10148: smatz@10148: if (!reset) { rubidium@9914: if (strlen(_cmd_text) >= MAX_LENGTH_WAYPOINT_NAME_BYTES) return CMD_ERROR; peter1138@7097: if (!IsUniqueWaypointName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); smatz@10148: } truelight@1542: smatz@10148: if (flags & DC_EXEC) { smatz@10148: free(wp->name); smatz@10148: smatz@10148: if (reset) { smatz@10148: MakeDefaultWaypointName(wp); // sets wp->name = NULL smatz@10148: } else { smatz@10148: wp->name = strdup(_cmd_text); truelight@1542: } truelight@1542: smatz@10148: UpdateWaypointSign(wp); smatz@10148: MarkWholeScreenDirty(); truelight@1542: } rubidium@6950: return CommandCost(); truelight@1542: } truelight@1542: belugas@6432: /** belugas@6432: * This hacks together some dummy one-shot Station structure for a waypoint. belugas@6432: * @param tile on which to work belugas@6432: * @return pointer to a Station belugas@6432: */ tron@1977: Station *ComposeWaypointStation(TileIndex tile) truelight@1542: { truelight@1542: Waypoint *wp = GetWaypointByTile(tile); KUDr@5734: KUDr@5734: /* instead of 'static Station stat' use byte array to avoid Station's destructor call upon exit. As KUDr@5734: * a side effect, the station is not constructed now. */ KUDr@5739: static byte stat_raw[sizeof(Station)]; KUDr@5734: static Station &stat = *(Station*)stat_raw; truelight@1542: truelight@1542: stat.train_tile = stat.xy = wp->xy; truelight@1542: stat.town = GetTown(wp->town_index); truelight@1542: stat.build_date = wp->build_date; truelight@1542: truelight@1542: return &stat; truelight@1542: } truelight@1542: belugas@6432: /** belugas@6432: * Draw a waypoint belugas@6432: * @param x coordinate belugas@6432: * @param y coordinate belugas@6432: * @param stat_id station id belugas@6432: * @param railtype RailType to use for belugas@6432: */ tron@2520: void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype) truelight@1542: { truelight@1542: x += 33; truelight@1542: y += 17; truelight@1542: peter1138@3764: if (!DrawStationTile(x, y, railtype, AXIS_X, STAT_CLASS_WAYP, stat_id)) { ludde@2261: DrawDefaultWaypointSprite(x, y, railtype); truelight@1542: } truelight@1542: } truelight@1542: rubidium@7381: Waypoint::Waypoint(TileIndex tile) rubidium@7381: { rubidium@7381: this->xy = tile; rubidium@7381: } rubidium@7381: rubidium@7381: Waypoint::~Waypoint() rubidium@7381: { peter1138@8258: free(this->name); rubidium@7413: rubidium@7413: if (CleaningPool()) return; belugas@9964: DeleteWindowById(WC_WAYPOINT_VIEW, this->index); rubidium@7381: RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, this->index); rubidium@7381: rubidium@7381: RedrawWaypointSign(this); rubidium@7381: this->xy = 0; rubidium@7381: } rubidium@7381: belugas@6432: /** belugas@6432: * Fix savegames which stored waypoints in their old format belugas@6432: */ rubidium@6247: void FixOldWaypoints() truelight@1542: { truelight@1542: Waypoint *wp; truelight@1542: truelight@1542: /* Convert the old 'town_or_string', to 'string' / 'town' / 'town_cn' */ truelight@1542: FOR_ALL_WAYPOINTS(wp) { rubidium@10236: wp->town_index = ClosestTownFromTile(wp->xy, UINT_MAX)->index; truelight@1542: wp->town_cn = 0; truelight@1542: if (wp->string & 0xC000) { truelight@1542: wp->town_cn = wp->string & 0x3F; truelight@1542: wp->string = STR_NULL; truelight@1542: } truelight@1542: } truelight@1542: } truelight@1542: rubidium@6247: void InitializeWaypoints() truelight@1542: { rubidium@7381: _Waypoint_pool.CleanPool(); rubidium@7381: _Waypoint_pool.AddBlockToPool(); truelight@1542: } truelight@1542: Darkvater@1881: static const SaveLoad _waypoint_desc[] = { rubidium@4344: SLE_CONDVAR(Waypoint, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), rubidium@4344: SLE_CONDVAR(Waypoint, xy, SLE_UINT32, 6, SL_MAX_VERSION), rubidium@4344: SLE_CONDVAR(Waypoint, town_index, SLE_UINT16, 12, SL_MAX_VERSION), smatz@8579: SLE_CONDVAR(Waypoint, town_cn, SLE_FILE_U8 | SLE_VAR_U16, 12, 88), smatz@8579: SLE_CONDVAR(Waypoint, town_cn, SLE_UINT16, 89, SL_MAX_VERSION), peter1138@8258: SLE_CONDVAR(Waypoint, string, SLE_STRINGID, 0, 83), peter1138@8258: SLE_CONDSTR(Waypoint, name, SLE_STR, 0, 84, SL_MAX_VERSION), rubidium@4344: SLE_VAR(Waypoint, deleted, SLE_UINT8), truelight@1542: rubidium@4344: SLE_CONDVAR(Waypoint, build_date, SLE_FILE_U16 | SLE_VAR_I32, 3, 30), rubidium@4344: SLE_CONDVAR(Waypoint, build_date, SLE_INT32, 31, SL_MAX_VERSION), rubidium@4344: SLE_CONDVAR(Waypoint, localidx, SLE_UINT8, 3, SL_MAX_VERSION), rubidium@4344: SLE_CONDVAR(Waypoint, grfid, SLE_UINT32, 17, SL_MAX_VERSION), belugas@9978: SLE_CONDVAR(Waypoint, owner, SLE_UINT8, 101, SL_MAX_VERSION), truelight@1542: truelight@1542: SLE_END() truelight@1542: }; truelight@1542: rubidium@6247: static void Save_WAYP() truelight@1542: { truelight@1542: Waypoint *wp; truelight@1542: truelight@1542: FOR_ALL_WAYPOINTS(wp) { truelight@4346: SlSetArrayIndex(wp->index); truelight@4346: SlObject(wp, _waypoint_desc); truelight@1542: } truelight@1542: } truelight@1542: rubidium@6247: static void Load_WAYP() truelight@1542: { truelight@1542: int index; truelight@1542: truelight@1542: while ((index = SlIterateArray()) != -1) { rubidium@7381: Waypoint *wp = new (index) Waypoint(); truelight@1542: SlObject(wp, _waypoint_desc); truelight@1542: } truelight@1542: } truelight@1542: rubidium@5587: extern const ChunkHandler _waypoint_chunk_handlers[] = { truelight@1542: { 'CHKP', Save_WAYP, Load_WAYP, CH_ARRAY | CH_LAST}, truelight@1542: };