Hello there.
I have a problem regarding my game. This error always shows up every time I exited the program.
This is not the first time I occured this error, and previously I was able to get rid of this error by using string variables carefully.
But this time I really got no idea on what caused the error to raise.
Here's a little part of my code that causes the error:
#define GameState int
#define SPR_SPLASHSCRN 300
//.......
GameState CurrentState = GS_RSRCLOADING;
void DarkGDK()
{
//.......
float SplashAlpha = 0, FadeStep = 1.25f;
bool SplashLoop1 = false, SplashLoop2 = false, SplashCompleted = false;
while(LoopGDK())
{
switch(CurrentState)
{
case GS_RSRCLOADING:
//.......
CurrentState = GS_SPLASHSCRN;
//.......
break;
case GS_SPLASHSCRN:
//.......
if(!SplashCompleted)
{
dbSprite(SPR_SPLASHSCRN, 0, 0, GetImageIDByName("State_Splash.png"));
// [[ HERE ]] ----------------------
// if I remove the code below, no BO will occur (starts from here)
if(!SplashLoop1 && !SplashLoop2)
{
if(SplashAlpha >= 254)
SplashLoop1 = true;
SplashAlpha += FadeStep;
}
else if(SplashLoop1 && !SplashLoop2)
{
if(SplashAlpha <= 1)
SplashLoop2 = true;
SplashAlpha -= FadeStep;
}
else if(SplashLoop1 && SplashLoop2)
SplashCompleted = true;
// (ends here)
dbSetSpriteAlpha(SPR_SPLASHSCRN, (int)SplashAlpha);
}
else
{
dbDeleteSprite(SPR_SPLASHSCRN);
CurrentState = GS_LOGINSCRN;
}
break;
case GS_LOGINSCRN:
//.......
break;
//.......
}
dbSync();
}
return;
}
I've searched around the forum, but most of the cases were related to carelessness in the use of C-string variables.
Any kind of help would be appreciated!
[note: GetImageIDByName(char *szImgName) returns an INT (yes, the ID for that image)]
A buffer overrun has occurred in MyGame.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.
For more details please see Help topic 'How to debug Buffer Overrun Issues'.
if(asleep) sheep++;