diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..f7c67e9 --- /dev/null +++ b/.clang-format @@ -0,0 +1,20 @@ +--- +# $Id: .clang-format 16 2025-01-30 10:59:29Z nishi $ +Language: Cpp +UseTab: Always +TabWidth: 8 +AlignConsecutiveAssignments: + Enabled: true +AlignConsecutiveDeclarations: + Enabled: true +IndentWidth: 8 +PointerAlignment: Left +ColumnLimit: 1024 +AllowShortIfStatementsOnASingleLine: Always +AllowShortBlocksOnASingleLine: Never +AllowShortLoopsOnASingleLine: true +SpaceBeforeParens: Never +AlignEscapedNewlines: DontAlign +SortIncludes: false +AllowShortEnumsOnASingleLine: false +#IndentPPDirectives: AfterHash diff --git a/Makefile b/Makefile index cd7804c..913cb71 100644 --- a/Makefile +++ b/Makefile @@ -8,16 +8,19 @@ GL_LIBS = `pkg-config --libs gl` AR = $(TARGET_PREFIX)ar CC = $(TARGET_PREFIX)gcc -CFLAGS = -D_DEFAULT_SOURCE $(ODE_CFLAGS) $(AMX_CFLAGS) $(GL_CFLAGS) +CFLAGS = -D_DEFAULT_SOURCE -I../engine $(ODE_CFLAGS) $(AMX_CFLAGS) $(GL_CFLAGS) LDFLAGS = LIBS = $(ODE_LIBS) $(AMX_LIBS) $(GL_LIBS) EXEC = -.PHONY: all clean ./engine ./src +.PHONY: all format clean ./engine ./src all: ./src +format: + clang-format --verbose -i `find ./src ./engine -name "*.c" -or -name "*.h"` + ./engine:: $(MAKE) -C $@ diff --git a/engine/Makefile b/engine/Makefile index 4d9e84a..49e7646 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -1,5 +1,5 @@ TARGET = libnishbox.a -OBJS = +OBJS = version.o include ../common.mk diff --git a/engine/nb_version.h b/engine/nb_version.h new file mode 100644 index 0000000..937e45a --- /dev/null +++ b/engine/nb_version.h @@ -0,0 +1,13 @@ +#ifndef __NB_VERSION_H__ +#define __NB_VERSION_H__ + +typedef struct nb_version { + int major; + int minor; + int patch; + char full[64]; +} nb_version_t; + +void nb_get_version(nb_version_t* version); + +#endif diff --git a/engine/version.c b/engine/version.c new file mode 100644 index 0000000..7ddd7c3 --- /dev/null +++ b/engine/version.c @@ -0,0 +1,32 @@ +#include "nb_version.h" + +#include +#include + +#define NB_VERSION "1.0.0" + +void nb_get_version(nb_version_t* version) { + char* cpstr = malloc(strlen(NB_VERSION) + 1); + int i; + int incr = 0; + int old = 0; + strcpy(cpstr, NB_VERSION); + strcpy(version->full, NB_VERSION); + for(i = 0;; i++) { + if(cpstr[i] == '.' || cpstr[i] == 0) { + int num; + cpstr[i] = 0; + num = atoi(cpstr + old); + if(incr == 0) { + version->major = num; + } else if(incr == 1) { + version->minor = num; + } else if(incr == 2) { + version->patch = num; + } + old = i + 1; + incr++; + if(incr == 3) break; + } + } +} diff --git a/src/main.c b/src/main.c index 6094cff..cc30883 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,3 @@ #include -int main(int argc, char** argv){ - return 0; -} +int main(int argc, char** argv) { return 0; }