From 61c57edc70134ddf3ce12beed8d3953aa924631b Mon Sep 17 00:00:00 2001 From: Warwick Date: Tue, 15 Aug 2023 15:57:02 +0100 Subject: [PATCH] Added quick move room method --- src/server/command.c | 15 +++++++++++++++ src/server/command.h | 10 ++++++++++ src/server/world.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/src/server/command.c b/src/server/command.c index e69de29..76dc490 100644 --- a/src/server/command.c +++ b/src/server/command.c @@ -0,0 +1,15 @@ +#include "command.h" + +Room *cmd__move(move_directions direction, Room *current_room) { + switch (direction) { + case NORTH: + return current_room->north; + case EAST: + return current_room->east; + case SOUTH: + return current_room->south; + case WEST: + return current_room->west; + } + return NULL; +} diff --git a/src/server/command.h b/src/server/command.h index e69de29..5dfaba8 100644 --- a/src/server/command.h +++ b/src/server/command.h @@ -0,0 +1,10 @@ +#pragma once + +#include "world.h" +#include + +typedef enum { NORTH, EAST, SOUTH, WEST } move_directions; + +// Returns pointer to new room based on current room and direction If room +// doesn't exist returns NULL +Room *cmd__move(move_directions direction, Room *current_room); diff --git a/src/server/world.h b/src/server/world.h index 828dd03..0365411 100644 --- a/src/server/world.h +++ b/src/server/world.h @@ -1,3 +1,5 @@ +#pragma once + #define WORLD_SIZE 100 #include