diff options
author | Henry Wilson <m3henry@googlemail.com> | 2019-04-10 22:07:06 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2019-04-10 23:22:20 +0200 |
commit | 7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch) | |
tree | 99f134b7e66367cf11e10bc5061896eab4a3264f /src/pathfinder/yapf/yapf_base.hpp | |
parent | 3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff) | |
download | openttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz |
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/pathfinder/yapf/yapf_base.hpp')
-rw-r--r-- | src/pathfinder/yapf/yapf_base.hpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/pathfinder/yapf/yapf_base.hpp b/src/pathfinder/yapf/yapf_base.hpp index 6360567bb..5483b9874 100644 --- a/src/pathfinder/yapf/yapf_base.hpp +++ b/src/pathfinder/yapf/yapf_base.hpp @@ -81,11 +81,11 @@ public: public: /** default constructor */ inline CYapfBaseT() - : m_pBestDestNode(NULL) - , m_pBestIntermediateNode(NULL) + : m_pBestDestNode(nullptr) + , m_pBestIntermediateNode(nullptr) , m_settings(&_settings_game.pf.yapf) , m_max_search_nodes(PfGetSettings().max_search_nodes) - , m_veh(NULL) + , m_veh(nullptr) , m_stats_cost_calcs(0) , m_stats_cache_hits(0) , m_num_steps(0) @@ -131,12 +131,12 @@ public: for (;;) { m_num_steps++; Node *n = m_nodes.GetBestOpenNode(); - if (n == NULL) { + if (n == nullptr) { break; } /* if the best open node was worse than the best path found, we can finish */ - if (m_pBestDestNode != NULL && m_pBestDestNode->GetCost() < n->GetCostEstimate()) { + if (m_pBestDestNode != nullptr && m_pBestDestNode->GetCost() < n->GetCostEstimate()) { break; } @@ -150,7 +150,7 @@ public: } } - bDestFound &= (m_pBestDestNode != NULL); + bDestFound &= (m_pBestDestNode != nullptr); perf.Stop(); if (_debug_yapf_level >= 2) { @@ -158,7 +158,7 @@ public: _total_pf_time_us += t; if (_debug_yapf_level >= 3) { - UnitID veh_idx = (m_veh != NULL) ? m_veh->unitnumber : 0; + UnitID veh_idx = (m_veh != nullptr) ? m_veh->unitnumber : 0; char ttc = Yapf().TransportTypeChar(); float cache_hit_ratio = (m_stats_cache_hits == 0) ? 0.0f : ((float)m_stats_cache_hits / (float)(m_stats_cache_hits + m_stats_cost_calcs) * 100.0f); int cost = bDestFound ? m_pBestDestNode->m_cost : -1; @@ -180,7 +180,7 @@ public: */ inline Node *GetBestNode() { - return (m_pBestDestNode != NULL) ? m_pBestDestNode : m_pBestIntermediateNode; + return (m_pBestDestNode != nullptr) ? m_pBestDestNode : m_pBestIntermediateNode; } /** @@ -198,7 +198,7 @@ public: { Yapf().PfNodeCacheFetch(n); /* insert the new node only if it is not there */ - if (m_nodes.FindOpenNode(n.m_key) == NULL) { + if (m_nodes.FindOpenNode(n.m_key) == nullptr) { m_nodes.InsertOpenNode(n); } else { /* if we are here, it means that node is already there - how it is possible? @@ -229,7 +229,7 @@ public: */ void PruneIntermediateNodeBranch() { - while (Yapf().m_pBestIntermediateNode != NULL && (Yapf().m_pBestIntermediateNode->m_segment->m_end_segment_reason & ESRB_CHOICE_FOLLOWS) == 0) { + while (Yapf().m_pBestIntermediateNode != nullptr && (Yapf().m_pBestIntermediateNode->m_segment->m_end_segment_reason & ESRB_CHOICE_FOLLOWS) == 0) { Yapf().m_pBestIntermediateNode = Yapf().m_pBestIntermediateNode->m_parent; } } @@ -262,20 +262,20 @@ public: /* detect the destination */ bool bDestination = Yapf().PfDetectDestination(n); if (bDestination) { - if (m_pBestDestNode == NULL || n < *m_pBestDestNode) { + if (m_pBestDestNode == nullptr || n < *m_pBestDestNode) { m_pBestDestNode = &n; } m_nodes.FoundBestNode(n); return; } - if (m_max_search_nodes > 0 && (m_pBestIntermediateNode == NULL || (m_pBestIntermediateNode->GetCostEstimate() - m_pBestIntermediateNode->GetCost()) > (n.GetCostEstimate() - n.GetCost()))) { + if (m_max_search_nodes > 0 && (m_pBestIntermediateNode == nullptr || (m_pBestIntermediateNode->GetCostEstimate() - m_pBestIntermediateNode->GetCost()) > (n.GetCostEstimate() - n.GetCost()))) { m_pBestIntermediateNode = &n; } /* check new node against open list */ Node *openNode = m_nodes.FindOpenNode(n.GetKey()); - if (openNode != NULL) { + if (openNode != nullptr) { /* another node exists with the same key in the open list * is it better than new one? */ if (n.GetCostEstimate() < openNode->GetCostEstimate()) { @@ -290,7 +290,7 @@ public: /* check new node against closed list */ Node *closedNode = m_nodes.FindClosedNode(n.GetKey()); - if (closedNode != NULL) { + if (closedNode != nullptr) { /* another node exists with the same key in the closed list * is it better than new one? */ int node_est = n.GetCostEstimate(); |