[ENet-discuss] Sending numerical values in packets
Mika Halttunen
lsoft at mbnet.fi
Sat Nov 8 04:26:05 PST 2003
Greetings!
I was wondering, how could I send numerical values, i.e. short ints,
ints and floats, using ENetPackets?
I would also need to read them in on the receiver's side of course. And
what about big- and little-endianess?
For example: I want to sent player position packet, containing id (=
byte) and a pair of floats.
------------------------------------------
char array[128] = "";
int data_len = 1 + 4 + 4; // 1 byte, two floats
// Modify the array here to contain the values
array[0] = PLAYER_POS_ID; // For example 1
// ...
ENetPacket *packet = enet_packet_create(array, data_len, 0);
// Send it away
// ...
------------------------------------------
Thanks in advance!
--
Mika Halttunen
lsoft at mbnet.fi
More information about the ENet-discuss
mailing list