about summary refs log tree commit diff
path: root/structs.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'structs.hpp')
-rw-r--r--structs.hpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/structs.hpp b/structs.hpp
new file mode 100644
index 0000000..94a65b7
--- /dev/null
+++ b/structs.hpp
@@ -0,0 +1,60 @@
+enum class PacketType
+{
+	packet_connect,
+	packet_disconnect,
+	packet_move,
+	packet_ping,
+	packet_server_info
+};
+
+struct Player 
+{
+	unsigned int sender_id;
+	int fd;
+	char name[20];
+	char ip[20];
+	int x, y;
+	int color;
+	bool is_color;
+};
+
+struct PacketConnect
+{
+	Player player;
+};
+
+struct PacketDisconnect
+{
+	Player player;
+};
+
+struct PacketMove
+{
+	Player player;
+	int x, y;
+       	bool is_color;	
+};
+
+struct PacketPing
+{
+};
+
+struct PacketServerInfo
+{
+	int max_players;
+	int fps;
+};
+
+struct Packet
+{
+	PacketType type;
+	unsigned int sender_id;
+	union
+	{
+		PacketConnect packet_connect;
+		PacketDisconnect packet_disconnect;
+		PacketMove packet_move;
+		PacketPing packet_ping;
+		PacketServerInfo packet_server_info;
+	} data;
+};