1 registered members (AndrewAMD),
1,310
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
OP
Serious User
|
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
Vadim647
Senior Member
|
Senior Member
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
OP
Serious User
|
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]
#184442
02/19/08 05:40
02/19/08 05:40
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
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
Excessus
Expert
|
Expert
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
OP
Serious User
|
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: Excessus]
#184446
02/22/08 04:00
02/22/08 04:00
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
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.
|
|
|
|