From 9528c0c69dba57117f38f84f576af2c81a3b435b Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Mon, 12 Dec 2022 18:06:53 +0100 Subject: multiplayer --- include/protocol.h | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'include/protocol.h') diff --git a/include/protocol.h b/include/protocol.h index 316a21f..989c4d5 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -6,17 +6,21 @@ typedef enum t_network_message_type { MESSAGE_GET_ID_UPSTREAM, MESSAGE_GET_ID_DOWNSTREAM, + MESSAGE_USER_LIST, + MESSAGE_USER_MOVED, + MESSAGE_USER_LOOK, + MESSAGE_ZOMBIE_LIST, } network_message_type; -typedef struct t_protocol_generic_message { - network_client client; - network_message_type type; -} protocol_generic_message; - typedef struct t_protocol_generic_client_message { network_message_type type; } protocol_generic_client_message; +typedef struct t_protocol_generic_message { + network_client client; + protocol_generic_client_message *message; +} protocol_generic_message; + typedef struct t_protocol_get_id_upstream { network_message_type type; } protocol_get_id_upstream; @@ -26,10 +30,44 @@ typedef struct t_protocol_get_id_downstream { u32 id; } protocol_get_id_downstream; +typedef struct t_protocol_user_list { + network_message_type type; + player players[10]; +} protocol_user_list; + +typedef struct t_protocol_zombie_list { + network_message_type type; + zombie zombies[20]; +} protocol_zombie_list; + +typedef enum t_protocol_move_type { + MOVE_UP, + MOVE_DOWN, + MOVE_LEFT, + MOVE_RIGHT, +} protocol_move_type; + +typedef struct t_protocol_move { + network_message_type type; + protocol_move_type move; + u32 id; +} protocol_move; + +typedef struct t_protocol_user_look { + network_message_type type; + u32 id; + float gunx; + float guny; +} protocol_user_look; + #define MAX_NETWORK_BUFFER_SIZE 50000 u8 network_buffer[50000]; network_message create_protocol_get_id_up(); network_message create_protocol_get_id_down(u32 id); +network_message create_protocol_user_list(); +network_message create_protocol_user_moved(protocol_move_type move, u32 id); +network_message create_protocol_user_look(u32 id, float gunx, float guny); +network_message create_protocol_zombie_list(); array messages_received_on_server; array messages_received_on_client; -- cgit v1.2.3-70-g09d2