diff options
author | alberth <alberth@openttd.org> | 2010-07-24 10:14:39 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-07-24 10:14:39 +0000 |
commit | be6c0584240caf420b2475a0be036391e842e8af (patch) | |
tree | 6111751cf5526e1eb41176782d84766c4e9ed185 /src/pathfinder | |
parent | 645b6ce77345867fa96861843197481131566c46 (diff) | |
download | openttd-be6c0584240caf420b2475a0be036391e842e8af.tar.xz |
(svn r20211) -Codechange: Indented code should have curly braces around it.
Diffstat (limited to 'src/pathfinder')
-rw-r--r-- | src/pathfinder/npf/aystar.cpp | 3 | ||||
-rw-r--r-- | src/pathfinder/npf/npf.cpp | 21 | ||||
-rw-r--r-- | src/pathfinder/yapf/yapf_rail.cpp | 3 |
3 files changed, 18 insertions, 9 deletions
diff --git a/src/pathfinder/npf/aystar.cpp b/src/pathfinder/npf/aystar.cpp index a4ea8f70c..581b76921 100644 --- a/src/pathfinder/npf/aystar.cpp +++ b/src/pathfinder/npf/aystar.cpp @@ -167,8 +167,9 @@ static int AyStarMain_Loop(AyStar *aystar) /* Check for end node and if found, return that code */ if (aystar->EndNodeCheck(aystar, current) == AYSTAR_FOUND_END_NODE) { - if (aystar->FoundEndNode != NULL) + if (aystar->FoundEndNode != NULL) { aystar->FoundEndNode(aystar, current); + } free(current); return AYSTAR_FOUND_END_NODE; } diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp index 62eb0f4e4..3944e5ce4 100644 --- a/src/pathfinder/npf/npf.cpp +++ b/src/pathfinder/npf/npf.cpp @@ -168,8 +168,9 @@ static int32 NPFCalcStationOrTileHeuristic(AyStar *as, AyStarNode *current, Open uint dist; /* for train-stations, we are going to aim for the closest station tile */ - if (as->user_data[NPF_TYPE] != TRANSPORT_WATER && fstd->station_index != INVALID_STATION) + if (as->user_data[NPF_TYPE] != TRANSPORT_WATER && fstd->station_index != INVALID_STATION) { to = CalcClosestStationTile(fstd->station_index, from, fstd->station_type); + } if (as->user_data[NPF_TYPE] == TRANSPORT_ROAD) { /* Since roads only have diagonal pieces, we use manhattan distance here */ @@ -314,11 +315,13 @@ static int32 NPFWaterPathCost(AyStar *as, AyStarNode *current, OpenListNode *par cost = _trackdir_length[trackdir]; // Should be different for diagonal tracks - if (IsBuoyTile(current->tile) && IsDiagonalTrackdir(trackdir)) + if (IsBuoyTile(current->tile) && IsDiagonalTrackdir(trackdir)) { cost += _settings_game.pf.npf.npf_buoy_penalty; // A small penalty for going over buoys + } - if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction)) + if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction)) { cost += _settings_game.pf.npf.npf_water_curve_penalty; + } /* @todo More penalties? */ @@ -373,8 +376,9 @@ static int32 NPFRoadPathCost(AyStar *as, AyStarNode *current, OpenListNode *pare /* Check for turns. Road vehicles only really drive diagonal, turns are * represented by non-diagonal tracks */ - if (!IsDiagonalTrackdir(current->direction)) + if (!IsDiagonalTrackdir(current->direction)) { cost += _settings_game.pf.npf.npf_road_curve_penalty; + } NPFMarkTile(tile); DEBUG(npf, 4, "Calculating G for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), cost); @@ -502,15 +506,17 @@ static int32 NPFRailPathCost(AyStar *as, AyStarNode *current, OpenListNode *pare /* HACK: We create a new_node here so we can call EndNodeCheck. Ugly as hell * of course... */ new_node.path.node = *current; - if (as->EndNodeCheck(as, &new_node) == AYSTAR_FOUND_END_NODE && NPFGetFlag(current, NPF_FLAG_LAST_SIGNAL_RED)) + if (as->EndNodeCheck(as, &new_node) == AYSTAR_FOUND_END_NODE && NPFGetFlag(current, NPF_FLAG_LAST_SIGNAL_RED)) { cost += _settings_game.pf.npf.npf_rail_lastred_penalty; + } /* Check for slope */ cost += NPFSlopeCost(current); /* Check for turns */ - if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction)) + if (current->direction != NextTrackdir((Trackdir)parent->path.node.direction)) { cost += _settings_game.pf.npf.npf_rail_curve_penalty; + } /* TODO, with realistic acceleration, also the amount of straight track between * curves should be taken into account, as this affects the speed limit. */ @@ -933,9 +939,10 @@ static void NPFFollowTrack(AyStar *aystar, OpenListNode *current) /* Tile with signals? */ if (IsTileType(dst_tile, MP_RAILWAY) && GetRailTileType(dst_tile) == RAIL_TILE_SIGNALS) { - if (HasSignalOnTrackdir(dst_tile, ReverseTrackdir(dst_trackdir)) && !HasSignalOnTrackdir(dst_tile, dst_trackdir) && IsOnewaySignal(dst_tile, TrackdirToTrack(dst_trackdir))) + if (HasSignalOnTrackdir(dst_tile, ReverseTrackdir(dst_trackdir)) && !HasSignalOnTrackdir(dst_tile, dst_trackdir) && IsOnewaySignal(dst_tile, TrackdirToTrack(dst_trackdir))) { /* If there's a one-way signal not pointing towards us, stop going in this direction. */ break; + } } { /* We've found ourselves a neighbour :-) */ diff --git a/src/pathfinder/yapf/yapf_rail.cpp b/src/pathfinder/yapf/yapf_rail.cpp index 4365ac50f..1fd6cfa0c 100644 --- a/src/pathfinder/yapf/yapf_rail.cpp +++ b/src/pathfinder/yapf/yapf_rail.cpp @@ -176,8 +176,9 @@ public: if (target != NULL) target->okay = true; - if (Yapf().CanUseGlobalCache(*m_res_node)) + if (Yapf().CanUseGlobalCache(*m_res_node)) { YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK); + } return true; } |