Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Assert Triggered in CScriptWeakRef with AngelScript 2.28 samples/game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Squared'D   Members   -  Reputation: 2217

Like
0Likes
Like

Posted 19 December 2013 - 08:36 PM

I've been meaning to use AngelScript for some time, but I'm just getting around to adding it. I thought I'd start with the sample game. I compiled it and ran the program, but after selecting an action, the program gives the following assert message "Assertion failed: strcmp(type->GetName(), "weakref") == 0, file ...\weakref.cpp line 85". I did some investigating and found that when I downgraded to 2.27 it works. So I tried just using the weakref.cpp file from 2.27 with 2.28 and it worked. I'm not experienced enough with AngelScript to figure out why it crashes, but here's the difference in the code

 

2.28 Crashes

CScriptWeakRef::CScriptWeakRef(void *ref, asIObjectType *type)
{
	refCount = 1;
	m_ref  = ref;
	m_type = type;
	m_type->AddRef();

	// The given type should be the weakref template instance
	assert( strcmp(type->GetName(), "weakref") == 0 );

	// Get the shared flag that will tell us when the object has been destroyed
	// This is threadsafe as we hold a strong reference to the object
	m_weakRefFlag = m_type->GetEngine()->GetWeakRefFlagOfScriptObject(m_ref, m_type->GetSubType());
	if( m_weakRefFlag )
		m_weakRefFlag->AddRef();
}

2.27 Works

CScriptWeakRef::CScriptWeakRef(void *ref, asIObjectType *type)
{
	refCount = 1;
	m_ref  = ref;
	m_type = type;
	m_type->AddRef();

	// Get the shared flag that will tell us when the object has been destroyed
	// This is threadsafe as we hold a strong reference to the object 
	m_weakRefFlag = m_type->GetEngine()->GetWeakRefFlagOfScriptObject(m_ref, m_type->GetSubType());
	if( m_weakRefFlag )
		m_weakRefFlag->AddRef();

	// Release the handle that was received, since the weakref isn't suppose to prevent the object from being destroyed
	m_type->GetEngine()->ReleaseScriptObject(m_ref, m_type->GetSubType());
}

I don't know enough about AngelScript to say if a script error (the script needs to be updated) or if there's a problem with the sample's C++ code.


Learn all about my current projects and watch some of the game development videos that I've made.

Squared Programming Home

New Personal Journal

 


Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3226

Like
0Likes
Like

Posted 20 December 2013 - 02:50 PM

I'll look into this. I think the bug is in the sample game on the C++ side, rather than in the weakref add-on.


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

#3 Andreas Jonsson   Moderators   -  Reputation: 3226

Like
0Likes
Like

Posted 20 December 2013 - 07:09 PM

The problem was with the assert(). It should expect either "weakref" or "const_weakref". 

 

I've fixed this in revision 1801. 

 

Regards,

Andreas


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

#4 Squared'D   Members   -  Reputation: 2217

Like
0Likes
Like

Posted 21 December 2013 - 07:21 AM

I'm glad it was a simple fix. I'm looking forward to giving this system a try. Thanks

Learn all about my current projects and watch some of the game development videos that I've made.

Squared Programming Home

New Personal Journal

 





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS