diff options
author | tron <tron@openttd.org> | 2006-06-10 08:37:41 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-06-10 08:37:41 +0000 |
commit | 0a72639c2d7254c37cd6f8ab0a9fa0f4d63fd2ea (patch) | |
tree | ddcc7798b94be03152e4b31cee4bf48bc73774e4 /npf.c | |
parent | 15c945c9263ffd64f01fd3da92fcb4efb17fe691 (diff) | |
download | openttd-0a72639c2d7254c37cd6f8ab0a9fa0f4d63fd2ea.tar.xz |
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
Diffstat (limited to 'npf.c')
-rw-r--r-- | npf.c | 26 |
1 files changed, 9 insertions, 17 deletions
@@ -277,8 +277,7 @@ static int32 NPFRoadPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare case MP_STREET: cost = NPF_TILE_LENGTH; /* Increase the cost for level crossings */ - if (IsLevelCrossing(tile)) - cost += _patches.npf_crossing_penalty; + if (IsLevelCrossing(tile)) cost += _patches.npf_crossing_penalty; break; default: @@ -407,15 +406,10 @@ static int32 NPFRailPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare /* Will find any depot */ static int32 NPFFindDepot(AyStar* as, OpenListNode *current) { - TileIndex tile = current->path.node.tile; - /* 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 */ - if (IsTileDepotType(tile, as->user_data[NPF_TYPE])) { - return AYSTAR_FOUND_END_NODE; - } else { - return AYSTAR_DONE; - } + return IsTileDepotType(current->path.node.tile, as->user_data[NPF_TYPE]) ? + AYSTAR_FOUND_END_NODE : AYSTAR_DONE; } /* Will find a station identified using the NPFFindStationOrTileData */ @@ -682,14 +676,12 @@ static NPFFoundTargetData NPFRouteInternal(AyStarNode* start1, AyStarNode* start _npf_aystar.EndNodeCheck = target_proc; _npf_aystar.FoundEndNode = NPFSaveTargetData; _npf_aystar.GetNeighbours = NPFFollowTrack; - if (type == TRANSPORT_RAIL) - _npf_aystar.CalculateG = NPFRailPathCost; - else if (type == TRANSPORT_ROAD) - _npf_aystar.CalculateG = NPFRoadPathCost; - else if (type == TRANSPORT_WATER) - _npf_aystar.CalculateG = NPFWaterPathCost; - else - assert(0); + switch (type) { + default: NOT_REACHED(); + case TRANSPORT_RAIL: _npf_aystar.CalculateG = NPFRailPathCost; break; + case TRANSPORT_ROAD: _npf_aystar.CalculateG = NPFRoadPathCost; break; + case TRANSPORT_WATER: _npf_aystar.CalculateG = NPFWaterPathCost; break; + } /* Initialize Start Node(s) */ start1->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR; |