|
@@ -120,25 +120,25 @@ void MakeDefaultWaypointName(Waypoint *w
|
|
|
if (local_wp->xy && local_wp->string == STR_NULL && local_wp->town_index == wp->town_index)
|
|
|
used_waypoint[local_wp->town_cn] = true;
|
|
|
}
|
|
|
|
|
|
/* Find an empty spot */
|
|
|
for (i = 0; used_waypoint[i] && i < MAX_WAYPOINTS_PER_TOWN; i++) {}
|
|
|
|
|
|
wp->string = STR_NULL;
|
|
|
wp->town_cn = i;
|
|
|
}
|
|
|
|
|
|
/* Find a deleted waypoint close to a tile. */
|
|
|
static Waypoint *FindDeletedWaypointCloseTo(uint tile)
|
|
|
static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile)
|
|
|
{
|
|
|
Waypoint *wp, *best = NULL;
|
|
|
uint thres = 8, cur_dist;
|
|
|
|
|
|
FOR_ALL_WAYPOINTS(wp) {
|
|
|
if (wp->deleted && wp->xy) {
|
|
|
cur_dist = DistanceManhattan(tile, wp->xy);
|
|
|
if (cur_dist < thres) {
|
|
|
thres = cur_dist;
|
|
|
best = wp;
|
|
|
}
|
|
|
}
|
|
@@ -234,25 +234,25 @@ void WaypointsDailyLoop(void)
|
|
|
{
|
|
|
Waypoint *wp;
|
|
|
|
|
|
/* Check if we need to delete a waypoint */
|
|
|
FOR_ALL_WAYPOINTS(wp) {
|
|
|
if (wp->deleted && !--wp->deleted) {
|
|
|
DoDeleteWaypoint(wp);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* Remove a waypoint */
|
|
|
int32 RemoveTrainWaypoint(uint tile, uint32 flags, bool justremove)
|
|
|
int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
|
|
|
{
|
|
|
Waypoint *wp;
|
|
|
|
|
|
/* Make sure it's a waypoint */
|
|
|
if (!IsTileType(tile, MP_RAILWAY) || !IsRailWaypoint(_map5[tile]))
|
|
|
return CMD_ERROR;
|
|
|
|
|
|
if (!CheckTileOwnership(tile) && !(_current_player == OWNER_WATER))
|
|
|
return CMD_ERROR;
|
|
|
|
|
|
if (!EnsureNoVehicle(tile))
|
|
|
return CMD_ERROR;
|
|
@@ -326,25 +326,25 @@ int32 CmdRenameWaypoint(int x, int y, ui
|
|
|
if (wp->string != STR_NULL)
|
|
|
DeleteName(wp->string);
|
|
|
|
|
|
MakeDefaultWaypointName(wp);
|
|
|
UpdateWaypointSign(wp);
|
|
|
MarkWholeScreenDirty();
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/* This hacks together some dummy one-shot Station structure for a waypoint. */
|
|
|
Station *ComposeWaypointStation(uint tile)
|
|
|
Station *ComposeWaypointStation(TileIndex tile)
|
|
|
{
|
|
|
Waypoint *wp = GetWaypointByTile(tile);
|
|
|
static Station stat;
|
|
|
|
|
|
stat.train_tile = stat.xy = wp->xy;
|
|
|
stat.town = GetTown(wp->town_index);
|
|
|
stat.string_id = wp->string == STR_NULL ? /* FIXME? */ 0 : wp->string;
|
|
|
stat.build_date = wp->build_date;
|
|
|
stat.class_id = 6;
|
|
|
stat.stat_id = wp->stat_id;
|
|
|
|
|
|
return &stat;
|