Compare commits

...

2 Commits

Author SHA1 Message Date
Atemo
ead1a80d3c Mistakes 2015-12-02 00:08:54 +01:00
Atemo
72d2658523 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.
2015-12-01 23:50:21 +01:00
14 changed files with 84 additions and 41 deletions

View File

@ -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
**/

View File

@ -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,

View File

@ -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"

View File

@ -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/

View File

@ -9,14 +9,15 @@
#include <unistd.h>
#endif
#include "../config/core.h"
#include "../common/cbasetypes.h"
#include "../common/grfio.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
#include "../common/utils.h"
#include "../config/renewal.h"
#include "../common/cli.h"
#define NO_WATER 1000000
@ -175,24 +176,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 +207,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);

View File

@ -130,6 +130,7 @@
<ClCompile Include="..\src\common\showmsg.c" />
<ClCompile Include="..\src\common\strlib.c" />
<ClCompile Include="..\src\common\utils.c" />
<ClCompile Include="..\src\common\cli.c" />
<ClCompile Include="..\src\tool\mapcache.c" />
</ItemGroup>
<ItemGroup>
@ -143,7 +144,8 @@
<ClInclude Include="..\src\common\strlib.h" />
<ClInclude Include="..\src\common\utils.h" />
<ClInclude Include="..\src\common\winapi.h" />
<ClInclude Include="..\src\config\renewal.h" />
<ClInclude Include="..\src\common\cli.h" />
<ClInclude Include="..\src\config\core.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -22,6 +22,9 @@
<ClCompile Include="..\src\common\utils.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="..\src\common\cli.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="..\src\tool\mapcache.c">
<Filter>mapcache</Filter>
</ClCompile>
@ -57,7 +60,10 @@
<ClInclude Include="..\src\common\winapi.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="..\src\config\renewal.h">
<ClCompile Include="..\src\common\cli.h">
<Filter>common</Filter>
</ClCompile>
<ClInclude Include="..\src\config\core.h">
<Filter>config</Filter>
</ClInclude>
</ItemGroup>

View File

@ -134,6 +134,7 @@
<ClCompile Include="..\src\common\showmsg.c" />
<ClCompile Include="..\src\common\strlib.c" />
<ClCompile Include="..\src\common\utils.c" />
<ClCompile Include="..\src\common\cli.c" />
<ClCompile Include="..\src\tool\mapcache.c" />
</ItemGroup>
<ItemGroup>
@ -147,7 +148,8 @@
<ClInclude Include="..\src\common\strlib.h" />
<ClInclude Include="..\src\common\utils.h" />
<ClInclude Include="..\src\common\winapi.h" />
<ClInclude Include="..\src\config\renewal.h" />
<ClInclude Include="..\src\common\cli.h" />
<ClInclude Include="..\src\config\core.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -22,6 +22,9 @@
<ClCompile Include="..\src\common\utils.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="..\src\common\cli.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="..\src\tool\mapcache.c">
<Filter>mapcache</Filter>
</ClCompile>
@ -57,7 +60,10 @@
<ClInclude Include="..\src\common\winapi.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="..\src\config\renewal.h">
<ClCompile Include="..\src\common\cli.h">
<Filter>common</Filter>
</ClCompile>
<ClInclude Include="..\src\config\core.h">
<Filter>config</Filter>
</ClInclude>
</ItemGroup>

View File

@ -134,6 +134,7 @@
<ClCompile Include="..\src\common\showmsg.c" />
<ClCompile Include="..\src\common\strlib.c" />
<ClCompile Include="..\src\common\utils.c" />
<ClCompile Include="..\src\common\cli.c" />
<ClCompile Include="..\src\tool\mapcache.c" />
</ItemGroup>
<ItemGroup>
@ -147,7 +148,8 @@
<ClInclude Include="..\src\common\strlib.h" />
<ClInclude Include="..\src\common\utils.h" />
<ClInclude Include="..\src\common\winapi.h" />
<ClInclude Include="..\src\config\renewal.h" />
<ClInclude Include="..\src\common\cli.h" />
<ClInclude Include="..\src\config\core.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -22,6 +22,9 @@
<ClCompile Include="..\src\common\utils.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="..\src\common\cli.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="..\src\tool\mapcache.c">
<Filter>mapcache</Filter>
</ClCompile>
@ -57,7 +60,10 @@
<ClInclude Include="..\src\common\winapi.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="..\src\config\renewal.h">
<ClCompile Include="..\src\common\cli.h">
<Filter>common</Filter>
</ClCompile>
<ClInclude Include="..\src\config\core.h">
<Filter>config</Filter>
</ClInclude>
</ItemGroup>

View File

@ -133,6 +133,7 @@
<ClCompile Include="..\src\common\showmsg.c" />
<ClCompile Include="..\src\common\strlib.c" />
<ClCompile Include="..\src\common\utils.c" />
<ClCompile Include="..\src\common\cli.c" />
<ClCompile Include="..\src\tool\mapcache.c" />
</ItemGroup>
<ItemGroup>
@ -146,7 +147,8 @@
<ClInclude Include="..\src\common\strlib.h" />
<ClInclude Include="..\src\common\utils.h" />
<ClInclude Include="..\src\common\winapi.h" />
<ClInclude Include="..\src\config\renewal.h" />
<ClInclude Include="..\src\common\cli.h" />
<ClInclude Include="..\src\config\core.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -22,6 +22,9 @@
<ClCompile Include="..\src\common\utils.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="..\src\common\cli.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="..\src\tool\mapcache.c">
<Filter>mapcache</Filter>
</ClCompile>
@ -57,7 +60,10 @@
<ClInclude Include="..\src\common\winapi.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="..\src\config\renewal.h">
<ClCompile Include="..\src\common\cli.h">
<Filter>common</Filter>
</ClCompile>
<ClInclude Include="..\src\config\core.h">
<Filter>config</Filter>
</ClInclude>
</ItemGroup>

View File

@ -270,6 +270,14 @@
RelativePath="..\src\common\winapi.h"
>
</File>
<File
RelativePath="..\src\common\cli.c"
>
</File>
<File
RelativePath="..\src\common\cli.h"
>
</File>
</Filter>
<Filter
Name="mapcache"
@ -279,7 +287,7 @@
>
</File>
<File
RelativePath="..\src\config\renewal.h"
RelativePath="..\src\config\core.h"
>
</File>
</Filter>