Adding of _t to (u)int types, and WChar to char32_t

See: eaae0bb5e
This commit is contained in:
Jonathan G Rennison
2024-01-07 16:41:53 +00:00
parent 55d78a23be
commit 97e6f3062e
655 changed files with 7555 additions and 7555 deletions

View File

@@ -473,12 +473,12 @@ public:
}
/* Check for speed limit imposed by railtype */
if (IsRailTT()) {
uint16 rail_speed = GetRailTypeInfo(GetRailTypeByTrack(m_old_tile, TrackdirToTrack(m_old_td)))->max_speed;
uint16_t rail_speed = GetRailTypeInfo(GetRailTypeByTrack(m_old_tile, TrackdirToTrack(m_old_td)))->max_speed;
if (rail_speed > 0) max_speed = std::min<int>(max_speed, rail_speed);
}
if (IsRoadTT()) {
/* max_speed is already in roadvehicle units, no need to further modify (divide by 2) */
uint16 road_speed = GetRoadTypeInfo(GetRoadType(m_old_tile, GetRoadTramType(RoadVehicle::From(m_veh)->roadtype)))->max_speed;
uint16_t road_speed = GetRoadTypeInfo(GetRoadType(m_old_tile, GetRoadTramType(RoadVehicle::From(m_veh)->roadtype)))->max_speed;
if (road_speed > 0) max_speed = std::min<int>(max_speed, road_speed);
}

View File

@@ -48,7 +48,7 @@ PathNode *AyStar::ClosedListIsInList(const AyStarNode *node)
void AyStar::ClosedListAdd(const PathNode *node)
{
/* Add a node to the ClosedList */
std::pair<uint32, PathNode *> new_node = this->closedlist_nodes.Allocate();
std::pair<uint32_t, PathNode *> new_node = this->closedlist_nodes.Allocate();
*(new_node.second) = *node;
this->closedlist_hash[this->HashKey(node->node.tile, node->node.direction)] = new_node.first;
@@ -59,7 +59,7 @@ void AyStar::ClosedListAdd(const PathNode *node)
* @param node Node to search.
* @return If the node is available, it is returned, else \c UINT32_MAX is returned.
*/
uint32 AyStar::OpenListIsInList(const AyStarNode *node)
uint32_t AyStar::OpenListIsInList(const AyStarNode *node)
{
const auto result = this->openlist_hash.find(this->HashKey(node->tile, node->direction));
@@ -71,11 +71,11 @@ uint32 AyStar::OpenListIsInList(const AyStarNode *node)
* It deletes the returned node from the open list.
* @returns the best node available, or \c nullptr of none is found.
*/
std::pair<uint32, OpenListNode *> AyStar::OpenListPop()
std::pair<uint32_t, OpenListNode *> AyStar::OpenListPop()
{
/* Return the item the Queue returns.. the best next OpenList item. */
uint32 idx = this->openlist_queue.Pop();
if (idx == UINT32_MAX) return std::pair<uint32, OpenListNode *>(idx, nullptr);
uint32_t idx = this->openlist_queue.Pop();
if (idx == UINT32_MAX) return std::pair<uint32_t, OpenListNode *>(idx, nullptr);
OpenListNode *res = this->openlist_nodes[idx];
this->openlist_hash.erase(this->HashKey(res->path.node.tile, res->path.node.direction));
@@ -90,7 +90,7 @@ std::pair<uint32, OpenListNode *> AyStar::OpenListPop()
void AyStar::OpenListAdd(PathNode *parent, const AyStarNode *node, int f, int g)
{
/* Add a new Node to the OpenList */
uint32 idx;
uint32_t idx;
OpenListNode *new_node;
std::tie(idx, new_node) = this->openlist_nodes.Allocate();
new_node->g = g;
@@ -136,7 +136,7 @@ void AyStar::CheckTile(AyStarNode *current, OpenListNode *parent)
closedlist_parent = this->ClosedListIsInList(&parent->path.node);
/* Check if this item is already in the OpenList */
uint32 check_idx = this->OpenListIsInList(current);
uint32_t check_idx = this->OpenListIsInList(current);
if (check_idx != UINT32_MAX) {
OpenListNode *check = this->openlist_nodes[check_idx];
@@ -174,7 +174,7 @@ int AyStar::Loop()
/* Get the best node from OpenList */
OpenListNode *current;
uint32 current_idx;
uint32_t current_idx;
std::tie(current_idx, current) = this->OpenListPop();
/* If empty, drop an error */
if (current == nullptr) return AYSTAR_EMPTY_OPENLIST;

View File

@@ -89,7 +89,7 @@ struct AyStar;
* - #AYSTAR_FOUND_END_NODE : indicates this is the end tile
* - #AYSTAR_DONE : indicates this is not the end tile (or direction was wrong)
*/
typedef int32 AyStar_EndNodeCheck(const AyStar *aystar, const OpenListNode *current);
typedef int32_t AyStar_EndNodeCheck(const AyStar *aystar, const OpenListNode *current);
/**
* Calculate the G-value for the %AyStar algorithm.
@@ -97,14 +97,14 @@ typedef int32 AyStar_EndNodeCheck(const AyStar *aystar, const OpenListNode *curr
* - #AYSTAR_INVALID_NODE : indicates an item is not valid (e.g.: unwalkable)
* - Any value >= 0 : the g-value for this tile
*/
typedef int32 AyStar_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
typedef int32_t AyStar_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
/**
* Calculate the H-value for the %AyStar algorithm.
* Mostly, this must return the distance (Manhattan way) between the current point and the end point.
* @return The h-value for this tile (any value >= 0)
*/
typedef int32 AyStar_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
typedef int32_t AyStar_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
/**
* This function requests the tiles around the current tile and put them in #neighbours.
@@ -171,19 +171,19 @@ struct AyStar {
protected:
inline uint32 HashKey(TileIndex tile, Trackdir td) const { return tile | (td << 28); }
inline uint32_t HashKey(TileIndex tile, Trackdir td) const { return tile | (td << 28); }
PodPool<PathNode*, sizeof(PathNode), 8192> closedlist_nodes;
robin_hood::unordered_flat_map<uint32, uint32> closedlist_hash;
robin_hood::unordered_flat_map<uint32_t, uint32_t> closedlist_hash;
BinaryHeap openlist_queue; ///< The open queue.
PodPool<OpenListNode*, sizeof(OpenListNode), 8192> openlist_nodes;
robin_hood::unordered_flat_map<uint32, uint32> openlist_hash;
robin_hood::unordered_flat_map<uint32_t, uint32_t> openlist_hash;
void OpenListAdd(PathNode *parent, const AyStarNode *node, int f, int g);
uint32 OpenListIsInList(const AyStarNode *node);
std::pair<uint32, OpenListNode *> OpenListPop();
uint32_t OpenListIsInList(const AyStarNode *node);
std::pair<uint32_t, OpenListNode *> OpenListPop();
void ClosedListAdd(const PathNode *node);
PathNode *ClosedListIsInList(const AyStarNode *node);

View File

@@ -129,7 +129,7 @@ static uint NPFDistanceTrack(TileIndex t0, TileIndex t1)
return diagTracks * NPF_TILE_LENGTH + straightTracks * NPF_TILE_LENGTH * STRAIGHT_TRACK_LENGTH;
}
static int32 NPFCalcZero(AyStar *as, AyStarNode *current, OpenListNode *parent)
static int32_t NPFCalcZero(AyStar *as, AyStarNode *current, OpenListNode *parent)
{
return 0;
}
@@ -137,7 +137,7 @@ static int32 NPFCalcZero(AyStar *as, AyStarNode *current, OpenListNode *parent)
/* Calculates the heuristic to the target station or tile. For train stations, it
* takes into account the direction of approach.
*/
static int32 NPFCalcStationOrTileHeuristic(AyStar *as, AyStarNode *current, OpenListNode *parent)
static int32_t NPFCalcStationOrTileHeuristic(AyStar *as, AyStarNode *current, OpenListNode *parent)
{
NPFFindStationOrTileData *fstd = (NPFFindStationOrTileData*)as->user_target;
NPFFoundTargetData *ftd = (NPFFoundTargetData*)as->user_path;
@@ -293,9 +293,9 @@ static Vehicle *CountShipProc(Vehicle *v, void *data)
return nullptr;
}
static int32 NPFWaterPathCost(AyStar *as, AyStarNode *current, OpenListNode *parent)
static int32_t NPFWaterPathCost(AyStar *as, AyStarNode *current, OpenListNode *parent)
{
int32 cost = 0;
int32_t cost = 0;
Trackdir trackdir = current->direction;
cost = _trackdir_length[trackdir]; // Should be different for diagonal tracks
@@ -321,10 +321,10 @@ static int32 NPFWaterPathCost(AyStar *as, AyStarNode *current, OpenListNode *par
}
/* Determine the cost of this node, for road tracks */
static int32 NPFRoadPathCost(AyStar *as, AyStarNode *current, OpenListNode *parent)
static int32_t NPFRoadPathCost(AyStar *as, AyStarNode *current, OpenListNode *parent)
{
TileIndex tile = current->tile;
int32 cost = 0;
int32_t cost = 0;
/* Determine base length */
switch (GetTileType(tile)) {
@@ -385,11 +385,11 @@ static int32 NPFRoadPathCost(AyStar *as, AyStarNode *current, OpenListNode *pare
/* Determine the cost of this node, for railway tracks */
static int32 NPFRailPathCost(AyStar *as, AyStarNode *current, OpenListNode *parent)
static int32_t NPFRailPathCost(AyStar *as, AyStarNode *current, OpenListNode *parent)
{
TileIndex tile = current->tile;
Trackdir trackdir = current->direction;
int32 cost = 0;
int32_t cost = 0;
/* HACK: We create a OpenListNode manually, so we can call EndNodeCheck */
OpenListNode new_node;
@@ -536,7 +536,7 @@ static int32 NPFRailPathCost(AyStar *as, AyStarNode *current, OpenListNode *pare
}
/* Will find any depot */
static int32 NPFFindDepot(const AyStar *as, const OpenListNode *current)
static int32_t NPFFindDepot(const AyStar *as, const OpenListNode *current)
{
AyStarUserData *user = (AyStarUserData *)as->user_data;
/* It's not worth caching the result with NPF_FLAG_IS_TARGET here as below,
@@ -546,7 +546,7 @@ static int32 NPFFindDepot(const AyStar *as, const OpenListNode *current)
}
/** Find any safe and free tile. */
static int32 NPFFindSafeTile(const AyStar *as, const OpenListNode *current)
static int32_t NPFFindSafeTile(const AyStar *as, const OpenListNode *current)
{
const Train *v = Train::From(((NPFFindStationOrTileData *)as->user_target)->v);
@@ -556,7 +556,7 @@ static int32 NPFFindSafeTile(const AyStar *as, const OpenListNode *current)
}
/* Will find a station identified using the NPFFindStationOrTileData */
static int32 NPFFindStationOrTile(const AyStar *as, const OpenListNode *current)
static int32_t NPFFindStationOrTile(const AyStar *as, const OpenListNode *current)
{
NPFFindStationOrTileData *fstd = (NPFFindStationOrTileData*)as->user_target;
const AyStarNode *node = &current->path.node;

View File

@@ -67,7 +67,7 @@ void BinaryHeap::Free()
* Pushes an element into the queue, at the appropriate place for the queue.
* Requires the queue pointer to be of an appropriate type, of course.
*/
bool BinaryHeap::Push(uint32 item, int priority)
bool BinaryHeap::Push(uint32_t item, int priority)
{
if (this->size == this->max_size) return false;
dbg_assert(this->size < this->max_size);
@@ -113,7 +113,7 @@ bool BinaryHeap::Push(uint32 item, int priority)
* known, which speeds up the deleting for some queue's. Should be -1
* if not known.
*/
bool BinaryHeap::Delete(uint32 item, int priority)
bool BinaryHeap::Delete(uint32_t item, int priority)
{
uint i = 0;
@@ -168,7 +168,7 @@ bool BinaryHeap::Delete(uint32 item, int priority)
* Pops the first element from the queue. What exactly is the first element,
* is defined by the exact type of queue.
*/
uint32 BinaryHeap::Pop()
uint32_t BinaryHeap::Pop()
{
if (this->size == 0) return UINT32_MAX;

View File

@@ -17,7 +17,7 @@
struct BinaryHeapNode {
uint32 item;
uint32_t item;
int priority;
};
@@ -33,9 +33,9 @@ struct BinaryHeap {
void Init(uint max_size);
bool Push(uint32 item, int priority);
uint32 Pop();
bool Delete(uint32 item, int priority);
bool Push(uint32_t item, int priority);
uint32_t Pop();
bool Delete(uint32_t item, int priority);
void Clear();
void Free();

View File

@@ -13,7 +13,7 @@
/** key for cached segment cost for rail YAPF */
struct CYapfRailSegmentKey
{
uint32 m_value;
uint32_t m_value;
inline CYapfRailSegmentKey(const CYapfNodeKeyTrackDir &node_key)
{
@@ -30,7 +30,7 @@ struct CYapfRailSegmentKey
m_value = (((int)node_key.m_tile) << 4) | node_key.m_td;
}
inline int32 CalcHash() const
inline int32_t CalcHash() const
{
return m_value;
}
@@ -123,12 +123,12 @@ struct CYapfRailNodeT
typedef CYapfRailSegment CachedData;
CYapfRailSegment *m_segment;
uint16 m_num_signals_passed;
uint16 m_num_signals_res_through_passed;
uint16_t m_num_signals_passed;
uint16_t m_num_signals_res_through_passed;
TileIndex m_last_non_reserve_through_signal_tile;
Trackdir m_last_non_reserve_through_signal_td;
union {
uint32 m_inherited_flags;
uint32_t m_inherited_flags;
struct {
bool m_targed_seen : 1;
bool m_choice_seen : 1;