From 125078582262b40dfa53695c5e3e30d48f1ec380 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 23 Jan 2011 15:01:24 +0000 Subject: SWORD25: Replaced BS_ASSERT() with assert() svn-id: r55464 --- engines/sword25/math/geometry_script.cpp | 50 ++++++++++++++++---------------- engines/sword25/math/region.cpp | 8 ++--- engines/sword25/math/region.h | 2 +- engines/sword25/math/vertex.cpp | 2 +- engines/sword25/math/walkregion.cpp | 6 ++-- 5 files changed, 34 insertions(+), 34 deletions(-) (limited to 'engines/sword25/math') diff --git a/engines/sword25/math/geometry_script.cpp b/engines/sword25/math/geometry_script.cpp index 8882d5e588..15b1aadac1 100644 --- a/engines/sword25/math/geometry_script.cpp +++ b/engines/sword25/math/geometry_script.cpp @@ -114,7 +114,7 @@ static bool isValidPolygonDefinition(lua_State *L) { } #ifdef DEBUG - BS_ASSERT(__startStackDepth == lua_gettop(L)); + assert(__startStackDepth == lua_gettop(L)); #endif return true; @@ -151,10 +151,10 @@ static void tablePolygonToPolygon(lua_State *L, Polygon &polygon) { // Vertex vertices.push_back(Vertex(X, Y)); } - BS_ASSERT((int)vertices.size() == vertexCount); + assert((int)vertices.size() == vertexCount); #ifdef DEBUG - BS_ASSERT(__startStackDepth == lua_gettop(L)); + assert(__startStackDepth == lua_gettop(L)); #endif // Create polygon @@ -185,10 +185,10 @@ static uint tableRegionToRegion(lua_State *L, const char *className) { } else if (!strcmp(className, WALKREGION_CLASS_NAME)) { regionHandle = WalkRegion::create(Region::RT_WALKREGION); } else { - BS_ASSERT(false); + assert(false); } - BS_ASSERT(regionHandle); + assert(regionHandle); // If the first element of the parameter is a number, then case 1 is accepted // If the first element of the parameter is a table, then case 2 is accepted @@ -224,7 +224,7 @@ static uint tableRegionToRegion(lua_State *L, const char *className) { tablePolygonToPolygon(L, holes.back()); lua_pop(L, 1); } - BS_ASSERT((int)holes.size() == polygonCount - 1); + assert((int)holes.size() == polygonCount - 1); RegionRegistry::instance().resolveHandle(regionHandle)->init(polygon, &holes); } @@ -237,7 +237,7 @@ static uint tableRegionToRegion(lua_State *L, const char *className) { } #ifdef DEBUG - BS_ASSERT(__startStackDepth == lua_gettop(L)); + assert(__startStackDepth == lua_gettop(L)); #endif return regionHandle; @@ -247,12 +247,12 @@ static void newUserdataRegion(lua_State *L, const char *className) { // Region due to the Lua code to create // Any errors that occur will be intercepted to the luaL_error uint regionHandle = tableRegionToRegion(L, className); - BS_ASSERT(regionHandle); + assert(regionHandle); newUintUserData(L, regionHandle); // luaL_getmetatable(L, className); LuaBindhelper::getMetatable(L, className); - BS_ASSERT(!lua_isnil(L, -1)); + assert(!lua_isnil(L, -1)); lua_setmetatable(L, -2); } @@ -290,7 +290,7 @@ static Region *checkRegion(lua_State *L) { static int r_isValid(lua_State *L) { Region *pR = checkRegion(L); - BS_ASSERT(pR); + assert(pR); lua_pushbooleancpp(L, pR->isValid()); return 1; @@ -298,7 +298,7 @@ static int r_isValid(lua_State *L) { static int r_getX(lua_State *L) { Region *pR = checkRegion(L); - BS_ASSERT(pR); + assert(pR); lua_pushnumber(L, pR->getPosX()); return 1; @@ -306,7 +306,7 @@ static int r_getX(lua_State *L) { static int r_getY(lua_State *L) { Region *pR = checkRegion(L); - BS_ASSERT(pR); + assert(pR); lua_pushnumber(L, pR->getPosY()); return 1; @@ -314,7 +314,7 @@ static int r_getY(lua_State *L) { static int r_getPos(lua_State *L) { Region *pR = checkRegion(L); - BS_ASSERT(pR); + assert(pR); Vertex::vertexToLuaVertex(L, pR->getPosition()); return 1; @@ -322,7 +322,7 @@ static int r_getPos(lua_State *L) { static int r_isPointInRegion(lua_State *L) { Region *pR = checkRegion(L); - BS_ASSERT(pR); + assert(pR); Vertex vertex; Vertex::luaVertexToVertex(L, 2, vertex); @@ -332,7 +332,7 @@ static int r_isPointInRegion(lua_State *L) { static int r_setPos(lua_State *L) { Region *pR = checkRegion(L); - BS_ASSERT(pR); + assert(pR); Vertex vertex; Vertex::luaVertexToVertex(L, 2, vertex); @@ -343,7 +343,7 @@ static int r_setPos(lua_State *L) { static int r_setX(lua_State *L) { Region *pR = checkRegion(L); - BS_ASSERT(pR); + assert(pR); pR->setPosX(static_cast(luaL_checknumber(L, 2))); @@ -352,7 +352,7 @@ static int r_setX(lua_State *L) { static int r_setY(lua_State *L) { Region *pR = checkRegion(L); - BS_ASSERT(pR); + assert(pR); pR->setPosY(static_cast(luaL_checknumber(L, 2))); @@ -361,7 +361,7 @@ static int r_setY(lua_State *L) { static void drawPolygon(const Polygon &polygon, uint color, const Vertex &offset) { GraphicEngine *pGE = Kernel::getInstance()->getGfx(); - BS_ASSERT(pGE); + assert(pGE); for (int i = 0; i < polygon.vertexCount - 1; i++) pGE->drawDebugLine(polygon.vertices[i] + offset, polygon.vertices[i + 1] + offset, color); @@ -377,7 +377,7 @@ static void drawRegion(const Region ®ion, uint color, const Vertex &offset) { static int r_draw(lua_State *L) { Region *pR = checkRegion(L); - BS_ASSERT(pR); + assert(pR); switch (lua_gettop(L)) { case 3: { @@ -400,7 +400,7 @@ static int r_draw(lua_State *L) { static int r_getCentroid(lua_State *L) { Region *RPtr = checkRegion(L); - BS_ASSERT(RPtr); + assert(RPtr); Vertex::vertexToLuaVertex(L, RPtr->getCentroid()); @@ -409,7 +409,7 @@ static int r_getCentroid(lua_State *L) { static int r_delete(lua_State *L) { Region *pR = checkRegion(L); - BS_ASSERT(pR); + assert(pR); delete pR; return 0; } @@ -443,7 +443,7 @@ static WalkRegion *checkWalkRegion(lua_State *L) { static int wr_getPath(lua_State *L) { WalkRegion *pWR = checkWalkRegion(L); - BS_ASSERT(pWR); + assert(pWR); Vertex start; Vertex::luaVertexToVertex(L, 2, start); @@ -471,11 +471,11 @@ static const luaL_reg WALKREGION_METHODS[] = { bool Geometry::registerScriptBindings() { Kernel *pKernel = Kernel::getInstance(); - BS_ASSERT(pKernel); + assert(pKernel); ScriptEngine *pScript = pKernel->getScript(); - BS_ASSERT(pScript); + assert(pScript); lua_State *L = static_cast< lua_State *>(pScript->getScriptObject()); - BS_ASSERT(L); + assert(L); if (!LuaBindhelper::addMethodsToClass(L, REGION_CLASS_NAME, REGION_METHODS)) return false; if (!LuaBindhelper::addMethodsToClass(L, WALKREGION_CLASS_NAME, REGION_METHODS)) return false; diff --git a/engines/sword25/math/region.cpp b/engines/sword25/math/region.cpp index ae729c4de3..d0d0859906 100644 --- a/engines/sword25/math/region.cpp +++ b/engines/sword25/math/region.cpp @@ -62,7 +62,7 @@ uint Region::create(REGION_TYPE type) { break; default: - BS_ASSERT(true); + assert(true); } return RegionRegistry::instance().resolvePtr(regionPtr); @@ -80,7 +80,7 @@ uint Region::create(InputPersistenceBlock &reader, uint handle) { } else if (type == RT_WALKREGION) { regionPtr = new WalkRegion(reader, handle); } else { - BS_ASSERT(false); + assert(false); } return RegionRegistry::instance().resolvePtr(regionPtr); @@ -206,7 +206,7 @@ Vertex Region::findClosestRegionPoint(const Vertex &point) const { const Polygon &polygon = _polygons[polygonIdx]; - BS_ASSERT(polygon.vertexCount > 1); + assert(polygon.vertexCount > 1); // For each line of the polygon, calculate the point that is cloest to the given point // The point of this set with the smallest distance to the given point is the result. @@ -287,7 +287,7 @@ Vertex Region::findClosestPointOnLine(const Vertex &lineStart, const Vertex &lin // Line of Sight bool Region::isLineOfSight(const Vertex &a, const Vertex &b) const { - BS_ASSERT(_polygons.size()); + assert(_polygons.size()); // The line must be within the contour polygon, and outside of any hole polygons Common::Array::const_iterator iter = _polygons.begin(); diff --git a/engines/sword25/math/region.h b/engines/sword25/math/region.h index fac9f98bb6..fa65b4b7ad 100644 --- a/engines/sword25/math/region.h +++ b/engines/sword25/math/region.h @@ -232,7 +232,7 @@ protected: }; inline const Polygon &Region::getHole(uint i) const { - BS_ASSERT(i < _polygons.size() - 1); + assert(i < _polygons.size() - 1); return _polygons[i + 1]; } diff --git a/engines/sword25/math/vertex.cpp b/engines/sword25/math/vertex.cpp index d9a709ab49..3746ec9410 100644 --- a/engines/sword25/math/vertex.cpp +++ b/engines/sword25/math/vertex.cpp @@ -62,7 +62,7 @@ Vertex &Vertex::luaVertexToVertex(lua_State *L, int stackIndex, Vertex &vertex) lua_pop(L, 1); #ifdef DEBUG - BS_ASSERT(__startStackDepth == lua_gettop(L)); + assert(__startStackDepth == lua_gettop(L)); #endif return vertex; diff --git a/engines/sword25/math/walkregion.cpp b/engines/sword25/math/walkregion.cpp index 23f0e4e2ca..8306553f7b 100644 --- a/engines/sword25/math/walkregion.cpp +++ b/engines/sword25/math/walkregion.cpp @@ -68,7 +68,7 @@ bool WalkRegion::init(const Polygon &contour, const Common::Array *pHol } bool WalkRegion::queryPath(Vertex startPoint, Vertex endPoint, BS_Path &path) { - BS_ASSERT(path.empty()); + assert(path.empty()); // If the start and finish are identical, no path can be found trivially if (startPoint == endPoint) @@ -111,7 +111,7 @@ static void initDijkstraNodes(DijkstraNode::Container &dijkstraNodes, const Regi (*dijkstraIter).parentIter = dijkstraNodes.end(); if (region.isLineOfSight(*nodesIter, start))(*dijkstraIter).cost = (*nodesIter).distance(start); } - BS_ASSERT(dijkstraIter == dijkstraNodes.end()); + assert(dijkstraIter == dijkstraNodes.end()); } static DijkstraNode::Iter chooseClosestNode(DijkstraNode::Container &nodes) { @@ -204,7 +204,7 @@ bool WalkRegion::findPath(const Vertex &start, const Vertex &end, BS_Path &path) // The list is done in reverse order and inserted into the path DijkstraNode::ConstIter curNode = endPoint.parentIter; while (curNode != dijkstraNodes.end()) { - BS_ASSERT((*curNode).chosen); + assert((*curNode).chosen); path.push_back(_nodes[curNode - dijkstraNodes.begin()]); curNode = (*curNode).parentIter; } -- cgit v1.2.3