Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (AndrewAMD, TipmyPip, NewbieZorro, Grant), 14,196 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: how to call ptr_for_handle without "crash" [Re: Oxy] #365905
03/30/11 02:41
03/30/11 02:41
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Very good programming.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: how to call ptr_for_handle without "crash" [Re: Oxy] #365926
03/30/11 12:51
03/30/11 12:51
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: Oxy
Right now I have the problem that a removed entity
is not recognized as NULL, but
is like a "ZERO" entity, with positiondata at 0,0,0 for example.

This engine really has some flaws.


if(myTarget!=NULL)
{
if((myTarget.x==0) && (myTarget.z==0) ) {ent_remove(myTarget);}

-> results in a crash, because myTarget is NULL ...

so first its Not Null, then its Null...
Very good engine programming

Removed entities are not NULL. An Entity cannot be NULL. NULL is a value that can be assigned to pointers. Lite-C has no way of finding out where you saved pointers to entities and set them automatically to NULL for you. Your code crashes because myTarget is a vagabonding pointer, not because it is NULL and suddenly not NULL. A value different from NULL does not mean a pointer is necessarily valid.

http://tutorial.3dgamestudio.net/


Always learn from history, to be sure you make the same mistakes again...
Re: how to call ptr_for_handle without "crash" [Re: Uhrwerk] #365930
03/30/11 13:16
03/30/11 13:16
Joined: Feb 2009
Posts: 2,154
Damocles_ Offline
Expert
Damocles_  Offline
Expert

Joined: Feb 2009
Posts: 2,154
is there an instruction to let the engine test if
a pointer is valid?

The pointer is known, the engine knows its objects internally.
So it should be a simple step to confirm the validity
of the object by iterating though the list of objects.

Re: how to call ptr_for_handle without "crash" [Re: Damocles_] #365932
03/30/11 13:37
03/30/11 13:37
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You can easily do that yourself by iterating over the engine objects with ptr_first (void* object). If the pointer you want to check is amongst the engine objects it is valid, otherwise it is not. However, this is not recommendable in terms of speed and won't work for other memory blocks you have allocated yourself.


Always learn from history, to be sure you make the same mistakes again...
Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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