From 72d26585236638cef4ba6a7713b0f198fbf25a38 Mon Sep 17 00:00:00 2001 From: Atemo Date: Tue, 1 Dec 2015 23:50:21 +0100 Subject: [PATCH] From 65b6861e84d29a8226680312ca4639bd15373bed Small cleanup And updata mapcache to use DBPATH instead rechecking RENEWAL macro, (code duplication) Make mapcache use cli.o to give some feedback on arguments given. --- src/config/const.h | 11 ++++++++ src/map/status.h | 10 -------- src/tool/CMakeLists.txt | 2 ++ src/tool/Makefile.in | 2 +- src/tool/mapcache.c | 41 +++++++++++++++--------------- vcproj-10/mapcache.vcxproj | 4 ++- vcproj-10/mapcache.vcxproj.filters | 8 +++++- vcproj-12/mapcache.vcxproj | 4 ++- vcproj-12/mapcache.vcxproj.filters | 8 +++++- vcproj-13/mapcache.vcxproj | 4 ++- vcproj-13/mapcache.vcxproj.filters | 8 +++++- vcproj-14/mapcache.vcxproj | 4 ++- vcproj-14/mapcache.vcxproj.filters | 8 +++++- vcproj-9/mapcache.vcproj | 10 +++++++- 14 files changed, 83 insertions(+), 41 deletions(-) diff --git a/src/config/const.h b/src/config/const.h index 4e2a510715..27f3fd08b7 100644 --- a/src/config/const.h +++ b/src/config/const.h @@ -93,6 +93,17 @@ time = time * (1 - (float)min(val, 100) / 100); \ } #endif + +/** + * Max Refine available to your server + * Changing this limit requires edits to refine_db.txt + **/ +#ifdef RENEWAL +# define MAX_REFINE 20 +#else +# define MAX_REFINE 10 +#endif + /** * End of File **/ diff --git a/src/map/status.h b/src/map/status.h index 1717a0fb43..ddea528d82 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -11,16 +11,6 @@ struct homun_data; struct mercenary_data; struct status_change; -/** - * Max Refine available to your server - * Changing this limit requires edits to refine_db.txt - **/ -#ifdef RENEWAL -# define MAX_REFINE 20 -#else -# define MAX_REFINE 10 -#endif - /// Refine type enum refine_type { REFINE_TYPE_ARMOR = 0, diff --git a/src/tool/CMakeLists.txt b/src/tool/CMakeLists.txt index a54ffa0e22..0f51e2e8e5 100644 --- a/src/tool/CMakeLists.txt +++ b/src/tool/CMakeLists.txt @@ -14,12 +14,14 @@ set( COMMON_HEADERS "${COMMON_SOURCE_DIR}/des.h" "${COMMON_SOURCE_DIR}/grfio.h" "${COMMON_SOURCE_DIR}/utils.h" + "${COMMON_SOURCE_DIR}/cli.h" ) set( COMMON_SOURCES ${COMMON_MINI_SOURCES} "${COMMON_SOURCE_DIR}/des.c" "${COMMON_SOURCE_DIR}/grfio.c" "${COMMON_SOURCE_DIR}/utils.c" + "${COMMON_SOURCE_DIR}/cli.c" ) set( MAPCACHE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/mapcache.c" diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 8e37c1113e..465c21fb40 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -1,5 +1,5 @@ -COMMON_OBJ = minicore.o malloc.o showmsg.o strlib.o utils.o des.o grfio.o +COMMON_OBJ = minicore.o malloc.o showmsg.o strlib.o utils.o des.o grfio.o cli.o COMMON_DIR_OBJ = $(COMMON_OBJ:%=../common/obj/%) COMMON_H = $(shell ls ../common/*.h) COMMON_INCLUDE = -I../common/ diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 5e8a5d6486..1b9f7198c8 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -9,6 +9,8 @@ #include #endif +#include "../config/core.h" + #include "../common/cbasetypes.h" #include "../common/grfio.h" #include "../common/malloc.h" @@ -16,8 +18,6 @@ #include "../common/showmsg.h" #include "../common/utils.h" -#include "../config/renewal.h" - #define NO_WATER 1000000 char grf_list_file[256] = "conf/grf-files.txt"; @@ -175,24 +175,28 @@ char *remove_extension(char *mapname) } // Processes command-line arguments -void process_args(int argc, char *argv[]) +int process_args(int argc, char *argv[]) { int i; - for(i = 0; i < argc; i++) { + for(i = 1; i < argc; i++) { if(strcmp(argv[i], "-grf") == 0) { - if(++i < argc) - strcpy(grf_list_file, argv[i]); + if(opt_has_next_value(argv[i],i,argc)) strcpy(grf_list_file, argv[++i]); + else return 1; } else if(strcmp(argv[i], "-list") == 0) { - if(++i < argc) - strcpy(map_list_file, argv[i]); + if(opt_has_next_value(argv[i],i,argc)) strcpy(map_list_file, argv[++i]); + else return 1; } else if(strcmp(argv[i], "-cache") == 0) { - if(++i < argc) - strcpy(map_cache_file, argv[i]); - } else if(strcmp(argv[i], "-rebuild") == 0) + if(opt_has_next_value(argv[i],i,argc)) strcpy(map_cache_file, argv[++i]); + else return 1; + } else if(strcmp(argv[i], "-rebuild") == 0) { rebuild = 1; + } else { + ShowWarning("Invalid argument given '%s'.\n", argv[i]); + return 1; + } } - + return 0; } int do_init(int argc, char** argv) @@ -202,17 +206,12 @@ int do_init(int argc, char** argv) struct map_data map; char name[MAP_NAME_LENGTH_EXT]; - /* setup pre-defined, #define-dependant */ - sprintf(map_cache_file,"db/%s/map_cache.dat", -#ifdef RENEWAL - "re" -#else - "pre-re" -#endif - ); + /* setup pre-defined, #define-dependant, use -cache option to override this */ + sprintf(map_cache_file,"db/%smap_cache.dat",DBPATH); // Process the command-line arguments - process_args(argc, argv); + if(process_args(argc, argv)) + return 0; ShowStatus("Initializing grfio with %s\n", grf_list_file); grfio_init(grf_list_file); diff --git a/vcproj-10/mapcache.vcxproj b/vcproj-10/mapcache.vcxproj index f2f5fec954..03ca08dc7e 100644 --- a/vcproj-10/mapcache.vcxproj +++ b/vcproj-10/mapcache.vcxproj @@ -130,6 +130,7 @@ + @@ -143,7 +144,8 @@ - + + diff --git a/vcproj-10/mapcache.vcxproj.filters b/vcproj-10/mapcache.vcxproj.filters index 12f73abd8a..2dfaefba9d 100644 --- a/vcproj-10/mapcache.vcxproj.filters +++ b/vcproj-10/mapcache.vcxproj.filters @@ -22,6 +22,9 @@ common + + common + mapcache @@ -57,7 +60,10 @@ common - + + common + + config diff --git a/vcproj-12/mapcache.vcxproj b/vcproj-12/mapcache.vcxproj index 32f6a3418d..5216c80095 100644 --- a/vcproj-12/mapcache.vcxproj +++ b/vcproj-12/mapcache.vcxproj @@ -134,6 +134,7 @@ + @@ -147,7 +148,8 @@ - + + diff --git a/vcproj-12/mapcache.vcxproj.filters b/vcproj-12/mapcache.vcxproj.filters index 12f73abd8a..2dfaefba9d 100644 --- a/vcproj-12/mapcache.vcxproj.filters +++ b/vcproj-12/mapcache.vcxproj.filters @@ -22,6 +22,9 @@ common + + common + mapcache @@ -57,7 +60,10 @@ common - + + common + + config diff --git a/vcproj-13/mapcache.vcxproj b/vcproj-13/mapcache.vcxproj index a5e7b8639d..2e0ea5c90d 100644 --- a/vcproj-13/mapcache.vcxproj +++ b/vcproj-13/mapcache.vcxproj @@ -134,6 +134,7 @@ + @@ -147,7 +148,8 @@ - + + diff --git a/vcproj-13/mapcache.vcxproj.filters b/vcproj-13/mapcache.vcxproj.filters index 12f73abd8a..2dfaefba9d 100644 --- a/vcproj-13/mapcache.vcxproj.filters +++ b/vcproj-13/mapcache.vcxproj.filters @@ -22,6 +22,9 @@ common + + common + mapcache @@ -57,7 +60,10 @@ common - + + common + + config diff --git a/vcproj-14/mapcache.vcxproj b/vcproj-14/mapcache.vcxproj index cf42e31a3b..2e49ad37bc 100644 --- a/vcproj-14/mapcache.vcxproj +++ b/vcproj-14/mapcache.vcxproj @@ -133,6 +133,7 @@ + @@ -146,7 +147,8 @@ - + + diff --git a/vcproj-14/mapcache.vcxproj.filters b/vcproj-14/mapcache.vcxproj.filters index 12f73abd8a..2dfaefba9d 100644 --- a/vcproj-14/mapcache.vcxproj.filters +++ b/vcproj-14/mapcache.vcxproj.filters @@ -22,6 +22,9 @@ common + + common + mapcache @@ -57,7 +60,10 @@ common - + + common + + config diff --git a/vcproj-9/mapcache.vcproj b/vcproj-9/mapcache.vcproj index 45d40a0040..5a4eb4de5e 100644 --- a/vcproj-9/mapcache.vcproj +++ b/vcproj-9/mapcache.vcproj @@ -270,6 +270,14 @@ RelativePath="..\src\common\winapi.h" > + + + +