forked from mirror/OpenTTD
(svn r1751) - Feature: New PathFinder (NPF).
- Supports trains, road vehicles and ships. - Uses A* pathfinding (same codebase as the new ai). - Currently unlimited search depth, so might perform badly on large maps/networks (especially ships). - Will always find a route if there is one. - Allows custom penalties for obstacles to be set in openttd.cfg (npf_ values). - With NPF enabled, ships can have orders that are very far apart. Be careful, this will break (ships get lost) when the old pathfinder is used again. - Feature: Disabling 90 degree turns for trains and ships. - Requires NPF to be enabled. - Ships and trains can no longer make weird 90 degree turns on tile borders. - Codechange: Removed table/directions.h. - table/directions.h contained ugly static tables but was included more than once. The tables, along with a few new ones are in npf.[ch] now. Better suggestions for a location? - Fix: Binary heap in queue.c did not allocate enough space, resulting in a segfault. - Codechange: Rewritten FindFirstBit2x64, added KillFirstBit2x64. - Codechange: Introduced constant INVALID_TILE, to replace the usage of 0 as an invalid tile. Also replaces TILE_WRAPPED. - Codechange: Moved TileAddWrap() to map.[ch] - Add TileIndexDiffCByDir(), TileIndexDiffCByDir(). - Codechange: Moved IsTrainStationTile() to station.h - Add: IsRoadStationTile() and GetRoadStationDir().
This commit is contained in:
33
map.c
33
map.c
@@ -108,6 +108,32 @@ uint ScaleByMapSize1D(uint n)
|
||||
}
|
||||
|
||||
|
||||
// This function checks if we add addx/addy to tile, if we
|
||||
// do wrap around the edges. For example, tile = (10,2) and
|
||||
// addx = +3 and addy = -4. This function will now return
|
||||
// INVALID_TILE, because the y is wrapped. This is needed in
|
||||
// for example, farmland. When the tile is not wrapped,
|
||||
// the result will be tile + TILE_XY(addx, addy)
|
||||
uint TileAddWrap(TileIndex tile, int addx, int addy)
|
||||
{
|
||||
uint x, y;
|
||||
x = TileX(tile) + addx;
|
||||
y = TileY(tile) + addy;
|
||||
|
||||
// Are we about to wrap?
|
||||
if (x < MapMaxX() && y < MapMaxY())
|
||||
return tile + TILE_XY(addx, addy);
|
||||
|
||||
return INVALID_TILE;
|
||||
}
|
||||
|
||||
const TileIndexDiffC _tileoffs_by_dir[] = {
|
||||
{-1, 0},
|
||||
{ 0, 1},
|
||||
{ 1, 0},
|
||||
{ 0, -1}
|
||||
};
|
||||
|
||||
uint DistanceManhattan(TileIndex t0, TileIndex t1)
|
||||
{
|
||||
return
|
||||
@@ -151,10 +177,3 @@ uint DistanceFromEdge(TileIndex tile)
|
||||
return minl < minh ? minl : minh;
|
||||
}
|
||||
|
||||
|
||||
const TileIndexDiffC _tileoffs_by_dir[] = {
|
||||
{-1, 0},
|
||||
{ 0, 1},
|
||||
{ 1, 0},
|
||||
{ 0, -1}
|
||||
};
|
||||
|
Reference in New Issue
Block a user