|
struct handle?
#184020
02/15/08 07:06
02/15/08 07:06
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
Can i get the handle of a struct? For example: Code:
typedef struct sZonePos { var zPos[3]; var zPan; } sZonePos;
sZonePos z1s0Pos;
...//inside some entity's function my.sZoneSlot = handle(z1s0Pos); ...
IF NOT, can someone explain to me how I can go about doing something like this?
"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: struct handle?
[Re: PrenceOfDarkness]
#184021
02/15/08 11:37
02/15/08 11:37
|
Joined: Feb 2008
Posts: 39
RicheyMB2
Newbie
|
Newbie
Joined: Feb 2008
Posts: 39
|
I don't think you can use the handle function to do this. It looks like this was a way around the problem of handles in c script. The code below shows storing the handle of tdata in the var v. Then passing that information into the pointer odata. Hope it helps. Code:
typedef struct MYDATA { int a; int b; int c; } MYDATA;
var v; MYDATA tdata;
MYDATA* odata;
function main() { tdata.a = 1; tdata.b = 2; tdata.c = 3; v = &tdata; odata = v; if (odata.a == 1) { video_window(NULL, NULL, 112, "hello"); } }
|
|
|
Re: struct handle?
[Re: ultranet]
#184023
02/15/08 22:18
02/15/08 22: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'm developing a multiplayer game... the values on one machine don't always match the values on other machines.
BTW thanks for the input, i will try all of that when i get home. Hopefully it will work over a network.
Last edited by PrenceOfDarkness; 02/15/08 22:19.
"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: struct handle?
[Re: PrenceOfDarkness]
#184024
02/15/08 22:49
02/15/08 22:49
|
Joined: Jan 2004
Posts: 2,013 The Netherlands
Excessus
Expert
|
Expert
Joined: Jan 2004
Posts: 2,013
The Netherlands
|
No, pointers won't work over the network and structs don't have handles. And there's a good reason for that.
Many structs don't have to be synchronized over the network. If you create a struct with pointers to all your HUD elements, other players don't have to know about that particular struct on your computer. So it is very well possible for a struct instance to exist on one machine, and not on another. So there is no way to have a handle that refers to the same instance on all connected machines, since you may not waht that instance to exist on all machines.
What the engine does with entities is replicate them. If you create an entity, a handle is assigned to it and the other systems on the network are told to create an entity with that handle, too. All changes made to the entity are broadcast to the other machines where the changes are effected too.
You can devise a similar system yourself. If you create a struct that you want to have replicated, you assign it some unique ID (make sure they're actually unique: have a single authority to assign IDs, or use GUIDs). Then broadcast a message to all systems to tell them that they should create a struct with that ID. Then everytime you change something about the struct somewhere, send an update stating that struct with ID x was changed to state y.
I hope this was usefull, let me know if you have questions..
|
|
|
Re: struct handle?
[Re: Excessus]
#184025
02/16/08 04:54
02/16/08 04:54
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
i understand completely but it kind of destroys my hope. Multiplayer just gets more and more complicated. And the bugs just make a seamingly simple thing incrediably teadious!
edit: I just want to make sure.. so that means even if I have a defined global struct from the get go, the pointer wont work right?
Last edited by PrenceOfDarkness; 02/16/08 05:18.
"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.
|
|
|
|