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

View File

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

View File

@ -229,7 +229,7 @@ static void ResizeSpriteOut(SpriteLoader::Sprite *sprite, ZoomLevel zoom)
SpriteLoader::CommonPixel *dst = sprite[zoom].data; SpriteLoader::CommonPixel *dst = sprite[zoom].data;
const SpriteLoader::CommonPixel *src = sprite[zoom - 1].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; const SpriteLoader::CommonPixel *src_end = src + sprite[zoom - 1].height * sprite[zoom - 1].width;
#endif #endif

View File

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

View File

@ -107,7 +107,7 @@ Town::~Town()
DeleteWindowById(WC_TOWN_VIEW, this->index); DeleteWindowById(WC_TOWN_VIEW, this->index);
/* Check no industry is related to us. */ /* Check no industry is related to us. */
#ifndef NDEBUG #ifdef WITH_ASSERT
for (const Industry *i : Industry::Iterate()) assert(i->town != this); for (const Industry *i : Industry::Iterate()) assert(i->town != this);
/* ... and no object is related to us. */ /* ... 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); return strecpy(buf, _name_czech_real[SeedModChance(4, lengthof(_name_czech_real), seed)], last);
} }
#ifndef NDEBUG #ifdef WITH_ASSERT
const char *orig = buf; const char *orig = buf;
#endif #endif

View File

@ -953,7 +953,7 @@ void CallVehicleTicks()
PerformanceAccumulator::Reset(PFE_GL_AIRCRAFT); PerformanceAccumulator::Reset(PFE_GL_AIRCRAFT);
for (Vehicle *v : Vehicle::Iterate()) { for (Vehicle *v : Vehicle::Iterate()) {
#ifndef NDEBUG #ifdef WITH_ASSERT
size_t vehicle_index = v->index; size_t vehicle_index = v->index;
#endif #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); 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. */ /* 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. uint max_smallest = this->smallest_y + 3 * max_vert_fill; // Upper limit to computing smallest height.
#endif #endif
uint cur_height = this->smallest_y; 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); 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. */ /* 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. uint max_smallest = this->smallest_x + 3 * max_hor_fill; // Upper limit to computing smallest height.
#endif #endif
uint cur_width = this->smallest_x; uint cur_width = this->smallest_x;