Change various asserts to not be included in release builds

This commit is contained in:
Jonathan G Rennison
2022-10-22 12:34:54 +01:00
parent 071ac374e8
commit 29a1e49c28
53 changed files with 522 additions and 520 deletions

View File

@@ -161,7 +161,7 @@ bool Vehicle::NeedsAutorenewing(const Company *c, bool use_renew_setting) const
* However this takes time and since the Company pointer is often present
* when this function is called then it's faster to pass the pointer as an
* argument rather than finding it again. */
assert(c == Company::Get(this->owner));
dbg_assert(c == Company::Get(this->owner));
if (use_renew_setting && !c->settings.engine_renew) return false;
if (this->age - this->max_age < (c->settings.engine_renew_months * 30)) return false;
@@ -179,7 +179,7 @@ bool Vehicle::NeedsAutorenewing(const Company *c, bool use_renew_setting) const
*/
void VehicleServiceInDepot(Vehicle *v)
{
assert(v != nullptr);
dbg_assert(v != nullptr);
const Engine *e = Engine::Get(v->engine_type);
if (v->type == VEH_TRAIN) {
if (v->Next() != nullptr) VehicleServiceInDepot(v->Next());
@@ -1104,7 +1104,7 @@ void Vehicle::PreDestructor()
HideFillingPercent(&this->fill_percent_te_id);
this->CancelReservation(INVALID_STATION, st);
delete this->cargo_payment;
assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
dbg_assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
}
if (this->IsEngineCountable()) {
@@ -1723,7 +1723,7 @@ void CallVehicleTicks()
default:
NOT_REACHED();
}
assert(type != INVALID_EXPENSES);
dbg_assert(type != INVALID_EXPENSES);
Money vehicle_new_value = v->GetEngine()->GetCost();
@@ -2475,7 +2475,7 @@ uint8 CalcPercentVehicleFilledOfCargo(const Vehicle *front, CargoID cargo)
void VehicleEnterDepot(Vehicle *v)
{
/* Always work with the front of the vehicle */
assert(v == v->First());
dbg_assert(v == v->First());
switch (v->type) {
case VEH_TRAIN: {
@@ -3337,7 +3337,7 @@ void Vehicle::LeaveStation()
assert(this->current_order.IsAnyLoadingType());
delete this->cargo_payment;
assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
dbg_assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
ClrBit(this->vehicle_flags, VF_COND_ORDER_WAIT);
@@ -3467,7 +3467,7 @@ void Vehicle::LeaveStation()
void Vehicle::AdvanceLoadingInStation()
{
assert(this->current_order.IsType(OT_LOADING));
assert(this->type == VEH_TRAIN);
dbg_assert(this->type == VEH_TRAIN);
ClrBit(Train::From(this)->flags, VRF_ADVANCE_IN_PLATFORM);
@@ -3901,7 +3901,7 @@ int ReversingDistanceTargetSpeed(const Train *v);
*/
void Vehicle::ShowVisualEffect(uint max_speed) const
{
assert(this->IsPrimaryVehicle());
dbg_assert(this->IsPrimaryVehicle());
bool sound = false;
/* Do not show any smoke when:
@@ -4057,7 +4057,7 @@ void Vehicle::ShowVisualEffect(uint max_speed) const
*/
void Vehicle::SetNext(Vehicle *next)
{
assert(this != next);
dbg_assert(this != next);
if (this->next != nullptr) {
/* We had an old next vehicle. Update the first and previous pointers */
@@ -4086,11 +4086,11 @@ void Vehicle::SetNext(Vehicle *next)
*/
void Vehicle::AddToShared(Vehicle *shared_chain)
{
assert(this->previous_shared == nullptr && this->next_shared == nullptr);
dbg_assert(this->previous_shared == nullptr && this->next_shared == nullptr);
if (shared_chain->orders == nullptr) {
assert(shared_chain->previous_shared == nullptr);
assert(shared_chain->next_shared == nullptr);
dbg_assert(shared_chain->previous_shared == nullptr);
dbg_assert(shared_chain->next_shared == nullptr);
this->orders = shared_chain->orders = new OrderList(nullptr, shared_chain);
}
@@ -4332,7 +4332,7 @@ void VehiclesYearlyLoop()
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
{
const Engine *e = Engine::GetIfValid(engine_type);
assert(e != nullptr);
dbg_assert(e != nullptr);
switch (e->type) {
case VEH_TRAIN:
@@ -4425,7 +4425,7 @@ StringID GetVehicleCannotUseStationReason(const Vehicle *v, const Station *st)
*/
GroundVehicleCache *Vehicle::GetGroundVehicleCache()
{
assert(this->IsGroundVehicle());
dbg_assert(this->IsGroundVehicle());
if (this->type == VEH_TRAIN) {
return &Train::From(this)->gcache;
} else {
@@ -4440,7 +4440,7 @@ GroundVehicleCache *Vehicle::GetGroundVehicleCache()
*/
const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const
{
assert(this->IsGroundVehicle());
dbg_assert(this->IsGroundVehicle());
if (this->type == VEH_TRAIN) {
return &Train::From(this)->gcache;
} else {
@@ -4455,7 +4455,7 @@ const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const
*/
uint16 &Vehicle::GetGroundVehicleFlags()
{
assert(this->IsGroundVehicle());
dbg_assert(this->IsGroundVehicle());
if (this->type == VEH_TRAIN) {
return Train::From(this)->gv_flags;
} else {
@@ -4470,7 +4470,7 @@ uint16 &Vehicle::GetGroundVehicleFlags()
*/
const uint16 &Vehicle::GetGroundVehicleFlags() const
{
assert(this->IsGroundVehicle());
dbg_assert(this->IsGroundVehicle());
if (this->type == VEH_TRAIN) {
return Train::From(this)->gv_flags;
} else {