1
0
Fork 0

Codechange: Prefer member-initialization.

pull/13030/head
Peter Nelson 2024-10-14 20:42:20 +01:00 committed by Peter Nelson
parent a6f412c615
commit a496e9397c
2 changed files with 21 additions and 39 deletions

View File

@ -57,32 +57,23 @@ public:
NodeList m_nodes; ///< node list multi-container NodeList m_nodes; ///< node list multi-container
protected: protected:
Node *m_pBestDestNode; ///< pointer to the destination node found at last round Node *m_pBestDestNode = nullptr; ///< pointer to the destination node found at last round
Node *m_pBestIntermediateNode; ///< here should be node closest to the destination if path not found Node *m_pBestIntermediateNode = nullptr; ///< here should be node closest to the destination if path not found
const YAPFSettings *m_settings; ///< current settings (_settings_game.yapf) const YAPFSettings *m_settings; ///< current settings (_settings_game.yapf)
int m_max_search_nodes; ///< maximum number of nodes we are allowed to visit before we give up int m_max_search_nodes; ///< maximum number of nodes we are allowed to visit before we give up
const VehicleType *m_veh; ///< vehicle that we are trying to drive const VehicleType *m_veh = nullptr; ///< vehicle that we are trying to drive
int m_stats_cost_calcs; ///< stats - how many node's costs were calculated int m_stats_cost_calcs = 0; ///< stats - how many node's costs were calculated
int m_stats_cache_hits; ///< stats - how many node's costs were reused from cache int m_stats_cache_hits = 0; ///< stats - how many node's costs were reused from cache
public: public:
int m_num_steps; ///< this is there for debugging purposes (hope it doesn't hurt) int m_num_steps = 0; ///< this is there for debugging purposes (hope it doesn't hurt)
public: public:
/** default constructor */ /** default constructor */
inline CYapfBaseT() inline CYapfBaseT() : m_settings(&_settings_game.pf.yapf), m_max_search_nodes(PfGetSettings().max_search_nodes) {}
: m_pBestDestNode(nullptr)
, m_pBestIntermediateNode(nullptr)
, m_settings(&_settings_game.pf.yapf)
, m_max_search_nodes(PfGetSettings().max_search_nodes)
, m_veh(nullptr)
, m_stats_cost_calcs(0)
, m_stats_cache_hits(0)
, m_num_steps(0)
{
}
/** default destructor */ /** default destructor */
~CYapfBaseT() {} ~CYapfBaseT() {}

View File

@ -69,24 +69,15 @@ struct CYapfRailSegment
typedef CYapfRailSegmentKey Key; typedef CYapfRailSegmentKey Key;
CYapfRailSegmentKey m_key; CYapfRailSegmentKey m_key;
TileIndex m_last_tile; TileIndex m_last_tile = INVALID_TILE;
Trackdir m_last_td; Trackdir m_last_td = INVALID_TRACKDIR;
int m_cost; int m_cost = -1;
TileIndex m_last_signal_tile; TileIndex m_last_signal_tile = INVALID_TILE;
Trackdir m_last_signal_td; Trackdir m_last_signal_td = INVALID_TRACKDIR;
EndSegmentReasonBits m_end_segment_reason; EndSegmentReasonBits m_end_segment_reason = ESRB_NONE;
CYapfRailSegment *m_hash_next; CYapfRailSegment *m_hash_next = nullptr;
inline CYapfRailSegment(const CYapfRailSegmentKey &key) inline CYapfRailSegment(const CYapfRailSegmentKey &key) : m_key(key) {}
: m_key(key)
, m_last_tile(INVALID_TILE)
, m_last_td(INVALID_TRACKDIR)
, m_cost(-1)
, m_last_signal_tile(INVALID_TILE)
, m_last_signal_td(INVALID_TRACKDIR)
, m_end_segment_reason(ESRB_NONE)
, m_hash_next(nullptr)
{}
inline const Key &GetKey() const inline const Key &GetKey() const
{ {