I'd like to know how the orxConfig_Clear() works. I call it and get the following warning:
Warning: section <Camera> can't be deleted as it's protected by 1 entities
This is the first warning, after that there are some others relating to other sections
this is my Camera section
FrustumWidth = 800
FrustumHeight = 600
FrustumFar = 1000.0
FrustumNear = 0.0
When I call orxConfig_Clear(), does orx clear every section?
I know I can protect a section from being deleted, but does the system protect some of them without my action?
Do I need to load the main config file after clearing?
Sections can be manually protected or will get protected by orx when you have living instances of structures created with *_CreateFromConfig(). This is to make sure that reading data on the fly by the created structure will still be valid (especially for the *_GetName() functions that reference directly config sections).
In your case you probably created a viewport that, in his turn, has created a camera named <Camera> and that is still alive when you call orxConfig_Clear().
When you clear the config, any information read from file or modified/created at runtime will be wiped off. You might want to reload some files in order to be able to continue running.
My question is what do you actually want to do when calling orxConfig_Clear()? I mean, for which purpose are you doing this? Do you really want to wipe everything off?
If not, you can simply clear specific sections or even simply override their content. So far I never had to clear entirely the config content myself (usually I only erase a level information or save data by cleaning the corresponding sections).
Hope this helps!
My purpose is the same as yours, erase level info. So, if I understood correctly if I have objects created by CreateFromConfig I need to delete them first and then delete the corresponding config section, right?
And what if I have a section with, let's say, ParentCamera set and the camera object is alive? If there is no living object created based on this section, will it be deleted?
Yes, I wasn't very clear: only the section itself won't get deleted but its content will still get wiped off. Orx only keeps direct references to section names and preventing the section from being deleted insures that its name as well as its parenting is conserved.
Protecting a section won't prevent any changes from being made on its content.