Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 629 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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 | chip programmers | 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