What happens when...?

Blitz3D Forums/Blitz3D Programming/What happens when...?

IPete2(Posted 2007) [#1]
I have a game which will have multiple levels and a menu system.

When I select to play the game and enter the main loop I load an entity in that level and set up its collision type using

Entitytype levelname , collisiontype

At the end of the game, if I free the entity 'levelname', does that remove the entitytype and radius settings too or do I have to do anything else? Are there any unusual circumstances where I have to be extra careful when freeing entitys? I noticed freeing a parent also frees anything parented to it.

Thanks,

IPete2.


I


jfk EO-11110(Posted 2007) [#2]
You don't have to do anthing with entity properties (as EntityType is). The whole structure of the entity will be freed.
If you load the same entity again, the structure will be initialized with the defaults, no matter if you use it with the same variable.
You maybe should set the variable to zero after freeing it, to make sure you'll be able to check if it's still a valid entity.


IPete2(Posted 2007) [#3]
Cool thanks,

Any thoughts on type items such as:

b\NPC_name = FindChild(b\entitymesh,"ROOT_UU3D")

b\NPC_name is an entity which I have to free isn't it? Will I have to clear animation sequences loaded using "loadanimseq" too or does freeentity b\nPC_name sort all the animations allocated to it too?

IPete2.


Dreamora(Posted 2007) [#4]
you don't have to free it.
but you have to delete b when you free the entitymesh or at least set b\NPC_name to 0 (although that is a pointless variable naming as an entity used as a name is highly missleading)


Gabriel(Posted 2007) [#5]
Yeah, you don't have to free it. As you already mentioned yourself before, children are freed automatically. FindChild ( and GetChild for that matter ) don't copy the entity, they just give you a reference to it. And that reference will die when you destroy the parent mesh, so Dreamora's right about deleting B or setting the variable to 0 so that you cannot accidentally refer to a non-existent mesh.


IPete2(Posted 2007) [#6]
You guys are great, thanks for the help.

IPete2.