From 599bc76379ed499019e2878b14f7f3873b2f4b46 Mon Sep 17 00:00:00 2001 From: Warwick Date: Tue, 15 Aug 2023 16:19:09 +0100 Subject: [PATCH] Moved some structures around so they're accessible by both cli and serv --- src/server/command.h | 3 +-- src/server/world.h | 11 ++--------- urchin-util/include/message.h | 5 +++++ urchin-util/include/world_structures.h | 15 +++++++++++++++ 4 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 urchin-util/include/world_structures.h diff --git a/src/server/command.h b/src/server/command.h index 5dfaba8..27569d1 100644 --- a/src/server/command.h +++ b/src/server/command.h @@ -2,8 +2,7 @@ #include "world.h" #include - -typedef enum { NORTH, EAST, SOUTH, WEST } move_directions; +#include // Returns pointer to new room based on current room and direction If room // doesn't exist returns NULL diff --git a/src/server/world.h b/src/server/world.h index 0365411..b1d26b1 100644 --- a/src/server/world.h +++ b/src/server/world.h @@ -7,15 +7,8 @@ #include #include -// Define what a room is. -typedef struct room { - char* name; - char* description; - struct room* north; - struct room* east; - struct room* south; - struct room* west; -} Room; +#include + // Creator and destructor for the world Room* wrld__create(); diff --git a/urchin-util/include/message.h b/urchin-util/include/message.h index 60d15de..bece632 100644 --- a/urchin-util/include/message.h +++ b/urchin-util/include/message.h @@ -23,3 +23,8 @@ int msg__accept_cli_connection(int server_sockfd); // Handle logins void msg__handle_login(int *con_sockfd); void msg__login_req(int *con_sockfd, char *usernm, char *passwd); + + +// send and recive commands +void msg__handle_command(int *con_sockfd); +void msg__command_req(int *con_sockfd, char *usernm, char *passwd); diff --git a/urchin-util/include/world_structures.h b/urchin-util/include/world_structures.h new file mode 100644 index 0000000..147355b --- /dev/null +++ b/urchin-util/include/world_structures.h @@ -0,0 +1,15 @@ +#pragma once +// Make world structures accessible to both server and client + +// Define moveable directions +typedef enum { NORTH, EAST, SOUTH, WEST } move_directions; + +// Define what a room is. +typedef struct room { + char* name; + char* description; + struct room* north; + struct room* east; + struct room* south; + struct room* west; +} Room;