int getfreeSN(){
int spritenumber = 11;
while (dbSpriteExist(spritenumber)==1){
spritenumber++;
}
return spritenumber;
}
I call this function when I want to assign a sprite number that is not in use to one of my sprites (example, boss[Uberdude].spriteNum = getfreeSN()
, I figured this would be a good way to manage sprites.
Some times it's returning a sprite number that is currently being used, making more than 1 sprite have the same number, which results in the last dbSprite command that used the shared sprite number being the one that shows up.
I can't figure out what it could be doing wrong. It should be starting at 11 every time it is called, then increasing it every time it finds out that sprite number is in use, then returning the value when it finds that it is not being used.
Is this a DGDK(7.4a) problem, or am I missing something incredibly obvious that's causing the problem?