D
D
Daamgo2015-12-14 01:16:08
C++ / C#
Daamgo, 2015-12-14 01:16:08

How to properly generate an economical player data package?

typedef struct 
{
 int id;
 std::string name;
 float pos[3];
 float eye[3];
} PacketMultiPlayer;

PacketMultiPlayer serverMuPacket[10];

//вот так отсылает сервер -> клиенту
send(sock,(char*)serverMuPacket,sizeof(serverMuPacket),0);

The task is roughly the following. There is a 3d space in which the players move.
The player's coordinates (X/Y/Z) and rotation (Y) are sent to the server.
The server gives an array of 10 - 1 (your player) players in which the coordinates of others are transmitted to set their positions on the client.
The problem is the following.
I receive an array from the server, but let's say if there are 2 players. The 8 others are empty. I believe that there is a more economical way to store information about players, the problem is that I do not know how.
Having googled a little foreign sites and forums, thanks to the translator. I managed to find out that they use vectors, sheets. It is sad that it was not possible to find examples of use.
for(int np = 0; np < 11; np++)
      {
        if(serverMuPacket[np].name != name && serverMuPacket[np].id != 0 && serverMuPacket[np].name != "")
        {
//устанавливаю позицию и поворот на клиенте
        }
      }

I need to generate a low cost player data package for a client. No empty arrays.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Wolf, 2015-12-14
@Daamgo

dev.mindillusion.ru/std-vector

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question