From ec6b78b252570bb063293c2a2486546588832e6d Mon Sep 17 00:00:00 2001 From: janwas Date: Tue, 28 Jun 2005 04:06:25 +0000 Subject: [PATCH] rename assert2 debug_assert; use instead of all plain assert(), since there are no longer any issues (e.g. can't use while handling an exception) This was SVN commit r2447. --- source/graphics/MapReader.cpp | 6 +- source/graphics/Material.cpp | 2 +- source/graphics/Model.cpp | 6 +- source/graphics/ObjectBase.cpp | 8 +- source/graphics/ObjectManager.cpp | 2 +- source/graphics/Particle.cpp | 4 +- source/graphics/RenderableObject.h | 6 +- source/graphics/Terrain.cpp | 2 +- source/graphics/TextureEntry.cpp | 4 +- source/graphics/TextureManager.cpp | 2 +- source/graphics/Unit.h | 6 +- .../graphics/scripting/JSInterface_Camera.cpp | 2 +- source/gui/CButton.cpp | 2 +- source/gui/CCheckBox.cpp | 2 +- source/gui/CGUI.cpp | 12 +-- source/gui/CInput.cpp | 4 +- source/gui/CList.cpp | 4 +- source/gui/CText.cpp | 2 +- source/gui/CTooltip.cpp | 2 +- source/gui/GUIRenderer.cpp | 2 +- source/gui/GUITooltip.cpp | 2 +- source/gui/GUItext.cpp | 2 +- source/gui/GUIutil.cpp | 2 +- source/gui/IGUIObject.cpp | 12 +-- .../gui/scripting/JSInterface_IGUIObject.cpp | 4 +- source/i18n/BufferVariable.h | 2 +- source/i18n/CLocale.cpp | 4 +- source/i18n/ScriptInterface.cpp | 8 +- source/i18n/StringBuffer.cpp | 2 +- source/lib/adts.h | 2 +- source/lib/detect.cpp | 2 +- source/lib/lf_alloc.cpp | 4 +- source/lib/lockfree.cpp | 80 +++++++++---------- source/lib/mmgr.cpp | 60 +++++++------- source/lib/mmgr.h | 2 +- source/lib/ogl.cpp | 10 +-- source/lib/res/cursor.cpp | 6 +- source/lib/res/file.cpp | 4 +- source/lib/res/h_mgr.cpp | 14 ++-- source/lib/res/h_mgr.h | 2 +- source/lib/res/mem.cpp | 6 +- source/lib/res/ogghack.cpp | 4 +- source/lib/res/ogl_tex.cpp | 6 +- source/lib/res/snd.cpp | 32 ++++++-- source/lib/res/tex.cpp | 4 +- source/lib/res/unifont.cpp | 6 +- source/lib/res/vfs.cpp | 8 +- source/lib/res/vfs_tree.cpp | 4 +- source/lib/res/zip.cpp | 10 +-- source/lib/string_s.cpp | 30 +++---- source/lib/sysdep/ia32.cpp | 8 +- source/lib/sysdep/sysdep.h | 2 +- source/lib/sysdep/win/printf.cpp | 8 +- source/lib/sysdep/win/waio.cpp | 14 ++-- source/lib/sysdep/win/wcpu.cpp | 2 +- source/lib/sysdep/win/wdetect.cpp | 4 +- source/lib/sysdep/win/wdir_watch.cpp | 8 +- source/lib/sysdep/win/wposix.cpp | 12 +-- source/lib/sysdep/win/wpthread.cpp | 14 ++-- source/lib/sysdep/win/wsdl.cpp | 16 ++-- source/lib/sysdep/win/wsock.cpp | 2 +- source/lib/sysdep/win/wtime.cpp | 20 ++--- source/main.cpp | 4 +- source/maths/Bound.cpp | 4 +- source/ps/CConsole.cpp | 2 +- source/ps/CStr.cpp | 4 +- source/ps/CStr.h | 4 +- source/ps/ConfigDB.cpp | 12 +-- source/ps/Game.cpp | 4 +- source/ps/Hotkey.cpp | 2 +- source/ps/Interact.cpp | 4 +- source/ps/Loader.cpp | 2 +- source/ps/Loader.h | 2 +- source/ps/NPFont.h | 4 +- source/ps/NPFontManager.cpp | 2 +- source/ps/Network/NetMessage.cpp | 2 +- source/ps/Network/Network.h | 2 +- source/ps/Network/SocketBase.cpp | 2 +- source/ps/Parser.cpp | 6 +- source/ps/Singleton.h | 8 +- source/ps/StringConvert.cpp | 6 +- source/ps/XMLWriter.cpp | 4 +- source/ps/XeroXMB.cpp | 8 +- source/ps/Xeromyces.cpp | 12 +-- source/ps/i18n.cpp | 2 +- source/ps/scripting/JSCollection.h | 6 +- source/ps/scripting/JSInterface_Console.cpp | 2 +- source/ps/scripting/JSInterface_VFS.cpp | 10 +-- source/renderer/ModelRData.cpp | 14 ++-- source/renderer/PatchRData.cpp | 16 ++-- source/renderer/VertexBuffer.cpp | 4 +- source/renderer/VertexBufferManager.cpp | 8 +- source/scripting/DOMEvent.cpp | 4 +- source/scripting/JSSerialization.h | 6 +- source/scripting/ScriptCustomTypes.cpp | 2 +- source/scripting/ScriptGlue.cpp | 16 ++-- source/scripting/ScriptableComplex.h | 18 ++--- source/scripting/ScriptableObject.h | 4 +- source/scripting/ScriptingHost.cpp | 4 +- source/simulation/BaseEntity.cpp | 2 +- source/simulation/BoundingObjects.cpp | 3 +- source/simulation/Collision.cpp | 2 +- source/simulation/Entity.cpp | 10 +-- source/simulation/Entity.h | 2 +- source/simulation/EntityHandles.cpp | 20 ++--- source/simulation/EntityManager.cpp | 4 +- source/simulation/EntityStateProcessing.cpp | 2 +- source/simulation/PathfindSparse.cpp | 6 +- source/simulation/Projectile.cpp | 2 +- source/simulation/Scheduler.cpp | 2 +- source/simulation/Simulation.cpp | 2 +- .../scripting/JSInterface_Entity.cpp | 4 +- source/sound/CMusicPlayer.cpp | 2 +- source/sound/JSI_Sound.cpp | 8 +- 114 files changed, 413 insertions(+), 398 deletions(-) diff --git a/source/graphics/MapReader.cpp b/source/graphics/MapReader.cpp index b86d0b859d..eba78b1725 100755 --- a/source/graphics/MapReader.cpp +++ b/source/graphics/MapReader.cpp @@ -314,7 +314,7 @@ void CXMLReader::Init(const CStr& xml_filename) #undef EL XMBElement root = xmb_file.getRoot(); - assert(root.getNodeName() == el_scenario); + debug_assert(root.getNodeName() == el_scenario); nodes = root.getChildNodes(); // find out total number of entities+nonentities @@ -379,7 +379,7 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time) // wrapped, since we only yield after a complete iteration. XMBElement entity = entities.item(entity_idx++); - assert(entity.getNodeName() == el_entity); + debug_assert(entity.getNodeName() == el_entity); CStrW TemplateName; int PlayerID; @@ -443,7 +443,7 @@ int CXMLReader::ReadNonEntities(XMBElement parent, double end_time) // wrapped, since we only yield after a complete iteration. XMBElement nonentity = nonentities.item(nonentity_idx++); - assert(nonentity.getNodeName() == el_nonentity); + debug_assert(nonentity.getNodeName() == el_nonentity); CStr ActorName; CVector3D Position; diff --git a/source/graphics/Material.cpp b/source/graphics/Material.cpp index 586d81dd34..984363b5a5 100755 --- a/source/graphics/Material.cpp +++ b/source/graphics/Material.cpp @@ -119,7 +119,7 @@ SMaterialColor CMaterial::GetEmissive() SMaterialColor CMaterial::GetPlayerColor() { - assert(m_PlayerID != PLAYER_NONE); + debug_assert(m_PlayerID != PLAYER_NONE); // because this should never be called unless IsPlayer returned true if (m_PlayerID == PLAYER_OTHER /* TODO: or if player-colour is globally disabled */ ) diff --git a/source/graphics/Model.cpp b/source/graphics/Model.cpp index b640cd4f20..ddba1dd314 100755 --- a/source/graphics/Model.cpp +++ b/source/graphics/Model.cpp @@ -111,7 +111,7 @@ static CVector3D SkinPoint(const CVector3D& pos,const SVertexBlend& blend, CVector3D result,tmp; // must have at least one valid bone if we're using SkinPoint - assert(blend.m_Bone[0]!=0xff); + debug_assert(blend.m_Bone[0]!=0xff); const CMatrix3D& m=bonestates[blend.m_Bone[0]]; m.Transform(pos,result); @@ -137,7 +137,7 @@ void CModel::CalcBounds() { if (m_Anim->m_ObjectBounds.IsEmpty()) CalcAnimatedObjectBound(m_Anim->m_AnimDef, m_Anim->m_ObjectBounds); - assert(! m_Anim->m_ObjectBounds.IsEmpty()); // (if this happens, it'll be recalculating the bounds every time) + debug_assert(! m_Anim->m_ObjectBounds.IsEmpty()); // (if this happens, it'll be recalculating the bounds every time) m_ObjectBounds = m_Anim->m_ObjectBounds; } @@ -272,7 +272,7 @@ void CModel::GenerateBoneMatrices() PROFILE( "generating bone matrices" ); - assert(m_pModelDef->GetNumBones() == m_Anim->m_AnimDef->GetNumKeys()); + debug_assert(m_pModelDef->GetNumBones() == m_Anim->m_AnimDef->GetNumKeys()); m_Anim->m_AnimDef->BuildBoneMatrices(m_AnimTime,m_BoneMatrices); diff --git a/source/graphics/ObjectBase.cpp b/source/graphics/ObjectBase.cpp index 256a71758e..62d6b20388 100644 --- a/source/graphics/ObjectBase.cpp +++ b/source/graphics/ObjectBase.cpp @@ -348,7 +348,7 @@ void CObjectBase::CalculateVariation(std::set& strings, variation_key& cho std::vector matches; typedef std::vector::const_iterator Iter; - assert(grp->size() < 256); // else they won't fit in the vector + debug_assert(grp->size() < 256); // else they won't fit in the vector for (uint i = 0; i < grp->size(); ++i) if (strings.count((*grp)[i].m_VariantName)) @@ -387,7 +387,7 @@ void CObjectBase::CalculateVariation(std::set& strings, variation_key& cho // since actors are meant to have purely visual manifestations.) int randNum = (int)( ((float)rand() / RAND_MAX) * totalFreq ); - assert(randNum < totalFreq); + debug_assert(randNum < totalFreq); // and use that to choose one of the variants for (Iter it = matches.begin(); it != matches.end(); ++it) @@ -400,12 +400,12 @@ void CObjectBase::CalculateVariation(std::set& strings, variation_key& cho } } - assert(randNum < 0); + debug_assert(randNum < 0); // This should always happen; otherwise it // wouldn't have chosen any of the variants. } - assert(choices.size() == m_Variants.size()); + debug_assert(choices.size() == m_Variants.size()); // Also, make choices for all props: diff --git a/source/graphics/ObjectManager.cpp b/source/graphics/ObjectManager.cpp index 0444792a5a..c1bcbf05f1 100755 --- a/source/graphics/ObjectManager.cpp +++ b/source/graphics/ObjectManager.cpp @@ -152,7 +152,7 @@ void CObjectManager::AddObjectType(const char* name) void CObjectManager::AddObject(ObjectKey& key, CObjectEntry* entry, int type) { - assert((uint)type + CParticle::CParticle() : m_duration(0.0f), @@ -64,7 +64,7 @@ void CParticle::Frame() void CParticle::Render() { - assert(m_sprite); + debug_assert(m_sprite); m_sprite->SetColour(m_colour); m_sprite->SetTranslation(m_position); diff --git a/source/graphics/RenderableObject.h b/source/graphics/RenderableObject.h index 3aa4740c8f..650ab6a9c5 100755 --- a/source/graphics/RenderableObject.h +++ b/source/graphics/RenderableObject.h @@ -9,7 +9,7 @@ #ifndef _RENDERABLEOBJECT_H #define _RENDERABLEOBJECT_H -#include + #include "Bound.h" #include "Matrix3D.h" @@ -87,9 +87,9 @@ public: // set the object renderdata // TODO,RC 10/04/04 - need to delete existing renderdata here, or can we // assume the renderer won't set renderdata when an object already has it? - // - just assert we've no renderdata at the minute + // - just debug_assert we've no renderdata at the minute void SetRenderData(CRenderData* renderdata) { - assert(m_RenderData==0); + debug_assert(m_RenderData==0); m_RenderData=renderdata; } diff --git a/source/graphics/Terrain.cpp b/source/graphics/Terrain.cpp index 373b20b029..e30433016e 100755 --- a/source/graphics/Terrain.cpp +++ b/source/graphics/Terrain.cpp @@ -177,7 +177,7 @@ float CTerrain::getExactGroundLevel( float x, float y ) const yi = m_MapSize - 1; yf = 1.0f; } /* - assert( isOnMap( x, y ) ); + debug_assert( isOnMap( x, y ) ); if( !isOnMap( x, y ) ) return 0.0f; diff --git a/source/graphics/TextureEntry.cpp b/source/graphics/TextureEntry.cpp index 2c0a7850ab..1f3c8ec335 100755 --- a/source/graphics/TextureEntry.cpp +++ b/source/graphics/TextureEntry.cpp @@ -153,7 +153,7 @@ void CTextureEntry::LoadTexture() { if (m_TexturePath.size() == 0) { - assert(m_pParent); + debug_assert(m_pParent); m_pParent->LoadTexture(); m_Handle = m_pParent->m_Handle; return; @@ -184,7 +184,7 @@ void CTextureEntry::BuildBaseColor() // cases c&d: We don't have our own texture, use parent base color instead if (m_TexturePath.size() == 0) { - assert(m_pParent); + debug_assert(m_pParent); m_BaseColor=m_pParent->GetBaseColor(); m_BaseColorValid=true; return; diff --git a/source/graphics/TextureManager.cpp b/source/graphics/TextureManager.cpp index b9710984a6..295dcb8ee3 100755 --- a/source/graphics/TextureManager.cpp +++ b/source/graphics/TextureManager.cpp @@ -121,7 +121,7 @@ void CTextureManager::LoadTerrainsFromXML(const char *filename) /*CTextureEntry* CTextureManager::AddTexture(const char* filename,int type) { - assert((uint)type + class CModel; class CObjectEntry; @@ -16,10 +16,10 @@ class CUnit public: // constructor - unit invalid without a model and object CUnit(CObjectEntry* object, CModel* model) : m_Object(object), m_Model(model), m_Entity(NULL) { - assert(object && model); + debug_assert(object && model); } CUnit(CObjectEntry* object, CModel* model, CEntity* entity) : m_Object(object), m_Model(model), m_Entity(entity) { - assert(object && model); + debug_assert(object && model); } // destructor diff --git a/source/graphics/scripting/JSInterface_Camera.cpp b/source/graphics/scripting/JSInterface_Camera.cpp index d1ee86b3fd..37c58ed89e 100755 --- a/source/graphics/scripting/JSInterface_Camera.cpp +++ b/source/graphics/scripting/JSInterface_Camera.cpp @@ -202,7 +202,7 @@ JSBool JSI_Camera::setProperty( JSContext* cx, JSObject* obj, jsval id, jsval* v JSBool JSI_Camera::lookAt( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) { - assert( argc >= 2 ); + debug_assert( argc >= 2 ); JSI_Vector3D::Vector3D_Info* v = NULL; Camera_Info* cameraInfo = (Camera_Info*)JS_GetPrivate( cx, obj ); diff --git a/source/gui/CButton.cpp b/source/gui/CButton.cpp index 9453c7092e..f7bd03b490 100755 --- a/source/gui/CButton.cpp +++ b/source/gui/CButton.cpp @@ -47,7 +47,7 @@ void CButton::SetupText() if (!GetGUI()) return; - assert(m_GeneratedTexts.size()>=1); + debug_assert(m_GeneratedTexts.size()>=1); CStr font; if (GUI::GetSetting(this, "font", font) != PS_OK || font.Length()==0) diff --git a/source/gui/CCheckBox.cpp b/source/gui/CCheckBox.cpp index 8079f14a4f..5dbbd1a0ca 100755 --- a/source/gui/CCheckBox.cpp +++ b/source/gui/CCheckBox.cpp @@ -62,7 +62,7 @@ void CCheckBox::SetupText() if (!GetGUI()) return; - assert(m_GeneratedTexts.size()>=1); + debug_assert(m_GeneratedTexts.size()>=1); CStr font; CGUIString caption; diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 6c1048b3b5..9753282e3b 100755 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -7,7 +7,7 @@ gee@pyro.nu #include "precompiled.h" #include -#include + #include #include "lib/res/unifont.h" @@ -292,7 +292,7 @@ CGUI::CGUI() : m_InternalNameNumber(0), m_MouseButtons(0), m_FocusedObject(NULL) // Construct the parent object for all GUI JavaScript things m_ScriptObject = JS_NewObject(g_ScriptingHost.getContext(), &GUIClass, NULL, NULL); - assert(m_ScriptObject != NULL); // How should it handle errors? + debug_assert(m_ScriptObject != NULL); // How should it handle errors? JS_AddRoot(g_ScriptingHost.getContext(), &m_ScriptObject); // This will make this invisible, not add @@ -346,7 +346,7 @@ void CGUI::Process() /* // TODO Gee: check if m_pInput is valid, otherwise return -/// assert(m_pInput); +/// debug_assert(m_pInput); // Pre-process all objects try @@ -1096,7 +1096,7 @@ void CGUI::Xeromyces_ReadRootSetup(XMBElement Element, CXeromyces* pFile) void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObject *pParent) { - assert(pParent); + debug_assert(pParent); int i; // Our object we are going to create @@ -1399,7 +1399,7 @@ void CGUI::Xeromyces_ReadSprite(XMBElement Element, CXeromyces* pFile) } else if (ElementName == "effect") { - assert(! effects); // DTD should only allow one effect per sprite + debug_assert(! effects); // DTD should only allow one effect per sprite effects = new SGUIImageEffects; Xeromyces_ReadEffects(child, pFile, *effects); } @@ -1534,7 +1534,7 @@ void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite CStr ElementName (pFile->getElementString(child.getNodeName())); if (ElementName == "effect") { - assert(! image.m_Effects); // DTD should only allow one effect per sprite + debug_assert(! image.m_Effects); // DTD should only allow one effect per sprite image.m_Effects = new SGUIImageEffects; Xeromyces_ReadEffects(child, pFile, *image.m_Effects); } diff --git a/source/gui/CInput.cpp b/source/gui/CInput.cpp index 0484d69831..48b5d362ca 100755 --- a/source/gui/CInput.cpp +++ b/source/gui/CInput.cpp @@ -58,7 +58,7 @@ CInput::~CInput() int CInput::ManuallyHandleEvent(const SDL_Event* ev) { - assert(m_iBufferPos != -1); + debug_assert(m_iBufferPos != -1); // Since the GUI framework doesn't handle to set settings // in Unicode (CStrW), we'll simply retrieve the actual @@ -1017,7 +1017,7 @@ void CInput::UpdateText(int from, int to_before, int to_after) } else { - assert(to_before != -1); + debug_assert(to_before != -1); list::iterator destroy_row_from, destroy_row_to; // Used to check if the above has been set to anything, diff --git a/source/gui/CList.cpp b/source/gui/CList.cpp index 2d1b2d243e..03a1be9b48 100644 --- a/source/gui/CList.cpp +++ b/source/gui/CList.cpp @@ -57,7 +57,7 @@ void CList::SetupText() //LOG(ERROR, LOG_CATEGORY, "SetupText() %s", GetPresentableName().c_str()); - //assert(m_GeneratedTexts.size()>=1); + //debug_assert(m_GeneratedTexts.size()>=1); m_ItemsYPositions.resize( pList->m_Items.size()+1 ); @@ -327,7 +327,7 @@ void CList::DrawList(const int &selected, if (selected != -1) { - assert(selected >= 0 && selected+1 < (int)m_ItemsYPositions.size()); + debug_assert(selected >= 0 && selected+1 < (int)m_ItemsYPositions.size()); // Get rectangle of selection: CRect rect(rect.left, rect.top + m_ItemsYPositions[selected] - scroll, diff --git a/source/gui/CText.cpp b/source/gui/CText.cpp index b45f2ed2e8..127e429526 100755 --- a/source/gui/CText.cpp +++ b/source/gui/CText.cpp @@ -55,7 +55,7 @@ void CText::SetupText() if (!GetGUI()) return; - assert(m_GeneratedTexts.size()>=1); + debug_assert(m_GeneratedTexts.size()>=1); CStr font; if (GUI::GetSetting(this, "font", font) != PS_OK || font.Length()==0) diff --git a/source/gui/CTooltip.cpp b/source/gui/CTooltip.cpp index 4115e23fe2..18c67a7123 100644 --- a/source/gui/CTooltip.cpp +++ b/source/gui/CTooltip.cpp @@ -45,7 +45,7 @@ void CTooltip::SetupText() if (!GetGUI()) return; - assert(m_GeneratedTexts.size()==1); + debug_assert(m_GeneratedTexts.size()==1); CStr font; if (GUI::GetSetting(this, "font", font) != PS_OK || font.Length()==0) diff --git a/source/gui/GUIRenderer.cpp b/source/gui/GUIRenderer.cpp index 88d8609d21..e24f217ddb 100644 --- a/source/gui/GUIRenderer.cpp +++ b/source/gui/GUIRenderer.cpp @@ -353,7 +353,7 @@ void GUIRenderer::UpdateDrawCallCache(DrawCalls &Calls, CStr &SpriteName, CRect Sprites[SpriteName] = Sprite; it = Sprites.find(SpriteName); - assert(it != Sprites.end()); // The insertion above shouldn't fail + debug_assert(it != Sprites.end()); // The insertion above shouldn't fail } else { diff --git a/source/gui/GUITooltip.cpp b/source/gui/GUITooltip.cpp index f81a3946ba..b6e5f7e13c 100644 --- a/source/gui/GUITooltip.cpp +++ b/source/gui/GUITooltip.cpp @@ -91,7 +91,7 @@ static bool GetTooltip(IGUIObject* obj, CStr &style) void ShowTooltip(IGUIObject* obj, CPos pos, CStr& style, CGUI* gui) { - assert(obj); + debug_assert(obj); // Get the object referenced by 'tooltip_style' IGUIObject* tooltipobj = gui->FindObjectByName("__tooltip_"+style); diff --git a/source/gui/GUItext.cpp b/source/gui/GUItext.cpp index 3f3f8e4cbc..508f8f85c5 100755 --- a/source/gui/GUItext.cpp +++ b/source/gui/GUItext.cpp @@ -60,7 +60,7 @@ void CGUIString::GenerateTextCall(SFeedback &Feedback, if (_to == _from && itTextChunk->m_From == itTextChunk->m_To) { // These should never be able to have more than one tag. - assert(itTextChunk->m_Tags.size()==1); + debug_assert(itTextChunk->m_Tags.size()==1); // Now do second check // because icons and images are placed on exactly one position diff --git a/source/gui/GUIutil.cpp b/source/gui/GUIutil.cpp index 29da48c119..2b270f247d 100755 --- a/source/gui/GUIutil.cpp +++ b/source/gui/GUIutil.cpp @@ -316,7 +316,7 @@ bool CClientArea::SetClientArea(const CStr& Value) { if (valuenr!=3) { - assert(valuenr <= 2); + debug_assert(valuenr <= 2); arg_start[valuenr+1] = i+1; arg_count[valuenr] = arg_start[valuenr+1] - arg_start[valuenr] - 1; } diff --git a/source/gui/IGUIObject.cpp b/source/gui/IGUIObject.cpp index e41cf29e81..462ed6837a 100755 --- a/source/gui/IGUIObject.cpp +++ b/source/gui/IGUIObject.cpp @@ -9,7 +9,7 @@ gee@pyro.nu ///// janwas: again, including etiquette? #include "Parser.h" -#include + ///// #include "gui/scripting/JSInterface_IGUIObject.h" @@ -87,7 +87,7 @@ IGUIObject::~IGUIObject() void IGUIObject::AddChild(IGUIObject *pChild) { // -// assert(pChild); +// debug_assert(pChild); pChild->SetParent(this); @@ -425,7 +425,7 @@ void IGUIObject::RegisterScriptHandler(const CStr& Action, const CStr& Code, CGU sprintf(buf, "__eventhandler%d", x++); JSFunction* func = JS_CompileFunction(g_ScriptingHost.getContext(), pGUI->m_ScriptObject, buf, paramCount, paramNames, (const char*)Code, Code.Length(), CodeName, 0); - assert(func); // TODO: Handle errors + debug_assert(func); // TODO: Handle errors if (func) SetScriptHandler(Action, JS_GetFunctionObject(func)); } @@ -452,14 +452,14 @@ void IGUIObject::ScriptEvent(const CStr& Action) // PRIVATE_TO_JSVAL assumes two-byte alignment, // so make sure that's always true - assert(! ((jsval)this & JSVAL_INT)); + debug_assert(! ((jsval)this & JSVAL_INT)); // The IGUIObject needs to be stored inside the script's object jsval guiObject = PRIVATE_TO_JSVAL(this); // Make a 'this', allowing access to the IGUIObject JSObject* jsGuiObject = JS_ConstructObjectWithArguments(g_ScriptingHost.getContext(), &JSI_IGUIObject::JSI_class, NULL, m_pGUI->m_ScriptObject, 1, &guiObject); - assert(jsGuiObject); // TODO: Handle errors + debug_assert(jsGuiObject); // TODO: Handle errors // Prevent it from being garbage-collected before it's passed into the function JS_AddRoot(g_ScriptingHost.getContext(), &jsGuiObject); @@ -470,7 +470,7 @@ void IGUIObject::ScriptEvent(const CStr& Action) mouseParams[1] = INT_TO_JSVAL(m_pGUI->m_MousePos.y); mouseParams[2] = INT_TO_JSVAL(m_pGUI->m_MouseButtons); JSObject* mouseObj = JS_ConstructObjectWithArguments(g_ScriptingHost.getContext(), &JSI_GUIMouse::JSI_class, NULL, m_pGUI->m_ScriptObject, 3, mouseParams); - assert(mouseObj); // TODO: Handle errors + debug_assert(mouseObj); // TODO: Handle errors // Don't garbage collect the mouse JS_AddRoot(g_ScriptingHost.getContext(), &mouseObj); diff --git a/source/gui/scripting/JSInterface_IGUIObject.cpp b/source/gui/scripting/JSInterface_IGUIObject.cpp index f9991a226f..a808cdb100 100755 --- a/source/gui/scripting/JSInterface_IGUIObject.cpp +++ b/source/gui/scripting/JSInterface_IGUIObject.cpp @@ -530,7 +530,7 @@ JSBool JSI_IGUIObject::construct(JSContext* cx, JSObject* obj, unsigned int argc return JS_FALSE; } - assert(argc == 1); + debug_assert(argc == 1); // Store the IGUIObject in the JS object's 'private' area IGUIObject* guiObject = (IGUIObject*)JSVAL_TO_PRIVATE(argv[0]); @@ -542,7 +542,7 @@ JSBool JSI_IGUIObject::construct(JSContext* cx, JSObject* obj, unsigned int argc JSBool JSI_IGUIObject::getByName(JSContext* cx, JSObject* UNUSEDPARAM(obj), unsigned int argc, jsval* argv, jsval* rval) { - assert(argc == 1); + debug_assert(argc == 1); CStr objectName = JS_GetStringBytes(JS_ValueToString(cx, argv[0])); diff --git a/source/i18n/BufferVariable.h b/source/i18n/BufferVariable.h index cfa22e63e3..59eb9056a4 100755 --- a/source/i18n/BufferVariable.h +++ b/source/i18n/BufferVariable.h @@ -12,7 +12,7 @@ providing hashes and strings on request. #include "StrImmutable.h" -#include + namespace I18n { diff --git a/source/i18n/CLocale.cpp b/source/i18n/CLocale.cpp index aba1eca2f2..e5724741bf 100755 --- a/source/i18n/CLocale.cpp +++ b/source/i18n/CLocale.cpp @@ -4,7 +4,7 @@ #include "TSComponent.h" #include "StringConvert.h" -#include + #include #include "ps/CLogger.h" @@ -328,7 +328,7 @@ bool CLocale::ReadCached(StringBuffer* sb, Str& str) return false; // Check every variable to see whether they're identical - assert(sb->Variables.size() == (*it).second.vars.size()); // this should always be true + debug_assert(sb->Variables.size() == (*it).second.vars.size()); // this should always be true size_t count = sb->Variables.size(); for (size_t i = 0; i < count; ++i) if (! ( *sb->Variables[i] == *(*it).second.vars[i] ) ) diff --git a/source/i18n/ScriptInterface.cpp b/source/i18n/ScriptInterface.cpp index d80971c733..e8ba34b918 100755 --- a/source/i18n/ScriptInterface.cpp +++ b/source/i18n/ScriptInterface.cpp @@ -18,12 +18,12 @@ namespace JSI_LookedupWord { static JSBool GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) { CLocale::LookupType* lookedup = (CLocale::LookupType*)JS_GetPrivate(cx, obj); - assert(lookedup); + debug_assert(lookedup); JSObject* parent = JS_GetParent(cx, obj); - assert(parent); + debug_assert(parent); CLocale* locale = (CLocale*)JS_GetPrivate(cx, parent); - assert(locale); + debug_assert(locale); JSString* prop = JS_ValueToString(cx, id); JS_ASSERT(prop, "lookup() property failed to convert to string"); @@ -50,7 +50,7 @@ namespace JSI_LookedupWord { // Free the LookupType that was allocated when building this object CLocale::LookupType* lookedup = (CLocale::LookupType*)JS_GetPrivate(cx, obj); - assert(lookedup); + debug_assert(lookedup); delete lookedup; } diff --git a/source/i18n/StringBuffer.cpp b/source/i18n/StringBuffer.cpp index 70a4f51cb1..83e5abd88e 100755 --- a/source/i18n/StringBuffer.cpp +++ b/source/i18n/StringBuffer.cpp @@ -7,7 +7,7 @@ // Vaguely useful utility function for deleting stuff template void delete_fn(T* v) { delete v; } -#include + #include #include "ps/CLogger.h" diff --git a/source/lib/adts.h b/source/lib/adts.h index 640bf4d158..1101bb1d95 100755 --- a/source/lib/adts.h +++ b/source/lib/adts.h @@ -208,7 +208,7 @@ public: l->refs++; else { - assert(l->refs > 0); + debug_assert(l->refs > 0); l->refs--; } return 0; diff --git a/source/lib/detect.cpp b/source/lib/detect.cpp index 49c3f2a00a..c86b1387b6 100755 --- a/source/lib/detect.cpp +++ b/source/lib/detect.cpp @@ -153,7 +153,7 @@ void get_snd_info() #else // At least reset the values for unhandled platforms. Should perhaps do // something like storing the OpenAL version or similar. - assert(SND_CARD_LEN >= 8 && SND_DRV_VER_LEN >= 8); // protect strcpy + debug_assert(SND_CARD_LEN >= 8 && SND_DRV_VER_LEN >= 8); // protect strcpy strcpy(snd_card, "Unknown"); // safe strcpy(snd_drv_ver, "Unknown"); // safe #endif diff --git a/source/lib/lf_alloc.cpp b/source/lib/lf_alloc.cpp index 7ec29408a5..e48d1d60fe 100644 --- a/source/lib/lf_alloc.cpp +++ b/source/lib/lf_alloc.cpp @@ -91,7 +91,7 @@ struct Active Active& operator=(Descriptor* desc) { *(Descriptor**)this = desc; - assert(credits == 0); // make sure ptr is aligned + debug_assert(credits == 0); // make sure ptr is aligned return *this; } @@ -502,7 +502,7 @@ return pool; // need to set up a new pool // .. but there are too many -assert2(0 <= num_pools && num_pools <= MAX_POOLS); +debug_assert(0 <= num_pools && num_pools <= MAX_POOLS); if(num_pools >= MAX_POOLS) { debug_warn("increase MAX_POOLS"); diff --git a/source/lib/lockfree.cpp b/source/lib/lockfree.cpp index 3fc5aa4db1..49457acd3b 100644 --- a/source/lib/lockfree.cpp +++ b/source/lib/lockfree.cpp @@ -141,7 +141,7 @@ static void tls_retire(void* tls_) if(CAS(&tls->active, 1, 0)) { atomic_add(&active_threads, -1); - assert2(active_threads >= 0); + debug_assert(active_threads >= 0); } } @@ -150,7 +150,7 @@ static void tls_retire(void* tls_) static void tls_init() { int ret = pthread_key_create(&tls_key, tls_retire); - assert2(ret == 0); + debug_assert(ret == 0); } @@ -158,7 +158,7 @@ static void tls_init() static void tls_shutdown() { int ret = pthread_key_delete(tls_key); - assert2(ret == 0); + debug_assert(ret == 0); tls_key = 0; while(tls_list) @@ -178,7 +178,7 @@ static TLS* tls_alloc() { // make sure we weren't shut down in the meantime - re-init isn't // possible since pthread_once (which can't be reset) calls tls_init. - assert2(tls_key != 0); + debug_assert(tls_key != 0); TLS* tls; @@ -198,7 +198,7 @@ static TLS* tls_alloc() { tls = (TLS*)-1; int ret = pthread_setspecific(tls_key, tls); - assert2(ret == 0); + debug_assert(ret == 0); return tls; } tls->active = 1; @@ -217,7 +217,7 @@ have_tls: atomic_add(&active_threads, 1); int ret = pthread_setspecific(tls_key, tls); - assert2(ret == 0); + debug_assert(ret == 0); return tls; } @@ -227,7 +227,7 @@ have_tls: static TLS* tls_get() { int ret = pthread_once(&tls_once, tls_init); - assert2(ret == 0); + debug_assert(ret == 0); // already allocated or tls_alloc failed. TLS* tls = (TLS*)pthread_getspecific(tls_key); @@ -267,7 +267,7 @@ static void smr_release_unreferenced_nodes(TLS* tls) return; // required for head/tail below; guaranteed by callers. - assert2(tls->num_retired_nodes != 0); + debug_assert(tls->num_retired_nodes != 0); // // build array of all active (non-NULL) hazard pointers (more efficient @@ -331,7 +331,7 @@ retry: static void smr_retire_node(Node* node) { TLS* tls = tls_get(); - assert2(tls != (void*)-1); + debug_assert(tls != (void*)-1); // if this triggers, tls_alloc called from lfl_init failed due to // lack of memory and the caller didn't check its return value. @@ -422,13 +422,13 @@ static inline bool is_marked_as_deleted(Node* p) static inline Node* with_mark(Node* p) { - assert2(!is_marked_as_deleted(p)); // paranoia + debug_assert(!is_marked_as_deleted(p)); // paranoia return p+1; } static inline Node* without_mark(Node* p) { - assert2(is_marked_as_deleted(p)); // paranoia + debug_assert(is_marked_as_deleted(p)); // paranoia return p-1; } @@ -472,7 +472,7 @@ void lfl_free(LFList* list) } atomic_add(&active_data_structures, -1); - assert2(active_data_structures >= 0); + debug_assert(active_data_structures >= 0); smr_try_shutdown(); } @@ -483,7 +483,7 @@ void lfl_free(LFList* list) static bool list_lookup(LFList* list, uintptr_t key, ListPos* pos) { TLS* tls = tls_get(); - assert2(tls != (void*)-1); + debug_assert(tls != (void*)-1); // if this triggers, tls_alloc called from lfl_init failed due to // lack of memory and the caller didn't check its return value. @@ -567,7 +567,7 @@ void* lfl_find(LFList* list, uintptr_t key) void* lfl_insert(LFList* list, uintptr_t key, size_t additional_bytes, int* was_inserted) { TLS* tls = tls_get(); - assert2(tls != (void*)-1); + debug_assert(tls != (void*)-1); // if this triggers, tls_alloc called from lfl_init failed due to // lack of memory and the caller didn't check its return value. @@ -620,7 +620,7 @@ have_node: int lfl_erase(LFList* list, uintptr_t key) { TLS* tls = tls_get(); - assert2(tls != (void*)-1); + debug_assert(tls != (void*)-1); // if this triggers, tls_alloc called from lfl_init failed due to // lack of memory and the caller didn't check its return value. @@ -660,8 +660,8 @@ retry: static void validate(LFHash* hash) { - assert2(hash->tbl); - assert2(is_pow2(hash->mask+1)); + debug_assert(hash->tbl); + debug_assert(is_pow2(hash->mask+1)); } // return hash "chain" (i.e. linked list) that is assigned to . @@ -769,11 +769,11 @@ static void basic_single_threaded_test() LFList list; err = lfl_init(&list); - assert2(err == 0); + debug_assert(err == 0); LFHash hash; err = lfh_init(&hash, 8); - assert2(err == 0); + debug_assert(err == 0); // add some entries; store "signatures" (ascending int values) for(uint i = 0; i < ENTRIES; i++) @@ -781,11 +781,11 @@ static void basic_single_threaded_test() int was_inserted; user_data = lfl_insert(&list, key+i, sizeof(int), &was_inserted); - assert2(user_data != 0 && was_inserted); + debug_assert(user_data != 0 && was_inserted); *(int*)user_data = sig+i; user_data = lfh_insert(&hash, key+i, sizeof(int), &was_inserted); - assert2(user_data != 0 && was_inserted); + debug_assert(user_data != 0 && was_inserted); *(int*)user_data = sig+i; } @@ -793,12 +793,12 @@ static void basic_single_threaded_test() for(uint i = 0; i < ENTRIES; i++) { user_data = lfl_find(&list, key+i); - assert2(user_data != 0); - assert2(*(int*)user_data == sig+i); + debug_assert(user_data != 0); + debug_assert(*(int*)user_data == sig+i); user_data = lfh_find(&hash, key+i); - assert2(user_data != 0); - assert2(*(int*)user_data == sig+i); + debug_assert(user_data != 0); + debug_assert(*(int*)user_data == sig+i); } @@ -866,15 +866,15 @@ static void* thread_func(void* arg) case TA_FIND: { user_data = lfl_find(&list, key); - assert2(was_in_set == (user_data != 0)); + debug_assert(was_in_set == (user_data != 0)); if(user_data) - assert2(*(uintptr_t*)user_data == ~key); + debug_assert(*(uintptr_t*)user_data == ~key); user_data = lfh_find(&hash, key); // typical failure site if lockfree data structure has bugs. - assert2(was_in_set == (user_data != 0)); + debug_assert(was_in_set == (user_data != 0)); if(user_data) - assert2(*(uintptr_t*)user_data == ~key); + debug_assert(*(uintptr_t*)user_data == ~key); } break; @@ -883,14 +883,14 @@ static void* thread_func(void* arg) int was_inserted; user_data = lfl_insert(&list, key, sizeof(uintptr_t), &was_inserted); - assert2(user_data != 0); // only triggers if out of memory + debug_assert(user_data != 0); // only triggers if out of memory *(uintptr_t*)user_data = ~key; // checked above - assert2(was_in_set == !was_inserted); + debug_assert(was_in_set == !was_inserted); user_data = lfh_insert(&hash, key, sizeof(uintptr_t), &was_inserted); - assert2(user_data != 0); // only triggers if out of memory + debug_assert(user_data != 0); // only triggers if out of memory *(uintptr_t*)user_data = ~key; // checked above - assert2(was_in_set == !was_inserted); + debug_assert(was_in_set == !was_inserted); } break; @@ -899,10 +899,10 @@ static void* thread_func(void* arg) int err; err = lfl_erase(&list, key); - assert2(was_in_set == (err == 0)); + debug_assert(was_in_set == (err == 0)); err = lfh_erase(&hash, key); - assert2(was_in_set == (err == 0)); + debug_assert(was_in_set == (err == 0)); } break; @@ -917,7 +917,7 @@ static void* thread_func(void* arg) } // while !is_complete atomic_add(&num_active_threads, -1); - assert2(num_active_threads >= 0); + debug_assert(num_active_threads >= 0); return 0; } @@ -935,11 +935,11 @@ static void multithreaded_torture_test() is_complete = false; err = lfl_init(&list); - assert2(err == 0); + debug_assert(err == 0); err = lfh_init(&hash, 128); - assert2(err == 0); + debug_assert(err == 0); err = pthread_mutex_init(&mutex, 0); - assert2(err == 0); + debug_assert(err == 0); // spin off test threads (many, to force preemption) const uint NUM_THREADS = 16; @@ -959,7 +959,7 @@ static void multithreaded_torture_test() lfl_free(&list); lfh_free(&hash); err = pthread_mutex_destroy(&mutex); - assert2(err == 0); + debug_assert(err == 0); } diff --git a/source/lib/mmgr.cpp b/source/lib/mmgr.cpp index b14faf51ec..3353d3d438 100644 --- a/source/lib/mmgr.cpp +++ b/source/lib/mmgr.cpp @@ -25,7 +25,7 @@ #include #include -#include + #include #include #include @@ -60,7 +60,7 @@ static void lock_init() throw() static void lock_shutdown() throw() { int ret = pthread_mutex_destroy(&mutex); - assert2(ret == 0); + debug_assert(ret == 0); lock_initialized = false; } @@ -69,7 +69,7 @@ static void lock() throw() if(lock_initialized) { int ret = pthread_mutex_lock(&mutex); - assert2(ret == 0); + debug_assert(ret == 0); } } @@ -78,7 +78,7 @@ static void unlock() throw() if(lock_initialized) { int ret = pthread_mutex_unlock(&mutex); - assert2(ret == 0); + debug_assert(ret == 0); } } @@ -115,7 +115,7 @@ uint mmgr_set_options(uint new_options) if(new_options != MMGR_QUERY) { - assert2(!(new_options & ~MMGR_ALL) && "unrecognized options set"); + debug_assert(!(new_options & ~MMGR_ALL) && "unrecognized options set"); options = new_options; } uint ret = options; @@ -139,7 +139,7 @@ static const char* insert_commas(char* out, size_t value) char num[NUM_SIZE]; sprintf(num, "%u", value); const size_t num_len = strlen(num); - assert2(num_len != 0); // messes up #comma calc below + debug_assert(num_len != 0); // messes up #comma calc below const size_t out_len = num_len + (num_len-1)/3; char* pos = out+out_len; @@ -247,7 +247,7 @@ static Alloc* alloc_new() freelist = (Alloc*)calloc(256, sizeof(Alloc)); if(!freelist) { - assert2(0 && "mmgr: failed to allocate freelist (out of memory)"); + debug_assert(0 && "mmgr: failed to allocate freelist (out of memory)"); return 0; } @@ -256,7 +256,7 @@ static Alloc* alloc_new() const size_t bytes = (num_reservoirs + 1) * sizeof(Alloc*); Alloc* *temp = (Alloc* *) realloc(reservoirs, bytes); - assert2(temp); + debug_assert(temp); if(temp) { reservoirs = temp; @@ -347,7 +347,7 @@ static void allocs_add(Alloc* a) static Alloc* allocs_find(const void* user_p) { if(!user_p) - assert2(user_p); + debug_assert(user_p); Alloc* a = hash_chain(user_p); while(a) @@ -605,7 +605,7 @@ static void log_init() log_fp = fopen(log_filename, "w"); if(!log_fp) { - assert2(0 && "log file open failed"); + debug_assert(0 && "log file open failed"); return; } @@ -702,7 +702,7 @@ void mmgr_write_report(void) FILE* f = fopen("mem_report.txt", "w"); if(!f) { - assert2(0 && "open of memory report file failed"); + debug_assert(0 && "open of memory report file failed"); return; } @@ -769,7 +769,7 @@ void mmgr_write_leak_report(void) FILE* f = fopen("mem_leaks.txt", "w"); if(!f) { - assert2(0 && "open of memory leak report file failed"); + debug_assert(0 && "open of memory leak report file failed"); return; } @@ -827,7 +827,7 @@ static bool alloc_is_valid(const Alloc* a) // this allocation has been over/underrun, i.e. modified outside the // allocation's memory range. - assert2(0 && "Memory over/underrun detected by mmgr"); + debug_assert(0 && "Memory over/underrun detected by mmgr"); log("[!] Memory over/underrun:\n"); log_this_alloc(a); return false; @@ -861,13 +861,13 @@ static bool validate_all() // enable MMGR_VALIDATE_ALL, trigger this condition again, // and check the log for the last successful operation. the problem // will have occurred between then and now. - assert2(0); + debug_assert(0); log("[!] Memory tracking hash table corrupt!\n"); } if(params.num_invalid) { - assert2(0); + debug_assert(0); log("[!] %d allocations are corrupt\n", params.num_invalid); } @@ -951,13 +951,13 @@ void mmgr_break_on_realloc(const void* p) Alloc* a = allocs_find(p); if(!a) { - assert2(0 && "setting realloc breakpoint on invalid pointer"); + debug_assert(0 && "setting realloc breakpoint on invalid pointer"); return; } // setting realloc breakpoint on an allocation that // doesn't support realloc. - assert2(a->type == AT_MALLOC || a->type == AT_CALLOC || + debug_assert(a->type == AT_MALLOC || a->type == AT_CALLOC || a->type == AT_REALLOC); a->break_on_realloc = true; @@ -973,7 +973,7 @@ void mmgr_break_on_free(const void* p) Alloc* a = allocs_find(p); if(!a) { - assert2(0 && "setting free breakpoint on invalid pointer"); + debug_assert(0 && "setting free breakpoint on invalid pointer"); return; } @@ -1003,11 +1003,11 @@ void* alloc_dbg(size_t user_size, AllocType type, const char* file, int line, co log("[+] %05d %8s of size 0x%08X(%08d) by %s\n", cur_alloc_count, types[type], user_size, user_size, caller_string); // caller's source file didn't include "mmgr.h" - assert2(type != AT_UNKNOWN); + debug_assert(type != AT_UNKNOWN); // you requested a breakpoint on this allocation number ++cur_alloc_count; - assert2(cur_alloc_count != break_on_count); + debug_assert(cur_alloc_count != break_on_count); // simulate random failures #ifdef RANDOM_FAILURE @@ -1026,7 +1026,7 @@ void* alloc_dbg(size_t user_size, AllocType type, const char* file, int line, co void* p = malloc(size); if(!p) { - assert2(0); + debug_assert(0); log("[!] Allocation failed (out of memory)\n"); goto fail; } @@ -1094,16 +1094,16 @@ void free_dbg(const void* user_p, AllocType type, const char* file, int line, co if(!a) { // you tried to free a pointer mmgr didn't allocate - assert2(0 && "mmgr tried to free a pointer mmgr didn't allocate"); + debug_assert(0 && "mmgr tried to free a pointer mmgr didn't allocate"); log("[!] mmgr_free: not allocated by this memory manager\n"); goto fail; } // .. overrun? (note: alloc_is_valid already asserts if invalid) alloc_is_valid(a); // .. the owner wasn't compiled with mmgr.h - assert2(type != AT_UNKNOWN); + debug_assert(type != AT_UNKNOWN); // .. allocator / deallocator type mismatch - assert2( + debug_assert( (type == AT_DELETE && a->type == AT_NEW ) || (type == AT_DELETE_ARRAY && a->type == AT_NEW_ARRAY) || (type == AT_FREE && a->type == AT_MALLOC ) || @@ -1111,7 +1111,7 @@ void free_dbg(const void* user_p, AllocType type, const char* file, int line, co (type == AT_FREE && a->type == AT_REALLOC ) ); // .. you requested a breakpoint when freeing this allocation - assert2(!a->break_on_free); + debug_assert(!a->break_on_free); // "poison" the allocation's memory, to catch use-after-free bugs. @@ -1157,7 +1157,7 @@ void* realloc_dbg(const void* user_p, size_t user_size, AllocType type, const ch void* ret = 0; uint old_size = 0; - assert2(type == AT_REALLOC); + debug_assert(type == AT_REALLOC); lock(); @@ -1175,18 +1175,18 @@ void* realloc_dbg(const void* user_p, size_t user_size, AllocType type, const ch if(!a) { // you called realloc for a pointer mmgr didn't allocate - assert2(0 && "realloc was called for a pointer mmgr didn't allocate"); + debug_assert(0 && "realloc was called for a pointer mmgr didn't allocate"); log("[!] realloc: wasn't previously allocated\n"); goto fail; } // .. the owner wasn't compiled with mmgr.h - assert2(a->type != AT_UNKNOWN); + debug_assert(a->type != AT_UNKNOWN); // .. realloc for an allocation type that doesn't support it. - assert2(a->type == AT_MALLOC || a->type == AT_CALLOC || + debug_assert(a->type == AT_MALLOC || a->type == AT_CALLOC || a->type == AT_REALLOC); // .. you requested a breakpoint when reallocating this allocation // (it will continue to be triggered unless you clear a->break_on_realloc) - assert2(!a->break_on_realloc); + debug_assert(!a->break_on_realloc); old_size = a->size; } diff --git a/source/lib/mmgr.h b/source/lib/mmgr.h index 20b5bef64e..63134e23d0 100644 --- a/source/lib/mmgr.h +++ b/source/lib/mmgr.h @@ -222,7 +222,7 @@ extern void operator delete[](void* p, const char* file, int line, const char* f // fixing your bugs // ---------------- // -// if this code crashes or fails an assert, it is most likely due to a bug +// if this code crashes or fails an debug_assert, it is most likely due to a bug // in your application. consult the current Alloc for information; // search the log for its address to determine what operation failed, // and what piece of code owns the allocation. diff --git a/source/lib/ogl.cpp b/source/lib/ogl.cpp index 9cc8ba9a3e..148d57adbf 100755 --- a/source/lib/ogl.cpp +++ b/source/lib/ogl.cpp @@ -18,7 +18,7 @@ #include "precompiled.h" -#include + #include #include #include @@ -61,7 +61,7 @@ static bool have_14, have_13, have_12; // (useful for crash logs). const char* oglExtList() { - assert(exts && "call oglInit before using this function"); + debug_assert(exts && "call oglInit before using this function"); return exts; } @@ -128,7 +128,7 @@ static bool isImplementedInCore(const char* ext) // takes subsequently added core support for some extensions into account. bool oglHaveExtension(const char* ext) { - assert(exts && "call oglInit before using this function"); + debug_assert(exts && "call oglInit before using this function"); if(isImplementedInCore(ext)) return true; @@ -388,9 +388,9 @@ static void CALL_CONV emulate_glCompressedTexImage2D( bool dxt1 = (internalformat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || internalformat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); bool dxt3 = (internalformat == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT); bool dxt5 = (internalformat == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT); - assert(dxt1 || dxt3 || dxt5); + debug_assert(dxt1 || dxt3 || dxt5); - assert(imageSize == blocks * (dxt1? 8 : 16)); + debug_assert(imageSize == blocks * (dxt1? 8 : 16)); // This code is inefficient, but I don't care: diff --git a/source/lib/res/cursor.cpp b/source/lib/res/cursor.cpp index adfbe5d07e..ecf92c09c8 100755 --- a/source/lib/res/cursor.cpp +++ b/source/lib/res/cursor.cpp @@ -150,7 +150,7 @@ static int Cursor_reload(Cursor* c, const char* name, Handle) else { // TODO: Handle errors - assert(! "Cursor texture not 32-bit RGBA/BGRA"); + debug_assert(! "Cursor texture not 32-bit RGBA/BGRA"); tex_free(tex); @@ -180,7 +180,7 @@ static int Cursor_reload(Cursor* c, const char* name, Handle) if (! iconbitmap) { // TODO: Handle errors - assert(! "Error creating icon DIB"); + debug_assert(! "Error creating icon DIB"); if (imgdata_bgra != imgdata) delete[] imgdata_bgra; tex_free(tex); @@ -195,7 +195,7 @@ static int Cursor_reload(Cursor* c, const char* name, Handle) if (! cursor) { // TODO: Handle errors - assert(! "Error creating cursor"); + debug_assert(! "Error creating cursor"); if (imgdata_bgra != imgdata) delete[] imgdata_bgra; tex_free(tex); diff --git a/source/lib/res/file.cpp b/source/lib/res/file.cpp index e87a05b460..f4009a2d11 100755 --- a/source/lib/res/file.cpp +++ b/source/lib/res/file.cpp @@ -835,7 +835,7 @@ static u64 block_make_id(const u32 fn_hash, const off_t ofs) // make sure block_num fits in 32 bits const size_t block_num = ofs / BLOCK_SIZE; - assert(block_num <= 0xffffffff); + debug_assert(block_num <= 0xffffffff); u64 id = fn_hash; // careful, don't shift a u32 32 bits left id <<= 32; @@ -1184,7 +1184,7 @@ if(from_cache && !temp) if(err < 0) return err; - assert(issue_cnt >= raw_transferred_cnt && raw_transferred_cnt >= data_size); + debug_assert(issue_cnt >= raw_transferred_cnt && raw_transferred_cnt >= data_size); return (ssize_t)actual_transferred_cnt; } diff --git a/source/lib/res/h_mgr.cpp b/source/lib/res/h_mgr.cpp index 3c92023331..4895f5440b 100755 --- a/source/lib/res/h_mgr.cpp +++ b/source/lib/res/h_mgr.cpp @@ -21,7 +21,7 @@ #include "lib.h" #include "res.h" -#include + #include // CHAR_BIT #include #include @@ -91,13 +91,13 @@ static inline u32 h_tag(const Handle h) static inline Handle handle(const u32 _idx, const u32 tag) { const u32 idx = _idx+1; - assert(idx <= IDX_MASK && tag <= TAG_MASK && "handle: idx or tag too big"); + debug_assert(idx <= IDX_MASK && tag <= TAG_MASK && "handle: idx or tag too big"); // somewhat clunky, but be careful with the shift: // *_SHIFT may be larger than its field's type. Handle h_idx = idx & IDX_MASK; h_idx <<= IDX_SHIFT; Handle h_tag = tag & TAG_MASK; h_tag <<= TAG_SHIFT; Handle h = h_idx | h_tag; - assert(h > 0); + debug_assert(h > 0); return h; } @@ -273,7 +273,7 @@ static int alloc_idx(i32& idx, HDATA*& hd) for(idx = 0; idx <= last_in_use; idx++) { hd = h_data_from_idx(idx); - assert(hd); // can't fail - idx is valid + debug_assert(hd); // can't fail - idx is valid // found one - done if(!hd->tag) @@ -283,7 +283,7 @@ static int alloc_idx(i32& idx, HDATA*& hd) // add another if(last_in_use >= hdata_cap) { - assert(!"alloc_idx: too many open handles (increase IDX_BITS)"); + debug_assert(!"alloc_idx: too many open handles (increase IDX_BITS)"); return ERR_LIMIT; } idx = last_in_use+1; // just incrementing idx would start it at 1 @@ -293,7 +293,7 @@ static int alloc_idx(i32& idx, HDATA*& hd) // can't fail for any other reason - idx is checked above. { // VC6 goto fix bool is_unused = !hd->tag; - assert(is_unused && "alloc_idx: invalid last_in_use"); + debug_assert(is_unused && "alloc_idx: invalid last_in_use"); } have_idx:; @@ -373,7 +373,7 @@ static void add_key(uintptr_t key, Handle h) static void remove_key(uintptr_t key, H_Type type) { Handle ret = find_key(key, type, true); - assert(ret > 0); + debug_assert(ret > 0); } diff --git a/source/lib/res/h_mgr.h b/source/lib/res/h_mgr.h index 02f6a942ac..9677729eef 100755 --- a/source/lib/res/h_mgr.h +++ b/source/lib/res/h_mgr.h @@ -359,7 +359,7 @@ guide to defining and using resources } again no provision for reporting errors - there's no one to act on it - if called at exit. you can assert or log the error, though. + if called at exit. you can debug_assert or log the error, though. 5) provide your layer on top of the handle manager: Handle res1_load(const char* filename, int my_flags) diff --git a/source/lib/res/mem.cpp b/source/lib/res/mem.cpp index f1fdc26784..cf9b177506 100755 --- a/source/lib/res/mem.cpp +++ b/source/lib/res/mem.cpp @@ -6,7 +6,7 @@ #include "res.h" #include -#include + #include @@ -105,7 +105,7 @@ static void remove_alloc(void* raw_p) { size_t num_removed = ptr_to_h.erase(raw_p); if(num_removed != 1) - assert(num_removed == 1 && "remove_alloc: not in map"); + debug_assert(num_removed == 1 && "remove_alloc: not in map"); } @@ -388,7 +388,7 @@ void* mem_get_ptr(Handle hm, size_t* user_size /* = 0 */) return 0; } - assert((!m->p || m->size) && "mem_get_ptr: mem corrupted (p valid =/=> size > 0)"); + debug_assert((!m->p || m->size) && "mem_get_ptr: mem corrupted (p valid =/=> size > 0)"); if(user_size) *user_size = m->size; diff --git a/source/lib/res/ogghack.cpp b/source/lib/res/ogghack.cpp index bc8c9b9f6f..0b954b4a49 100755 --- a/source/lib/res/ogghack.cpp +++ b/source/lib/res/ogghack.cpp @@ -128,7 +128,7 @@ void ogg_open(void* _o, ALenum& fmt, ALsizei& freq) void* datasource = &o->incoming_bufs; if(ov_open_callbacks(datasource, &o->oggStream, NULL, 0, cbs) < 0) { - assert(!"ov_open failed"); + debug_assert(!"ov_open failed"); } o->vorbisInfo = ov_info(&o->oggStream, -1); @@ -166,7 +166,7 @@ size_t ogg_read(void* _o, void* buf, size_t max_size) if(result > 0) bytes_written += result; else if(result < 0) - assert(!"ogg read error"); + debug_assert(!"ogg read error"); // clean break - end of data else break; diff --git a/source/lib/res/ogl_tex.cpp b/source/lib/res/ogl_tex.cpp index a1e3aa9133..8aa494d975 100755 --- a/source/lib/res/ogl_tex.cpp +++ b/source/lib/res/ogl_tex.cpp @@ -109,13 +109,13 @@ static int get_gl_fmt(int bpp, int flags, GLenum* fmt, GLenum* int_fmt) *int_fmt = high_quality? GL_LUMINANCE8_ALPHA8 : GL_LUMINANCE4_ALPHA4; return 0; case 24: - assert(!alpha); + debug_assert(!alpha); *fmt = bgr? GL_BGR : GL_RGB; *int_fmt = high_quality? GL_RGB8 : GL_RGB4; // note: BGR can't be used as internal format return 0; case 32: - assert(alpha); + debug_assert(alpha); *fmt = bgr? GL_BGRA : GL_RGBA; *int_fmt = high_quality? GL_RGBA8 : GL_RGBA4; // note: BGR can't be used as internal format @@ -126,7 +126,7 @@ static int get_gl_fmt(int bpp, int flags, GLenum* fmt, GLenum* int_fmt) } // unreachable - assert(0); + debug_assert(0); } diff --git a/source/lib/res/snd.cpp b/source/lib/res/snd.cpp index 7146a0aa18..547b5dcaf3 100755 --- a/source/lib/res/snd.cpp +++ b/source/lib/res/snd.cpp @@ -45,6 +45,7 @@ # include "sysdep/win/win_internal.h" #endif + #define OGG_HACK #include "ogghack.h" @@ -104,7 +105,7 @@ static void hsd_list_free_all(); // 1 error at a time, so this is called after every OpenAL request. static void al_check(const char* caller = "(unknown)") { - assert(al_initialized); + debug_assert(al_initialized); ALenum err = alGetError(); if(err == AL_NO_ERROR) @@ -206,6 +207,21 @@ static int alc_init() dlls[2] = LoadLibrary("wdmaud.drv"); #endif + // for reasons unknown, the NV native OpenAL implementation + // causes an invalid exception internally when loaded (it's not + // caused by the DLL load hack above). we need to catch it to + // prevent the unhandled exception filter from reporting it. +#ifdef _WIN32 + __try + { + alc_dev = alcOpenDevice((ALubyte*)alc_dev_name); + } + __except(1) // EXCEPTION_E XECUTE_HANDLER + { + debug_assert(!"hit me"); + } +#endif + alc_dev = alcOpenDevice((ALubyte*)alc_dev_name); if(alc_dev) { @@ -337,7 +353,7 @@ static void al_buf_free(ALuint al_buf) if(!al_buf) return; - assert(alIsBuffer(al_buf)); + debug_assert(alIsBuffer(al_buf)); alDeleteBuffers(1, &al_buf); al_check("al_buf_free"); @@ -386,7 +402,7 @@ static void al_src_init() // we've reached the limit, no more are available. if(alGetError() != AL_NO_ERROR) break; - assert(alIsSource(al_srcs[i])); + debug_assert(alIsSource(al_srcs[i])); al_src_allocated++; } @@ -396,7 +412,7 @@ static void al_src_init() al_src_cap = al_src_allocated; // make sure we got the minimum guaranteed by OpenAL. - assert(al_src_allocated >= 16); + debug_assert(al_src_allocated >= 16); } @@ -405,7 +421,7 @@ static void al_src_init() // called from al_shutdown. static void al_src_shutdown() { - assert(al_src_used == 0); + debug_assert(al_src_used == 0); alDeleteSources(al_src_allocated, al_srcs); al_src_allocated = 0; al_check("al_src_shutdown"); @@ -424,9 +440,9 @@ static ALuint al_src_alloc() static void al_src_free(ALuint al_src) { - assert(alIsSource(al_src)); + debug_assert(alIsSource(al_src)); al_srcs[--al_src_used] = al_src; - assert(al_src_used < al_src_allocated); + debug_assert(al_src_used < al_src_allocated); // don't compare against cap - it might have been // decreased to less than were in use. } @@ -598,7 +614,7 @@ static void* io_buf_freelist; static void io_buf_free(void* p) { - assert(io_bufs <= p && p <= (char*)io_bufs+TOTAL_BUF_SIZE); + debug_assert(io_bufs <= p && p <= (char*)io_bufs+TOTAL_BUF_SIZE); *(void**)p = io_buf_freelist; io_buf_freelist = p; } diff --git a/source/lib/res/tex.cpp b/source/lib/res/tex.cpp index 95dde920bc..8906e8ee28 100755 --- a/source/lib/res/tex.cpp +++ b/source/lib/res/tex.cpp @@ -20,7 +20,7 @@ #include #include -#include + #include @@ -1025,7 +1025,7 @@ fail: png_read_image(png_ptr, (png_bytepp)rows); png_read_end(png_ptr, info_ptr); - assert(f.p == file && f.size == file_size && f.pos == f.size); + debug_assert(f.p == file && f.size == file_size && f.pos == f.size); // store image info mem_free_h(t->hm); diff --git a/source/lib/res/unifont.cpp b/source/lib/res/unifont.cpp index 453553e86e..a40753c069 100755 --- a/source/lib/res/unifont.cpp +++ b/source/lib/res/unifont.cpp @@ -19,7 +19,7 @@ Unicode OpenGL texture font #include #include -#include + /*/*#include #define LOG_CATEGORY "graphics"*/ @@ -154,7 +154,7 @@ static int UniFont_reload(UniFont* f, const char* fn, Handle UNUSEDPARAM(h)) (*f->glyphs_size)[(wchar_t)Codepoint] = Advance; } - assert(f->Height); // Ensure the height has been found (which should always happen if the font includes an 'I') + debug_assert(f->Height); // Ensure the height has been found (which should always happen if the font includes an 'I') // Load glyph texture std::string FilenameTex = FilenameBase+".tga"; @@ -232,7 +232,7 @@ void glvwprintf(const wchar_t* fmt, va_list args) // Make sure there's always null termination buf[buf_size-1] = 0; - assert(BoundGlyphs != NULL); // You always need to bind something first + debug_assert(BoundGlyphs != NULL); // You always need to bind something first // Count the number of characters size_t len = wcslen(buf); diff --git a/source/lib/res/vfs.cpp b/source/lib/res/vfs.cpp index 60d8a547f8..aff4b07933 100755 --- a/source/lib/res/vfs.cpp +++ b/source/lib/res/vfs.cpp @@ -647,7 +647,7 @@ int vfs_make_vfs_path(const char* path, char* vfs_path) // used by vfs_realpath and VFile_reopen. static int make_file_path(char* path, const char* vfs_path, const TMountPoint* mount_point) { - assert(mount_point->archive == 0); + debug_assert(mount_point->archive == 0); const char* remove = mount_point->v_mount_point.c_str(); const char* replace = mount_point->p_real_path.c_str(); @@ -925,14 +925,14 @@ H_TYPE_DEFINE(VFile); static off_t& vf_size(VFile* vf) { - assert(offsetof(struct File, size) == offsetof(struct ZFile, ucsize)); + debug_assert(offsetof(struct File, size) == offsetof(struct ZFile, ucsize)); return vf->f.size; } static uint& vf_flags(VFile* vf) { - assert(offsetof(struct File, flags) == offsetof(struct ZFile, flags)); + debug_assert(offsetof(struct File, flags) == offsetof(struct ZFile, flags)); return vf->f.flags; } @@ -1179,7 +1179,7 @@ debug_printf("vfs_load v_fn=%s\n", v_fn); p = mem_get_ptr(vf->hm, &size); if(p) { - assert(vf_size(vf) == (off_t)size && "vfs_load: mismatch between File and Mem size"); + debug_assert(vf_size(vf) == (off_t)size && "vfs_load: mismatch between File and Mem size"); hm = vf->hm; goto ret; } diff --git a/source/lib/res/vfs_tree.cpp b/source/lib/res/vfs_tree.cpp index 49b0c9a4de..d7c031a1da 100644 --- a/source/lib/res/vfs_tree.cpp +++ b/source/lib/res/vfs_tree.cpp @@ -458,7 +458,7 @@ int TDir::lookup(const char* path, uint flags, TNode** pnode, char* exact_path) } CHECK_PATH(path); - assert( (flags & ~(LF_CREATE_MISSING|LF_START_DIR)) == 0 ); + debug_assert( (flags & ~(LF_CREATE_MISSING|LF_START_DIR)) == 0 ); // no undefined bits set const bool create_missing = !!(flags & LF_CREATE_MISSING); @@ -716,7 +716,7 @@ struct NodeLatch const TNode* get_next() { - assert(!empty()); + debug_assert(!empty()); return v[i++]; } }; diff --git a/source/lib/res/zip.cpp b/source/lib/res/zip.cpp index b566237c97..731d6c51b3 100755 --- a/source/lib/res/zip.cpp +++ b/source/lib/res/zip.cpp @@ -43,7 +43,7 @@ #include -#include + #include // provision for removing all ZLib code (all inflate calls will fail). @@ -209,7 +209,7 @@ static time_t convert_dos_date(u16 fatdate, u16 fattime) t.tm_year = bits(fatdate, 9,15) + 80; // since 1900 t.tm_isdst = -1; // unknown - let libc determine - assert(t.tm_year < 138); + debug_assert(t.tm_year < 138); // otherwise: totally bogus, and at the limit of 32-bit time_t time_t ret = mktime(&t); @@ -462,7 +462,7 @@ static int lookup_add_file_cb(uintptr_t user, i32 idx, // adding a regular file. - assert(idx < li->num_entries); + debug_assert(idx < li->num_entries); FnHash fn_hash = fnv_lc_hash(fn, fn_len); // fill ZEnt @@ -553,7 +553,7 @@ static int lookup_get_file_info(LookupInfo* li, const char* fn, ZLoc* loc) return ERR_FILE_NOT_FOUND; i = it->second; - assert(0 <= i && i < li->num_files); + debug_assert(0 <= i && i < li->num_files); } have_idx: @@ -842,7 +842,7 @@ total_inf_time += t1-t0; // which doesn't abort the read. size_t avail_out = zs->avail_out; - assert(avail_out <= prev_avail_out); + debug_assert(avail_out <= prev_avail_out); // make sure output buffer size didn't magically increase ssize_t nread = (ssize_t)(prev_avail_out - avail_out); if(!nread) diff --git a/source/lib/string_s.cpp b/source/lib/string_s.cpp index dc93d7fbf1..92078b605e 100644 --- a/source/lib/string_s.cpp +++ b/source/lib/string_s.cpp @@ -62,7 +62,7 @@ #define ENFORCE(condition, retval) STMT(\ if(!(condition)) \ { \ - assert2(condition); \ + debug_assert(condition); \ return retval; \ } \ ) @@ -88,7 +88,7 @@ size_t tlen_s(const tchar* str, size_t max_len) { // note: we can't bail - what would the return value be? - assert2(str != 0); + debug_assert(str != 0); WARN_IF_PTR_LEN(max_len); @@ -234,53 +234,53 @@ static tchar no_null[] = { 'n','o','_','n','u','l','l'}; #define TEST_LEN(string, limit, expected) \ STMT( \ - assert2(tlen_s((string), (limit)) == (expected)); \ + debug_assert(tlen_s((string), (limit)) == (expected)); \ ) #define TEST_CPY(dst, dst_max, src, expected_ret, expected_dst) \ STMT( \ int ret = tcpy_s((dst), dst_max, (src)); \ - assert2(ret == expected_ret); \ + debug_assert(ret == expected_ret); \ if(dst != 0) \ - assert2(!tcmp(dst, T(expected_dst))); \ + debug_assert(!tcmp(dst, T(expected_dst))); \ ) #define TEST_CPY2(dst, src, expected_ret, expected_dst) \ STMT( \ int ret = tcpy_s((dst), ARRAY_SIZE(dst), (src)); \ - assert2(ret == expected_ret); \ + debug_assert(ret == expected_ret); \ if(dst != 0) \ - assert2(!tcmp(dst, T(expected_dst))); \ + debug_assert(!tcmp(dst, T(expected_dst))); \ ) #define TEST_NCPY(dst, src, max_src_chars, expected_ret, expected_dst) \ STMT( \ int ret = tncpy_s((dst), ARRAY_SIZE(dst), (src), (max_src_chars)); \ - assert2(ret == expected_ret); \ + debug_assert(ret == expected_ret); \ if(dst != 0) \ - assert2(!tcmp(dst, T(expected_dst))); \ + debug_assert(!tcmp(dst, T(expected_dst))); \ ) #define TEST_CAT(dst, dst_max, src, expected_ret, expected_dst) \ STMT( \ int ret = tcat_s((dst), dst_max, (src)); \ - assert2(ret == expected_ret); \ + debug_assert(ret == expected_ret); \ if(dst != 0) \ - assert2(!tcmp(dst, T(expected_dst))); \ + debug_assert(!tcmp(dst, T(expected_dst))); \ ) #define TEST_CAT2(dst, dst_val, src, expected_ret, expected_dst) \ STMT( \ tcpy(dst, T(dst_val)); \ int ret = tcat_s((dst), ARRAY_SIZE(dst), (src)); \ - assert2(ret == expected_ret); \ + debug_assert(ret == expected_ret); \ if(dst != 0) \ - assert2(!tcmp(dst, T(expected_dst))); \ + debug_assert(!tcmp(dst, T(expected_dst))); \ ) #define TEST_NCAT(dst, dst_val, src, max_src_chars, expected_ret, expected_dst)\ STMT( \ tcpy(dst, T(dst_val)); \ int ret = tncat_s((dst), ARRAY_SIZE(dst), (src), (max_src_chars)); \ - assert2(ret == expected_ret); \ + debug_assert(ret == expected_ret); \ if(dst != 0) \ - assert2(!tcmp(dst, T(expected_dst))); \ + debug_assert(!tcmp(dst, T(expected_dst))); \ ) diff --git a/source/lib/sysdep/ia32.cpp b/source/lib/sysdep/ia32.cpp index d121b1629a..a847caa839 100755 --- a/source/lib/sysdep/ia32.cpp +++ b/source/lib/sysdep/ia32.cpp @@ -28,7 +28,7 @@ #include "win/wtime.h" #endif -#include + #include #include @@ -454,7 +454,7 @@ int get_cur_processor_id() // called on each CPU by on_each_cpu. static void check_smp() { - assert(cpus > 0 && "must know # CPUs (call OS-specific detect first)"); + debug_assert(cpus > 0 && "must know # CPUs (call OS-specific detect first)"); // we don't check if it's Intel and P4 or above - HT may be supported // on other CPUs in future. haven't come across a processor that @@ -566,7 +566,7 @@ __declspec(naked) bool __cdecl CAS_(uintptr_t* location, uintptr_t expected, uin { // try to see if caller isn't passing in an address // (CAS's arguments are silently casted) - assert2(location >= (uintptr_t*)0x10000); + debug_assert(location >= (uintptr_t*)0x10000); __asm { @@ -621,7 +621,7 @@ bool CAS_(uintptr_t* location, uintptr_t expected, uintptr_t new_value) { uintptr_t prev; - assert2(location >= (uintptr_t *)0x10000); + debug_assert(location >= (uintptr_t *)0x10000); __asm__ __volatile__("lock; cmpxchgl %1,%2" : "=a"(prev) // %0: Result in eax should be stored in prev diff --git a/source/lib/sysdep/sysdep.h b/source/lib/sysdep/sysdep.h index c29176d219..2e3666611c 100755 --- a/source/lib/sysdep/sysdep.h +++ b/source/lib/sysdep/sysdep.h @@ -30,7 +30,7 @@ enum DisplayErrorFlags DE_MANUAL_BREAK = 4 }; -// user choices in the assert/unhandled exception dialog. +// user choices in the debug_assert/unhandled exception dialog. enum ErrorReaction { // ignore, continue as if nothing happened. diff --git a/source/lib/sysdep/win/printf.cpp b/source/lib/sysdep/win/printf.cpp index 44e6fb639d..fe3acc03b9 100755 --- a/source/lib/sysdep/win/printf.cpp +++ b/source/lib/sysdep/win/printf.cpp @@ -27,7 +27,7 @@ #include #include #include -#include + #include #include #include @@ -271,7 +271,7 @@ extern "C" int vsnprintf2(TCHAR* buffer, size_t count, const TCHAR* format, va_l if (chr == _T('I')) { - assert(! "MSVC-style \"%I64\" is not allowed!"); + debug_assert(! "MSVC-style \"%I64\" is not allowed!"); } if (is_lengthmod(chr)) @@ -420,7 +420,7 @@ finished_reading: { if (varsizes[i] <= 0) { - assert(! "Invalid variable type somewhere - make sure all variable things are positional and defined"); + debug_assert(! "Invalid variable type somewhere - make sure all variable things are positional and defined"); return -1; } @@ -442,7 +442,7 @@ finished_reading: FormatVariable* s = static_cast(*it); if (s->position <= 0) { - assert(! "Invalid use of positional elements - make sure all variable things are positional and defined"); + debug_assert(! "Invalid use of positional elements - make sure all variable things are positional and defined"); return -1; } newstack += std::string( stackitems[s->position-1].first, stackitems[s->position-1].second ); diff --git a/source/lib/sysdep/win/waio.cpp b/source/lib/sysdep/win/waio.cpp index dbf3b1bd62..a4182b13b8 100755 --- a/source/lib/sysdep/win/waio.cpp +++ b/source/lib/sysdep/win/waio.cpp @@ -22,7 +22,7 @@ #include "posix.h" #include "win_internal.h" -#include + #include #include // _aligned_malloc @@ -304,7 +304,7 @@ static void req_cleanup(void) for(int i = 0; i < MAX_REQS; i++, r++) { HANDLE& h = r->ovl.hEvent; - assert(h != INVALID_HANDLE_VALUE); + debug_assert(h != INVALID_HANDLE_VALUE); CloseHandle(h); h = INVALID_HANDLE_VALUE; @@ -339,7 +339,7 @@ static Req* req_find(const aiocb* cb) static Req* req_alloc(aiocb* cb) { - assert(cb); + debug_assert(cb); // first free Req, or 0 Req* r = req_find(0); @@ -353,7 +353,7 @@ static Req* req_alloc(aiocb* cb) static int req_free(Req* r) { - assert(r->cb != 0 && "req_free: not currently in use"); + debug_assert(r->cb != 0 && "req_free: not currently in use"); r->cb = 0; return 0; } @@ -390,7 +390,7 @@ static int aio_rw(struct aiocb* cb) const size_t size = cb->aio_nbytes; const off_t ofs = cb->aio_offset; void* buf = (void*)cb->aio_buf; // from volatile void* - assert(buf); + debug_assert(buf); // allocate IO request r = req_alloc(cb); @@ -566,7 +566,7 @@ ssize_t aio_return(struct aiocb* cb) return -1; } - assert(r->ovl.Internal == 0 && "aio_return with transfer in progress"); + debug_assert(r->ovl.Internal == 0 && "aio_return with transfer in progress"); const BOOL wait = FALSE; // should already be done! DWORD bytes_transferred; @@ -738,7 +738,7 @@ static int waio_init() SetErrorMode(old_err_mode); - assert(is_pow2((long)sector_size)); + debug_assert(is_pow2((long)sector_size)); return 0; } diff --git a/source/lib/sysdep/win/wcpu.cpp b/source/lib/sysdep/win/wcpu.cpp index d40b0ca859..38265d79cc 100755 --- a/source/lib/sysdep/win/wcpu.cpp +++ b/source/lib/sysdep/win/wcpu.cpp @@ -249,7 +249,7 @@ static uintptr_t get_target_pc() ///////////////////////////////////////////// ret = ResumeThread(hThread); - assert(ret != 0); + debug_assert(ret != 0); // don't fail (we have a valid PC), but warn return pc; diff --git a/source/lib/sysdep/win/wdetect.cpp b/source/lib/sysdep/win/wdetect.cpp index 688ffc69e1..b6d9a619d5 100755 --- a/source/lib/sysdep/win/wdetect.cpp +++ b/source/lib/sysdep/win/wdetect.cpp @@ -24,7 +24,7 @@ #include "win_internal.h" -#include + #include #include @@ -429,7 +429,7 @@ static void add_oal_dlls_in_dir(const char* dir, DllSet* dlls) const int len = snprintf(path, MAX_PATH, "%s\\", dir); if(len < 0) { - assert(0); + debug_assert(0); return; } PathInfo pi = { path, path+len, MAX_PATH-len, dlls }; diff --git a/source/lib/sysdep/win/wdir_watch.cpp b/source/lib/sysdep/win/wdir_watch.cpp index c28a36425f..c4c4f4a612 100755 --- a/source/lib/sysdep/win/wdir_watch.cpp +++ b/source/lib/sysdep/win/wdir_watch.cpp @@ -21,7 +21,7 @@ #include "win_internal.h" #include "lib/res/file.h" // file_is_subpath -#include + #include #include @@ -240,7 +240,7 @@ int dir_add_watch(const char* dir, intptr_t* _reqnum) try { Watch* w = new Watch(reqnum, dir_s, hDir); - assert(w != 0); // happened once; heap corruption? + debug_assert(w != 0); // happened once; heap corruption? // add trailing \ if not already there if(dir_s[dir_s.length()-1] != '\\') @@ -285,7 +285,7 @@ int dir_cancel_watch(const intptr_t reqnum) } // we're freeing a reference - done. - assert(w->refs >= 1); + debug_assert(w->refs >= 1); if(--w->refs != 0) return 0; @@ -304,7 +304,7 @@ int dir_cancel_watch(const intptr_t reqnum) static int extract_events(Watch* w) { - assert(w); + debug_assert(w); // points to current FILE_NOTIFY_INFORMATION; // char* simplifies advancing to the next (variable length) FNI. diff --git a/source/lib/sysdep/win/wposix.cpp b/source/lib/sysdep/win/wposix.cpp index 020ceb835c..7c24ceb014 100755 --- a/source/lib/sysdep/win/wposix.cpp +++ b/source/lib/sysdep/win/wposix.cpp @@ -24,7 +24,7 @@ #include "posix.h" #include "win_internal.h" -#include + #include #include @@ -113,7 +113,7 @@ int close(int fd) debug_printf("close %d\n", fd); #endif - assert(3 <= fd && fd < 256); + debug_assert(3 <= fd && fd < 256); // note: there's no good way to notify us that wasn't opened for // AIO, so we could skip aio_close. storing a bit in the fd is evil and @@ -214,13 +214,13 @@ static void detect_filesystem() { char root_path[MAX_PATH] = "c:\\"; // default in case GCD fails DWORD gcd_ret = GetCurrentDirectory(sizeof(root_path), root_path); - assert2(gcd_ret != 0); + debug_assert(gcd_ret != 0); // if this fails, no problem - we have the default from above. root_path[3] = '\0'; // cut off after "c:\" char fs_name[32]; BOOL ret = GetVolumeInformation(root_path, 0,0,0,0,0, fs_name, sizeof(fs_name)); - assert2(ret != 0); + debug_assert(ret != 0); // if this fails, no problem - we really only care if fs is FAT, // and will assume that's not the case (since fs_name != "FAT"). @@ -525,7 +525,7 @@ void* mmap(void* user_start, size_t len, int prot, int flags, int fd, off_t offs if(flags & MAP_FIXED) { start = user_start; - if(start == 0) // assert below would fire + if(start == 0) // debug_assert below would fire goto fail; } @@ -584,7 +584,7 @@ void* mmap(void* user_start, size_t len, int prot, int flags, int fd, off_t offs // but after freeing the mapping object. goto fail; - assert(!(flags & MAP_FIXED) || (ptr == start)); + debug_assert(!(flags & MAP_FIXED) || (ptr == start)); // fixed => ptr = start WIN_RESTORE_LAST_ERROR; diff --git a/source/lib/sysdep/win/wpthread.cpp b/source/lib/sysdep/win/wpthread.cpp index a3c8630ae1..10daf7b696 100644 --- a/source/lib/sysdep/win/wpthread.cpp +++ b/source/lib/sysdep/win/wpthread.cpp @@ -125,7 +125,7 @@ int pthread_key_create(pthread_key_t* key, void (*dtor)(void*)) if(idx == TLS_OUT_OF_INDEXES) return -ENOMEM; - assert2(idx < TLS_LIMIT); + debug_assert(idx < TLS_LIMIT); *key = (pthread_key_t)idx; // store dtor @@ -146,10 +146,10 @@ int pthread_key_create(pthread_key_t* key, void (*dtor)(void*)) int pthread_key_delete(pthread_key_t key) { DWORD idx = (DWORD)key; - assert2(idx < TLS_LIMIT); + debug_assert(idx < TLS_LIMIT); BOOL ret = TlsFree(idx); - assert2(ret != 0); + debug_assert(ret != 0); return 0; } @@ -157,7 +157,7 @@ int pthread_key_delete(pthread_key_t key) void* pthread_getspecific(pthread_key_t key) { DWORD idx = (DWORD)key; - assert2(idx < TLS_LIMIT); + debug_assert(idx < TLS_LIMIT); // TlsGetValue sets last error to 0 on success (boo). // we don't want this to hide previous errors, so it's restored below. @@ -183,10 +183,10 @@ void* pthread_getspecific(pthread_key_t key) int pthread_setspecific(pthread_key_t key, const void* value) { DWORD idx = (DWORD)key; - assert2(idx < TLS_LIMIT); + debug_assert(idx < TLS_LIMIT); BOOL ret = TlsSetValue(idx, (void*)value); - assert2(ret != 0); + debug_assert(ret != 0); return 0; } @@ -210,7 +210,7 @@ again: if(tls) { int ret = pthread_setspecific(key, 0); - assert2(ret == 0); + debug_assert(ret == 0); dtor(tls); had_valid_tls = true; diff --git a/source/lib/sysdep/win/wsdl.cpp b/source/lib/sysdep/win/wsdl.cpp index 9c7a1152f4..f9f8da7bff 100755 --- a/source/lib/sysdep/win/wsdl.cpp +++ b/source/lib/sysdep/win/wsdl.cpp @@ -42,7 +42,7 @@ #include #include // _beginthreadex -#include + #include #include @@ -271,7 +271,7 @@ inline SDLKey vkmap(int vk) ONCE( init_vkmap(VK_SDLKMap); ); - assert(vk >= 0 && vk < 256); + debug_assert(vk >= 0 && vk < 256); return VK_SDLKMap[vk]; } @@ -279,7 +279,7 @@ inline SDLKey vkmap(int vk) int SDL_WaitEvent(SDL_Event* ev) { - assert(ev == 0 && "can't store event, since wsdl doesn't have a real queue"); + debug_assert(ev == 0 && "can't store event, since wsdl doesn't have a real queue"); WaitMessage(); return 0; } @@ -299,7 +299,7 @@ int SDL_PollEvent(SDL_Event* ev) // input is waiting in buffer return_char: - assert(num_chars <= CHAR_BUF_SIZE); + debug_assert(num_chars <= CHAR_BUF_SIZE); if(num_chars > 0) { num_chars--; @@ -387,7 +387,7 @@ return_char: default: if( ( msg.message >= WM_APP ) && ( msg.message < 0xC000 ) ) // 0xC000 = maximum application message { - assert( SDL_USEREVENT+(msg.message-WM_APP) <= 0xff && "Message too far above WM_APP"); + debug_assert( SDL_USEREVENT+(msg.message-WM_APP) <= 0xff && "Message too far above WM_APP"); ev->type = (u8)(SDL_USEREVENT+(msg.message-WM_APP)); ev->user.code = (int)msg.wParam; return 1; @@ -506,13 +506,13 @@ static void enable_kbd_hook(bool enable) /* if(enable) { - assert(hKeyboard_LL_Hook == 0); + debug_assert(hKeyboard_LL_Hook == 0); hKeyboard_LL_Hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_ll_hook, hInst, 0); - assert(hKeyboard_LL_Hook != 0); + debug_assert(hKeyboard_LL_Hook != 0); } else { - assert(hKeyboard_LL_Hook != 0); + debug_assert(hKeyboard_LL_Hook != 0); UnhookWindowsHookEx(hKeyboard_LL_Hook); hKeyboard_LL_Hook = 0; } diff --git a/source/lib/sysdep/win/wsock.cpp b/source/lib/sysdep/win/wsock.cpp index 584efb0f8e..dddf106871 100755 --- a/source/lib/sysdep/win/wsock.cpp +++ b/source/lib/sysdep/win/wsock.cpp @@ -22,7 +22,7 @@ #include "wsock.h" #include "wdll.h" -#include + #ifdef _MSC_VER #pragma comment(lib, "ws2_32.lib") diff --git a/source/lib/sysdep/win/wtime.cpp b/source/lib/sysdep/win/wtime.cpp index 1c377cea0d..895032b203 100755 --- a/source/lib/sysdep/win/wtime.cpp +++ b/source/lib/sysdep/win/wtime.cpp @@ -306,7 +306,7 @@ static i64 ticks_lk() { LARGE_INTEGER i; BOOL ok = QueryPerformanceCounter(&i); - assert(ok); // shouldn't fail if it was chosen above + debug_assert(ok); // shouldn't fail if it was chosen above return i.QuadPart; } #endif @@ -336,8 +336,8 @@ static i64 ticks_lk() // (not a problem, but avoids a BoundsChecker warning) static double time_lk() { - assert(hrt_cur_freq > 0.0); - assert(hrt_cal_ticks > 0); + debug_assert(hrt_cur_freq > 0.0); + debug_assert(hrt_cal_ticks > 0); // elapsed ticks and time since last calibration const i64 delta_ticks = ticks_lk() - hrt_cal_ticks; @@ -381,7 +381,7 @@ static int reset_impl_lk() old_time = time_lk(); CHECK_ERR(choose_impl()); - assert(hrt_impl != HRT_NONE && hrt_nominal_freq > 0.0); + debug_assert(hrt_impl != HRT_NONE && hrt_nominal_freq > 0.0); // impl has changed; reset timer state. if(old_impl != hrt_impl) @@ -427,7 +427,7 @@ lock(); double freq = hrt_cur_freq; unlock(); - assert(freq != -1.0 && "hrt_delta_s: hrt_cur_freq not set"); + debug_assert(freq != -1.0 && "hrt_delta_s: hrt_cur_freq not set"); return (end - start) / freq; } @@ -447,7 +447,7 @@ lock(); unlock(); - assert(nominal_freq > 0.0 && "hrt_query_impl: invalid hrt_nominal_freq"); + debug_assert(nominal_freq > 0.0 && "hrt_query_impl: invalid hrt_nominal_freq"); } @@ -502,7 +502,7 @@ static long safe_time() // lock must be held. static void calibrate_lk() { - assert(hrt_cal_ticks > 0); + debug_assert(hrt_cal_ticks > 0); // we're called from a WinMM event or after thread wakeup, // so the timer has just been updated. @@ -547,7 +547,7 @@ static void calibrate_lk() hrt_cur_freq = hrt_nominal_freq; } - assert(hrt_cur_freq > 0.0); + debug_assert(hrt_cur_freq > 0.0); } @@ -775,7 +775,7 @@ static void sleep_ns(i64 ns) int clock_gettime(clockid_t clock, struct timespec* t) { - assert(clock == CLOCK_REALTIME); + debug_assert(clock == CLOCK_REALTIME); const i64 ns = time_ns(); t->tv_sec = (time_t)((ns / _1e9) & 0xffffffff); @@ -786,7 +786,7 @@ int clock_gettime(clockid_t clock, struct timespec* t) int clock_getres(clockid_t clock, struct timespec* ts) { - assert(clock == CLOCK_REALTIME); + debug_assert(clock == CLOCK_REALTIME); HRTImpl impl; double nominal_freq, res; diff --git a/source/main.cpp b/source/main.cpp index 9d7a737d85..68dd0a79f3 100755 --- a/source/main.cpp +++ b/source/main.cpp @@ -681,7 +681,7 @@ static void LoadGlobals() float gain; val->GetFloat(gain); int ret = snd_set_master_gain(gain); - assert2(ret == 0); + debug_assert(ret == 0); } LOG(NORMAL, LOG_CATEGORY, "g_x/yres is %dx%d", g_xres, g_yres); @@ -1374,7 +1374,7 @@ static void Frame() last_time = time; ONCE(return); // first call: set last_time and return - assert(TimeSinceLastFrame >= 0.0f); + debug_assert(TimeSinceLastFrame >= 0.0f); PROFILE_START( "reload changed files" ); MICROLOG(L"reload files"); diff --git a/source/maths/Bound.cpp b/source/maths/Bound.cpp index f739c75351..ecc6f4f0b0 100755 --- a/source/maths/Bound.cpp +++ b/source/maths/Bound.cpp @@ -9,7 +9,7 @@ #include "precompiled.h" // necessary includes -#include + #include #include "Bound.h" @@ -147,7 +147,7 @@ bool CBound::IsEmpty() // (can't remember which one it was, though) void CBound::Transform(const CMatrix3D& m,CBound& result) const { - assert(this!=&result); + debug_assert(this!=&result); for (int i=0;i<3;++i) { // handle translation diff --git a/source/ps/CConsole.cpp b/source/ps/CConsole.cpp index a902542942..a880e85700 100755 --- a/source/ps/CConsole.cpp +++ b/source/ps/CConsole.cpp @@ -473,7 +473,7 @@ void CConsole::ProcessBuffer(const wchar_t* szLine){ if (szLine == NULL) return; if (wcslen(szLine) <= 0) return; - assert(wcslen(szLine) < CONSOLE_BUFFER_SIZE); + debug_assert(wcslen(szLine) < CONSOLE_BUFFER_SIZE); m_deqBufHistory.push_front(szLine); SaveHistory(); // Do this each line for the moment; if a script causes diff --git a/source/ps/CStr.cpp b/source/ps/CStr.cpp index 09d2a4fe14..2bea9163e9 100755 --- a/source/ps/CStr.cpp +++ b/source/ps/CStr.cpp @@ -309,14 +309,14 @@ CStr CStr::UCase() const // Retrieve the substring of the first n characters CStr CStr::Left(size_t len) const { - assert(len <= length()); + debug_assert(len <= length()); return substr(0, len); } // Retrieve the substring of the last n characters CStr CStr::Right(size_t len) const { - assert(len <= length()); + debug_assert(len <= length()); return substr(length()-len, len); } diff --git a/source/ps/CStr.h b/source/ps/CStr.h index 255e276e16..1729727e86 100755 --- a/source/ps/CStr.h +++ b/source/ps/CStr.h @@ -212,8 +212,8 @@ public: operator const tchar*() const; // Do some range checking in debug builds - tchar &operator[](size_t n) { assert(n < length()); return this->std::tstring::operator[](n); } - tchar &operator[](int n) { assert(n >= 0 && (size_t)n < length()); return this->std::tstring::operator[](n); } + tchar &operator[](size_t n) { debug_assert(n < length()); return this->std::tstring::operator[](n); } + tchar &operator[](int n) { debug_assert(n >= 0 && (size_t)n < length()); return this->std::tstring::operator[](n); } // Conversion to utf16string inline utf16string utf16() const diff --git a/source/ps/ConfigDB.cpp b/source/ps/ConfigDB.cpp index ce62b1530d..ae1e571211 100755 --- a/source/ps/ConfigDB.cpp +++ b/source/ps/ConfigDB.cpp @@ -170,9 +170,9 @@ namespace ConfigDB_JS int flags=JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT; #define cfg_ns(_propname, _enum) STMT (\ JSObject *nsobj=g_ScriptingHost.CreateCustomObject("ConfigNamespace"); \ - assert(nsobj); \ + debug_assert(nsobj); \ ConfigNamespace_JS::SetNamespace(cx, nsobj, _enum); \ - assert(JS_DefineProperty(cx, newObj, _propname, OBJECT_TO_JSVAL(nsobj), NULL, NULL, flags)); ) + debug_assert(JS_DefineProperty(cx, newObj, _propname, OBJECT_TO_JSVAL(nsobj), NULL, NULL, flags)); ) cfg_ns("system", CFG_SYSTEM); cfg_ns("user", CFG_USER); @@ -202,7 +202,7 @@ CConfigValue *CConfigDB::GetValue(EConfigNamespace ns, CStr name) CConfigValueSet *CConfigDB::GetValues(EConfigNamespace ns, CStr name ) { - assert(ns < CFG_LAST && ns >= 0); + debug_assert(ns < CFG_LAST && ns >= 0); TConfigMap::iterator it = m_Map[CFG_COMMAND].find( name ); if( it != m_Map[CFG_COMMAND].end() ) @@ -220,7 +220,7 @@ CConfigValueSet *CConfigDB::GetValues(EConfigNamespace ns, CStr name ) CConfigValue *CConfigDB::CreateValue(EConfigNamespace ns, CStr name) { - assert(ns < CFG_LAST && ns >= 0); + debug_assert(ns < CFG_LAST && ns >= 0); CConfigValue *ret=GetValue(ns, name); if (ret) return ret; @@ -231,7 +231,7 @@ CConfigValue *CConfigDB::CreateValue(EConfigNamespace ns, CStr name) void CConfigDB::SetConfigFile(EConfigNamespace ns, bool useVFS, CStr path) { - assert(ns < CFG_LAST && ns >= 0); + debug_assert(ns < CFG_LAST && ns >= 0); m_ConfigFile[ns]=path; m_UseVFS[ns]=useVFS; @@ -336,7 +336,7 @@ bool CConfigDB::Reload(EConfigNamespace ns) bool CConfigDB::WriteFile(EConfigNamespace ns, bool useVFS, CStr path) { - assert(ns >= 0 && ns < CFG_LAST); + debug_assert(ns >= 0 && ns < CFG_LAST); char realpath[VFS_MAX_PATH]; char nativepath[VFS_MAX_PATH]; diff --git a/source/ps/Game.cpp b/source/ps/Game.cpp index bf06b7cfbc..dc8fca6129 100755 --- a/source/ps/Game.cpp +++ b/source/ps/Game.cpp @@ -69,7 +69,7 @@ PSRETURN CGame::ReallyStartGame() // Call the reallyStartGame function, but only if it exists jsval fval, rval; JSBool ok = JS_GetProperty(g_ScriptingHost.getContext(), g_GUI.GetScriptObject(), "reallyStartGame", &fval); - assert(ok); + debug_assert(ok); if (ok && !JSVAL_IS_VOID(fval)) { ok = JS_CallFunctionValue(g_ScriptingHost.getContext(), g_GUI.GetScriptObject(), fval, 0, NULL, &rval); @@ -139,7 +139,7 @@ CPlayer *CGame::GetPlayer(uint idx) if (m_Players.size() == 0) { // Hmm. This is a bit of a problem. - assert2(! "### ### ### ### ERROR: Tried to access the players list when there aren't any players. That really isn't going to work, so I'll give up. ### ###"); + debug_assert(! "### ### ### ### ERROR: Tried to access the players list when there aren't any players. That really isn't going to work, so I'll give up. ### ###"); abort(); return NULL; // else VC2005 warns about not returning a value } diff --git a/source/ps/Hotkey.cpp b/source/ps/Hotkey.cpp index 21d3c13e05..8498ca8af4 100755 --- a/source/ps/Hotkey.cpp +++ b/source/ps/Hotkey.cpp @@ -416,7 +416,7 @@ int hotkeyInputHandler( const SDL_Event* ev ) int keyCode = *itKey & ~HOTKEY_NEGATION_FLAG; // Clear the negation-modifier bit bool rqdState = !( *itKey & HOTKEY_NEGATION_FLAG ); - // assert( !rqdState ); + // debug_assert( !rqdState ); if( keyCode < SDLK_LAST ) { diff --git a/source/ps/Interact.cpp b/source/ps/Interact.cpp index 56ac07704f..b37adbda50 100755 --- a/source/ps/Interact.cpp +++ b/source/ps/Interact.cpp @@ -30,7 +30,7 @@ bool customSelectionMode=false; void CSelectedEntities::addSelection( HEntity entity ) { m_group = -1; - assert( !isSelected( entity ) ); + debug_assert( !isSelected( entity ) ); m_selected.push_back( entity ); entity->m_selected = true; m_selectionChanged = true; @@ -39,7 +39,7 @@ void CSelectedEntities::addSelection( HEntity entity ) void CSelectedEntities::removeSelection( HEntity entity ) { m_group = -1; - assert( isSelected( entity ) ); + debug_assert( isSelected( entity ) ); entity->m_selected = false; std::vector::iterator it; for( it = m_selected.begin(); it < m_selected.end(); it++ ) diff --git a/source/ps/Loader.cpp b/source/ps/Loader.cpp index 732491c4d3..813de5610b 100644 --- a/source/ps/Loader.cpp +++ b/source/ps/Loader.cpp @@ -285,7 +285,7 @@ int LDR_ProgressiveLoad(double time_budget, wchar_t* description, // set output params (there are several return points above) done: *progress_percent = (int)(progress * 100.0); - assert2(0 <= *progress_percent && *progress_percent <= 100); + debug_assert(0 <= *progress_percent && *progress_percent <= 100); // we want the next task, instead of what just completed: // it will be displayed during the next load phase. diff --git a/source/ps/Loader.h b/source/ps/Loader.h index f0df969614..5799d9886b 100644 --- a/source/ps/Loader.h +++ b/source/ps/Loader.h @@ -164,7 +164,7 @@ extern int LDR_NonprogressiveLoad(); /* 0 means "finished", so don't return that! */\ if(progress_percent == 0)\ progress_percent = 1;\ - assert2(0 < progress_percent && progress_percent <= 100);\ + debug_assert(0 < progress_percent && progress_percent <= 100);\ return progress_percent;\ } diff --git a/source/ps/NPFont.h b/source/ps/NPFont.h index 7e9a07e6b6..7dfc475c42 100755 --- a/source/ps/NPFont.h +++ b/source/ps/NPFont.h @@ -26,7 +26,7 @@ public: const char* name() const { return (const char*) _name; } // accessors for font metrics - int width(int c) const { assert(c>=0 && c<128); return _chars[c]._width; } + int width(int c) const { debug_assert(c>=0 && c<128); return _chars[c]._width; } int height() const { return _metrics._height; } int descent() const { return _metrics._descent; } int maxcharwidth() const { return _metrics._maxcharwidth; } @@ -43,7 +43,7 @@ public: // accessor for character data const CharData& chardata(char c) const { - assert( !(c&0x80) ); // only allow 7-bit ASCII + debug_assert( !(c&0x80) ); // only allow 7-bit ASCII return _chars[c]; } diff --git a/source/ps/NPFontManager.cpp b/source/ps/NPFontManager.cpp index 9a4e2fe7d2..7e2cd9b1fa 100755 --- a/source/ps/NPFontManager.cpp +++ b/source/ps/NPFontManager.cpp @@ -80,7 +80,7 @@ bool NPFontManager::remove(const char* name) } else { typedef std::vector::iterator Iter; Iter iter=std::find(_fonts.begin(),_fonts.end(),font); - assert(iter != _fonts.end()); + debug_assert(iter != _fonts.end()); _fonts.erase(iter); } diff --git a/source/ps/Network/NetMessage.cpp b/source/ps/Network/NetMessage.cpp index a3ba1354d0..5c0cc2a3b7 100755 --- a/source/ps/Network/NetMessage.cpp +++ b/source/ps/Network/NetMessage.cpp @@ -84,7 +84,7 @@ void CNetMessage::ScriptingInit() CNetCommand *CNetMessage::CommandFromJSArgs(const CEntityList &entities, JSContext *cx, uintN argc, jsval *argv) { - assert(argc >= 1); + debug_assert(argc >= 1); int msgType; diff --git a/source/ps/Network/Network.h b/source/ps/Network/Network.h index b24e70db77..ac6b5a142b 100755 --- a/source/ps/Network/Network.h +++ b/source/ps/Network/Network.h @@ -159,7 +159,7 @@ public: */ inline IMessagePipeEnd &GetEnd(int idx) { - assert(idx==1 || idx==0); + debug_assert(idx==1 || idx==0); return m_Ends[idx]; } }; diff --git a/source/ps/Network/SocketBase.cpp b/source/ps/Network/SocketBase.cpp index e4cdbdc37a..0c6dcf3601 100755 --- a/source/ps/Network/SocketBase.cpp +++ b/source/ps/Network/SocketBase.cpp @@ -288,7 +288,7 @@ void CSocketBase::Destroy() // Remove any data associated with the file descriptor GLOBAL_LOCK(); - assert2(g_SocketSetInternal.m_NumSockets > 0); + debug_assert(g_SocketSetInternal.m_NumSockets > 0); g_SocketSetInternal.m_NumSockets--; g_SocketSetInternal.m_HandleMap.erase(m_pInternal->m_fd); diff --git a/source/ps/Parser.cpp b/source/ps/Parser.cpp index 51644ebbac..d0174c443e 100755 --- a/source/ps/Parser.cpp +++ b/source/ps/Parser.cpp @@ -889,7 +889,7 @@ next [a] Null [a] <-- added NewNode } // Dive into the alternative node - assert(! CurNode->m_AltNode); + debug_assert(! CurNode->m_AltNode); CurNode->m_AltNode = new CParserTaskTypeNode(); CurNode->m_AltNode->m_ParentNode = CurNode; @@ -934,7 +934,7 @@ next [a] Null [a] <-- added NewNode { // Check if this is the first input // CONSTRUCT A CHILD NODE - assert(! CurNode->m_NextNode); + debug_assert(! CurNode->m_NextNode); CurNode->m_NextNode = new CParserTaskTypeNode(); CurNode->m_NextNode->m_ParentNode = CurNode; @@ -982,7 +982,7 @@ next [a] Null [a] <-- added NewNode if (Extract == false) { // CONSTRUCT A CHILD NODE - assert(! CurNode->m_NextNode); + debug_assert(! CurNode->m_NextNode); CurNode->m_NextNode = new CParserTaskTypeNode(); CurNode->m_NextNode->m_ParentNode = CurNode; diff --git a/source/ps/Singleton.h b/source/ps/Singleton.h index 66f6786303..f0a3e53f8a 100755 --- a/source/ps/Singleton.h +++ b/source/ps/Singleton.h @@ -27,7 +27,7 @@ class Singleton public: Singleton() { - assert2( !ms_singleton ); + debug_assert( !ms_singleton ); //use a cunning trick to get the singleton pointing to the start of //the whole, rather than the start of the Singleton part of the object @@ -37,19 +37,19 @@ class Singleton ~Singleton() { - assert2( ms_singleton ); + debug_assert( ms_singleton ); ms_singleton=0; } static T& GetSingleton() { - assert2( ms_singleton ); + debug_assert( ms_singleton ); return *ms_singleton; } static T* GetSingletonPtr() { - assert2( ms_singleton ); + debug_assert( ms_singleton ); return ms_singleton; } diff --git a/source/ps/StringConvert.cpp b/source/ps/StringConvert.cpp index d277462f2d..cdd93905f2 100755 --- a/source/ps/StringConvert.cpp +++ b/source/ps/StringConvert.cpp @@ -3,7 +3,7 @@ #include "StringConvert.h" #include "lib/types.h" -#include + #include "scripting/SpiderMonkey.h" @@ -50,7 +50,7 @@ void StringConvert::jsstring_to_wstring(JSString* str, std::wstring& result) void StringConvert::jschars_to_wstring(const jschar* chars, size_t len, std::wstring& result) { - assert(result.empty()); + debug_assert(result.empty()); result.resize(len); for (size_t i = 0; i < len; ++i) @@ -60,7 +60,7 @@ void StringConvert::jschars_to_wstring(const jschar* chars, size_t len, std::wst void StringConvert::ucs2le_to_wstring(const char* start, const char* end, std::wstring& result) { - assert(result.empty()); + debug_assert(result.empty()); result.resize((end-start)/2); size_t i = 0; diff --git a/source/ps/XMLWriter.cpp b/source/ps/XMLWriter.cpp index f66149c381..51dc7e15c7 100644 --- a/source/ps/XMLWriter.cpp +++ b/source/ps/XMLWriter.cpp @@ -87,7 +87,7 @@ void XMLWriter_File::ElementEnd(const char* name, int type) m_Data += "\n" + Indent() + ""; break; default: - assert(0); + debug_assert(0); } } @@ -135,7 +135,7 @@ template <> void XMLWriter_File::ElementAttribute(const char* name, const } else { - assert(m_LastElement && m_LastElement->m_Type == EL_ATTR); + debug_assert(m_LastElement && m_LastElement->m_Type == EL_ATTR); m_Data += " "; m_Data += name; m_Data += "=\"" + value + "\""; diff --git a/source/ps/XeroXMB.cpp b/source/ps/XeroXMB.cpp index d610e8ded8..027e8f5cd9 100755 --- a/source/ps/XeroXMB.cpp +++ b/source/ps/XeroXMB.cpp @@ -6,7 +6,7 @@ #include "ps/utf16string.h" -#include + const int HeaderMagic = 0x30424D58; // = "XMB0" (little-endian) const char* HeaderMagicStr = "XMB0"; @@ -17,7 +17,7 @@ void XMBFile::Initialise(char* FileData) { m_Pointer = FileData; int Header = *(int*)m_Pointer; m_Pointer += 4; - assert(Header == HeaderMagic && "Invalid XMB header!"); + debug_assert(Header == HeaderMagic && "Invalid XMB header!"); int i; @@ -178,7 +178,7 @@ int XMBElement::getLineNumber() const XMBElement XMBElementList::item(const int id) { - assert(id >= 0 && id < Count && "Element ID out of range"); + debug_assert(id >= 0 && id < Count && "Element ID out of range"); char* Pos; // If access is sequential, don't bother scanning @@ -221,7 +221,7 @@ utf16string XMBAttributeList::getNamedItem(const int AttributeName) const XMBAttribute XMBAttributeList::item(const int id) { - assert(id >= 0 && id < Count && "Attribute ID out of range"); + debug_assert(id >= 0 && id < Count && "Attribute ID out of range"); char* Pos; // If access is sequential, don't bother scanning through diff --git a/source/ps/Xeromyces.cpp b/source/ps/Xeromyces.cpp index a007da3861..31191f8e93 100755 --- a/source/ps/Xeromyces.cpp +++ b/source/ps/Xeromyces.cpp @@ -47,7 +47,7 @@ public: membuffer() { buffer = (char*)malloc(bufferinc); - assert(buffer); + debug_assert(buffer); allocated = bufferinc; length = 0; } @@ -66,7 +66,7 @@ public: void write(const void* data, int size, int offset) { - assert(offset >= 0 && offset+size <= length); + debug_assert(offset >= 0 && offset+size <= length); memcpy(&buffer[offset], data, size); } @@ -91,7 +91,7 @@ private: { allocated += bufferinc; buffer = (char*)realloc(buffer, allocated); - assert(buffer); + debug_assert(buffer); } }; @@ -325,8 +325,8 @@ bool CXeromyces::ReadXMBFile(const char* filename) const void* buffer = file->GetBuffer(); - assert(file->GetBufferSize() >= 42 && "Invalid XMB file"); // 42 bytes is the smallest possible XMB. (Well, maybe not quite, but it's a nice number.) - assert(*(int*)buffer == HeaderMagic && "Invalid XMB file header"); + debug_assert(file->GetBufferSize() >= 42 && "Invalid XMB file"); // 42 bytes is the smallest possible XMB. (Well, maybe not quite, but it's a nice number.) + debug_assert(*(int*)buffer == HeaderMagic && "Invalid XMB file header"); // Store the Handle so it can be closed later XMBFileHandle = file; @@ -433,7 +433,7 @@ void XeroHandler::CreateXMB() } // All the XML contents must be surrounded by a single element - assert(Root->childs.size() == 1); + debug_assert(Root->childs.size() == 1); OutputElement(Root->childs[0]); diff --git a/source/ps/i18n.cpp b/source/ps/i18n.cpp index 7e7fc9bb8a..53d9b55ea0 100755 --- a/source/ps/i18n.cpp +++ b/source/ps/i18n.cpp @@ -24,7 +24,7 @@ bool I18n::LoadLanguage(const char* name) if (name == NULL) { CLocale_interface* locale_ptr = I18n::NewLocale(NULL, NULL); - assert(locale_ptr); + debug_assert(locale_ptr); delete g_CurrentLocale; g_CurrentLocale = locale_ptr; g_CurrentLocaleName = ""; diff --git a/source/ps/scripting/JSCollection.h b/source/ps/scripting/JSCollection.h index 6c7c910538..b35b0eec01 100755 --- a/source/ps/scripting/JSCollection.h +++ b/source/ps/scripting/JSCollection.h @@ -313,7 +313,7 @@ template JSBool CJSCollection::E template JSBool CJSCollection::Subset( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) { - assert( argc > 0 ); + debug_assert( argc > 0 ); std::vector* Set = RetrieveSet( cx, obj ); if( !Set ) @@ -355,7 +355,7 @@ template JSBool CJSCollection::C template JSBool CJSCollection::Push( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) { - assert( argc > 0 ); + debug_assert( argc > 0 ); std::vector* Set = RetrieveSet( cx, obj ); if( !Set ) @@ -392,7 +392,7 @@ template JSBool CJSCollection::P template JSBool CJSCollection::Remove( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) { - assert( argc > 0 ); + debug_assert( argc > 0 ); std::vector* Set = RetrieveSet( cx, obj ); diff --git a/source/ps/scripting/JSInterface_Console.cpp b/source/ps/scripting/JSInterface_Console.cpp index f0f85a6c1e..08425484f2 100755 --- a/source/ps/scripting/JSInterface_Console.cpp +++ b/source/ps/scripting/JSInterface_Console.cpp @@ -84,7 +84,7 @@ JSBool JSI_Console::getConsole( JSContext* cx, JSObject* obj, jsval id, jsval* v JSBool JSI_Console::writeConsole( JSContext* UNUSEDPARAM(context), JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval) ) { - assert( argc >= 1 ); + debug_assert( argc >= 1 ); CStrW output; for( unsigned int i = 0; i < argc; i++ ) { diff --git a/source/ps/scripting/JSInterface_VFS.cpp b/source/ps/scripting/JSInterface_VFS.cpp index 2e23bf7930..b8dff1d408 100644 --- a/source/ps/scripting/JSInterface_VFS.cpp +++ b/source/ps/scripting/JSInterface_VFS.cpp @@ -69,7 +69,7 @@ JSBool JSI_VFS::BuildFileList( JSContext* cx, JSObject* obj, uintN argc, jsval* // get arguments // - assert( argc >= 1 ); + debug_assert( argc >= 1 ); CStr path; if( !ToPrimitive( cx, argv[0], path ) ) return( JS_FALSE ); @@ -109,7 +109,7 @@ JSBool JSI_VFS::BuildFileList( JSContext* cx, JSObject* obj, uintN argc, jsval* // filename: VFS filename (may include path) JSBool JSI_VFS::GetFileMTime( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) { - assert( argc >= 1 ); + debug_assert( argc >= 1 ); CStr filename; if( !ToPrimitive( cx, argv[0], filename ) ) return( JS_FALSE ); @@ -129,7 +129,7 @@ JSBool JSI_VFS::GetFileMTime( JSContext* cx, JSObject* obj, uintN argc, jsval* a // filename: VFS filename (may include path) JSBool JSI_VFS::GetFileSize( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) { - assert( argc >= 1 ); + debug_assert( argc >= 1 ); CStr filename; if( !ToPrimitive( cx, argv[0], filename ) ) return( JS_FALSE ); @@ -149,7 +149,7 @@ JSBool JSI_VFS::GetFileSize( JSContext* cx, JSObject* obj, uintN argc, jsval* ar // filename: VFS filename (may include path) JSBool JSI_VFS::ReadFile( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) { - assert( argc >= 1 ); + debug_assert( argc >= 1 ); CStr filename; if( !ToPrimitive( cx, argv[0], filename ) ) return( JS_FALSE ); @@ -173,7 +173,7 @@ JSBool JSI_VFS::ReadFile( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, // filename: VFS filename (may include path) JSBool JSI_VFS::ReadFileLines( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval ) { - assert( argc >= 1 ); + debug_assert( argc >= 1 ); CStr filename; if( !ToPrimitive( cx, argv[0], filename ) ) return( JS_FALSE ); diff --git a/source/renderer/ModelRData.cpp b/source/renderer/ModelRData.cpp index 8f7f7023df..3cf7fe4fff 100755 --- a/source/renderer/ModelRData.cpp +++ b/source/renderer/ModelRData.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" -#include + #include #include "res/ogl_tex.h" #include "Renderer.h" @@ -21,7 +21,7 @@ std::vector CModelRData::m_Models; CModelRData::CModelRData(CModel* model) : m_Model(model), m_Vertices(0), m_Normals(0), m_Indices(0), m_VB(0), m_Flags(0) { - assert(model); + debug_assert(model); // build all data now Build(); } @@ -64,10 +64,10 @@ void CModelRData::Build() void CModelRData::BuildIndices() { CModelDefPtr mdef=m_Model->GetModelDef(); - assert(mdef); + debug_assert(mdef); // must have a valid vertex buffer by this point so we know where indices are supposed to start - assert(m_VB); + debug_assert(m_VB); // allocate indices if we haven't got any already if (!m_Indices) { @@ -104,7 +104,7 @@ static void SkinPoint(const SModelVertex& vertex,const CMatrix3D* matrices,CVect const SVertexBlend& blend=vertex.m_Blend; // must have at least one valid bone if we're using SkinPoint - assert(blend.m_Bone[0]!=0xff); + debug_assert(blend.m_Bone[0]!=0xff); const CMatrix3D& m=matrices[blend.m_Bone[0]]; m.Transform(vertex.m_Coords,result); @@ -125,7 +125,7 @@ static void SkinNormal(const SModelVertex& vertex,const CMatrix3D* invmatrices,C const SVertexBlend& blend=vertex.m_Blend; // must have at least one valid bone if we're using SkinNormal - assert(blend.m_Bone[0]!=0xff); + debug_assert(blend.m_Bone[0]!=0xff); const CMatrix3D& m=invmatrices[blend.m_Bone[0]]; m.RotateTransposed(vertex.m_Norm,result); @@ -299,7 +299,7 @@ float CModelRData::BackToFrontIndexSort(CMatrix3D& objToCam) // SubmitBatches: submit batches for this model to the vertex buffer void CModelRData::SubmitBatches() { - assert(m_VB); + debug_assert(m_VB); m_VB->m_Owner->AppendBatch(m_VB,m_Model->GetTexture()->GetHandle(),m_Model->GetModelDef()->GetNumFaces()*3,m_Indices); } diff --git a/source/renderer/PatchRData.cpp b/source/renderer/PatchRData.cpp index 2b531c07b7..6eab139a81 100755 --- a/source/renderer/PatchRData.cpp +++ b/source/renderer/PatchRData.cpp @@ -1,6 +1,6 @@ #include "precompiled.h" -#include + #include #include #include "Pyrogenesis.h" @@ -47,7 +47,7 @@ static SColor4ub ConvertColor(const RGBColor& src) // CPatchRData constructor CPatchRData::CPatchRData(CPatch* patch) : m_Patch(patch), m_Vertices(0), m_VBBase(0), m_VBBlends(0) { - assert(patch); + debug_assert(patch); Build(); } @@ -270,7 +270,7 @@ void CPatchRData::BuildBlends() m_BlendSplats.resize(splatTextures.size()); int splatCount=0; - assert(m_VBBlends->m_Index < 65536); + debug_assert(m_VBBlends->m_Index < 65536); unsigned short base = (unsigned short)m_VBBlends->m_Index; std::set::iterator iter=splatTextures.begin(); for (;iter!=splatTextures.end();++iter) { @@ -297,7 +297,7 @@ void CPatchRData::BuildBlends() void CPatchRData::BuildIndices() { // must have allocated some vertices before trying to build corresponding indices - assert(m_VBBase); + debug_assert(m_VBBase); // number of vertices in each direction in each patch int vsize=PATCH_SIZE+1; @@ -422,7 +422,7 @@ void CPatchRData::Update() void CPatchRData::RenderBase() { - assert(m_UpdateFlags==0); + debug_assert(m_UpdateFlags==0); u8* base=m_VBBase->m_Owner->Bind(); @@ -445,7 +445,7 @@ void CPatchRData::RenderBase() void CPatchRData::RenderStreams(u32 streamflags) { - assert(m_UpdateFlags==0); + debug_assert(m_UpdateFlags==0); u8* base=m_VBBase->m_Owner->Bind(); @@ -468,7 +468,7 @@ void CPatchRData::RenderStreams(u32 streamflags) void CPatchRData::RenderBlends() { - assert(m_UpdateFlags==0); + debug_assert(m_UpdateFlags==0); if (m_BlendVertices.size()==0) return; @@ -549,7 +549,7 @@ void CPatchRData::RenderOutline() // SubmitBaseBatches: submit base batches for this patch to the vertex buffer void CPatchRData::SubmitBaseBatches() { - assert(m_VBBase); + debug_assert(m_VBBase); for (uint i=0;im_Index*m_VertexSize,chunk->m_Count*m_VertexSize,data); if (glGetError() != GL_NO_ERROR) throw PSERROR_Renderer_VBOFailed(); } else { - assert(m_SysMem); + debug_assert(m_SysMem); memcpy(m_SysMem+chunk->m_Index*m_VertexSize,data,chunk->m_Count*m_VertexSize); } } diff --git a/source/renderer/VertexBufferManager.cpp b/source/renderer/VertexBufferManager.cpp index 3a8b0ae156..4067d8536a 100755 --- a/source/renderer/VertexBufferManager.cpp +++ b/source/renderer/VertexBufferManager.cpp @@ -6,7 +6,7 @@ // /////////////////////////////////////////////////////////////////////////////// #include "precompiled.h" -#include + #include "ogl.h" #include "VertexBufferManager.h" #include "ps/CLogger.h" @@ -51,12 +51,12 @@ CVertexBuffer::VBChunk* CVertexBufferManager::Allocate(size_t vertexSize,size_t m_Buffers.push_front(buffer); result=buffer->Allocate(vertexSize,numVertices,dynamic); - // TODO, RC - assert not really suitable? probably need to handle "failed to create + // TODO, RC - debug_assert not really suitable? probably need to handle "failed to create // VBO case" better if (!result) { LOG(ERROR, LOG_CATEGORY, "Failed to create VBOs"); - assert2(!"Failed to create VBOs"); + debug_assert(!"Failed to create VBOs"); } return result; @@ -66,7 +66,7 @@ CVertexBuffer::VBChunk* CVertexBufferManager::Allocate(size_t vertexSize,size_t // Release: return given chunk to it's owner void CVertexBufferManager::Release(CVertexBuffer::VBChunk* chunk) { - assert(chunk); + debug_assert(chunk); chunk->m_Owner->Release(chunk); } diff --git a/source/scripting/DOMEvent.cpp b/source/scripting/DOMEvent.cpp index e94b17b2b9..12e1b2949a 100755 --- a/source/scripting/DOMEvent.cpp +++ b/source/scripting/DOMEvent.cpp @@ -102,7 +102,7 @@ bool IEventTarget::RemoveHandler( CStrW TypeString, DOMEventHandler handler ) bool IEventTarget::AddHandlerJS( JSContext* cx, uintN argc, jsval* argv ) { - assert( argc >= 2 ); + debug_assert( argc >= 2 ); DOMEventHandler handler = new CScriptObject( argv[1] ); if( !handler->Defined() ) { @@ -119,7 +119,7 @@ bool IEventTarget::AddHandlerJS( JSContext* cx, uintN argc, jsval* argv ) bool IEventTarget::RemoveHandlerJS( JSContext* cx, uintN argc, jsval* argv ) { - assert( argc >= 2 ); + debug_assert( argc >= 2 ); DOMEventHandler handler = new CScriptObject( argv[1] ); if( !handler->Defined() ) { diff --git a/source/scripting/JSSerialization.h b/source/scripting/JSSerialization.h index 17cb615480..1e16e0cd86 100755 --- a/source/scripting/JSSerialization.h +++ b/source/scripting/JSSerialization.h @@ -59,7 +59,7 @@ public: case TAG_STRING: return( 1 + (ToPrimitive(m_data)).GetSerializedLength() ); default: - assert( 0 && "An attempt was made to serialize a jsval other than a number, boolean or string." ); + debug_assert( 0 && "An attempt was made to serialize a jsval other than a number, boolean or string." ); return( 1 ); } } @@ -88,7 +88,7 @@ public: buffer = ( ToPrimitive( m_data ) ).Serialize( buffer ); break; default: - assert( 0 && "An attempt was made to serialize a jsval other than a number, boolean or string." ); + debug_assert( 0 && "An attempt was made to serialize a jsval other than a number, boolean or string." ); break; } return( buffer ); @@ -127,7 +127,7 @@ public: } break; default: - assert( 0 && "An attempt was made to deserialize a jsval other than a number, boolean or string." ); + debug_assert( 0 && "An attempt was made to deserialize a jsval other than a number, boolean or string." ); break; } return( buffer ); diff --git a/source/scripting/ScriptCustomTypes.cpp b/source/scripting/ScriptCustomTypes.cpp index 6f06998a13..1aa3802850 100755 --- a/source/scripting/ScriptCustomTypes.cpp +++ b/source/scripting/ScriptCustomTypes.cpp @@ -70,7 +70,7 @@ jsval SColour::ToString( JSContext* cx, uintN argc, jsval* argv ) JSBool SColour::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) { - assert( argc >= 3 ); + debug_assert( argc >= 3 ); float alpha = 1.0; if( argc >= 4 ) alpha = ToPrimitive( argv[3] ); diff --git a/source/scripting/ScriptGlue.cpp b/source/scripting/ScriptGlue.cpp index 1349e459d0..57555f8f3a 100755 --- a/source/scripting/ScriptGlue.cpp +++ b/source/scripting/ScriptGlue.cpp @@ -146,7 +146,7 @@ JSBool WriteLog(JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigne JSBool getEntityByHandle( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* rval ) { - assert( argc >= 1 ); + debug_assert( argc >= 1 ); i32 handle; try { @@ -173,7 +173,7 @@ JSBool getEntityByHandle( JSContext* context, JSObject* UNUSEDPARAM(globalObject JSBool getEntityTemplate( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* rval ) { - assert( argc >= 1 ); + debug_assert( argc >= 1 ); CStrW templateName; try { @@ -280,7 +280,7 @@ JSBool setCameraTarget( JSContext* context, JSObject* obj, unsigned int argc, js JSBool setTimeout( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval) ) { - assert( argc >= 2 ); + debug_assert( argc >= 2 ); size_t delay; try { @@ -314,7 +314,7 @@ JSBool setTimeout( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsi JSBool setInterval( JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* UNUSEDPARAM(rval) ) { - assert( argc >= 2 ); + debug_assert( argc >= 2 ); size_t first, interval; try { @@ -364,7 +364,7 @@ JSBool cancelInterval( JSContext* UNUSEDPARAM(context), JSObject* UNUSEDPARAM(gl JSBool v3dist( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) { - assert( argc >= 2 ); + debug_assert( argc >= 2 ); CVector3D* a = ToNative( argv[0] ); CVector3D* b = ToNative( argv[1] ); float dist = ( *a - *b ).GetLength(); @@ -400,7 +400,7 @@ JSBool setCursor(JSContext* UNUSEDPARAM(context), JSObject* UNUSEDPARAM(globalOb { if (argc != 1) { - assert(! "Invalid parameter count to setCursor"); + debug_assert(! "Invalid parameter count to setCursor"); return JS_FALSE; } g_CursorName = g_ScriptingHost.ValueToString(argv[0]); @@ -577,8 +577,8 @@ JSBool _lodbias(JSContext* context, JSObject* globalObject, unsigned int argc, j JSBool issueCommand(JSContext* context, JSObject* UNUSEDPARAM(globalObject), unsigned int argc, jsval* argv, jsval* rval) { - assert(argc >= 2); - assert(JSVAL_IS_OBJECT(argv[0])); + debug_assert(argc >= 2); + debug_assert(JSVAL_IS_OBJECT(argv[0])); CEntityList entities; diff --git a/source/scripting/ScriptableComplex.h b/source/scripting/ScriptableComplex.h index 20baa37fae..8d7f070089 100644 --- a/source/scripting/ScriptableComplex.h +++ b/source/scripting/ScriptableComplex.h @@ -413,7 +413,7 @@ public: } void ImmediateCopy( IJSComplex* CopyTo, IJSComplex* CopyFrom, IJSComplexProperty* CopyProperty ) { - assert( 0 && "ImmediateCopy called on a CJSValComplexProperty (something's gone wrong with the inheritance on this object)" ); + debug_assert( 0 && "ImmediateCopy called on a CJSValComplexProperty (something's gone wrong with the inheritance on this object)" ); } }; @@ -433,7 +433,7 @@ public: m_Getter = Getter; m_Setter = Setter; // Must at least be able to read - assert( m_Getter ); + debug_assert( m_Getter ); } jsval Get( JSContext* cx, IJSComplex* owner ) { @@ -446,7 +446,7 @@ public: } void ImmediateCopy( IJSComplex* CopyTo, IJSComplex* CopyFrom, IJSComplexProperty* CopyProperty ) { - assert( 0 && "ImmediateCopy called on a property wrapping getter/setter functions (something's gone wrong with the inheritance for this object)" ); + debug_assert( 0 && "ImmediateCopy called on a property wrapping getter/setter functions (something's gone wrong with the inheritance for this object)" ); } }; @@ -633,7 +633,7 @@ public: if( !Native ) return( JS_TRUE ); - assert( argc >= 1 ); + debug_assert( argc >= 1 ); CScriptObject watch( argv[0] ); std::vector::iterator it; @@ -777,7 +777,7 @@ public: if( extProp->m_JSAccessor ) { CJSComplexPropertyAccessor< CJSComplex >* accessor = (CJSComplexPropertyAccessor< CJSComplex >*)JS_GetPrivate( g_ScriptingHost.GetContext(), extProp->m_JSAccessor ); - assert( accessor ); + debug_assert( accessor ); delete( accessor ); JS_SetPrivate( g_ScriptingHost.GetContext(), extProp->m_JSAccessor, NULL ); JS_RemoveRoot( g_ScriptingHost.GetContext(), &( extProp->m_JSAccessor ) ); @@ -791,7 +791,7 @@ public: for( it_a = m_Reflectors.begin(); it_a != m_Reflectors.end(); it_a++ ) { CJSComplexPropertyAccessor< CJSComplex >* accessor = (CJSComplexPropertyAccessor< CJSComplex >*)JS_GetPrivate( g_ScriptingHost.GetContext(), it_a->second->m_JSAccessor ); - assert( accessor ); + debug_assert( accessor ); delete( accessor ); JS_SetPrivate( g_ScriptingHost.GetContext(), it_a->second->m_JSAccessor, NULL ); JS_RemoveRoot( g_ScriptingHost.GetContext(), &( it_a->second->m_JSAccessor ) ); @@ -839,7 +839,7 @@ public: // If it can be inherited, inherit it. if( cp && cp->m_AllowsInheritance ) { - assert( cp->m_Intrinsic ); + debug_assert( cp->m_Intrinsic ); it->second->ImmediateCopy( this, m_Parent, cp ); } } @@ -853,7 +853,7 @@ public: if( cp && cp->m_AllowsInheritance ) { - assert( cp->m_Intrinsic ); + debug_assert( cp->m_Intrinsic ); it->second->ImmediateCopy( this, m_Parent, cp ); } } @@ -897,7 +897,7 @@ public: } void AddProperty( CStrW PropertyName, jsval Value ) { - assert( !HasProperty( PropertyName ) ); + debug_assert( !HasProperty( PropertyName ) ); CJSDynamicComplexProperty* newProp = new CJSValComplexProperty( Value, false ); m_Properties[PropertyName] = newProp; diff --git a/source/scripting/ScriptableObject.h b/source/scripting/ScriptableObject.h index 99c488172c..eb5f35530b 100755 --- a/source/scripting/ScriptableObject.h +++ b/source/scripting/ScriptableObject.h @@ -107,7 +107,7 @@ public: m_Getter = Getter; m_Setter = Setter; // Must at least be able to read - assert( m_Getter ); + debug_assert( m_Getter ); } jsval Get( JSContext* cx, IJSObject* obj ) { @@ -279,7 +279,7 @@ public: void AddProperty( CStrW PropertyName, jsval Value ) { - assert( !HasProperty( PropertyName ) ); + debug_assert( !HasProperty( PropertyName ) ); CJSValProperty* newProp = new CJSValProperty( Value ); m_ScriptProperties[PropertyName] = newProp; } diff --git a/source/scripting/ScriptingHost.cpp b/source/scripting/ScriptingHost.cpp index 5b83049158..91d5e563cc 100755 --- a/source/scripting/ScriptingHost.cpp +++ b/source/scripting/ScriptingHost.cpp @@ -105,7 +105,7 @@ void ScriptingHost::LoadScriptFromDisk(const std::string & fileName) JSBool ok = JS_EvaluateScript(m_Context, m_GlobalObject, (const char*)script, (unsigned int)script_len, fn, 0, &rval); int err = mem_free(script); - assert(err == 0); + debug_assert(err == 0); if (ok == JS_FALSE) throw PSERROR_Scripting_LoadFile_EvalErrors(); @@ -130,7 +130,7 @@ jsval ScriptingHost::ExecuteScript(const CStrW& script, const CStrW& calledFrom, /* Unicode->ASCII conversion (mostly) for calledFrom */ size_t len = wcstombs( NULL, calledFrom, 0 ); - assert( len != (size_t)-1 ); + debug_assert( len != (size_t)-1 ); char* asciiName = new char[len + 1]; wcstombs( asciiName, calledFrom, len + 1 ); diff --git a/source/simulation/BaseEntity.cpp b/source/simulation/BaseEntity.cpp index 02c1c3c02d..9a495066c5 100755 --- a/source/simulation/BaseEntity.cpp +++ b/source/simulation/BaseEntity.cpp @@ -257,7 +257,7 @@ bool CBaseEntity::loadXML( CStr filename ) { jsval fnval; JSBool ret = JS_GetUCProperty( g_ScriptingHost.GetContext(), g_ScriptingHost.GetGlobalObject(), ExternalFunction.c_str(), ExternalFunction.size(), &fnval ); - assert( ret ); + debug_assert( ret ); JSFunction* fn = JS_ValueToFunction( g_ScriptingHost.GetContext(), fnval ); if( !fn ) { diff --git a/source/simulation/BoundingObjects.cpp b/source/simulation/BoundingObjects.cpp index bab387eca3..71a37eb19e 100755 --- a/source/simulation/BoundingObjects.cpp +++ b/source/simulation/BoundingObjects.cpp @@ -4,7 +4,6 @@ #include "ogl.h" #include "MathUtil.h" #include "stdio.h" -#include "assert.h" bool CBoundingObject::intersects( CBoundingObject* obj ) { @@ -64,7 +63,7 @@ void CBoundingCircle::setRadius( float radius ) bool CBoundingCircle::_intersects( CBoundingObject* obj, const CVector2D& delta ) { - assert( obj->m_type == BOUND_CIRCLE ); + debug_assert( obj->m_type == BOUND_CIRCLE ); // Easy enough. The only time this gets called is a circle-circle collision, // but we know the circles collide (they passed the trivial rejection step) return( true ); diff --git a/source/simulation/Collision.cpp b/source/simulation/Collision.cpp index 491fe6513b..eb898066c5 100755 --- a/source/simulation/Collision.cpp +++ b/source/simulation/Collision.cpp @@ -70,7 +70,7 @@ CBoundingObject* getCollisionObject( CBoundingObject* bounds ) HEntity getCollisionObject( CEntity* entity ) { #ifndef NDEBUG - assert( entity->m_bounds ); + debug_assert( entity->m_bounds ); #else if( !entity->m_bounds ) return( HEntity() ); #endif diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp index 7f732aa3da..4e6a513bf5 100755 --- a/source/simulation/Entity.cpp +++ b/source/simulation/Entity.cpp @@ -319,7 +319,7 @@ void CEntity::update( size_t timestep ) m_orderQueue.pop_front(); break; default: - assert( 0 && "Invalid entity order" ); + debug_assert( 0 && "Invalid entity order" ); } } @@ -775,7 +775,7 @@ void CEntity::ScriptingInit() JSBool CEntity::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) { - assert( argc >= 2 ); + debug_assert( argc >= 2 ); CBaseEntity* baseEntity = NULL; CVector3D position; @@ -846,7 +846,7 @@ jsval CEntity::ToString( JSContext* cx, uintN argc, jsval* argv ) bool CEntity::Order( JSContext* cx, uintN argc, jsval* argv, bool Queued ) { // This needs to be sorted (uses Scheduler rather than network messaging) - assert( argc >= 1 ); + debug_assert( argc >= 1 ); int orderCode; @@ -995,14 +995,14 @@ jsval CEntity::GetSpawnPoint( JSContext* cx, uintN argc, jsval* argv ) { case CBoundingObject::BOUND_CIRCLE: spawn_clearance = be->m_bound_circle->m_radius; break; case CBoundingObject::BOUND_OABB: spawn_clearance = be->m_bound_box->m_radius; break; - default: assert( 0 && "No bounding information for spawned object!" ); + default: debug_assert( 0 && "No bounding information for spawned object!" ); } } else spawn_clearance = ToPrimitive( argv[0] ); } else - assert( 0 && "No arguments to Entity::GetSpawnPoint()" ); + debug_assert( 0 && "No arguments to Entity::GetSpawnPoint()" ); // TODO: Make netsafe. CBoundingCircle spawn( 0.0f, 0.0f, spawn_clearance, 0.0f ); diff --git a/source/simulation/Entity.h b/source/simulation/Entity.h index b7c9024416..b38b6e51b4 100755 --- a/source/simulation/Entity.h +++ b/source/simulation/Entity.h @@ -219,7 +219,7 @@ public: } bool HasClass( JSContext* cx, uintN argc, jsval* argv ) { - assert( argc >= 1 ); + debug_assert( argc >= 1 ); return( m_classes.IsMember( ToPrimitive( cx, argv[0] ) ) ); } static void ScriptingInit(); diff --git a/source/simulation/EntityHandles.cpp b/source/simulation/EntityHandles.cpp index 909561dd69..8cf9d2eb65 100755 --- a/source/simulation/EntityHandles.cpp +++ b/source/simulation/EntityHandles.cpp @@ -50,7 +50,7 @@ HEntity::operator bool() const if( m_handle == INVALID_HANDLE ) return( false ); - assert( g_EntityManager.m_entities[m_handle].m_refcount ); + debug_assert( g_EntityManager.m_entities[m_handle].m_refcount ); return( !g_EntityManager.m_entities[m_handle].m_entity->m_destroyed ); } @@ -59,7 +59,7 @@ bool HEntity::operator!() const if( m_handle == INVALID_HANDLE ) return( true ); - assert( g_EntityManager.m_entities[m_handle].m_refcount ); + debug_assert( g_EntityManager.m_entities[m_handle].m_refcount ); return( g_EntityManager.m_entities[m_handle].m_entity->m_destroyed ); } @@ -67,7 +67,7 @@ void HEntity::addRef() { if( m_handle != INVALID_HANDLE ) { - assert( m_handle < MAX_HANDLES ); + debug_assert( m_handle < MAX_HANDLES ); g_EntityManager.m_entities[m_handle].m_refcount++; } } @@ -83,8 +83,8 @@ void HEntity::decRef() CEntity* HEntity::operator->() const { - assert( m_handle != INVALID_HANDLE ); - assert( g_EntityManager.m_entities[m_handle].m_refcount ); + debug_assert( m_handle != INVALID_HANDLE ); + debug_assert( g_EntityManager.m_entities[m_handle].m_refcount ); return( g_EntityManager.m_entities[m_handle].m_entity ); } @@ -93,13 +93,13 @@ HEntity::operator CEntity*() const if( m_handle == INVALID_HANDLE ) return( NULL ); - assert( g_EntityManager.m_entities[m_handle].m_refcount ); + debug_assert( g_EntityManager.m_entities[m_handle].m_refcount ); return( g_EntityManager.m_entities[m_handle].m_entity ); } CEntity& HEntity::operator*() const { - assert( m_handle != INVALID_HANDLE ); - assert( g_EntityManager.m_entities[m_handle].m_refcount ); + debug_assert( m_handle != INVALID_HANDLE ); + debug_assert( g_EntityManager.m_entities[m_handle].m_refcount ); return( *g_EntityManager.m_entities[m_handle].m_entity ); } @@ -117,7 +117,7 @@ u8 *HEntity::Serialize(u8 *buffer) const const u8 *HEntity::Deserialize(const u8 *buffer, const u8 *end) { Deserialize_int_2(buffer, m_handle); - // We can't let addRef assert just because someone sent us bogus data + // We can't let addRef debug_assert just because someone sent us bogus data if (m_handle < MAX_HANDLES && m_handle != INVALID_HANDLE) addRef(); return buffer; @@ -150,7 +150,7 @@ const u8 *CEntityList::Deserialize(const u8 *buffer, const u8 *end) { Deserialize_int_2(buffer, n); handle = n & ~HANDLE_SENTINEL_BIT; - // We have to validate the data, or the HEntity constructor will assert + // We have to validate the data, or the HEntity constructor will debug_assert // on us. // FIXME 4096 shouldn't be hard-coded // FIXME We should also check that the entity actually exists diff --git a/source/simulation/EntityManager.cpp b/source/simulation/EntityManager.cpp index 314536e46a..6d22b9f279 100755 --- a/source/simulation/EntityManager.cpp +++ b/source/simulation/EntityManager.cpp @@ -52,14 +52,14 @@ void CEntityManager::deleteAll() HEntity CEntityManager::create( CBaseEntity* base, CVector3D position, float orientation ) { - assert( base ); + debug_assert( base ); if( !base ) return HEntity(); while( m_entities[m_nextalloc].m_refcount ) { m_nextalloc++; - assert(m_nextalloc < MAX_HANDLES); + debug_assert(m_nextalloc < MAX_HANDLES); } m_entities[m_nextalloc].m_entity = new CEntity( base, position, orientation ); m_entities[m_nextalloc].m_entity->me = HEntity( m_nextalloc ); diff --git a/source/simulation/EntityStateProcessing.cpp b/source/simulation/EntityStateProcessing.cpp index 762b5e6df4..1a42599a48 100755 --- a/source/simulation/EntityStateProcessing.cpp +++ b/source/simulation/EntityStateProcessing.cpp @@ -133,7 +133,7 @@ uint CEntity::processGotoHelper( CEntityOrder* current, size_t timestep_millis, // Yes. Oh dear. That can't be good. // This really shouldn't happen in the current build. - assert( false && "Overlapping objects" ); + debug_assert( false && "Overlapping objects" ); // Erm... do nothing? diff --git a/source/simulation/PathfindSparse.cpp b/source/simulation/PathfindSparse.cpp index 76502c3d61..30def24c5c 100755 --- a/source/simulation/PathfindSparse.cpp +++ b/source/simulation/PathfindSparse.cpp @@ -170,7 +170,7 @@ bool sparsePathTree::slice() void sparsePathTree::pushResults( std::vector& nodelist ) { - assert( type & SPF_SOLVED ); + debug_assert( type & SPF_SOLVED ); if( type == SPF_CLOSED_DIRECT ) { @@ -188,7 +188,7 @@ void sparsePathTree::pushResults( std::vector& nodelist ) } else { - assert( !rightImpossible ); + debug_assert( !rightImpossible ); rightPost->pushResults( nodelist ); rightPre->pushResults( nodelist ); } @@ -242,7 +242,7 @@ void pathSparse( HEntity entity, CVector2D destination ) sparsePathTree sparseEngine( source, destination, entity, getContainingObject( destination ), SPF_RECURSION_DEPTH ); while( sparseEngine.type & sparsePathTree::SPF_OPEN ) sparseEngine.slice(); - // assert( sparseEngine.type & sparsePathTree::SPF_SOLVED ); // Shouldn't be any impossible cases yet. + // debug_assert( sparseEngine.type & sparsePathTree::SPF_SOLVED ); // Shouldn't be any impossible cases yet. if( sparseEngine.type & sparsePathTree::SPF_SOLVED ) { diff --git a/source/simulation/Projectile.cpp b/source/simulation/Projectile.cpp index ae7d898c5c..f5b01d941e 100644 --- a/source/simulation/Projectile.cpp +++ b/source/simulation/Projectile.cpp @@ -126,7 +126,7 @@ void CProjectile::ScriptingInit() JSBool CProjectile::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) { - assert( argc >= 4 ); + debug_assert( argc >= 4 ); CStr ModelString; CVector3D Here, There; float Speed; diff --git a/source/simulation/Scheduler.cpp b/source/simulation/Scheduler.cpp index 34e6a04669..ed3bcd6cd7 100755 --- a/source/simulation/Scheduler.cpp +++ b/source/simulation/Scheduler.cpp @@ -130,7 +130,7 @@ void CJSProgressTimer::ScriptingInit() JSBool CJSProgressTimer::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) { - assert( argc >= 2 ); + debug_assert( argc >= 2 ); double max = ToPrimitive( argv[0] ); double increment = ToPrimitive( argv[1] ); JSFunction* callback_fn = NULL; diff --git a/source/simulation/Simulation.cpp b/source/simulation/Simulation.cpp index e4b92b42dc..c4380fd9c6 100755 --- a/source/simulation/Simulation.cpp +++ b/source/simulation/Simulation.cpp @@ -76,7 +76,7 @@ void CSimulation::Update(double frameTime) // TODO Remove // Fountain of arrows CObjectEntry* arrow = g_ObjMan.FindObject( "props/weapon/weap_arrow_front.xml" ); - assert( arrow ); + debug_assert( arrow ); float mapsize = (float)( m_pWorld->GetTerrain()->GetVerticesPerSide() * 4 ); diff --git a/source/simulation/scripting/JSInterface_Entity.cpp b/source/simulation/scripting/JSInterface_Entity.cpp index 7d60882a7a..2247b0a79e 100755 --- a/source/simulation/scripting/JSInterface_Entity.cpp +++ b/source/simulation/scripting/JSInterface_Entity.cpp @@ -82,7 +82,7 @@ JSBool JSI_Entity::setProperty( JSContext* cx, JSObject* obj, jsval id, jsval* v JSBool JSI_Entity::construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) { - assert( argc >= 2 ); + debug_assert( argc >= 2 ); CBaseEntity* baseEntity = NULL; CVector3D position; float orientation = 0.0f; @@ -175,7 +175,7 @@ JSBool JSI_Entity::order( JSContext* cx, JSObject* obj, uintN argc, jsval* argv, HEntity* e = (HEntity*)JS_GetPrivate( cx, obj ); // This needs to be sorted (uses Scheduler rather than network messaging) - assert( argc >= 1 ); + debug_assert( argc >= 1 ); int orderCode; diff --git a/source/sound/CMusicPlayer.cpp b/source/sound/CMusicPlayer.cpp index 3fcac3e121..cb2156a776 100755 --- a/source/sound/CMusicPlayer.cpp +++ b/source/sound/CMusicPlayer.cpp @@ -126,7 +126,7 @@ bool CMusicPlayer::issue(int slot_idx) ssize_t left = (ssize_t)memFile.dataSize - (ssize_t)memFile.dataRead; ssize_t size = MIN(64*KB, left); - assert(size >= 0); + debug_assert(size >= 0); void* data = memFile.dataPtr; data = (char*)data + memFile.dataRead; memFile.dataRead += size; diff --git a/source/sound/JSI_Sound.cpp b/source/sound/JSI_Sound.cpp index 04556a055e..3bf15689b7 100755 --- a/source/sound/JSI_Sound.cpp +++ b/source/sound/JSI_Sound.cpp @@ -28,7 +28,7 @@ JSI_Sound::~JSI_Sound() bool JSI_Sound::SetGain( JSContext* cx, uintN argc, jsval* argv ) { - assert( argc >= 1 ); + debug_assert( argc >= 1 ); float gain; if( !ToPrimitive( cx, argv[0], gain) ) return false; @@ -39,7 +39,7 @@ bool JSI_Sound::SetGain( JSContext* cx, uintN argc, jsval* argv ) bool JSI_Sound::SetPitch( JSContext* cx, uintN argc, jsval* argv ) { - assert( argc >= 1 ); + debug_assert( argc >= 1 ); float pitch; if( !ToPrimitive( cx, argv[0], pitch) ) return false; @@ -50,7 +50,7 @@ bool JSI_Sound::SetPitch( JSContext* cx, uintN argc, jsval* argv ) bool JSI_Sound::SetPosition( JSContext* cx, uintN argc, jsval* argv ) { - assert( argc >= 1 ); + debug_assert( argc >= 1 ); CVector3D pos; // absolute world coords if( ToPrimitive( cx, argv[0], pos ) ) @@ -117,7 +117,7 @@ jsval JSI_Sound::ToString( JSContext* cx, uintN argc, jsval* argv ) JSBool JSI_Sound::Construct( JSContext* cx, JSObject* obj, unsigned int argc, jsval* argv, jsval* rval ) { - assert( argc >= 1 ); + debug_assert( argc >= 1 ); CStrW filename; if( !ToPrimitive( cx, argv[0], filename ) ) return( JS_FALSE );