Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualjustin12343

Posted 24 May 2013 - 04:00 PM

I solved that frame rate problem. My debug output window was filling up with "accessing null pointer" errors. Now I'm checking for null pointers before I try to access:

 

for (int i = 0; i < NumLogs; ++i)
{
	int id = create_instance( x+(LogWidth*i), y, objBridgeNode);
	objBridgeNode_controller @node;
	Object @obj = get_instance( id);

	if (obj != null)
		@node = cast<objBridgeNode_controller>( @obj.GetScriptObject());
	else
		continue;
	
	if (node == null)
		continue;

	node.ParentBridge = GetId();
	node.Id = i;
	
	Nodes[i] = id;
}

Apparently, I'm getting null pointers every time as if the cast operator does not know what type the returned asIScriptObject really is.

 

Even this doesn't work:

 

Base_Object_IMP @base = null;

base = cast<Base_Object_IMP>( @obj.GetScriptObject());

 

The result is still null. I know asIScriptObject being passed is valid before hand, so what can this problem be?

 

Edit:

 

Here's my other Base_Object class if it helps:

class Base_Object : Base_Object_IMP
{
//========== Constructor / Destructor ===========
	Base_Object( Object @obj)
	{
		@this.object = obj;
		x = object.x;
		y = object.y;
		sprite_index = -1;
		mask_index = -1;
		image_index = object.image_index;
		depth = object.depth;
	}

//=========== Events =============
	void Create(){}
	void Destroy(){}
	void Alarm1(){}
	void Alarm2(){}
	void Alarm3(){}
	void Alarm4(){}
	void Alarm5(){}
	void Alarm6(){}
	void Alarm7(){}
	void Alarm8(){}
	void Alarm9(){}
	void Alarm10(){}
	void Alarm11(){}
	
	void BeginStep(){}
	void Step(){}
	void EndStep(){}
	
	void Collision( int objType, int objId, Object @other){}
	
	void Key( int key){}
	void KeyPressed( int key){}
	void KeyReleased( int key){}
	
	void MouseButton( int button){}
	void MouseButtonPressed( int button){}
	void MouseButtonReleased( int button){}
	
	void JoystickButton( int id, int button){}
	void JoystickButtonPressed( int id, int button){}
	void JoystickButtonReleased( int id, int button){}
	
	void OutsideRoom(){}
	void OutsideView(){}
	void IntersectBoundary(){}
	
	void GameStart(){}
	void GameEnd(){}
	
	void RoomStart(){}
	void RoomEnd(){}
	
	void NoMoreLives(){}
	void NoMoreHealth(){}
	
	void AnimationEnd(){}
	void EndOfPath(){}
	void Draw(){}

//======= Collision =========
	bool place_meeting( float mX, float mY, int type)
	{
		return object.PlaceMeeting( mX, mY, type);
	}
	
	bool place_meeting_depth( float mX, float mY, int depth, int type)
	{
		return object.PlaceMeetingDepth( mX, mY, type, depth);
	}
	
	Base_Object @object_place( float mX, float mY, int type)
	{
		Base_Object @base = null;
		Object @obj = object.ObjectPlace( mX, mY, type);
		
		if (obj == null)
			return null;
		else
			//obj.GetScriptObject().retrieve( @base);
			@base = cast<Base_Object>(@obj.GetScriptObject());
			
		return base;
	}


//========== Misc ===========
	uint GetId()
	{
		return object.GetId();
	}

	void SetRect( int l, int t, int w, int h)
	{
		object.general_rect.left = l;
		object.general_rect.top = t;
		object.general_rect.right = l+w;
		object.general_rect.bottom = t+h;
	}
	
//======= Variables =========
	Object @object;
	float x;
	float y;
	int sprite_index;
	int mask_index;
	int image_index;
	int depth;
}

 

classes are declared like:

objBridge_controller : Base_Object

{

....

}


#1justin12343

Posted 24 May 2013 - 03:52 PM

I solved that frame rate problem. My debug output window was filling up with "accessing null pointer" errors. Now I'm checking for null pointers before I try to access:

 

for (int i = 0; i < NumLogs; ++i)
{
	int id = create_instance( x+(LogWidth*i), y, objBridgeNode);
	objBridgeNode_controller @node;
	Object @obj = get_instance( id);

	if (obj != null)
		@node = cast<objBridgeNode_controller>( @obj.GetScriptObject());
	else
		continue;
	
	if (node == null)
		continue;

	node.ParentBridge = GetId();
	node.Id = i;
	
	Nodes[i] = id;
}

Apparently, I'm getting null pointers every time as if the cast operator does not know what type the returned asIScriptObject really is.

 

Even this doesn't work:

 

Base_Object_IMP @base = null;

base = cast<Base_Object_IMP>( @obj.GetScriptObject());

 

The result is still null. I know asIScriptObject being passed is valid before hand, so what can this problem be?


PARTNERS