prepare for daemonisation by splitting into a client/server/common design
This commit is contained in:
parent
d9a5962c32
commit
8b04672d34
@ -1,32 +1,12 @@
|
|||||||
|
# CmakeLists.txt
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
project(simworld VERSION 0.0.1 LANGUAGES C)
|
||||||
|
|
||||||
# Set the project name and specify the languages
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Wshadow -Wwrite-strings -Wstrict-prototypes -g")
|
||||||
project(simworld LANGUAGES C)
|
|
||||||
|
|
||||||
# Set compiler flags
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Wshadow -Wwrite-strings -Wstrict-prototypes")
|
|
||||||
|
|
||||||
# Specify the source directory
|
add_subdirectory(common)
|
||||||
set(SOURCE_DIR ${CMAKE_SOURCE_DIR}/src)
|
add_subdirectory(server)
|
||||||
|
# add_subdirectory(client)
|
||||||
# Create a list of source files
|
|
||||||
file(GLOB_RECURSE SOURCES ${SOURCE_DIR}/*.c)
|
|
||||||
|
|
||||||
# Create the executable from the source files
|
|
||||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
|
||||||
|
|
||||||
# Dependencies
|
|
||||||
find_package(PkgConfig REQUIRED)
|
|
||||||
pkg_check_modules(LUA REQUIRED lua)
|
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} ${LUA_LIBRARIES})
|
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${LUA_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
# `#define DEBUG` if `cmake -DCMAKE_BUILD_TYPE=debug`
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "debug")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_DEBUG)
|
|
||||||
else()
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_RELEASE)
|
|
||||||
endif()
|
|
||||||
|
13
TODO.gmi
13
TODO.gmi
@ -1,11 +1,18 @@
|
|||||||
# TODO
|
# TODO
|
||||||
A list of things I'd like to accomplish
|
A list of things I'd like to accomplish
|
||||||
|
|
||||||
* Game loop
|
## In Progress
|
||||||
* Create and load worlds
|
|
||||||
* Daemonise the serverside
|
* Daemonise the serverside
|
||||||
* Expose a socket or pipe on the daemon for the client
|
* Expose a socket or pipe on the daemon for the client
|
||||||
* Client connection to daemon
|
* Create client to connect to daemon
|
||||||
|
|
||||||
|
## Completed
|
||||||
|
* Split into client and server (and common library?)
|
||||||
|
* Write Makefile to automate compilation
|
||||||
|
|
||||||
|
## Planned
|
||||||
|
* Game loop
|
||||||
|
* Create and load worlds
|
||||||
* Display environment and pan camera
|
* Display environment and pan camera
|
||||||
* Time controls (play/pause/speed up)
|
* Time controls (play/pause/speed up)
|
||||||
* See creature stats
|
* See creature stats
|
||||||
|
25
build.sh
25
build.sh
@ -4,23 +4,11 @@ set -e
|
|||||||
|
|
||||||
run_exe=0
|
run_exe=0
|
||||||
|
|
||||||
## Ensure first argument is correct
|
if [ "$1" = "run" ]; then
|
||||||
if [ "$1" = "debug" ]; then
|
|
||||||
debug=1
|
|
||||||
elif [ "$1" = "release" ]; then
|
|
||||||
debug=0
|
|
||||||
else
|
|
||||||
echo "Run as '$0 debug' or '$0 release'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
## Ensure second argument is correct
|
|
||||||
if [ "$2" = "run" ]; then
|
|
||||||
run_exe=1
|
run_exe=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Ensure its run in the right place
|
if ! [ -f ".gitignore" ]; then
|
||||||
if ! [ -f "CMakeLists.txt" ]; then
|
|
||||||
echo "Run in the project root"
|
echo "Run in the project root"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -28,16 +16,11 @@ fi
|
|||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd build || exit
|
cd build || exit
|
||||||
|
|
||||||
if [ ${debug} -eq 1 ]; then
|
cmake ..
|
||||||
cmake -DCMAKE_BUILD_TYPE=debug ..
|
|
||||||
else
|
|
||||||
cmake -DCMAKE_BUILD_TYPE=release ..
|
|
||||||
fi
|
|
||||||
|
|
||||||
make
|
make
|
||||||
|
|
||||||
if [ ${run_exe} -eq 1 ]; then
|
if [ ${run_exe} -eq 1 ]; then
|
||||||
./simworld
|
./server/simworld-daemon
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
16
common/CMakeLists.txt
Normal file
16
common/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# common/CMakeLists.txt
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
project(libsimworld VERSION 0.0.1 LANGUAGES C)
|
||||||
|
|
||||||
|
set(SOURCE_DIR ${CMAKE_SOURCE_DIR}/common/src)
|
||||||
|
file(GLOB_RECURSE SOURCES ${SOURCE_DIR}/*.c)
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME} SHARED ${SOURCES})
|
||||||
|
target_include_directories(${PROJECT_NAME} PUBLIC ${SOURCE_DIR})
|
||||||
|
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(LUA REQUIRED lua)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME} ${LUA_LIBRARIES})
|
||||||
|
target_include_directories(${PROJECT_NAME} PRIVATE ${LUA_INCLUDE_DIRS})
|
10
server/CMakeLists.txt
Normal file
10
server/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# server/CMakeLists.txt
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
project(simworld-daemon VERSION 0.0.1 LANGUAGES C)
|
||||||
|
|
||||||
|
set(SOURCE_DIR ${CMAKE_SOURCE_DIR}/server/src)
|
||||||
|
file(GLOB_RECURSE SOURCES ${SOURCE_DIR}/*.c)
|
||||||
|
|
||||||
|
add_executable(simworld-daemon ${SOURCES})
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE libsimworld)
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "world.h"
|
|
||||||
#include "render/render.h"
|
#include "render/render.h"
|
||||||
|
#include "world.h"
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
enum error_t err = ERR_OK;
|
enum error_t err = ERR_OK;
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef RENDER_H
|
#ifndef RENDER_H
|
||||||
#define RENDER_H
|
#define RENDER_H
|
||||||
|
|
||||||
#include "../world.h"
|
#include "world.h"
|
||||||
|
|
||||||
void render_world(struct world_t const *);
|
void render_world(struct world_t const *);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user