-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
ShortPlayerData.c
34 lines (30 loc) · 1.08 KB
/
ShortPlayerData.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <Server/Packets/Packets.h>
#include <Server/ParseConvert.h>
#include <Util/DataStream.h>
#include <Util/Enums.h>
#include <Util/Log.h>
#include <Util/Uthash.h>
#include <Util/Weapon.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
void receive_short_player(server_t* server, player_t* player, stream_t* data)
{
if (player->team != TEAM_SPECTATOR) {
return;
}
stream_skip(data, 1); // Sender has to match the player we are getting info of.
player->team = stream_read_u8(data);
player->weapon = stream_read_u8(data);
if (player->team != TEAM_A && player->team != TEAM_B && player->team != TEAM_SPECTATOR) {
LOG_WARNING("Player %s (#%hhu) sent invalid team. Switching them to Spectator", player->name, player->id);
player->team = TEAM_SPECTATOR;
}
set_default_player_ammo(player);
player->state = STATE_SPAWNING;
char IP[17];
format_ip_to_str(IP, player->ip);
char team[15];
team_id_to_str(server, team, player->team);
LOG_INFO("Player %s (%s, #%hhu) joined %s", player->name, IP, player->id, team);
}