Game Development Community

Can't add new SimObjectPtr to GameConnection

by Noah Dyer · in Torque Game Engine · 04/03/2006 (12:15 pm) · 3 replies

My game requires that the user be able to control two objects simultaneously, the player and a GameBase object. But I'm getting stopped in my tracks fairly early on.

In GameConnection.h I added the following line after the declaration of mControlObject (I'm not in front of my dev machine right now, so forgive me if I make any capitilization or similar errors):
SimObjectPtr<GameBase> mControl2;
Then in gameConnection.cc I added the following in the GameConnection constructor
mControl2 =  NULL;
I've not exposed the variable to script, I've not assigned it a value anywhere, and I've not created any methods that use it. However, when I run the engine it crashes even before the GG splash screen is shown. It says the error is in netstringtable and reads "error ref count is already 0".

Any ideas why my additions would be causing this error. I did a search for SimObjectPtr and SimObjectPtr looking for similar problems, but came up empty handed. I also made the same changes on a clean build and had the same problem, so I don't think its anything I've done to the Engine.

#1
04/04/2006 (11:28 am)
I got my builds confused :$ Everything above is correct except for one major difference: there is no error message when the game crashes. Sorry to have thrown any of you potential helpers off the trail.
#2
04/04/2006 (12:06 pm)
Hmm, that should work fine.
are you sure it's not something else ?
try getting rid of mControl2 and seeing if it runs.

mAimObject is a SimObjectPtr, implemented as you describe.
#3
04/04/2006 (2:42 pm)
When I comment out the two lines containing mControl2 it compiles and runs fine. Also, I get the same crash if I change GameBase to ShapeBase. I looked at the call stack in the debugger, and it looks like the last thing GameConnection related that is still on the stack when the crash occurs is the the destructor.