diff --git a/CMakeLists.txt b/CMakeLists.txt index fc81157..97e5e2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,20 @@ target_sources(${PROJECT_NAME} PRIVATE src/xxhash_str.cpp ) +if(USER_SAVE_LOC) +set(USER_SAVE ${USER_SAVE_LOC}) +else() +set(USER_SAVE "\"../users.json\"") +endif() + +if(DROGON_CONFIG_LOC) +set(DROGON_CONFIG ${DROGON_CONFIG_LOC}) +else() +set(DROGON_CONFIG "\"../config.json\"") +endif() + +configure_file(ccash_config.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/ccash_config.hpp) + target_include_directories(${PROJECT_NAME} PUBLIC include) target_include_directories(${PROJECT_NAME} PUBLIC third_party) target_include_directories(${PROJECT_NAME} PUBLIC third_party/drogon/lib/inc) diff --git a/ccash_config.hpp b/ccash_config.hpp new file mode 100644 index 0000000..edf679a --- /dev/null +++ b/ccash_config.hpp @@ -0,0 +1,39 @@ +#pragma once + +// Setting both values to 0 does not compile logging (useful for if disk/memory is very valuable) +#define MAX_LOG_SIZE 100 +#define PRE_LOG_SIZE 10 + +//default to minecraft usernames +constexpr unsigned min_name_size = 3; +constexpr unsigned max_name_size = 16; + +constexpr const char *users_location = "yo"; +constexpr const char *config_location = ; + +// Returns money to an account on deletion (useful if you dont want any money to leave the economy) +#define RETURN_ON_DEL false +constexpr const char *return_account = ""; + +/* +if true, when frequency is hit AND changes have happened then save + pros + LOW disk usage + cons + LOW atomic overhead +if false, when frequency is hit save + pros + ZERO atomic overhead + cons + HIGH disk usage +*/ +#define CONSERVATIVE_DISK_SAVE true + +/* +example, when set to 2 +version 1 will not work +version 2 will work +version 3 will work +etc +*/ +#define API_VERSION 1 diff --git a/include/consts.hpp b/ccash_config.hpp.in similarity index 75% rename from include/consts.hpp rename to ccash_config.hpp.in index 48b4255..3b9c13a 100644 --- a/include/consts.hpp +++ b/ccash_config.hpp.in @@ -4,11 +4,12 @@ #define MAX_LOG_SIZE 100 #define PRE_LOG_SIZE 10 +//default to minecraft usernames constexpr unsigned min_name_size = 3; constexpr unsigned max_name_size = 16; -constexpr const char *users_location = "../users.json"; -constexpr const char *config_location = "../config.json"; +constexpr const char *users_location = @USER_SAVE@; +constexpr const char *config_location = @DROGON_CONFIG@; // Returns money to an account on deletion (useful if you dont want any money to leave the economy) #define RETURN_ON_DEL false @@ -28,4 +29,11 @@ if false, when frequency is hit save */ #define CONSERVATIVE_DISK_SAVE true +/* +example, when set to 2 +version 1 will not work +version 2 will work +version 3 will work +etc +*/ #define API_VERSION 1 \ No newline at end of file diff --git a/include/log.h b/include/log.h index 62b3a66..2d1ef98 100644 --- a/include/log.h +++ b/include/log.h @@ -2,7 +2,7 @@ #include // to be removed later #include #include -#include "consts.hpp" +#include "ccash_config.hpp" #include "change_flag.h" #include "transaction.h"