diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/game.h | 32 | ||||
| -rw-r--r-- | include/pathfinding.h | 1 | ||||
| -rw-r--r-- | include/protocol.h | 40 |
3 files changed, 73 insertions, 0 deletions
diff --git a/include/game.h b/include/game.h new file mode 100644 index 0000000..944a831 --- /dev/null +++ b/include/game.h @@ -0,0 +1,32 @@ +#ifndef INCLUDE_GAME +#define INCLUDE_GAME + +#include <projectbase/project_base.h> + +#include "../include/protocol.h" + +typedef enum t_game_state { + GAMESTATE_IDLE, + GAMESTATE_LOADING_MAP, + GAMESTATE_PLAYING, +} game_state; + +typedef enum t_network_state { + CONNECTING, + WAITING_FOR_ID, + CONNECTED, + DISCONNECTED, +} network_state; + +typedef struct t_game { + game_state state; + network_state network_state; + network_server *server; + network_client *client; +} game; + +game global_state; + +void init_game(); + +#endif
\ No newline at end of file diff --git a/include/pathfinding.h b/include/pathfinding.h index 6bef101..9dcaab3 100644 --- a/include/pathfinding.h +++ b/include/pathfinding.h @@ -19,6 +19,7 @@ typedef struct t_pathfinding_request array global_pathfinding_queue; +void* pathfinding_thread(void *args); void make_pathfinding_request(vec2f start, vec2f end, array *to_fill, pathfinding_request *request); #endif
\ No newline at end of file diff --git a/include/protocol.h b/include/protocol.h new file mode 100644 index 0000000..316a21f --- /dev/null +++ b/include/protocol.h @@ -0,0 +1,40 @@ +#ifndef INCLUDE_PROTOCOL +#define INCLUDE_PROTOCOL + +#include <projectbase/project_base.h> + +typedef enum t_network_message_type { + MESSAGE_GET_ID_UPSTREAM, + MESSAGE_GET_ID_DOWNSTREAM, +} 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_get_id_upstream { + network_message_type type; +} protocol_get_id_upstream; + +typedef struct t_protocol_get_id_downstream { + network_message_type type; + u32 id; +} protocol_get_id_downstream; + +#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); + +array messages_received_on_server; +array messages_received_on_client; + +void server_on_message_received(u8* buffer, u32 length, network_client client); +void client_on_message_received(u8* buffer, u32 length); + +#endif
\ No newline at end of file |
