Posted: 26th Nov 2011 5:54
So after finding a bug with how agk deletes images, I tried to go for a much more object-oriented solution(yay!).

Now the game crashes before it even gets going.

It crashes at the first assignment statement:

+ Code Snippet
template<class T> T* cHashedList<T>::GetItem( const char *szID )
{
	if ( !szID ) return UNDEF;
	UINT index = HashIndex( szID );
	cHashedItem *pItem = m_pHashedItems[ index ];
	while( pItem )
	{
		if ( pItem->m_szID && strcmp( szID, pItem->m_szID ) == 0 ) return pItem->m_pItem;
		pItem = pItem->m_pNextItem;
	}

	return UNDEF;
}


If this isn't a bug, some explanation would help.
Posted: 26th Nov 2011 6:04
More info, in case it's needed:

szID has values for the location and file name of one of the images I'm trying to load and value 'a'

It also appears to be the first item it's trying to load, which would make sense, because I can't place any breakpoints before the crash happens, so it apparently occurs before the Begin function is executed.
Posted: 26th Nov 2011 11:54
And just to be sure, I've now gotten the latest version of AGK...still crashes
Posted: 26th Nov 2011 12:01
Hey, I'm nothing if not persistent...

It happens when I check to see if a file exists.
Posted: 26th Nov 2011 12:15
If I decide not to go the safe route, and just load up whatever image comes along, it crashes at the same location.

Also, if I decide to pass a literal instead of a variable, it crashes on that as well.
Posted: 26th Nov 2011 12:52
What's the HashIndex() function doing?
Posted: 26th Nov 2011 12:54
Wish I knew. I think, I'm slowly tracking it down though.

Being a bit of a novice with C++, apparently, you cannot make really complex commands during initialization of an object.

I moved the complex commands to a different function, so I have an initialization, and then a setup. This has removed the bug for now...we'll see if it's a solution...
Posted: 27th Nov 2011 1:28
i don't like hash tables. It looks like you somehow going off the array somehow. If you use a vector instead of a hash table you can resize the vector accordingly. The problem I find with hash tables are they are static and not dynamic.
or you can change
cHashedItem *pItem = m_pHashedItems[ index ];
to
cHashedItem *pItem = m_pHashedItems[ index+1 ];
Posted: 27th Nov 2011 6:56
Yeah, the hash table was part of AGK's code, not mine.

But no worried (for now) I have worked around it by not putting so much complex code in the class initializer.