Dynamic reloading script
I'm not entirely sure if it is enough to do just that, or if something else will be required to make things fully working. I'll continue to analyse this over the time.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
wait for the new version!
[edit] I analyze this! Empty constructor is really need!
Example this code
Before reload ref_a.val == 10 after ref_a.val == -1
A ref_a;
B @r;
class A
{
int val;
}
class B
{
B(){
ref_a.val = -1;
}
}
void startGame()
{
@r = B();
ref_a.val = 10;
}
void reloaded()
{
output( "ref_a: " + ref_a.val );
}
Obviously if the object is created with the new method, and then the CSerializer doesn't initialize all the members, for example if a new member has been introduced in the script, then script may not work as expected afterwards. But I guess that is expected. I'll see if it is easy to warn in case this happens.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
You'll find the changes in revision 1327.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
I chose to use the name AddExtraObjectToStore() as I thought it was more clear on the meaning of the function.
You can get the changes in revision 1329.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
I find two bugs, frist:
file: serealizer.cpp line: 98
void *newPtr = m_engine->CreateScriptObject( type->GetTypeId() );
change to:
void *newPtr = m_engine->CreateUninitializedScriptObject( type->GetTypeId() );
second:
file: serealizer.cpp line: 357
if( type->GetFactoryCount() == 0 )
{
(void**)m_restorePtr = m_handlePtr;
}
change to:
if( type->GetFactoryCount() == 0 )
{
m_children[0]->m_restorePtr = m_handlePtr;
}
full source: http://www.everfall.com/paste/id.php?9kzqvaefx31w
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game