Changeset - r23245:c5cb79c9bc26
[Not reviewed]
master
0 3 0
J0an Josep - 5 years ago 2019-01-14 22:13:12
juanjo.ng.83@gmail.com
Codechange: [NPF] Add some consts.
3 files changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/landscape.cpp
Show inline comments
 
@@ -1095,13 +1095,13 @@ static bool FlowsDown(TileIndex begin, T
 
			(slopeEnd == SLOPE_FLAT || IsInclinedSlope(slopeEnd)) &&
 
			/* Slope continues, then it must be lower... or either end must be flat. */
 
			((slopeEnd == slopeBegin && heightEnd < heightBegin) || slopeEnd == SLOPE_FLAT || slopeBegin == SLOPE_FLAT);
 
}
 

	
 
/* AyStar callback for checking whether we reached our destination. */
 
static int32 River_EndNodeCheck(AyStar *aystar, OpenListNode *current)
 
static int32 River_EndNodeCheck(const AyStar *aystar, const OpenListNode *current)
 
{
 
	return current->path.node.tile == *(TileIndex*)aystar->user_target ? AYSTAR_FOUND_END_NODE : AYSTAR_DONE;
 
}
 

	
 
/* AyStar callback for getting the cost of the current node. */
 
static int32 River_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent)
src/pathfinder/npf/aystar.h
Show inline comments
 
@@ -72,13 +72,13 @@ struct AyStar;
 
 * don't try to enter the file tile with a 90-degree curve. So please, leave
 
 * this an #OpenListNode, it works just fine.
 
 * @return Status of the node:
 
 *  - #AYSTAR_FOUND_END_NODE : indicates this is the end tile
 
 *  - #AYSTAR_DONE : indicates this is not the end tile (or direction was wrong)
 
 */
 
typedef int32 AyStar_EndNodeCheck(AyStar *aystar, OpenListNode *current);
 
typedef int32 AyStar_EndNodeCheck(const AyStar *aystar, const OpenListNode *current);
 

	
 
/**
 
 * Calculate the G-value for the %AyStar algorithm.
 
 * @return G value of the node:
 
 *  - #AYSTAR_INVALID_NODE : indicates an item is not valid (e.g.: unwalkable)
 
 *  - Any value >= 0 : the g-value for this tile
src/pathfinder/npf/npf.cpp
Show inline comments
 
@@ -526,36 +526,36 @@ static int32 NPFRailPathCost(AyStar *as,
 
	NPFMarkTile(tile);
 
	DEBUG(npf, 4, "Calculating G for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), cost);
 
	return cost;
 
}
 

	
 
/* Will find any depot */
 
static int32 NPFFindDepot(AyStar *as, OpenListNode *current)
 
static int32 NPFFindDepot(const AyStar *as, const OpenListNode *current)
 
{
 
	AyStarUserData *user = (AyStarUserData *)as->user_data;
 
	/* It's not worth caching the result with NPF_FLAG_IS_TARGET here as below,
 
	 * since checking the cache not that much faster than the actual check */
 
	return IsDepotTypeTile(current->path.node.tile, user->type) ?
 
		AYSTAR_FOUND_END_NODE : AYSTAR_DONE;
 
}
 

	
 
/** Find any safe and free tile. */
 
static int32 NPFFindSafeTile(AyStar *as, OpenListNode *current)
 
static int32 NPFFindSafeTile(const AyStar *as, const OpenListNode *current)
 
{
 
	const Train *v = Train::From(((NPFFindStationOrTileData *)as->user_target)->v);
 

	
 
	return (IsSafeWaitingPosition(v, current->path.node.tile, current->path.node.direction, true, _settings_game.pf.forbid_90_deg) &&
 
			IsWaitingPositionFree(v, current->path.node.tile, current->path.node.direction, _settings_game.pf.forbid_90_deg)) ?
 
				AYSTAR_FOUND_END_NODE : AYSTAR_DONE;
 
}
 

	
 
/* Will find a station identified using the NPFFindStationOrTileData */
 
static int32 NPFFindStationOrTile(AyStar *as, OpenListNode *current)
 
static int32 NPFFindStationOrTile(const AyStar *as, const OpenListNode *current)
 
{
 
	NPFFindStationOrTileData *fstd = (NPFFindStationOrTileData*)as->user_target;
 
	AyStarNode *node = &current->path.node;
 
	const AyStarNode *node = &current->path.node;
 
	TileIndex tile = node->tile;
 

	
 
	if (fstd->station_index == INVALID_STATION && tile == fstd->dest_coords) return AYSTAR_FOUND_END_NODE;
 

	
 
	if (IsTileType(tile, MP_STATION) && GetStationIndex(tile) == fstd->station_index) {
 
		if (fstd->v->type == VEH_TRAIN) return AYSTAR_FOUND_END_NODE;
0 comments (0 inline, 0 general)