diff --git a/doc/map_server_generator.md b/doc/map_server_generator.md new file mode 100644 index 0000000000..2f29b5f1e5 --- /dev/null +++ b/doc/map_server_generator.md @@ -0,0 +1,26 @@ +# Map Server Generator + +This is a tool to generate files that are hard to manually create. + +Only navigation files can be generated at this time. + +## How to run +### Linux +Run `make tools`. +This creates a new binary called `map-server-generator`. + +It can be ran with: `./map-server-generator` + +### Windows +It can be ran with `./map-server-generator.exe`, or with the provided `.bat` files. + +## Available options +On Linux, prefix with `--` + +On Windows, prefix with `/` + +option | feature +---|--- +generate-navi | create navigation files + + diff --git a/rAthena.sln b/rAthena.sln index bb70fb5b26..884a0f66c4 100644 --- a/rAthena.sln +++ b/rAthena.sln @@ -59,6 +59,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server", "src\map\map-s {F8FD7B1E-8E1C-4CC3-9CD1-2E28F77B6559} = {F8FD7B1E-8E1C-4CC3-9CD1-2E28F77B6559} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server-generator", "src\map\map-server-generator.vcxproj", "{EB03BC16-8A47-43B9-B5BB-D0200E4A2775}" + ProjectSection(ProjectDependencies) = postProject + {F8FD7B1E-8E1C-4CC3-9CD1-2E28F77B6559} = {F8FD7B1E-8E1C-4CC3-9CD1-2E28F77B6559} + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common-minicore", "src\common\common-minicore.vcxproj", "{352B45B3-FE88-4431-9D89-48CF811446DB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{9F328FE9-129D-4C0C-820B-BE4AA5996652}" @@ -149,6 +154,14 @@ Global {B4114A9C-EEA4-433C-A830-56119A984F24}.Release|Win32.Build.0 = Release|Win32 {B4114A9C-EEA4-433C-A830-56119A984F24}.Release|x64.ActiveCfg = Release|x64 {B4114A9C-EEA4-433C-A830-56119A984F24}.Release|x64.Build.0 = Release|x64 + {EB03BC16-8A47-43B9-B5BB-D0200E4A2775}.Debug|Win32.ActiveCfg = Debug|Win32 + {EB03BC16-8A47-43B9-B5BB-D0200E4A2775}.Debug|Win32.Build.0 = Debug|Win32 + {EB03BC16-8A47-43B9-B5BB-D0200E4A2775}.Debug|x64.ActiveCfg = Debug|x64 + {EB03BC16-8A47-43B9-B5BB-D0200E4A2775}.Debug|x64.Build.0 = Debug|x64 + {EB03BC16-8A47-43B9-B5BB-D0200E4A2775}.Release|Win32.ActiveCfg = Release|Win32 + {EB03BC16-8A47-43B9-B5BB-D0200E4A2775}.Release|Win32.Build.0 = Release|Win32 + {EB03BC16-8A47-43B9-B5BB-D0200E4A2775}.Release|x64.ActiveCfg = Release|x64 + {EB03BC16-8A47-43B9-B5BB-D0200E4A2775}.Release|x64.Build.0 = Release|x64 {352B45B3-FE88-4431-9D89-48CF811446DB}.Debug|Win32.ActiveCfg = Debug|Win32 {352B45B3-FE88-4431-9D89-48CF811446DB}.Debug|Win32.Build.0 = Debug|Win32 {352B45B3-FE88-4431-9D89-48CF811446DB}.Debug|x64.ActiveCfg = Debug|x64 @@ -232,6 +245,7 @@ Global {864805EA-FD39-453D-9248-C581951BA058} = {6D9F5D00-2988-4812-844D-D155C4F588DC} {FED3A941-0AF7-49FE-85CF-E1DFDC0EBB23} = {6D9F5D00-2988-4812-844D-D155C4F588DC} {B4114A9C-EEA4-433C-A830-56119A984F24} = {6D9F5D00-2988-4812-844D-D155C4F588DC} + {EB03BC16-8A47-43B9-B5BB-D0200E4A2775} = {9F328FE9-129D-4C0C-820B-BE4AA5996652} {352B45B3-FE88-4431-9D89-48CF811446DB} = {C0A6FC9A-3A5C-48F8-A4B6-8D463C61C021} {FC4C071B-2C26-4B03-948A-335C94A88B5E} = {9F328FE9-129D-4C0C-820B-BE4AA5996652} {61D6A599-6BED-4154-A9FC-40553BD972E0} = {6ABA1767-6242-4CA0-BA22-A30972DC8918} diff --git a/src/common/cli.cpp b/src/common/cli.cpp index b4ace89add..d2ad3f8fc4 100644 --- a/src/common/cli.cpp +++ b/src/common/cli.cpp @@ -88,6 +88,10 @@ int cli_get_options(int argc, char ** argv) { for (i = 1; i < argc; i++) { const char* arg = argv[i]; + // to temporarily support mapgenerator options + if (!arg) + continue; + if (arg[0] != '-' && (arg[0] != '/' || arg[1] == '-')) {// -, -- and / ShowError("Unknown option '%s'.\n", argv[i]); exit(EXIT_FAILURE); diff --git a/src/map/Makefile.in b/src/map/Makefile.in index e315e7afa3..9a58299136 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -36,7 +36,7 @@ else endif TOOLS_DEPENDS=map-server-generator -TOOLS_FLAGS="-DGENERATE_NAVI" +TOOLS_FLAGS="-DMAP_GENERATOR" @SET_MAKE@ diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 82cbd5ee4d..d91bbac2f5 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -10473,7 +10473,7 @@ void battle_adjust_conf() ShowWarning("Battle setting 'custom_cell_stack_limit' takes no effect as this server was compiled without Cell Stack Limit support.\n"); #endif -#ifdef GENERATE_NAVI +#ifdef MAP_GENERATOR battle_config.dynamic_mobs = 1; #endif } diff --git a/src/map/map-server-generator.vcxproj b/src/map/map-server-generator.vcxproj new file mode 100644 index 0000000000..d74de78760 --- /dev/null +++ b/src/map/map-server-generator.vcxproj @@ -0,0 +1,372 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {EB03BC16-8A47-43B9-B5BB-D0200E4A2775} + Win32Proj + mapserver + + + + Application + true + $(DefaultPlatformToolset) + MultiByte + + + Application + true + $(DefaultPlatformToolset) + MultiByte + + + Application + false + $(DefaultPlatformToolset) + true + MultiByte + + + Application + false + $(DefaultPlatformToolset) + true + MultiByte + + + + + + + + + + + + + + + + + + + true + $(SolutionDir) + $(SolutionDir).vs\build\$(ProjectName)\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir) + $(SolutionDir).vs\build\$(ProjectName)\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir) + $(SolutionDir).vs\build\$(ProjectName)\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir) + $(SolutionDir).vs\build\$(ProjectName)\$(Platform)\$(Configuration)\ + + + true + + + true + + + true + + + true + + + false + + + + + + Level3 + Disabled + $(DefineConstants);MAP_GENERATOR;WIN32;FD_SETSIZE=4096;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;LIBCONFIG_STATIC;YY_USE_CONST;_DEBUG;_CONSOLE;_LIB;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + 4018;4200 + true + MultiThreadedDebug + $(SolutionDir)\3rdparty\rapidyaml\src;$(SolutionDir)\3rdparty\rapidyaml\ext\c4core\src;%(AdditionalIncludeDirectories) + + + Console + true + ws2_32.lib;$(SolutionDir).vs\build\ryml.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + $(DefineConstants);MAP_GENERATOR;WIN32;FD_SETSIZE=4096;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;LIBCONFIG_STATIC;YY_USE_CONST;_DEBUG;_CONSOLE;_LIB;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + 4018 + MultiThreadedDebug + $(SolutionDir)\3rdparty\rapidyaml\src;$(SolutionDir)\3rdparty\rapidyaml\ext\c4core\src;%(AdditionalIncludeDirectories) + + + Console + true + ws2_32.lib;$(SolutionDir).vs\build\ryml.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + $(DefineConstants);MAP_GENERATOR;WIN32;FD_SETSIZE=4096;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;LIBCONFIG_STATIC;YY_USE_CONST;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + MultiThreaded + 4018 + $(SolutionDir)\3rdparty\rapidyaml\src;$(SolutionDir)\3rdparty\rapidyaml\ext\c4core\src;%(AdditionalIncludeDirectories) + + + Console + true + true + true + ws2_32.lib;$(SolutionDir).vs\build\ryml.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;%(AdditionalDependencies) + true + + + + + Level3 + + + MaxSpeed + true + true + $(DefineConstants);MAP_GENERATOR;WIN32;FD_SETSIZE=4096;PCRE_SUPPORT;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;LIBCONFIG_STATIC;YY_USE_CONST;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + MultiThreaded + 4018 + $(SolutionDir)\3rdparty\rapidyaml\src;$(SolutionDir)\3rdparty\rapidyaml\ext\c4core\src;%(AdditionalIncludeDirectories) + + + Console + true + true + true + ws2_32.lib;$(SolutionDir).vs\build\ryml.lib;$(SolutionDir).vs\build\common.lib;$(SolutionDir).vs\build\libconfig.lib;$(SolutionDir)3rdparty\zlib\lib\$(Platform)\zlib.lib;$(SolutionDir)3rdparty\pcre\lib\$(Platform)\pcre8.lib;$(SolutionDir)3rdparty\mysql\lib\$(Platform)\libmysql.lib;%(AdditionalDependencies) + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Disabled + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/map/map-server-generator.vcxproj.filters b/src/map/map-server-generator.vcxproj.filters new file mode 100644 index 0000000000..147286c910 --- /dev/null +++ b/src/map/map-server-generator.vcxproj.filters @@ -0,0 +1,284 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + diff --git a/src/map/map.cpp b/src/map/map.cpp index 5292d475ca..7d80f7c287 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -188,6 +188,12 @@ int console = 0; int enable_spy = 0; //To enable/disable @spy commands, which consume too much cpu time when sending packets. [Skotlex] int enable_grf = 0; //To enable/disable reading maps from GRF files, bypassing mapcache [blackhole89] +#ifdef MAP_GENERATOR +struct s_generator_options { + bool navi; +} gen_options; +#endif + /** * Get the map data * @param mapid: Map ID to lookup @@ -4871,7 +4877,7 @@ void do_final(void){ do_final_battle(); do_final_chrif(); do_final_clan(); -#ifndef GENERATE_NAVI +#ifndef MAP_GENERATOR do_final_clif(); #endif do_final_npc(); @@ -5078,6 +5084,42 @@ const char* map_msg_txt(struct map_session_data *sd, int msg_number){ return "??"; } +/** + * Read the option specified in command line + * and assign the confs used by the different server. + * @param argc: Argument count + * @param argv: Argument values + * @return true or Exit on failure. + */ +int mapgenerator_get_options(int argc, char** argv) { +#ifdef MAP_GENERATOR + bool optionSet = false; + for (int i = 1; i < argc; i++) { + const char *arg = argv[i]; + if (arg[0] != '-' && (arg[0] != '/' || arg[1] == '-')) {// -, -- and / + } else if (arg[0] == '/' || (++arg)[0] == '-') {// long option + arg++; + + if (strcmp(arg, "generate-navi") == 0) { + gen_options.navi = true; + } else { + // pass through to default get_options + continue; + } + + // clear option + argv[i] = nullptr; + optionSet = true; + } + } + if (!optionSet) { + ShowError("No options passed to the map generator, you must set at least one.\n"); + exit(1); + } +#endif + return 1; +} + /// Called when a terminate signal is received. void do_shutdown(void) @@ -5136,6 +5178,9 @@ int do_init(int argc, char *argv[]) inter_config.emblem_woe_change = true; inter_config.emblem_transparency_limit = 80; +#ifdef MAP_GENERATOR + mapgenerator_get_options(argc, argv); +#endif cli_get_options(argc,argv); rnd_init(); @@ -5208,7 +5253,7 @@ int do_init(int argc, char *argv[]) do_init_instance(); do_init_chrif(); do_init_clan(); -#ifndef GENERATE_NAVI +#ifndef MAP_GENERATOR do_init_clif(); #endif do_init_script(); @@ -5240,10 +5285,12 @@ int do_init(int argc, char *argv[]) if (battle_config.pk_mode) ShowNotice("Server is running on '" CL_WHITE "PK Mode" CL_RESET "'.\n"); +#ifndef MAP_GENERATOR ShowStatus("Server is '" CL_GREEN "ready" CL_RESET "' and listening on port '" CL_WHITE "%d" CL_RESET "'.\n\n", map_port); - -#ifdef GENERATE_NAVI - navi_create_lists(); +#else + // depending on gen_options, generate the correct things + if (gen_options.navi) + navi_create_lists(); runflag = CORE_ST_STOP; #endif diff --git a/src/map/map.hpp b/src/map/map.hpp index 362ead0491..87b681d307 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -813,7 +813,7 @@ struct map_data { /* speeds up clif_updatestatus processing by causing hpmeter to run only when someone with the permission can view it */ unsigned short hpmeter_visible; -#ifdef GENERATE_NAVI +#ifdef MAP_GENERATOR struct { std::vector npcs; std::vector warps_into; diff --git a/src/map/navi.cpp b/src/map/navi.cpp index 38b3621ea8..5594d7b182 100644 --- a/src/map/navi.cpp +++ b/src/map/navi.cpp @@ -1,6 +1,6 @@ #include "../config/core.hpp" -#ifdef GENERATE_NAVI +#ifdef MAP_GENERATOR #include #include @@ -12,8 +12,9 @@ #include #include "../common/db.hpp" -#include "../common/showmsg.hpp" #include "../common/malloc.hpp" +#include "../common/showmsg.hpp" +#include "../common/utils.hpp" #include "map.hpp" #include "mob.hpp" #include "navi.hpp" @@ -424,6 +425,13 @@ void write_object_lists() { auto npc_file = std::ofstream(filePrefix + "./navi_npc_krpri.lub"); auto map_file = std::ofstream(filePrefix + "./navi_map_krpri.lub"); + if (!mob_file) { + ShowError("Failed to create mobfile.\n"); + ShowError("Maybe the file directory \"%s\" does not exist?\n", filePrefix.c_str()); + ShowInfo("Create the directory and rerun map-server-generator\n"); + exit(1); + } + int warp_count = 0; int npc_count = 0; int spawn_count = 0; @@ -623,12 +631,6 @@ void navi_create_lists() { auto starttime = std::chrono::system_clock::now(); - if (!fileExists(filePrefix)) { - ShowError("File directory %s does not exist.\n", filePrefix.c_str()); - ShowInfo("Create the directory and rerun map-server"); - exit(1); - } - npc_event_runall(script_config.navi_generate_name); write_object_lists(); @@ -646,4 +648,4 @@ void navi_create_lists() { BHEAP_CLEAR(g_open_set); } -#endif \ No newline at end of file +#endif diff --git a/src/map/navi.hpp b/src/map/navi.hpp index 7fc479dfa6..0af5d1bcbc 100644 --- a/src/map/navi.hpp +++ b/src/map/navi.hpp @@ -3,7 +3,7 @@ #include "../config/core.hpp" -#ifdef GENERATE_NAVI +#ifdef MAP_GENERATOR struct navi_pos { int m; int x; @@ -39,5 +39,5 @@ struct navi_walkpath_data { void navi_create_lists(); -#endif // ifdef GENERATE_NAVI +#endif // ifdef MAP_GENERATOR #endif diff --git a/src/map/npc.cpp b/src/map/npc.cpp index a63d16c4b9..1f61feb8a1 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -3716,7 +3716,7 @@ struct npc_data *npc_create_npc(int16 m, int16 x, int16 y){ nd->progressbar.timeout = 0; nd->vd = npc_viewdb[0]; // Default to JT_INVISIBLE -#ifdef GENERATE_NAVI +#ifdef MAP_GENERATOR nd->navi.pos = {m, x, y}; nd->navi.id = 0; nd->navi.npc = nd; @@ -3842,7 +3842,7 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const nd->u.warp.xs = xs; nd->u.warp.ys = ys; -#ifdef GENERATE_NAVI +#ifdef MAP_GENERATOR nd->navi.warp_dest = {map_mapindex2mapid(i), to_x, to_y}; #endif diff --git a/src/map/npc.hpp b/src/map/npc.hpp index 1629414cd1..47730bd2b8 100644 --- a/src/map/npc.hpp +++ b/src/map/npc.hpp @@ -208,7 +208,7 @@ struct npc_data { unsigned long color; } progressbar; -#ifdef GENERATE_NAVI +#ifdef MAP_GENERATOR struct navi_link navi; // for warps and the src of npcs std::vector links; // for extra links, like warper npc #endif diff --git a/src/map/script.cpp b/src/map/script.cpp index a6fa4b9830..365e7284f5 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -26009,7 +26009,7 @@ BUILDIN_FUNC(getenchantgrade){ } BUILDIN_FUNC(naviregisterwarp) { -#ifdef GENERATE_NAVI +#ifdef MAP_GENERATOR TBL_NPC* nd; int x, y, m; const char *warpname, *mapname=NULL; @@ -26085,7 +26085,7 @@ BUILDIN_FUNC( openstylist ){ } BUILDIN_FUNC(navihide) { -#ifdef GENERATE_NAVI +#ifdef MAP_GENERATOR TBL_NPC *nd; nd = map_id2nd(st->oid); diff --git a/tools/navigenerator.bat b/tools/navigenerator.bat new file mode 100644 index 0000000000..8e0d38173d --- /dev/null +++ b/tools/navigenerator.bat @@ -0,0 +1,4 @@ +@ECHO OFF +map-server-generator.exe /generate-navi +ECHO. +pause \ No newline at end of file