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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,310 guests, and 1 spider.
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 1 of 2 1 2
Send_var_2 and pointers #184437
02/17/08 18:18
02/17/08 18:18
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
I know that send_var_2 can't send pointers and I don't want it to. Is there any way for me to send the variable that the pointer is pointing to?


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: Send_var_2 and pointers [Re: PrenceOfDarkness] #184438
02/17/08 18:43
02/17/08 18:43
Joined: Feb 2008
Posts: 337
V
Vadim647 Offline
Senior Member
Vadim647  Offline
Senior Member
V

Joined: Feb 2008
Posts: 337
Try sending handle(you)
It will simply send object id. Then use ptr_for_handle(myvar).
P.S: You're studying multiplayer, as I see.


I switched to other account since marth 2010. Guess which.
Re: Send_var_2 and pointers [Re: Vadim647] #184439
02/18/08 00:54
02/18/08 00:54
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
variables don't have handles, according to handles in the manual. Anyone else?


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: Send_var_2 and pointers [Re: PrenceOfDarkness] #184440
02/18/08 03:05
02/18/08 03:05
Joined: Apr 2006
Posts: 136
San Francisco
T
Tor Offline
Member
Tor  Offline
Member
T

Joined: Apr 2006
Posts: 136
San Francisco
dereference the pointer.


"Towlie, you're the worst character ever." I know...
Re: Send_var_2 and pointers [Re: Tor] #184441
02/18/08 05:13
02/18/08 05:13
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
how?


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: Send_var_2 and pointers [Re: PrenceOfDarkness] #184442
02/19/08 05:40
02/19/08 05:40
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
I did derefrence it, the game crashes...


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: Send_var_2 and pointers [Re: PrenceOfDarkness] #184443
02/19/08 07:57
02/19/08 07:57
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
If I understand you correctly, what you explain is the normal, intended use of send_var_to.

For example, say you have declared global var v. Then you give v a value: v=10;. Then you send it with send_var_to(my, &v). Now it will send the variable that "&v" is pointing to, which is ofcourse v.

&v is a pointer, and likewise you can send any pointer, as long as it points to a global var. For example:
var* p; // var pointer
var v; // var
p = &v; // p points to v
v = 10;
send_var_to(my, p); // no & this time, p is a pointer so you shouldn't take it's address (thats what & does), but just pass its contents which IS a mem addr.

Re: Send_var_2 and pointers [Re: Excessus] #184444
02/21/08 18:37
02/21/08 18:37
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
you are completely right! I'm so glad to say that I was doing some stupid stuff with the code I didn't realize.

By any chance do you know the proper way to pass a structs pointer to a function and use it in the function correctly? That's what the crash was. I'm still kind of new to structs I guess.

Code:

typedef struct sZoneMove
{
var zMove;
var zRotate;
} sZoneMove;

sZoneMove sZone1Move1;
sZoneMove* pZoneMove;

function sendVarZone(sZoneMove* test, var zoneNum)
{
send_var_to(tempEnt,test);
}

function someOtherFunction{
pZoneStruct = my.zoneStruct;
pZoneMove = &sZone1Move1;
sendVarZone(pZoneMove.zMove,my.zone);}



Isn't that right?


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: Send_var_2 and pointers [Re: PrenceOfDarkness] #184445
02/21/08 18:44
02/21/08 18:44
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Whenever you have such a problem, you should be asking yourself: what type is expected here, and what am I actually passing in?

In the case of your sendVarZone function, what type does it expect as first parameter?
What type are you actually passing as a parameter?

Re: Send_var_2 and pointers [Re: Excessus] #184446
02/22/08 04:00
02/22/08 04:00
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
Okay I saw that, but it still crashes:

Code:

typedef struct sZoneMove
{
var zMove;
var zRotate;
} sZoneMove;

sZoneMove sZone1Move1;
sZoneMove* pZoneMove;

function sendVarZone(sZoneMove *var, var zoneNum)
{
//the crash happens as soon as sendVarZone is called, nothing ever happens in here
}

....
sendVarZone(pZoneMove,my.zone);



Try it yourself really quick, and you'll see what i mean.


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

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