mirror of https://github.com/OpenTTD/OpenTTD
(svn r10374) [0.5] -Backport from trunk (r10333, r10336, r10337, r10345, 10346, 10368):
- Fix: Waypoints could be renamed when you are not the owner (r10368) - Fix: The 'old' pathfinders (OPF and NPF) for road vehicles could not find a path when in a tunnel [FS#290] (r10345, r10346) - Fix: Only add the autoreplace menu when autoreplace actually knows about the group [FS#880] (r10337) - Fix: Signal state sometimes not properly set when the signal "pathfinder" reached the end of a line [FS#910] (r10336) - Fix: News messages were shown over the endgame/highscore windows [FS#943] (r10333)release/0.5
parent
cd32a5f18c
commit
a221bece84
67
pathfind.c
67
pathfind.c
|
@ -251,31 +251,13 @@ const byte _ffb_64[128] = {
|
||||||
48, 56, 56, 58, 56, 60, 60, 62,
|
48, 56, 56, 58, 56, 60, 60, 62,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void TPFMode1(TrackPathFinder* tpf, TileIndex tile, DiagDirection direction)
|
static void TPFMode1(TrackPathFinder* tpf, TileIndex tile, DiagDirection direction);
|
||||||
|
|
||||||
|
/** Most code of the "Normal" case of TPF Mode 1; for signals special tricks
|
||||||
|
* have to be done, but those happen in TPFMode1; this is just to prevent
|
||||||
|
* gotos ;). */
|
||||||
|
static inline void TPFMode1_NormalCase(TrackPathFinder* tpf, TileIndex tile, TileIndex tile_org, DiagDirection direction)
|
||||||
{
|
{
|
||||||
uint bits;
|
|
||||||
int i;
|
|
||||||
RememberData rd;
|
|
||||||
TileIndex tile_org = tile;
|
|
||||||
|
|
||||||
// check if the old tile can be left at that direction
|
|
||||||
if (tpf->tracktype == TRANSPORT_ROAD) {
|
|
||||||
// road stops and depots now have a track (r4419)
|
|
||||||
// don't enter road stop from the back
|
|
||||||
if (IsRoadStopTile(tile) && GetRoadStopDir(tile) != direction) return;
|
|
||||||
// don't enter road depot from the back
|
|
||||||
if (IsTileDepotType(tile, TRANSPORT_ROAD) && GetRoadDepotDirection(tile) != direction) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsTunnelTile(tile)) {
|
|
||||||
if (GetTunnelDirection(tile) != direction ||
|
|
||||||
GetTunnelTransportType(tile) != tpf->tracktype) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tile = SkipToEndOfTunnel(tpf, tile, direction);
|
|
||||||
}
|
|
||||||
tile += TileOffsByDiagDir(direction);
|
|
||||||
|
|
||||||
/* Check in case of rail if the owner is the same */
|
/* Check in case of rail if the owner is the same */
|
||||||
if (tpf->tracktype == TRANSPORT_RAIL) {
|
if (tpf->tracktype == TRANSPORT_RAIL) {
|
||||||
// don't enter train depot from the back
|
// don't enter train depot from the back
|
||||||
|
@ -302,11 +284,46 @@ static void TPFMode1(TrackPathFinder* tpf, TileIndex tile, DiagDirection directi
|
||||||
/* Check if the new tile is a tunnel or bridge head and that the direction
|
/* Check if the new tile is a tunnel or bridge head and that the direction
|
||||||
* and transport type match */
|
* and transport type match */
|
||||||
if (IsTileType(tile, MP_TUNNELBRIDGE) && IsTunnel(tile)) {
|
if (IsTileType(tile, MP_TUNNELBRIDGE) && IsTunnel(tile)) {
|
||||||
|
if (GetTunnelTransportType(tile) != tpf->tracktype) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* Only skip through the tunnel if heading inwards. We can
|
||||||
|
* be headed outwards if our starting position was in a
|
||||||
|
* tunnel and we're pathfinding backwards */
|
||||||
|
if (GetTunnelDirection(tile) == direction) {
|
||||||
|
tile = SkipToEndOfTunnel(tpf, tile, direction);
|
||||||
|
} else if (GetTunnelDirection(tile) != ReverseDiagDir(direction)) {
|
||||||
|
/* We don't support moving through the sides of a tunnel
|
||||||
|
* entrance :-) */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TPFMode1(TrackPathFinder* tpf, TileIndex tile, DiagDirection direction)
|
||||||
|
{
|
||||||
|
uint bits;
|
||||||
|
int i;
|
||||||
|
RememberData rd;
|
||||||
|
TileIndex tile_org = tile;
|
||||||
|
|
||||||
|
// check if the old tile can be left at that direction
|
||||||
|
if (tpf->tracktype == TRANSPORT_ROAD) {
|
||||||
|
// road stops and depots now have a track (r4419)
|
||||||
|
// don't enter road stop from the back
|
||||||
|
if (IsRoadStopTile(tile) && GetRoadStopDir(tile) != direction) return;
|
||||||
|
// don't enter road depot from the back
|
||||||
|
if (IsTileDepotType(tile, TRANSPORT_ROAD) && GetRoadDepotDirection(tile) != direction) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsTunnelTile(tile)) {
|
||||||
if (GetTunnelDirection(tile) != direction ||
|
if (GetTunnelDirection(tile) != direction ||
|
||||||
GetTunnelTransportType(tile) != tpf->tracktype) {
|
GetTunnelTransportType(tile) != tpf->tracktype) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
tile = SkipToEndOfTunnel(tpf, tile, direction);
|
||||||
}
|
}
|
||||||
|
tile += TileOffsByDiagDir(direction);
|
||||||
|
|
||||||
tpf->rd.cur_length++;
|
tpf->rd.cur_length++;
|
||||||
|
|
||||||
|
@ -336,6 +353,8 @@ static void TPFMode1(TrackPathFinder* tpf, TileIndex tile, DiagDirection directi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TPFMode1_NormalCase(tpf, tile, tile_org, direction);
|
||||||
|
|
||||||
/* the next is only used when signals are checked.
|
/* the next is only used when signals are checked.
|
||||||
* seems to go in 2 directions simultaneously */
|
* seems to go in 2 directions simultaneously */
|
||||||
|
|
||||||
|
|
|
@ -332,7 +332,7 @@ static const Depot* FindClosestRoadDepot(const Vehicle* v)
|
||||||
/* See where we are now */
|
/* See where we are now */
|
||||||
Trackdir trackdir = GetVehicleTrackdir(v);
|
Trackdir trackdir = GetVehicleTrackdir(v);
|
||||||
|
|
||||||
ftd = NPFRouteToDepotBreadthFirst(v->tile, trackdir, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE);
|
ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, v->tile, ReverseTrackdir(trackdir), TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE, 0);
|
||||||
if (ftd.best_bird_dist == 0) {
|
if (ftd.best_bird_dist == 0) {
|
||||||
return GetDepotByTile(ftd.node.tile); /* Target found */
|
return GetDepotByTile(ftd.node.tile); /* Target found */
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1769,7 +1769,7 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
/* XXX - Substite string since the dropdown cannot handle dynamic strings */
|
/* XXX - Substite string since the dropdown cannot handle dynamic strings */
|
||||||
action_str[2] = depot_name[vl->vehicle_type - VEH_Train];
|
action_str[2] = depot_name[vl->vehicle_type - VEH_Train];
|
||||||
ShowDropDownMenu(w, action_str, 0, VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN, 0, 0);
|
ShowDropDownMenu(w, action_str, 0, VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN, 0, (w->window_number & VLW_MASK) == VLW_STANDARD ? 0 : 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -316,13 +316,15 @@ int32 CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
if (!IsValidWaypointID(p1)) return CMD_ERROR;
|
if (!IsValidWaypointID(p1)) return CMD_ERROR;
|
||||||
|
|
||||||
|
wp = GetWaypoint(p1);
|
||||||
|
if (!CheckTileOwnership(wp->xy)) return CMD_ERROR;
|
||||||
|
|
||||||
if (_cmd_text[0] != '\0') {
|
if (_cmd_text[0] != '\0') {
|
||||||
StringID str = AllocateNameUnique(_cmd_text, 0);
|
StringID str = AllocateNameUnique(_cmd_text, 0);
|
||||||
|
|
||||||
if (str == 0) return CMD_ERROR;
|
if (str == 0) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
wp = GetWaypoint(p1);
|
|
||||||
if (wp->string != STR_NULL) DeleteName(wp->string);
|
if (wp->string != STR_NULL) DeleteName(wp->string);
|
||||||
|
|
||||||
wp->string = str;
|
wp->string = str;
|
||||||
|
@ -335,7 +337,6 @@ int32 CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
wp = GetWaypoint(p1);
|
|
||||||
if (wp->string != STR_NULL) DeleteName(wp->string);
|
if (wp->string != STR_NULL) DeleteName(wp->string);
|
||||||
|
|
||||||
MakeDefaultWaypointName(wp);
|
MakeDefaultWaypointName(wp);
|
||||||
|
|
2
window.c
2
window.c
|
@ -596,7 +596,7 @@ static Window *LocalAllocateWindow(
|
||||||
* XXX - Yes, ugly, probably needs something like w->always_on_top flag
|
* XXX - Yes, ugly, probably needs something like w->always_on_top flag
|
||||||
* to implement correctly, but even then you need some kind of distinction
|
* to implement correctly, but even then you need some kind of distinction
|
||||||
* between on-top of chat/news and status windows, because these conflict */
|
* between on-top of chat/news and status windows, because these conflict */
|
||||||
if (wz != _z_windows && w->window_class != WC_SEND_NETWORK_MSG) {
|
if (wz != _z_windows && w->window_class != WC_SEND_NETWORK_MSG && w->window_class != WC_HIGHSCORE && w->window_class != WC_ENDSCREEN) {
|
||||||
if (FindWindowById(WC_MAIN_TOOLBAR, 0) != NULL) wz--;
|
if (FindWindowById(WC_MAIN_TOOLBAR, 0) != NULL) wz--;
|
||||||
if (FindWindowById(WC_STATUS_BAR, 0) != NULL) wz--;
|
if (FindWindowById(WC_STATUS_BAR, 0) != NULL) wz--;
|
||||||
if (FindWindowById(WC_NEWS_WINDOW, 0) != NULL) wz--;
|
if (FindWindowById(WC_NEWS_WINDOW, 0) != NULL) wz--;
|
||||||
|
|
Loading…
Reference in New Issue