Began updating server data definitions.
This commit is contained in:
28
server/src/api.c
Normal file
28
server/src/api.c
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "include/data.h"
|
||||
|
||||
PacketType packet_type_parse(const char* type_str) {
|
||||
if (!type_str) return PACKET_TYPE_INVALID;
|
||||
if (!strcmp(type_str, "join")) return PACKET_TYPE_JOIN;
|
||||
if (!strcmp(type_str, "JOIN_EV")) return PACKET_TYPE_JOIN_EV;
|
||||
return PACKET_TYPE_INVALID;
|
||||
}
|
||||
|
||||
Packet* packet_init(PacketType type, void* data) {
|
||||
Packet* packet = malloc(sizeof(Packet));
|
||||
if (!packet) return NULL;
|
||||
|
||||
packet->type = type;
|
||||
packet->data = data;
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
Packet* packet_init_untrusted(PacketType type, void* data) {
|
||||
Packet* packet = malloc(sizeof(Packet));
|
||||
if (!packet) return NULL;
|
||||
|
||||
packet->type = type;
|
||||
packet->data = data;
|
||||
|
||||
return packet;
|
||||
}
|
||||
Reference in New Issue
Block a user