Only compile OrderList::DebugCheckSanity when WITH_ASSERT defined

This commit is contained in:
Jonathan G Rennison
2024-01-02 14:48:57 +00:00
parent be4f8b91c6
commit 9ea49d6680
4 changed files with 9 additions and 1 deletions

View File

@@ -1981,9 +1981,11 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log, CheckC
} }
} }
#ifdef WITH_ASSERT
for (OrderList *order_list : OrderList::Iterate()) { for (OrderList *order_list : OrderList::Iterate()) {
order_list->DebugCheckSanity(); order_list->DebugCheckSanity();
} }
#endif
extern void ValidateVehicleTickCaches(); extern void ValidateVehicleTickCaches();
ValidateVehicleTickCaches(); ValidateVehicleTickCaches();

View File

@@ -967,7 +967,9 @@ public:
void FreeChain(bool keep_orderlist = false); void FreeChain(bool keep_orderlist = false);
#ifdef WITH_ASSERT
void DebugCheckSanity() const; void DebugCheckSanity() const;
#endif
bool CheckOrderListIndexing() const; bool CheckOrderListIndexing() const;
inline std::vector<DispatchSchedule> &GetScheduledDispatchScheduleSet() { return this->dispatch_schedules; } inline std::vector<DispatchSchedule> &GetScheduledDispatchScheduleSet() { return this->dispatch_schedules; }

View File

@@ -840,6 +840,7 @@ bool OrderList::IsCompleteTimetable() const
return true; return true;
} }
#ifdef WITH_ASSERT
/** /**
* Checks for internal consistency of order list. Triggers assertion if something is wrong. * Checks for internal consistency of order list. Triggers assertion if something is wrong.
*/ */
@@ -878,6 +879,7 @@ void OrderList::DebugCheckSanity() const
this->num_vehicles, this->timetable_duration, this->total_duration); this->num_vehicles, this->timetable_duration, this->total_duration);
assert(this->CheckOrderListIndexing()); assert(this->CheckOrderListIndexing());
} }
#endif
/** /**
* Checks whether the order goes to a station or not, i.e. whether the * Checks whether the order goes to a station or not, i.e. whether the
@@ -2822,7 +2824,7 @@ void CheckOrders(const Vehicle *v)
/* Do we only have 1 station in our order list? */ /* Do we only have 1 station in our order list? */
if (n_st < 2 && message == INVALID_STRING_ID) message = STR_NEWS_VEHICLE_HAS_TOO_FEW_ORDERS; if (n_st < 2 && message == INVALID_STRING_ID) message = STR_NEWS_VEHICLE_HAS_TOO_FEW_ORDERS;
#ifndef NDEBUG #ifdef WITH_ASSERT
if (v->orders != nullptr) v->orders->DebugCheckSanity(); if (v->orders != nullptr) v->orders->DebugCheckSanity();
#endif #endif

View File

@@ -3972,9 +3972,11 @@ bool AfterLoadGame()
} }
} }
} }
#ifdef WITH_ASSERT
for (OrderList *order_list : OrderList::Iterate()) { for (OrderList *order_list : OrderList::Iterate()) {
order_list->DebugCheckSanity(); order_list->DebugCheckSanity();
} }
#endif
} }
if (SlXvIsFeaturePresent(XSLFI_TRAIN_THROUGH_LOAD, 0, 1)) { if (SlXvIsFeaturePresent(XSLFI_TRAIN_THROUGH_LOAD, 0, 1)) {