🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Config groups not working as expected in 2.5

Started by
1 comment, last by WitchLord 18 years, 5 months ago
Hey, I have some code that worked in 2.4 but stopped working when I upgraded to 2.5. I make all game objects in my game global variables so that all scripts can see them. When a new level is loaded, I need to clear these global variables. It seemed like the way to clear out global variables in angelscript was to make them part of a config group, and then remove that config group when I needed those variables to disappear. In the level load stage, I create a config group called "Level", setup all of my game objects, and then end config group. I then give my main level module access to this config group. When the level clears, I do the following actions in order: 1. I abort the context for the level. 2. I release the context for the level. 3. I create a new context for the level. 4. I discard the level's module. 5. I run GC on the script engine 6. I call RemoveConfigGroup("Level") I now get a asCONFIG_GROUP_IS_IN_USE after the call. When the new level loads, all common objects (for example, a wall texture) already exist (but point to bad memory) and I get asNAME_TAKEN errors (obviously). Any suggestions on a way to fix my config group or an alternate way to clear out global variables? Update: Here's some more info. It appears that RemoveConfigGroup() returns the error because the group's refcount is greater than 0, NOT because it has live objects. Thanks [Edited by - Zoma on January 18, 2006 12:34:43 PM]
Advertisement
I found the problem. I have a keyboard binding system, similar to the Quake series. When a bound key is pressed, it runs a command using ExecString(). I used ExecString() with the same module that was used by my level. I'm not sure why this worked before and not now. Perhaps a reference to the config group is not released after the call to execstring() is finished? Or perhaps I have to release the context that is used in the execstring() call?
The ExecuteString() function should automatically release the context upon exit, unless you tell it to return the context to you (by passing a pointer to a pointer to a context in the parameter.)

The context has to be released, otherwise it will hold a reference to the function it just executed, which in turn may hold a reference to the config group that you're trying to release.

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