Advertisement

asCModule::Build() now deletes previous scripts before compiling new?

Started by May 03, 2012 05:31 PM
2 comments, last by WitchLord 12 years, 6 months ago
Hello there,

sorry for consuming your time once again, but I'm stuck at a strange AngelScript behaviour and I need a hint from the original author of this source to solve the issue.

I just upgraded from 2.20.3 to 2.23.1. Upgrading was done be simply copying over the new files, removing the one asm-file that seems to be gone, and adding every new source to the solution. Compiles fine, no apparent interface changes, good thing. But suddenly all but one of my scripts are not executed anymore.

I do the following for hundreds of times:

asIScriptModule::AddScriptSection( "module", someCode);
asIScriptModule::Build();

which worked fine in 2.20.3. Now in 2.23.1 most of my script executions end up with an error "function 'prepare" with 'null'" or something. I stepped through the code for some hours and I finally noticed what I think is the problem. Whenever I call Build(), the InternalReset() function at as_module.cpp:196 destroys all my previously compiled script functions before compiling the new one. I end up with three script modules, each with exactly ONE script function inside. All application-registered types, functions, methods are still there, but all but one script functions compiled at startup are gone. What do I need to do to fix this problem?

Thanks for your time!

Bye, Thomas
----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.
Whenever Build() is called it discards the old content and compiles the new script. This has always been the case.

If you want a module built from multiple script sections then you should add all the script sections first and only call Build() at the end so they will be built together.

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
As much as I appreciate your work, but I have to disagree. At least in version 2.20.3 you could incrementally add script sections and build all the accumulated script code repeatedly. My software design was based on this assumption, and upto now it worked just fine.

But from your answer I learned that this was an accident, and it won't come back for good. I better get started rewriting the script system to account for this.
----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.
What probably happened was that the script functions in previous builds were kept alive by the garbage collector or explicit references, e.g. by a live object that might call the old functions.

This is still true, i.e. even though you discard a module the compiled script is not immediately destroyed unless nobody is referencing it.

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

This topic is closed to new replies.

Advertisement