- Code: Select all
Actor *getClosestClone( char *actorName)
{
Actor *resultActor;
Actor *testActor;
int nClones = 0;
int index = 1;
double testDistance;
double minDistance = 1024;
nClones = ActorCount( actorName );
while ( index <= nClones )
{
testActor = getclone2( actorName, index - 1 );
testDistance = distance ( x, y , testActor->x, testActor->y );
if ( testDistance < minDistance )
{
minDistance = testDistance;
resultActor = testActor;
}
index++;
}
return resultActor;
}
How do I set this up so it will return Actor if success, invalid Actor (with cloneindex = -1 and name = "invalid Actor") on error?