Skip to content

Commit

Permalink
Codechange: Simplified YAPF ship region node
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuhnovic committed Nov 12, 2024
1 parent 3e195df commit 6faf4fa
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/pathfinder/yapf/yapf_ship_regions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,10 @@ inline uint ManhattanDistance(const CYapfRegionPatchNodeKey &a, const CYapfRegio

/** Yapf Node for water regions. */
template <class Tkey_>
struct CYapfRegionNodeT {
struct CYapfRegionNodeT : CYapfNodeT<Tkey_, CYapfRegionNodeT<Tkey_> > {
typedef Tkey_ Key;
typedef CYapfRegionNodeT<Tkey_> Node;

Tkey_ key;
Node *hash_next;
Node *parent;
int cost;
int estimate;

inline void Set(Node *parent, const WaterRegionPatchDesc &water_region_patch)
{
this->key.Set(water_region_patch);
Expand All @@ -66,7 +60,7 @@ struct CYapfRegionNodeT {

DiagDirection GetDiagDirFromParent() const
{
if (!this->parent) return INVALID_DIAGDIR;
if (this->parent == nullptr) return INVALID_DIAGDIR;
const int dx = this->key.water_region_patch.x - this->parent->key.water_region_patch.x;
const int dy = this->key.water_region_patch.y - this->parent->key.water_region_patch.y;
if (dx > 0 && dy == 0) return DIAGDIR_SW;
Expand All @@ -75,13 +69,6 @@ struct CYapfRegionNodeT {
if (dx == 0 && dy < 0) return DIAGDIR_NW;
return INVALID_DIAGDIR;
}

inline Node *GetHashNext() { return this->hash_next; }
inline void SetHashNext(Node *pNext) { this->hash_next = pNext; }
inline const Tkey_ &GetKey() const { return this->key; }
inline int GetCost() { return this->cost; }
inline int GetCostEstimate() { return this->estimate; }
inline bool operator<(const Node &other) const { return this->estimate < other.estimate; }
};

/** YAPF origin for water regions. */
Expand Down

0 comments on commit 6faf4fa

Please sign in to comment.