Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
0 registered members (), 631 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
doubts with send_data and struct list #414476
01/03/13 00:09
01/03/13 00:09
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
I'm working on a multi Massive Game ONLINE and came across the following problem.

Below a picture of the game running ONLINE.



I believe that is not possible I send data packets using different (structs lists) in client and server, if I'm wrong, please correct me!
So I'm a great difficulty to developing a communication in order to maintain an updated LIST of the Online Players in clients.

Below is another picture showing how I am working with structs communication on client and server



When the player enters the game, the server sends to him an updated list with all players online in moment.

On Client This struct list contains only one variable to the entity (handle) of the players.
Because this way, I can set all entities for you, and apply individual actions for (players entitys);

My problem is send this struct list to customers. because I can only send the same list of communication that I already use to send the information:
(path, angle, messages etc ...).

someone could tell me some suggestion?
How can I keep this list updated on the clients?


Please! Use easy words to be translated. because my English is not very good! Grateful.
_______________________________________________________
Re: doubts with send_data and struct list [Re: NeoNeper] #414486
01/03/13 07:40
01/03/13 07:40
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The first byte of your structs should be an identification byte, f.i. as follows:

struct _DATA {
int type; // or short or char
};

struct _DATA_CHAT {
int type;
short player_id;
char msg[128];
};

struct _DATA_MOVE {
int type;
short player_id;
var input; // f.i holds the key inputs from the player
};

typedef struct _DATA DATA;
typedef struct _DATA_CHAT DATA_CHAT;
typedef struct _DATA_MOVE DATA_MOVE;

#define TYPE_CHAT 1
#define TYPE_MOVE 2

DATA_MOVE dm_player[16];

The first struct is not really necessary but IMO makes it nicer to handle.
Now you can proceed as follows:

received data/ buffer?
DATA* mydata = (DATA*)buffer;
if(mydata->type == TYPE_MOVE)
{
DATA_MOVE* move = (DATA_MOVE*)buffer;
dm_player[move->player_id].input = move->input;
}
if(mydata->type == TYPE_CHAT) ...


I hope this gives you an idea how to handle this situation (only programmed something like this once, so it may not be the best method, I don't know).
Additionally, I would suggest that you do not use synchronized global entities (and thus their handles) but only create local entities. If you know have let's say 20 players you simply create 20 player models on each machine locally and move and handle them using your data structs. This gives you full control over your simulation and you do not have to rely on or wait for the entity synchronization and so on.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: doubts with send_data and struct list [Re: Superku] #414520
01/03/13 19:22
01/03/13 19:22
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
ohh mannn. Thanks for the explanation!
I really knew not handle the "void * buffer" in this way. I am also grateful for the tip to use local entities!

if be done this way, security would not be more vulnerable?


Please! Use easy words to be translated. because my English is not very good! Grateful.
_______________________________________________________
Re: doubts with send_data and struct list [Re: NeoNeper] #414521
01/03/13 19:45
01/03/13 19:45
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
You're welcome!
I don't know much about security in multiplayer games but obviously your server should check and verify all input he gets from one client before he sends it to the remaining clients (valid movements/ actions, ...).
Just don't try to create something like WoW or another MMORPG and you will be fine, it's way too complicated (and expensive), even for some big studios.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: doubts with send_data and struct list [Re: Superku] #414709
01/06/13 23:19
01/06/13 23:19
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
I did some tests using local entities.
I used the "cheat engine" to do some basic hacks of the speed and position and noticed that with this is very easy to cheat the game.

Create validations on the server for each transmission of information would be very labor intensive and cost more processing time.

I'll make some tests using global entities and report the result

Could you give me more some informations?
doing this way you taught me. How could I send data packets containing struc array?

Last edited by NeoNeper; 01/06/13 23:59.

Please! Use easy words to be translated. because my English is not very good! Grateful.
_______________________________________________________
Re: doubts with send_data and struct list [Re: NeoNeper] #414744
01/07/13 11:20
01/07/13 11:20
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Well I don't know about that program or multiplayer/ network security but a very simple yet maybe effective check on the server could be if the entity moved more than his maximum speed in the last frames (the server should then of course save the old position of every player).

Quote:
How could I send data packets containing struc array?

I don't know what you mean, could you explain in detail?
Sending something like
PL_INFO player_info[16];
could be realized as simple as
for(i = 0; i < max_player; i++) send_data_to(NULL,player_info[i],sizeof(PL_INFO));


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: doubts with send_data and struct list [Re: Superku] #414784
01/07/13 16:09
01/07/13 16:09
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
Code:
PLAYERS* players[100];
...
players[0]=new(PLAYERS);
players[0].id = id;
players[0].sampla= sample;
...
send_data_to(NULL,players,sizeof(PLAYERS));



this way I did up there, it works, but I have no way of knowing what kind of data is being sent.
no have "_type" variable for *void in on receive.

So I need to send a simple struct containing an struct array within another struct

Sample:
Code:
typedef struct _PLAYERS
{

var id;
var sample;
...

}PLAYERS

typedef struct _clients
{

int _type;
struct _PLAYERS client[100]

}clients

...
send data
...

clients* players=new(clients);

players._type = PLAYERS_LIST;
players->client[0]=new(PLAYERS);
players->client[0].id = id;
players->client[0].id = id;

players->client[1]=new(PLAYERS);
players->client[1].id = id;
players->client[1].id = id;
...etc

send_data_to(NULL,players,sizeof(clients));



Its no work (T.T)


Last edited by NeoNeper; 01/07/13 16:12.

Please! Use easy words to be translated. because my English is not very good! Grateful.
_______________________________________________________
Re: doubts with send_data and struct list [Re: NeoNeper] #414787
01/07/13 16:44
01/07/13 16:44
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Just do it as I suggested, use a simple struct to determine the type of the struct and then cast the void pointer to the appropriate struct:

received data/ buffer?
DATA* mydata = (DATA*)buffer;
if(mydata->type == TYPE_MOVE)

{
DATA_MOVE* move = (DATA_MOVE*)buffer;
dm_player[move->player_id].input = move->input;
}
if(mydata->type == TYPE_CHAT) ...

All structs have to have the same type variable as the first member.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: doubts with send_data and struct list [Re: Superku] #415394
01/18/13 00:42
01/18/13 00:42
Joined: Nov 2007
Posts: 318
Brasil, Paraná
NeoNeper Offline OP
Senior Member
NeoNeper  Offline OP
Senior Member

Joined: Nov 2007
Posts: 318
Brasil, Paraná
Superku!
I'm working the way you taught me, usando using _type to identify data packets.
This works very well!.
But I still need learn to send and receive this type of list:

Code:
typedef struct _DATA_CLIENTS
{	
	int _type;
	struct _PLAYERS* client[100];
	
}DATA_CLIENTS;



I did not want to use a "for()" loop to this because it will be the server that will send this data packet.
I do not want to overload the server with many send_data_to inside a "for()" loop.


could you give me more this help? .
Tanks Superku! You is Brother (^.~)

Last edited by NeoNeper; 01/18/13 00:42.

Please! Use easy words to be translated. because my English is not very good! Grateful.
_______________________________________________________
Re: doubts with send_data and struct list [Re: NeoNeper] #415395
01/18/13 00:47
01/18/13 00:47
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Glad that it works for you.
However, I don't think that this is possible as your struct here only contains 100 POINTERS, not there actual content. When you are using multiple send_data_to calls (or other send_... instructions) the engine does not send the data immediately but collects it and sends a bigger pack (there is some variable like dplay_packetsize or the like) then, thus it should be fine to use a loop and multiple send_ instructions. (I'm not a 100% sure, though.)


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Page 1 of 2 1 2

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