Gamestudio Links
Zorro Links
Newest Posts
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
Zorro version 3.0 prerelease!
by TipmyPip. 02/24/26 17:09
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
4 registered members (Martin_HH, TipmyPip, AndrewAMD, Grant), 5,825 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
check for valid handle #373847
06/13/11 16:34
06/13/11 16:34
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi Jcl,

I need to check if a handle is valid (for some kind of garbage collection).

Therefore I currently use "ptr_for_handle" and check the return value. If it is NULL I assume that the handle was invalid.

The code works fine, but when I set warn_level >= 2 I get a warn message from the engine (as stated in the manuel).

Is there any better way to check for a valid handle so that I can use warn_level >=2 ???

Regards,
Pegamode.

Re: check for valid handle [Re: pegamode] #373852
06/13/11 17:31
06/13/11 17:31
Joined: Jul 2008
Posts: 894
T
TechMuc Offline
User
TechMuc  Offline
User
T

Joined: Jul 2008
Posts: 894
1) check if the type of the handle is destroyed (see: "The handle is stored in the first 4 bytes of an engine object. It consists of a unique index number plus an object type identifier in the high byte, taken from the following table . The handle can be used to identify the type of the object. For converting the handle to a var that contains the index number, right shift it by 24, then left shift the resulting int by 10. The identifiers are defined in atypes.h" http://www.conitec.net/beta/ain-handle.htm)

2) If the type is valid iterate over the given type via ptr_first and c_link.next ( http://www.conitec.net/beta/aptr_first.htm ), and search for the given handle.

This will allow you the use of a "silent" ptr_for_handle..

Re: check for valid handle [Re: TechMuc] #373856
06/13/11 18:12
06/13/11 18:12
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Thanks for the answer ... I did step 1) already in another part of my code, so I can reuse the function. Unfortunately I forgot that I did it this way some months ago :-)


Moderated by  old_bill, Tobias 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1