Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Trading Journey
by 7th_zorro. 04/27/24 04:42
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 747 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Even_data question #316655
03/25/10 20:01
03/25/10 20:01
Joined: Feb 2009
Posts: 46
Spain
B
Beker Offline OP
Newbie
Beker  Offline OP
Newbie
B

Joined: Feb 2009
Posts: 46
Spain
I need to send two types of different "struct" in my network code, how do I recognise inside "EVEN_DATA", which of the two "struct" commands I have recieved up to this point, I have not seen any example of of either.

Re: Even_data question [Re: Beker] #316694
03/25/10 21:57
03/25/10 21:57
Joined: Nov 2002
Posts: 913
Berlin, Germany
S
SchokoKeks Offline
User
SchokoKeks  Offline
User
S

Joined: Nov 2002
Posts: 913
Berlin, Germany
that is a very good question, I'm interested in the answer too.

Re: Even_data question [Re: Beker] #316973
03/28/10 11:15
03/28/10 11:15
Joined: Feb 2009
Posts: 46
Spain
B
Beker Offline OP
Newbie
Beker  Offline OP
Newbie
B

Joined: Feb 2009
Posts: 46
Spain
nobody knows??????????????? crazy

Re: Even_data question [Re: Beker] #316976
03/28/10 11:27
03/28/10 11:27
Joined: May 2009
Posts: 445
Peine, Germany
Razoron Offline
Senior Member
Razoron  Offline
Senior Member

Joined: May 2009
Posts: 445
Peine, Germany
I don't know if this works, but maybe like this:
Code:
typedef struct MYDATA1 {
  int x;
  char c[20];
} MYDATA;
typedef struct MYDATA2 {
  int x;
  int y;
  char c[20];
} MYDATA2;
... 
MYDATA1* mydata1 = { x = 1; c = "Test!"; }
MYDAT21* mydata2 = { x = 1; y = 1; c = "Test!"; }
 
// sending data
send_data_to(NULL,mydata,sizeof(MYDATA1));
 
//receiving data
function on_client_event(void* buffer) 
{
  if (event_type == EVENT_DATA)
    if(sizeof(buffer)==sizeof(MYDATA1))
      ....
    if(sizeof(buffer)==sizeof(MYDATA2))
      ....
}



Last edited by Razoron; 03/28/10 11:28.
Re: Even_data question [Re: Beker] #320363
04/21/10 09:13
04/21/10 09:13
Joined: Feb 2009
Posts: 46
Spain
B
Beker Offline OP
Newbie
Beker  Offline OP
Newbie
B

Joined: Feb 2009
Posts: 46
Spain
This idea has a problem, if all structs have the same size can not differentiate.

Re: Even_data question [Re: Beker] #320379
04/21/10 12:22
04/21/10 12:22
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
You could use ANet for this. If you send a struct with ANet, it is automatically updated on the receiver. If you want to see if the struct has changed, just send an event after you updated the struct or you could save the content of the struct and check if the content has changed.

Visit: http://www.anet-plugin.com for further informations. The Manual should give you an idea of how a struct can be sent (enet_send_data() is the function you are looking for).


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: Even_data question [Re: Dark_samurai] #323741
05/17/10 03:31
05/17/10 03:31
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Wouldn't this do?


Code:
Code:typedef struct MYDATA1 {
  bool dirty;
  int x;
  char c[20];
} MYDATA;
typedef struct MYDATA2 {
  bool dirty;
  int x;
  int y;
  char c[20];
} MYDATA2;
... 
MYDATA1* mydata1 = { dirty = 0,x = 1; c = "Test!"; }
MYDAT21* mydata2 = { dirty =0, x = 1; y = 1; c = "Test!"; }
 
// sending data
mydata1.dirty=1;
send_data_to(NULL,mydata,sizeof(MYDATA1));
 
//receiving data
function on_client_event(void* buffer) 
{
  if (event_type == EVENT_DATA)
    if(Mydata1.dirty == 1)
    {
       Do_Something_Dirty1();
       mydata1.dirty =0;
    }
      ....
       if(Mydata2.dirty == 1)
    {
       Do_Something_Dirty2();
       mydata2.dirty =0;
    }
...

}




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