* Change animObj_Remove such that it doesn't set the passed in ANIM_OBJECT* pointer to NULL (i.e. a ** pointer was passed)

* Instead rely on setting that pointer to NULL in the client code that calls animObj_Remove in the first place
  - This was already done in all but one case where animObj_Remove was called

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6180 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-10-16 17:40:58 +00:00
parent 64910221e7
commit cb2ec762e2
5 changed files with 30 additions and 43 deletions

View File

@ -286,16 +286,7 @@ animObj_Find( void *pParentObj, int iAnimID )
return (ANIM_OBJECT*)hashTable_FindElement(g_pAnimObjTable, (intptr_t) pParentObj, iAnimID);
}
/***************************************************************************/
BOOL
animObj_Remove( ANIM_OBJECT **ppsObj, int iAnimID )
bool animObj_Remove(ANIM_OBJECT* psObj, int iAnimID)
{
BOOL bRemOK = hashTable_RemoveElement(g_pAnimObjTable, *ppsObj, (intptr_t)(*ppsObj)->psParent, iAnimID);
//init the animation
*ppsObj = NULL;
return bRemOK;
return hashTable_RemoveElement(g_pAnimObjTable, psObj, (intptr_t)psObj->psParent, iAnimID);
}
/***************************************************************************/

View File

@ -97,7 +97,7 @@ void animObj_SetDoneFunc( ANIM_OBJECT *psObj,
/* uwCycles=0 for infinite looping */
ANIM_OBJECT * animObj_Add( void *pParentObj, int iAnimID,
UDWORD udwStartDelay, UWORD uwCycles );
BOOL animObj_Remove( ANIM_OBJECT **ppsObj, int iAnimID );
bool animObj_Remove(ANIM_OBJECT* psObj, int iAnimID);
ANIM_OBJECT * animObj_GetFirst( void );
ANIM_OBJECT * animObj_GetNext( void );

View File

@ -285,7 +285,7 @@ void droidRelease(DROID *psDroid)
/* remove animation if present */
if (psDroid->psCurAnim != NULL)
{
animObj_Remove(&psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID);
animObj_Remove(psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID);
psDroid->psCurAnim = NULL;
}
@ -386,7 +386,6 @@ void recycleDroid(DROID *psDroid)
void removeDroidBase(DROID *psDel)
{
DROID *psCurr, *psNext;
BOOL bRet;
DROID_GROUP *psGroup;
STRUCTURE *psStruct;
@ -413,8 +412,8 @@ void removeDroidBase(DROID *psDel)
/* remove animation if present */
if (psDel->psCurAnim != NULL)
{
bRet = animObj_Remove( &psDel->psCurAnim, psDel->psCurAnim->psAnim->uwID );
ASSERT( bRet == true, "destroyUnit: animObj_Remove failed" );
const bool bRet = animObj_Remove(psDel->psCurAnim, psDel->psCurAnim->psAnim->uwID);
ASSERT(bRet, "animObj_Remove failed");
psDel->psCurAnim = NULL;
}
@ -669,8 +668,6 @@ static void droidBurntCallback( ANIM_OBJECT * psObj )
void droidBurn(DROID *psDroid)
{
BOOL bRet;
CHECK_DROID(psDroid);
if ( psDroid->droidType != DROID_PERSON )
@ -689,8 +686,8 @@ void droidBurn(DROID *psDroid)
}
else
{
bRet = animObj_Remove( &psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID );
ASSERT( bRet == true, "unitBurn: animObj_Remove failed" );
const bool bRet = animObj_Remove(psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID);
ASSERT(bRet, "animObj_Remove failed");
psDroid->psCurAnim = NULL;
}
}

View File

@ -2280,7 +2280,6 @@ static void moveUpdatePersonModel(DROID *psDroid, SDWORD speed, SDWORD direction
float fPerpSpeed, fNormalSpeed, dx, dy, fSpeed;
float iDroidDir;
SDWORD slideDir;
BOOL bRet;
CHECK_DROID(psDroid);
@ -2296,8 +2295,8 @@ static void moveUpdatePersonModel(DROID *psDroid, SDWORD speed, SDWORD direction
if ( psDroid->psCurAnim != NULL &&
psDroid->psCurAnim->psAnim->uwID != ID_ANIM_DROIDFIRE )
{
bRet = animObj_Remove( &psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID );
ASSERT( bRet == true, "moveUpdatePersonModel: animObj_Remove failed" );
const bool bRet = animObj_Remove(psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID);
ASSERT(bRet, "animObj_Remove failed");
psDroid->psCurAnim = NULL;
}
@ -2358,8 +2357,8 @@ static void moveUpdatePersonModel(DROID *psDroid, SDWORD speed, SDWORD direction
(psDroid->psCurAnim->psAnim->uwID != ID_ANIM_DROIDRUN ||
psDroid->psCurAnim->psAnim->uwID != ID_ANIM_DROIDRUN) )
{
bRet = animObj_Remove( &psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID );
ASSERT( bRet == true, "moveUpdatePersonModel: animObj_Remove failed" );
const bool bRet = animObj_Remove(psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID);
ASSERT(bRet, "animObj_Remove failed" );
psDroid->psCurAnim = NULL;
}
@ -2375,8 +2374,8 @@ static void moveUpdatePersonModel(DROID *psDroid, SDWORD speed, SDWORD direction
} else {
// If the droid went off screen then remove the animation, saves memory and time.
if(!clipXY(psDroid->pos.x,psDroid->pos.y)) {
bRet = animObj_Remove( &psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID );
ASSERT( bRet == true, "moveUpdatePersonModel : animObj_Remove failed" );
const bool bRet = animObj_Remove(psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID);
ASSERT(bRet, "animObj_Remove failed");
psDroid->psCurAnim = NULL;
debug( LOG_NEVER, "Removed person run anim\n" );
}
@ -2585,7 +2584,6 @@ moveUpdateCyborgModel( DROID *psDroid, SDWORD moveSpeed, SDWORD moveDir, UBYTE o
BASE_OBJECT *psObj = (BASE_OBJECT *) psDroid;
UDWORD iMapZ = map_Height(psDroid->pos.x, psDroid->pos.y);
SDWORD iDist, iDx, iDy, iDz, iDroidZ;
BOOL bRet;
CHECK_DROID(psDroid);
@ -2594,9 +2592,9 @@ moveUpdateCyborgModel( DROID *psDroid, SDWORD moveSpeed, SDWORD moveDir, UBYTE o
{
if ( psDroid->psCurAnim != NULL )
{
if ( animObj_Remove( &psDroid->psCurAnim, psDroid->psCurAnim->uwID ) == false )
if (!animObj_Remove(psDroid->psCurAnim, psDroid->psCurAnim->uwID))
{
debug( LOG_NEVER, "moveUpdateCyborgModel: couldn't remove walk anim\n" );
debug(LOG_NEVER, "couldn't remove walk anim");
}
psDroid->psCurAnim = NULL;
}
@ -2664,8 +2662,8 @@ moveUpdateCyborgModel( DROID *psDroid, SDWORD moveSpeed, SDWORD moveDir, UBYTE o
// If the droid went off screen then remove the animation, saves memory and time.
if(!clipXY(psDroid->pos.x,psDroid->pos.y))
{
bRet = animObj_Remove( &psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID );
ASSERT( bRet == true, "moveUpdateCyborgModel : animObj_Remove failed" );
const bool bRet = animObj_Remove(psDroid->psCurAnim, psDroid->psCurAnim->psAnim->uwID);
ASSERT(bRet, "animObj_Remove failed");
psDroid->psCurAnim = NULL;
}
}
@ -2678,13 +2676,14 @@ moveUpdateCyborgModel( DROID *psDroid, SDWORD moveSpeed, SDWORD moveDir, UBYTE o
/* jumping cyborg: remove walking animation if present */
if ( psDroid->psCurAnim != NULL )
{
if ( (psDroid->psCurAnim->uwID == ID_ANIM_CYBORG_RUN ||
psDroid->psCurAnim->uwID == ID_ANIM_SUPERCYBORG_RUN ||
psDroid->psCurAnim->uwID == ID_ANIM_CYBORG_PACK_RUN) &&
(animObj_Remove( &psDroid->psCurAnim, psDroid->psCurAnim->uwID ) == false) )
if ((psDroid->psCurAnim->uwID == ID_ANIM_CYBORG_RUN
|| psDroid->psCurAnim->uwID == ID_ANIM_SUPERCYBORG_RUN
|| psDroid->psCurAnim->uwID == ID_ANIM_CYBORG_PACK_RUN)
&& !animObj_Remove(psDroid->psCurAnim, psDroid->psCurAnim->uwID))
{
debug( LOG_NEVER, "moveUpdateCyborgModel: couldn't remove walk anim\n" );
debug(LOG_NEVER, "couldn't remove walk anim");
}
psDroid->psCurAnim = NULL;
}
/* add jumping or landing anim */

View File

@ -3762,9 +3762,9 @@ void structureUpdate(STRUCTURE *psBuilding)
void structureRelease(STRUCTURE *psBuilding)
{
/* remove animation if present */
if ( psBuilding->psCurAnim != NULL )
if (psBuilding->psCurAnim != NULL)
{
animObj_Remove( &psBuilding->psCurAnim, psBuilding->psCurAnim->psAnim->uwID );
animObj_Remove(psBuilding->psCurAnim, psBuilding->psCurAnim->psAnim->uwID);
psBuilding->psCurAnim = NULL;
}
@ -4809,9 +4809,9 @@ BOOL removeStruct(STRUCTURE *psDel, BOOL bDestroy)
}
/* remove animation if present */
if ( psDel->psCurAnim != NULL )
if (psDel->psCurAnim != NULL)
{
animObj_Remove( &psDel->psCurAnim, psDel->psCurAnim->psAnim->uwID );
animObj_Remove(psDel->psCurAnim, psDel->psCurAnim->psAnim->uwID);
psDel->psCurAnim = NULL;
}
@ -4971,9 +4971,9 @@ BOOL destroyStruct(STRUCTURE *psDel)
}
/* remove animation if present */
if ( psDel->psCurAnim != NULL )
if (psDel->psCurAnim != NULL)
{
animObj_Remove( &psDel->psCurAnim, psDel->psCurAnim->psAnim->uwID );
animObj_Remove(psDel->psCurAnim, psDel->psCurAnim->psAnim->uwID);
psDel->psCurAnim = NULL;
}