Gamestudio Links
Zorro Links
Newest Posts
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
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, Power_P), 1,065 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Pointer valid? #221204
08/12/08 19:07
08/12/08 19:07
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Hi!
I have the following code:

Code:
entity* temppointer;

function blabla()
{
   var savepointer;
   savepointer = you;
   you = null;
   while(1)
   {
      temppointer = savepointer;
      if(temppointer == NULL) {return(-1);}
      wait(1);
   }
}


But this function will never return -1 because it never goes into the if, even if the you entity is removed. So how can I check if a pointer is still valid even if the pointer isn't set to null from another function?

Thanks for your help!

Dark_Samurai


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: Pointer valid? [Re: Dark_samurai] #221206
08/12/08 19:10
08/12/08 19:10
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
why not set temppointe to 0 when its removed?


"empty"
Re: Pointer valid? [Re: flits] #221208
08/12/08 19:21
08/12/08 19:21
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Because temppointer is only used for getting access to skills... of the entity, but the pointer itself is saved in the var. So this is like the variable temp (you can/should only use it one frame long because other functions will also use this).
The only solution I currently can imagin would be to use a global pointer for this, but thats not realy handy because in my chase I would need a lot global pointers...

Dark_Samurai


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: Pointer valid? [Re: Dark_samurai] #221221
08/12/08 21:49
08/12/08 21:49
Joined: May 2006
Posts: 398
Bot190 Offline
Senior Member
Bot190  Offline
Senior Member

Joined: May 2006
Posts: 398
if you want the var savepointer to be updated when "you" changes you have to put it in a loop. right now, it sets savepointer to what ever "you" is. but doesn't change when you set "you" to null.


Wait, there isn't a "Make My Game Now" button?
Re: Pointer valid? [Re: Bot190] #221606
08/15/08 03:08
08/15/08 03:08
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Code:
/************************************
	ef_h
		validated get entity by handle
*************************************/
ENTITY* eh1; // entity for ptr_for_handle validation
function ef_h(_handle) {
	eh1 = NULL;
	if (_handle == 0) {
		return(0);
	} 
	eh1 = ptr_for_handle(_handle);
	if (eh1 == NULL) {
		return(0);
	}
	return(handle(eh1));
} 
define _eTarget, skill22;
//...
my._eTarget = handle(you);
//...later
// ...meanwhile back at the ranch
ef_h(my._eTarget);
if (eh1 != NULL) {
	// go home
}
//...

Indeed, it doesn't apply at all.

Re: Pointer valid? [Re: testDummy] #221646
08/15/08 09:56
08/15/08 09:56
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Ok, thanks for your help!
I solved the problem now!

Dark_Samurai


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version

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