clearworld and types

Blitz3D Forums/Blitz3D Beginners Area/clearworld and types

Doggie(Posted 2007) [#1]
What's the deal with types after issuing a clearworld?
To load a new level I issue a clearworld then call a function from an include file to load the new level then use a goto to take the program back in front of the main loop to reload the player, the enemies and bullets which are all types but I keep getting an entity doesn't exist error for either the enemies or their bullets. I know the goto works cuz my player is reloaded. What do I need to do to types to get them to reload after the new level is loaded?


Stevie G(Posted 2007) [#2]
Only entities are deleted when using clearworld. So I'm guessing that you need to also delete the existing player enemy and bullet types before creating new ones.

You should really have a reload_all_entities function rather than using a goto, where you can keep all the existing types as they are but just allocate the newly loaded meshes to their respective fields. Without seeing your code it's not easy to go into more detail.

Stevie


Doggie(Posted 2007) [#3]
http://files.filefront.com/shootrar/;9183498;/fileinfo.html

Use army8.bb

Thanks for having a look


Stevie G(Posted 2007) [#4]
Sorry mate but I don't have time to hunt through all that code and fix it for you - I was merely making a suggestion.


Doggie(Posted 2007) [#5]
That's ok, maybe someone will get curious.
Thanks!

Dog


Matty(Posted 2007) [#6]
I always try to design my code that a clear world is unnecessary by including an unload and a load function after and before my 'core loop'. Usually I store references to all entity handles, texture handles, pivots, sounds, music etc in types and/or banks then manually free them as required. It is not too hard with a bit of forethought to design your system so that there are no memory leaks and that resources are managed such that it is easy to free them all and unfree them. What can complicate matters is if you are using external libs which include calls to 'clearworld' in their cleanup code.