Fix #8919: Release builds with asserts enabled (#8925)

This commit is contained in:
Charles Pigott 2021-04-01 23:57:49 +01:00 committed by GitHub
parent 2a9825b8de
commit dd798d688b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 17 deletions

View File

@ -252,7 +252,7 @@ SQInteger SQSharedState::CollectGarbage(SQVM *vm)
SQVM *vms = _thread(_root_vm);
vms->Mark(&tchain);
#ifndef NDEBUG
#ifdef WITH_ASSERT
SQInteger x = _table(_thread(_root_vm)->_roottable)->CountUsed();
#endif
_refs_table.Mark(&tchain);
@ -291,7 +291,7 @@ SQInteger SQSharedState::CollectGarbage(SQVM *vm)
t = t->_next;
}
_gc_chain = tchain;
#ifndef NDEBUG
#ifdef WITH_ASSERT
SQInteger z = _table(_thread(_root_vm)->_roottable)->CountUsed();
assert(z == x);
#endif

View File

@ -1460,7 +1460,7 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr
}
}
res = t;
}
}
break;
default:
Raise_Error("attempt to delete a slot from a %s",GetTypeName(self));
@ -1471,7 +1471,7 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr
bool SQVM::Call(SQObjectPtr &closure,SQInteger nparams,SQInteger stackbase,SQObjectPtr &outres,SQBool raiseerror,SQBool can_suspend)
{
#ifndef NDEBUG
#ifdef WITH_ASSERT
SQInteger prevstackbase = _stackbase;
#endif
switch(type(closure)) {
@ -1482,13 +1482,13 @@ bool SQVM::Call(SQObjectPtr &closure,SQInteger nparams,SQInteger stackbase,SQObj
bool ret = Execute(closure, _top - nparams, nparams, stackbase,outres,raiseerror);
this->_can_suspend = backup_suspend;
return ret;
}
}
break;
case OT_NATIVECLOSURE:{
case OT_NATIVECLOSURE: {
bool suspend;
return CallNative(_nativeclosure(closure), nparams, stackbase, outres,suspend);
}
}
break;
case OT_CLASS: {
SQObjectPtr constr;
@ -1499,12 +1499,12 @@ bool SQVM::Call(SQObjectPtr &closure,SQInteger nparams,SQInteger stackbase,SQObj
return Call(constr,nparams,stackbase,temp,raiseerror,false);
}
return true;
}
}
break;
default:
return false;
}
#ifndef NDEBUG
#ifdef WITH_ASSERT
if(!_suspended) {
assert(_stackbase == prevstackbase);
}

View File

@ -229,7 +229,7 @@ static void ResizeSpriteOut(SpriteLoader::Sprite *sprite, ZoomLevel zoom)
SpriteLoader::CommonPixel *dst = sprite[zoom].data;
const SpriteLoader::CommonPixel *src = sprite[zoom - 1].data;
#ifndef NDEBUG
#ifdef WITH_ASSERT
const SpriteLoader::CommonPixel *src_end = src + sprite[zoom - 1].height * sprite[zoom - 1].width;
#endif

View File

@ -658,7 +658,7 @@ static void HeightMapCurves(uint level)
for (uint t = 0; t < lengthof(curve_maps); t++) {
if (!HasBit(corner_bits, t)) continue;
#ifndef NDEBUG
#ifdef WITH_ASSERT
bool found = false;
#endif
const control_point_t *cm = curve_maps[t].list;
@ -668,7 +668,7 @@ static void HeightMapCurves(uint level)
if (*h >= p1.x && *h < p2.x) {
ht[t] = p1.y + (*h - p1.x) * (p2.y - p1.y) / (p2.x - p1.x);
#ifndef NDEBUG
#ifdef WITH_ASSERT
found = true;
#endif
break;

View File

@ -107,7 +107,7 @@ Town::~Town()
DeleteWindowById(WC_TOWN_VIEW, this->index);
/* Check no industry is related to us. */
#ifndef NDEBUG
#ifdef WITH_ASSERT
for (const Industry *i : Industry::Iterate()) assert(i->town != this);
/* ... and no object is related to us. */

View File

@ -600,7 +600,7 @@ static char *MakeCzechTownName(char *buf, const char *last, uint32 seed)
return strecpy(buf, _name_czech_real[SeedModChance(4, lengthof(_name_czech_real), seed)], last);
}
#ifndef NDEBUG
#ifdef WITH_ASSERT
const char *orig = buf;
#endif

View File

@ -953,7 +953,7 @@ void CallVehicleTicks()
PerformanceAccumulator::Reset(PFE_GL_AIRCRAFT);
for (Vehicle *v : Vehicle::Iterate()) {
#ifndef NDEBUG
#ifdef WITH_ASSERT
size_t vehicle_index = v->index;
#endif

View File

@ -1156,7 +1156,7 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w, bool init_array)
this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding_top + child_wid->padding_bottom);
}
/* 1b. Make the container higher if needed to accommodate all children nicely. */
#ifndef NDEBUG
#ifdef WITH_ASSERT
uint max_smallest = this->smallest_y + 3 * max_vert_fill; // Upper limit to computing smallest height.
#endif
uint cur_height = this->smallest_y;
@ -1323,7 +1323,7 @@ void NWidgetVertical::SetupSmallestSize(Window *w, bool init_array)
this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
}
/* 1b. Make the container wider if needed to accommodate all children nicely. */
#ifndef NDEBUG
#ifdef WITH_ASSERT
uint max_smallest = this->smallest_x + 3 * max_hor_fill; // Upper limit to computing smallest height.
#endif
uint cur_width = this->smallest_x;