Skip to main content
gamedev.net
🔒 Locked

Scripting

Started by Red Skwerl 3 replies 1k views
Original Post
Red Skwerl
Red Skwerl
Hey, I'm developing a 2D game and I'm using a Game Object class as a base for all objects in the world. With the collision detection, originally the type checking was done hardcoded (i.e. what to and what not to collide with). So, me thinking I'm cleaver have made a generic extension of this game object class and have a loop which reads a STD::List for type checking. However, the iterator seems to crash when theres a lot of objects in the world. I think this may be due to the structure being over worked as it works when there aren't that many objects in the world. What do people think: have a generic glass, or have a hardcoded concrete extension? Or am I going int the wrong direction here? Cheers, Red.
Kylotan
Kylotan
I'm not sure what this has to do with scripting, to be honest. However I can tell you that any crash is almost certainly due to an error in your code. std::lists of strings can hold many thousands of objects and are very robust and well-tested. Perhaps it is something you are doing in the loop which breaks things.
Red Skwerl
Red Skwerl
Thanks, sorry, this isn't really a scripting problem per say, I use an XML file to store the collisions and these are loaded at the start of exucution and these structures are re-used.

Im still fairly new to C++, so I'm not sure about the error codes.

I get an "Unhandled exception at 0x00479a17 in game.exe: 0xC00000005: Access violation reading location 0xfeeefeee."

The error happens in "iterator begin()" in list, my code reads

StringList is defined earlier as list and mCollisions is an instance of this.

for (StringList::iterator jt = mCollisions->begin(); jt != mCollisions.end(); jt++){
blah!
}

mCollisions is a SmartPtr, don't know if that changes anything?
Drew_Benton
Drew_Benton
Quote:
Original post by Red Skwerl
I get an "Unhandled exception at 0x00479a17 in game.exe: 0xC00000005: Access violation reading location 0xfeeefeee."

The error happens in "iterator begin()" in list, my code reads


I believe that error means that you are accessing data that is not initialized. Before you enter in that for loop, check to see if mCollisions.size() > 0. 0xfeeefeee usually means free memory I believe. They have added in certain memory assigments so you have tips in debugging - such as "0xcccccccc" and "0xdeadc0de". Also you say that "the iterator seems to crash when theres a lot of objects in the world". Does it work with less objects at all? If so what are the interactions of the objects. IE: If you have 100 objects colliding it may crash, but if you have 10 objects and it works, but they do not collide, that could be a case testing problem.

- Drew
Red Skwerl
Red Skwerl
according to this: http://www.nobugs.org/developer/win32/debug_crt_heap.html#table the 0xfeeefeee occurs after HeapFree() is called which is part of malloc. This is going a lot deeper then my knowledge.

This article http://support.microsoft.com/default.aspx?kbid=873155 seems to suggest that the 0xC00000005 error code means something has not been initialised properly.

At the moment, I've only got two objects in the game world, a tank and bullets that are fired from the tank. I've left the game alone for a few minutes and nothing fails, I fire a few times, nothing, it happens when I fire alot, the bullets wrap around the screen and maybe overlap the tank a few times. This is when the crash occurs.

I added a conditional to see if size > 0 and still get the same errors.

~Red

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.