Posted: 24th Nov 2011 7:26
Hello Everyone--

I'm getting a crash at agk::sync() and I think the following function is the problem:

+ Code Snippet
void app::myLoadImage(int imageNum, char fileLoc[])
{
	if (agk::GetFileExists(fileLoc))
	{
		if (agk::GetImageExists(imageNum))
			agk::DeleteImage(imageNum);

		agk::LoadImage(imageNum, fileLoc);
	}
}


We need certain sprites (not all) to maintain the same image number, even if we change the image. If we just do a loadimage, the game complains that the imagenumber is already being used. So I tried this solution, but this seems to not work either.
Posted: 24th Nov 2011 8:37
For more information:

The crash actually occurs in this piece of code (in cspritemgr.h) on the else case.

+ Code Snippet
			UINT GetTextureID()
			{
				switch( m_iType )
				{
					case 1: 
					{
						if ( !((cSprite*)m_pItem)->GetImagePtr() ) return 0;
						else return ((cSprite*)m_pItem)->GetImagePtr()->GetTextureID();
						break;
					}

					case 2: return 0; break;
					case 3: return 0; break;
					default: return 0;
				}
			}
Posted: 24th Nov 2011 10:54
Actually, I take that back, it's crashing on the if statement, I read VS2010 incorrectly.
Posted: 24th Nov 2011 17:40
Thanks, I'll get that fixed. Since you are in tier 2 you have the option of working around it by using the image pointer to load a replacement image.

+ Code Snippet
cImage* pImage = agk::GetImagePtr( imageNum );
pImage->Load( fileLoc );