ClearWorld and Includes??

Blitz3D Forums/Blitz3D Programming/ClearWorld and Includes??

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

After the ClearWorld statement all of your resources are lost

I think clearworld only applies to the 3d stuff.? I think images and sounds are not effected (or so i seem to remember :/ )

Its always good programming practise to dispose of every resource when it is no longer required as a matter of protocol rather than relying on clearworld/endgraphics etc. It makes it more effecient when loading a new level etc. I usually load all my "source meshes" and hide them straight away. Then when i need them (like monsters etc) just use copyentity to create disposable instances of the originals in small datastructures.

Eg. What i usually do is create a type datastructure for all disposables as a rule of thumb, then i can then just call: (for example)

function cleanuplevel()
    ;clear level's SFX
    freesound g_leveltune : g_leveltune=0

    ;Dispose of main level mesh
    Freeentity g_levelmesh : g_levelmesh=0

    ;Clean copies of loaded "source" meshes
    For s.t_scenerycompoent=each t_scenerycomponent 
         freeentity s\handle : delete s 
    next
    For m.t_monsters=each t_monsters 
         freeentity m\handle: delete m 
    next

    etc...

end function

then for things that can stay loaded like source meshes, they dont get wiped out and have to be reloaded next time.