Gamestudio Links
Zorro Links
Newest Posts
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
3 registered members (AndrewAMD, 7th_zorro, Ayumi), 749 guests, and 8 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
struct handle? #184020
02/15/08 07:06
02/15/08 07:06
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
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
R
RicheyMB2 Offline
Newbie
RicheyMB2  Offline
Newbie
R

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: RicheyMB2] #184022
02/15/08 15:47
02/15/08 15:47
Joined: Jul 2005
Posts: 34
Hong Kong
U
ultranet Offline
Newbie
ultranet  Offline
Newbie
U

Joined: Jul 2005
Posts: 34
Hong Kong
struct doesn't have a handle.

In your example:
typedef struct sZonePos{ var zPos[3]; var zPan;} sZonePos;
sZonePos z1s0Pos;
...//inside some entity's function
my.sZoneSlot = handle(z1s0Pos);...

Why do you do it in this way to set "my.sZoneSlot = handle(z1s0Pos);" ?
You can get sZoneSlot anywhere because it is declared by you in the global scope. And you can declare a local struct pointer to sZoneSlot if only the current entity need to access this struct.

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 Offline OP
Serious User
PrenceOfDarkness  Offline 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
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

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 Offline OP
Serious User
PrenceOfDarkness  Offline 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.
Re: struct handle? [Re: PrenceOfDarkness] #184026
02/16/08 10:27
02/16/08 10:27
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Hmm that's an interesting point. The pointer will certainly not work, but since a global struct is guaranteed to exist on all machines, the engine could implement handles for global structs..

Re: struct handle? [Re: Excessus] #184027
02/16/08 11:45
02/16/08 11:45
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Hey, it seems like jcl has read your post, check this out: http://www.conitec.net/beta/ pVars is exactly what you need.


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