Well, I use the same system for multiple types. If there are multiple handles, and you want to free them all, then just:
For tmp.mytype = each mytype
if tmp.mytype<>0 then
FreeEntity tmp.mytype
tmp.mytype = 0
endif
Next
For my weapon system I have huge number of types both for the declarations loaded from a .mis file, types for the weapons placed in the world, and types for the weapon in your inventory. Many types refer to eachother with my id system. Like:
Weapon gets loaded into the declaration system, with the id 'ingram' for example. Then my PlaceWeapon command in my custom script system places it in the world, with the parameter 'ingram' then. Which means, when you pick the weapon, it checks the master record telling accuracy, firerate, type of gun etc..., and loads the info from there. Then when you pick it, the weapon in the inventory type also gets the same id as the master record has to get more info when it shoots.
Here's an example on how you can solve this:
Then we just make similar functions for moving them, etc... This is just an example though! :) Handling multiple pointers with unknown number of types is never difficult. Just make sure you think of all bugs before you test :P.
For tmp.mytype = each mytype
if tmp.mytype<>0 then
FreeEntity tmp.mytype
tmp.mytype = 0
endif
Next
For my weapon system I have huge number of types both for the declarations loaded from a .mis file, types for the weapons placed in the world, and types for the weapon in your inventory. Many types refer to eachother with my id system. Like:
Weapon gets loaded into the declaration system, with the id 'ingram' for example. Then my PlaceWeapon command in my custom script system places it in the world, with the parameter 'ingram' then. Which means, when you pick the weapon, it checks the master record telling accuracy, firerate, type of gun etc..., and loads the info from there. Then when you pick it, the weapon in the inventory type also gets the same id as the master record has to get more info when it shoots.
Here's an example on how you can solve this:
Type Models Field id$,filename$,model End Type Function LoadModel(filename$,id$) For tmp.Models = each Models if tmp.Models\id$ = id$ then RuntimeError "Two models can't have same ID!" endif Next tmp.Models = New Models tmp.Models\id$ = id$ tmp.Models\filename$ = filename$ ;store it just incase tmp.Models\model = LoadModel(filename$) if tmp.Models\model<>0 then RuntimeError "Error loading "+filename$+"! Illegal filename?" endif End Function Function KillModel(id$) For tmp.Models = Each Models if tmp.Models\id$ = id$ then FreeEntity tmp.Models\model Delete tmp.Models ;no need to put it back to 0 here, cuz we delete the type entry endif Next End Function
Then we just make similar functions for moving them, etc... This is just an example though! :) Handling multiple pointers with unknown number of types is never difficult. Just make sure you think of all bugs before you test :P.