Advertisement

Null Pointer Reference

Started by August 25, 2011 08:35 PM
1 comment, last by _orm_ 13 years, 3 months ago
See title. Here is the stack trace. The object in question is the TA_Body that is being passed down into an agent's memory hash.




=========================
| Exception: Null pointer access (T46)
| Module : Stage
| Section : TribalAeronauts/AI/TA_Fighter_Think.ang
| Line : 38
| Column : 9
=========================
---- CALL STACK ----
(Stack - 0)Func: void TA_Fighter_Think::BodyEncountered(TA_Body@)
(Stack - 0)Sect: TribalAeronauts/AI/TA_Fighter_Think.ang
(Stack - 0)Modl: Stage | Line: 38, Colu: 9
(Stack - 0)Variables: this = 0xa5b7300(TA_Fighter_Think)
TA_Body@ body = 0xa5bf5cc,

(Stack - 1)Func: void TA_Mind_Fighter::OnBodyWithinRadarRange(TA_Body@)
(Stack - 1)Sect: TribalAeronauts/TA_Mind_Fighter.ang
(Stack - 1)Modl: Stage | Line: 33, Colu: 9
(Stack - 1)Variables: this = 0xbfefd70(TA_Fighter_Think)
TA_Body@ body = 0xa5bf5e0,

(Stack - 2)Func: void TA_Body::OnCollide(Actor@, CollisionBody@)
(Stack - 2)Sect: TribalAeronauts/TA_Body.ang
(Stack - 2)Modl: Stage | Line: 247, Colu: 3
(Stack - 2)Variables: this = 0xbfcc388(TA_Fighter_Think)
Actor@ other = 0xa5bf604,
CollisionBody@ mcb = 0xa5bf608,

(Stack - 3)Func: void Actor::OnCollideTest(int, int)
(Stack - 3)Sect: Engine/Actor.ang
(Stack - 3)Modl: Stage | Line: 148, Colu: 98
(Stack - 3)Variables: this = 0xbfcc388(TA_Fighter_Think)
int act = 37,
int mycolbody = 41,


EDIT: I fixed the problem by nullcheckking an earlier cast to the TA_Body type, but what is bizzare is that I have a function that allows me to explicitly check if an object is of a certain type by means of a string. That ended up returning true... What is more, not a single object I am casting is returning a valid handle when I know for a fact that there is at least one object that should cast correctly to the TA_Body.
Can you show a bit of your script? Perhaps I can help you figure out why the cast is not valid.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Figured out what the problem was, and it was a bit silly on my part. When the OnCollide function is called, I was actually passing in an integer handle for an Actor type and wrapping that in an instance of just Actor. So basically the entire inheritance tree was lost. I resolved this by passing in an IObject for the collision callback instead of the integer, and then cast it from there. The new OnCollide callback looks like this.

void OnCollide(IObject@ other,CollisionBody@ mcb)
{
if(mcb.ID == m_AwarenessSphere.m_CB.ID)
{
Actor@ act = cast<Actor@>(other);
if(m_RadarListener !is null && act.Is("TA_Body"))
{
Println("the object is a TA_Body.");
TA_Body@ b = cast<TA_Body@>(act);
m_RadarListener.OnBodyWithinRadarRange(b);
}
}
}



I would, however, like to convert this to use the generic handle type, but I can't see how I would do so from the C++ side.

This topic is closed to new replies.

Advertisement