Change various asserts to not be included in release builds
This commit is contained in:
@@ -58,22 +58,22 @@ struct CFollowTrackT
|
||||
|
||||
inline CFollowTrackT(Owner o, RailTypes railtype_override = INVALID_RAILTYPES)
|
||||
{
|
||||
assert(IsRailTT());
|
||||
dbg_assert(IsRailTT());
|
||||
m_veh = nullptr;
|
||||
Init(o, railtype_override);
|
||||
}
|
||||
|
||||
inline void Init(const VehicleType *v, RailTypes railtype_override)
|
||||
{
|
||||
assert(!IsRailTT() || (v != nullptr && v->type == VEH_TRAIN));
|
||||
dbg_assert(!IsRailTT() || (v != nullptr && v->type == VEH_TRAIN));
|
||||
m_veh = v;
|
||||
Init(v != nullptr ? v->owner : INVALID_OWNER, IsRailTT() && railtype_override == INVALID_RAILTYPES ? Train::From(v)->compatible_railtypes : railtype_override);
|
||||
}
|
||||
|
||||
inline void Init(Owner o, RailTypes railtype_override)
|
||||
{
|
||||
assert(!IsRoadTT() || m_veh != nullptr);
|
||||
assert(!IsRailTT() || railtype_override != INVALID_RAILTYPES);
|
||||
dbg_assert(!IsRoadTT() || m_veh != nullptr);
|
||||
dbg_assert(!IsRailTT() || railtype_override != INVALID_RAILTYPES);
|
||||
m_veh_owner = o;
|
||||
/* don't worry, all is inlined so compiler should remove unnecessary initializations */
|
||||
m_old_tile = INVALID_TILE;
|
||||
@@ -98,7 +98,7 @@ struct CFollowTrackT
|
||||
/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */
|
||||
inline DiagDirection GetSingleTramBit(TileIndex tile)
|
||||
{
|
||||
assert(IsTram()); // this function shouldn't be called in other cases
|
||||
dbg_assert(IsTram()); // this function shouldn't be called in other cases
|
||||
|
||||
const bool is_bridge = IsRoadCustomBridgeHeadTile(tile);
|
||||
if (is_bridge || IsNormalRoadTile(tile)) {
|
||||
@@ -123,7 +123,7 @@ struct CFollowTrackT
|
||||
m_old_tile = old_tile;
|
||||
m_old_td = old_td;
|
||||
m_err = EC_NONE;
|
||||
assert_tile(
|
||||
dbg_assert_tile(
|
||||
((TrackStatusToTrackdirBits(
|
||||
GetTileTrackStatus(m_old_tile, TT(), (IsRoadTT() && m_veh != nullptr) ? (this->IsTram() ? RTT_TRAM : RTT_ROAD) : 0)
|
||||
) & TrackdirToTrackdirBits(m_old_td)) != 0) ||
|
||||
@@ -219,7 +219,9 @@ protected:
|
||||
m_tiles_skipped = GetTunnelBridgeLength(m_new_tile, m_old_tile);
|
||||
return;
|
||||
}
|
||||
if (!IsRoadCustomBridgeHeadTile(m_old_tile) && !IsRailCustomBridgeHeadTile(m_old_tile)) assert(ReverseDiagDir(enterdir) == m_exitdir);
|
||||
if (!IsRoadCustomBridgeHeadTile(m_old_tile) && !IsRailCustomBridgeHeadTile(m_old_tile)) {
|
||||
dbg_assert(ReverseDiagDir(enterdir) == m_exitdir);
|
||||
}
|
||||
}
|
||||
|
||||
/* normal or station tile, do one step */
|
||||
|
@@ -80,7 +80,7 @@ public:
|
||||
/** insert given item as open node (into m_open and m_open_queue) */
|
||||
inline void InsertOpenNode(Titem_ &item)
|
||||
{
|
||||
assert(m_closed.Find(item.GetKey()) == nullptr);
|
||||
dbg_assert(m_closed.Find(item.GetKey()) == nullptr);
|
||||
m_open.Push(item);
|
||||
m_open_queue.Include(&item);
|
||||
if (&item == m_new_node) {
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
|
||||
inline void DequeueBestOpenNode()
|
||||
{
|
||||
assert(!m_open_queue.IsEmpty());
|
||||
dbg_assert(!m_open_queue.IsEmpty());
|
||||
m_open_queue.Shift();
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
/** close node */
|
||||
inline void InsertClosedNode(Titem_ &item)
|
||||
{
|
||||
assert(m_open.Find(item.GetKey()) == nullptr);
|
||||
dbg_assert(m_open.Find(item.GetKey()) == nullptr);
|
||||
m_closed.Push(item);
|
||||
}
|
||||
|
||||
|
@@ -93,8 +93,8 @@ public:
|
||||
|
||||
inline int CurveCost(Trackdir td1, Trackdir td2)
|
||||
{
|
||||
assert(IsValidTrackdir(td1));
|
||||
assert(IsValidTrackdir(td2));
|
||||
dbg_assert(IsValidTrackdir(td1));
|
||||
dbg_assert(IsValidTrackdir(td2));
|
||||
int cost = 0;
|
||||
if (TrackFollower::Allow90degTurns()
|
||||
&& HasTrackdir(TrackdirCrossesTrackdirs(td1), td2)) {
|
||||
@@ -484,9 +484,9 @@ public:
|
||||
{
|
||||
int cost = 0;
|
||||
const Train *v = Yapf().GetVehicle();
|
||||
assert(v != nullptr);
|
||||
assert(v->type == VEH_TRAIN);
|
||||
assert(v->gcache.cached_total_length != 0);
|
||||
dbg_assert(v != nullptr);
|
||||
dbg_assert(v->type == VEH_TRAIN);
|
||||
dbg_assert(v->gcache.cached_total_length != 0);
|
||||
int missing_platform_length = CeilDiv(v->gcache.cached_total_length, TILE_SIZE) - platform_length;
|
||||
if (missing_platform_length < 0) {
|
||||
/* apply penalty for longer platform than needed */
|
||||
@@ -511,9 +511,9 @@ public:
|
||||
*/
|
||||
inline bool PfCalcCost(Node &n, const TrackFollower *tf)
|
||||
{
|
||||
assert(!n.flags_u.flags_s.m_targed_seen);
|
||||
assert(tf->m_new_tile == n.m_key.m_tile);
|
||||
assert((HasTrackdir(tf->m_new_td_bits, n.m_key.m_td)));
|
||||
dbg_assert(!n.flags_u.flags_s.m_targed_seen);
|
||||
dbg_assert(tf->m_new_tile == n.m_key.m_tile);
|
||||
dbg_assert((HasTrackdir(tf->m_new_td_bits, n.m_key.m_td)));
|
||||
|
||||
/* Does the node have some parent node? */
|
||||
bool has_parent = (n.m_parent != nullptr);
|
||||
@@ -568,7 +568,7 @@ public:
|
||||
|
||||
if (!has_parent) {
|
||||
/* We will jump to the middle of the cost calculator assuming that segment cache is not used. */
|
||||
assert(!is_cached_segment);
|
||||
dbg_assert(!is_cached_segment);
|
||||
/* Skip the first transition cost calculation. */
|
||||
goto no_entry_cost;
|
||||
} else if (n.flags_u.flags_s.m_teleport) {
|
||||
@@ -595,7 +595,7 @@ public:
|
||||
end_segment_reason = segment.m_end_segment_reason;
|
||||
/* We will need also some information about the last signal (if it was red). */
|
||||
if (segment.m_last_signal_tile != INVALID_TILE) {
|
||||
assert_tile(HasSignalOnTrackdir(segment.m_last_signal_tile, segment.m_last_signal_td), segment.m_last_signal_tile);
|
||||
dbg_assert_tile(HasSignalOnTrackdir(segment.m_last_signal_tile, segment.m_last_signal_td), segment.m_last_signal_tile);
|
||||
SignalState sig_state = GetSignalStateByTrackdir(segment.m_last_signal_tile, segment.m_last_signal_td);
|
||||
bool is_red = (sig_state == SIGNAL_STATE_RED);
|
||||
n.flags_u.flags_s.m_last_signal_was_red = is_red;
|
||||
@@ -634,7 +634,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
|
||||
/* Tests for 'potential target' reasons to close the segment. */
|
||||
if (cur.tile == prev.tile) {
|
||||
/* Penalty for reversing in a depot. */
|
||||
assert_tile(IsRailDepot(cur.tile), cur.tile);
|
||||
dbg_assert_tile(IsRailDepot(cur.tile), cur.tile);
|
||||
segment_cost += Yapf().PfGetSettings().rail_depot_reverse_penalty;
|
||||
|
||||
} else if (IsRailDepotTile(cur.tile)) {
|
||||
@@ -654,7 +654,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
|
||||
/* Arbitrary maximum tiles to follow to avoid infinite loops. */
|
||||
uint max_tiles = 20;
|
||||
while (ft.Follow(t, td)) {
|
||||
assert(t != ft.m_new_tile);
|
||||
dbg_assert(t != ft.m_new_tile);
|
||||
t = ft.m_new_tile;
|
||||
if (t == cur.tile || --max_tiles == 0) {
|
||||
/* We looped back on ourself or found another loop, bail out. */
|
||||
@@ -731,7 +731,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
|
||||
tf_local.Init(v, Yapf().GetCompatibleRailTypes());
|
||||
|
||||
if (!tf_local.Follow(cur.tile, cur.td)) {
|
||||
assert(tf_local.m_err != TrackFollower::EC_NONE);
|
||||
dbg_assert(tf_local.m_err != TrackFollower::EC_NONE);
|
||||
/* Can't move to the next tile (EOL?). */
|
||||
if (!(end_segment_reason & (ESRB_RAIL_TYPE | ESRB_DEAD_END))) end_segment_reason |= ESRB_DEAD_END_EOL;
|
||||
if (tf_local.m_err == TrackFollower::EC_RAIL_ROAD_TYPE) {
|
||||
@@ -855,7 +855,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
|
||||
/* Station platform-length penalty. */
|
||||
if ((end_segment_reason & ESRB_STATION) != ESRB_NONE) {
|
||||
const BaseStation *st = BaseStation::GetByTile(n.GetLastTile());
|
||||
assert(st != nullptr);
|
||||
dbg_assert(st != nullptr);
|
||||
uint platform_length = st->GetPlatformLength(n.GetLastTile(), ReverseDiagDir(TrackdirToExitdir(n.GetLastTrackdir())));
|
||||
/* Reduce the extra cost caused by passing-station penalty (each station receives it in the segment cost). */
|
||||
extra_cost -= Yapf().PfGetSettings().rail_station_penalty * platform_length;
|
||||
|
@@ -177,19 +177,19 @@ struct CYapfRailNodeT
|
||||
|
||||
inline TileIndex GetLastTile() const
|
||||
{
|
||||
assert(m_segment != nullptr);
|
||||
dbg_assert(m_segment != nullptr);
|
||||
return m_segment->m_last_tile;
|
||||
}
|
||||
|
||||
inline Trackdir GetLastTrackdir() const
|
||||
{
|
||||
assert(m_segment != nullptr);
|
||||
dbg_assert(m_segment != nullptr);
|
||||
return m_segment->m_last_td;
|
||||
}
|
||||
|
||||
inline void SetLastTileTrackdir(TileIndex tile, Trackdir td)
|
||||
{
|
||||
assert(m_segment != nullptr);
|
||||
dbg_assert(m_segment != nullptr);
|
||||
m_segment->m_last_tile = tile;
|
||||
m_segment->m_last_td = td;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ struct CYapfRailNodeT
|
||||
|
||||
if (!ft.Follow(cur, cur_td)) break;
|
||||
cur = ft.m_new_tile;
|
||||
assert(KillFirstBit(ft.m_new_td_bits) == TRACKDIR_BIT_NONE);
|
||||
dbg_assert(KillFirstBit(ft.m_new_td_bits) == TRACKDIR_BIT_NONE);
|
||||
cur_td = FindFirstTrackdir(ft.m_new_td_bits);
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ struct CYapfRailNodeT
|
||||
if (!ft.Follow(cur, cur_td)) break;
|
||||
length += TILE_SIZE * ft.m_tiles_skipped;
|
||||
cur = ft.m_new_tile;
|
||||
assert(KillFirstBit(ft.m_new_td_bits) == TRACKDIR_BIT_NONE);
|
||||
dbg_assert(KillFirstBit(ft.m_new_td_bits) == TRACKDIR_BIT_NONE);
|
||||
cur_td = FindFirstTrackdir(ft.m_new_td_bits);
|
||||
}
|
||||
|
||||
|
@@ -166,7 +166,7 @@ public:
|
||||
/** Check the node for a possible reservation target. */
|
||||
inline void FindSafePositionOnNode(Node *node)
|
||||
{
|
||||
assert(node->m_parent != nullptr);
|
||||
dbg_assert(node->m_parent != nullptr);
|
||||
|
||||
/* We will never pass more than two non-reserve-through signals, no need to check for a safe tile. */
|
||||
if (node->m_parent->m_num_signals_passed - node->m_parent->m_num_signals_res_through_passed >= 2) return;
|
||||
|
@@ -153,7 +153,7 @@ public:
|
||||
/* move back to the old tile/trackdir (where ship is coming from) */
|
||||
TileIndex src_tile = TileAddByDiagDir(tile, ReverseDiagDir(enterdir));
|
||||
Trackdir trackdir = v->GetVehicleTrackdir();
|
||||
assert(IsValidTrackdir(trackdir));
|
||||
dbg_assert(IsValidTrackdir(trackdir));
|
||||
|
||||
/* convert origin trackdir to TrackdirBits */
|
||||
TrackdirBits trackdirs = TrackdirToTrackdirBits(trackdir);
|
||||
@@ -262,8 +262,8 @@ protected:
|
||||
public:
|
||||
inline int CurveCost(Trackdir td1, Trackdir td2)
|
||||
{
|
||||
assert(IsValidTrackdir(td1));
|
||||
assert(IsValidTrackdir(td2));
|
||||
dbg_assert(IsValidTrackdir(td1));
|
||||
dbg_assert(IsValidTrackdir(td2));
|
||||
|
||||
if (HasTrackdir(TrackdirCrossesTrackdirs(td1), td2)) {
|
||||
/* 90-deg curve penalty */
|
||||
|
Reference in New Issue
Block a user