1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-25 05:04:07 +01:00

Codechange: Remove redundant data members from YAPF ship node. (#14577)

This commit is contained in:
Kuhnovic
2025-09-03 12:52:15 +02:00
committed by GitHub
parent 5602555a7a
commit 80f672d5b4
2 changed files with 4 additions and 15 deletions

View File

@@ -16,19 +16,8 @@
#include "yapf_node.hpp"
/** Yapf Node for ships */
template <class Tkey_>
struct CYapfShipNodeT : CYapfNodeT<Tkey_, CYapfShipNodeT<Tkey_>> {
typedef CYapfNodeT<Tkey_, CYapfShipNodeT<Tkey_>> base;
TileIndex segment_last_tile;
Trackdir segment_last_td;
void Set(CYapfShipNodeT *parent, TileIndex tile, Trackdir td, bool is_choice)
{
this->base::Set(parent, tile, td, is_choice);
this->segment_last_tile = tile;
this->segment_last_td = td;
}
template <class TKey>
struct CYapfShipNodeT : CYapfNodeT<TKey, CYapfShipNodeT<TKey>> {
};
/* now define two major node types (that differ by key type) */

View File

@@ -72,7 +72,7 @@ public:
/** Called by YAPF to detect if node ends in the desired destination. */
inline bool PfDetectDestination(Node &n)
{
return this->PfDetectDestinationTile(n.segment_last_tile, n.segment_last_td);
return this->PfDetectDestinationTile(n.GetTile(), n.GetTrackdir());
}
inline bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir)
@@ -101,7 +101,7 @@ public:
return true;
}
n.estimate = n.cost + OctileDistanceCost(n.segment_last_tile, n.segment_last_td, destination_tile);
n.estimate = n.cost + OctileDistanceCost(n.GetTile(), n.GetTrackdir(), destination_tile);
assert(n.estimate >= n.parent->estimate);
return true;
}