Use assert or return macro in action.c and mapgrid.c
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7493 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
aea547e583
commit
28c3264c1c
24
src/action.c
24
src/action.c
|
@ -647,11 +647,7 @@ BOOL actionVisibleTarget(DROID *psDroid, BASE_OBJECT *psTarget, int weapon_slot)
|
|||
WEAPON_STATS *psStats;
|
||||
|
||||
CHECK_DROID(psDroid);
|
||||
ASSERT(psTarget != NULL, "actionVisibleTarget: Target is NULL");
|
||||
if (!psTarget)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ASSERT_OR_RETURN(false, psTarget != NULL, "Target is NULL");
|
||||
|
||||
if (psDroid->numWeaps == 0)
|
||||
{
|
||||
|
@ -880,12 +876,8 @@ BOOL actionReachedBuildPos(DROID *psDroid, SDWORD x, SDWORD y, BASE_STATS *psSta
|
|||
{
|
||||
SDWORD width, breadth, tx,ty, dx,dy;
|
||||
|
||||
ASSERT_OR_RETURN(false, psStats != NULL && psDroid != NULL, "Bad stat or droid");
|
||||
CHECK_DROID(psDroid);
|
||||
ASSERT(psStats != NULL, "Bad stat");
|
||||
if (!psStats || !psDroid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// do all calculations in half tile units so that
|
||||
// the droid moves to within half a tile of the target
|
||||
|
@ -938,12 +930,7 @@ BOOL actionDroidOnBuildPos(DROID *psDroid, SDWORD x, SDWORD y, BASE_STATS *psSta
|
|||
SDWORD width, breadth, tx,ty, dx,dy;
|
||||
|
||||
CHECK_DROID(psDroid);
|
||||
|
||||
ASSERT(psStats != NULL, "Bad stat");
|
||||
if (!psStats)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ASSERT_OR_RETURN(false, psStats != NULL, "Bad stat");
|
||||
|
||||
dx = map_coord(psDroid->pos.x);
|
||||
dy = map_coord(psDroid->pos.y);
|
||||
|
@ -979,8 +966,7 @@ static void actionHomeBasePos(SDWORD player, SDWORD *px, SDWORD *py)
|
|||
{
|
||||
STRUCTURE *psStruct;
|
||||
|
||||
ASSERT( player >= 0 && player < MAX_PLAYERS,
|
||||
"actionHomeBasePos: invalide player number" );
|
||||
ASSERT_OR_RETURN(, player >= 0 && player < MAX_PLAYERS, "Invalid player number %d", (int)player);
|
||||
|
||||
for(psStruct = apsStructLists[player]; psStruct; psStruct=psStruct->psNext)
|
||||
{
|
||||
|
@ -1016,7 +1002,7 @@ void actionUpdateDroid(DROID *psDroid)
|
|||
CHECK_DROID(psDroid);
|
||||
|
||||
psPropStats = asPropulsionStats + psDroid->asBits[COMP_PROPULSION].nStat;
|
||||
ASSERT(psPropStats != NULL, "invalid propulsion stats pointer");
|
||||
ASSERT_OR_RETURN(, psPropStats != NULL, "Invalid propulsion stats pointer");
|
||||
|
||||
// clear the target if it has died
|
||||
for (i = 0; i < DROID_MAXWEAPS; i++)
|
||||
|
|
|
@ -192,7 +192,8 @@ static void gridCalcCoverage(BASE_OBJECT *psObj, SDWORD objx, SDWORD objy, COVER
|
|||
// add an object to the grid system
|
||||
void gridAddObject(BASE_OBJECT *psObj)
|
||||
{
|
||||
ASSERT(!isDead(psObj), "Added a dead object to the map grid!");
|
||||
ASSERT_OR_RETURN(, psObj != NULL, "Attempted to add a NULL pointer");
|
||||
ASSERT_OR_RETURN(, !isDead(psObj), "Attempted to add dead object %s(%d) to the map grid!", objInfo(psObj), (int)psObj->id);
|
||||
gridCalcCoverage(psObj, (SDWORD)psObj->pos.x, (SDWORD)psObj->pos.y, GRID_ADDOBJECT);
|
||||
}
|
||||
|
||||
|
@ -232,7 +233,7 @@ void gridRemoveObject(BASE_OBJECT *psObj)
|
|||
{
|
||||
if (psCurr->apsObjects[i] == psObj)
|
||||
{
|
||||
ASSERT(false, "Grid out of sync at (%u,%u):%u removing %s", x, y, i, objInfo(psObj));
|
||||
ASSERT(false, "Grid out of sync at (%u,%u):%u removing %s(%d)", x, y, i, objInfo(psObj), (int)psObj->id);
|
||||
psCurr->apsObjects[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -248,12 +249,12 @@ void gridRemoveObject(BASE_OBJECT *psObj)
|
|||
// could affect a location (x,y in world coords)
|
||||
void gridStartIterate(SDWORD x, SDWORD y)
|
||||
{
|
||||
ASSERT(x >= 0 && x < gridWidth * GRID_UNITS && y >= 0 && y < gridHeight * GRID_UNITS, "coords(%d, %d) off grid", x, y);
|
||||
const int nx = x / GRID_UNITS;
|
||||
const int ny = y / GRID_UNITS;
|
||||
|
||||
x = x / GRID_UNITS;
|
||||
y = y / GRID_UNITS;
|
||||
ASSERT_OR_RETURN(, nx >= 0 && nx < gridWidth && ny >= 0 && ny < gridHeight, "Coordinates(%d, %d) off grid(%u, %u)", nx, ny, gridWidth, gridHeight);
|
||||
|
||||
psIterateGrid = apsMapGrid[GridIndex(x,y)];
|
||||
psIterateGrid = apsMapGrid[GridIndex(nx, ny)];
|
||||
iterateEntry = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue