Game Crashing on Startup...

Started by
6 comments, last by TheAzazel666 17 years, 5 months ago
Hello, I've been writing a game in C++ with CRM32Pro, but have been having trouble implementing objects. The problem is, that as soon as you start it up, the program crashes with a "Runtime Error". The log doesn't show anything either... It's a pretty large project, so I've zipped it up and uploaded it to Rapidshare: http://rapidshare.de/files/37396141/Haunt.zip.html Any help would be appreciated ;)
Advertisement
You should be running it through a debugger. When it crashes it will break on the line where the error ocurred and you can debug from there.

-me
Gah, sorry for not mentioning that before ;)

I did that, and found the function that causes it - the problem is, that I can't see what's causing the crashes. The Function is inherited from another class, and looks like this:

bool worldApplication::LoadObject(string iName, string iImage, string iAScript, string iCScript, int xWidth, int xHeight, int iPosX, int iPosY, int iSound)
{
object* temp;

temp = new object();
temp->init(iName, iImage, iAScript, iCScript, xWidth, xHeight, iPosX, iPosY, iSound);

objects.push_back(temp);

return true;
}

Where Objects is a vector of object*. It might be something in the Object Class, but I can't figure it out...

Thanks for your suggestion, though...
If you have built the project as a debug build, you should be able to 'step in' right up to the instruction that causes the exception. It's most likely a memory access-violation, but it could be one of a few things. Once you've located the source of the crash, trace it back to find out how to prevent it. Your debugger should provide some helpful information about the nature of the crash.

This is an absolutely essential debugging manouevre that you'll need to do hundreds, if not thousands of times in your career. You shoudl really learn to solve this on your own - you can't expect others to download and debug your work for you. If you get stuck on a specific, we'd be happy to help, but you'll need to provide a lot more information than you currently are.

Regards
Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
You can't (as far a I know) put a pointer into a vector like that.

It's better to do something like this:

// Assuming it's Global
std::vector< Object* > g_objectList;

// Where you're going to add to the vector list
size_t idx = (!g_objectList.empty()) ? g_objectList.size() : 0;
g_objectList.push_back( NULL );
g_objectList[ idx ] = new Object();

I bet this will fix it.

I know, Admiral, but I've never been particularly good at debugging - especially with this new GCC + Code::Blocks thing - guess it's time to look for some guides, eh? ;)

But, unfortunatly, that wasn't the problem shwasasin. I doubt it's related to the Object class, so I'll fool around with the function a little more..

Thanks for your suggestions, though.
Quote:Original post by shwasasin
You can't (as far a I know) put a pointer into a vector like that.

It's better to do something like this:

// Assuming it's Global
std::vector< Object* > g_objectList;

// Where you're going to add to the vector list
size_t idx = (!g_objectList.empty()) ? g_objectList.size() : 0;
g_objectList.push_back( NULL );
g_objectList[ idx ] = new Object();

I bet this will fix it.


His code for pushing the object into the vector is perfectly fine. Your code too is fine, but it could be made even simplier:
// Assuming it's Globalstd::vector< Object* >        g_objectList;// Where you're going to add to the vector listg_objectList.push_back( new Object() );
Incogito, did you fix the above issue?

This topic is closed to new replies.

Advertisement