Skip to content

Commit c751ca6

Browse files
authored
Client Navigation Generator (rathena#6023)
Creates navigation files for the client.
1 parent b1b371f commit c751ca6

17 files changed

+1669
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,6 @@ Thumbs.db
144144

145145
# CMakeFiles
146146
/CMakeFiles/
147+
148+
# generated files
149+
generated

Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ libconfig:
6060

6161
tools:
6262
@$(MAKE) -C src/tool
63+
@$(MAKE) -C src/map tools
6364

6465
rapidyaml:
6566
@$(MAKE) -C 3rdparty/rapidyaml

doc/script_commands.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,11 @@ Only the special labels which are not associated with any script command are
978978
listed here. There are other kinds of labels which may be triggered in a similar
979979
manner, but they are described with their associated commands.
980980

981+
OnNaviGenerate:
982+
983+
This special label triggers when running the map-server-generator binary. It is used
984+
in combination with 'naviregisterwarp' to register extra warps for an npc.
985+
981986
On<label name>:
982987

983988
These special labels are used with Mob scripts mostly, and script commands
@@ -9446,6 +9451,20 @@ with the given character id.
94469451

94479452
---------------------------------------
94489453

9454+
*naviregisterwarp("<Name of Link>", "<dest_map>", <dest_x>, <dest_y>)
9455+
9456+
Only useful when using the map-server-generator. Registers an extra warp from this
9457+
npc to the destination map/x/y for the generated client files.
9458+
9459+
---------------------------------------
9460+
9461+
*navihide
9462+
9463+
Only useful when using the map-server-generator. Hides this npc and all links from
9464+
this npc in the navigation generation.
9465+
9466+
---------------------------------------
9467+
94499468
========================
94509469
|7.- Instance commands.|
94519470
========================

npc/custom/warper.txt

Lines changed: 701 additions & 0 deletions
Large diffs are not rendered by default.

src/map/Makefile.in

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ RAPIDYAML_INCLUDE = -I../../3rdparty/rapidyaml/src -I../../3rdparty/rapidyaml/ex
1616
MAP_OBJ = $(shell ls *.cpp | sed -e "s/\.cpp/\.o/g")
1717
#MAP_OBJ += $(shell ls *.c | sed -e "s/\.c/\.o/g")
1818
MAP_DIR_OBJ = $(MAP_OBJ:%=obj/%)
19+
MAP_GEN_DIR_OBJ = $(MAP_OBJ:%=obj-gen/%)
1920
MAP_H = $(shell ls ../map/*.hpp) \
2021
$(shell ls ../config/*.hpp)
2122

@@ -34,6 +35,9 @@ else
3435
PCRE_CFLAGS=
3536
endif
3637

38+
TOOLS_DEPENDS=map-server-generator
39+
TOOLS_FLAGS="-DGENERATE_NAVI"
40+
3741
@SET_MAKE@
3842

3943
#####################################################################
@@ -43,6 +47,8 @@ all: $(ALL_DEPENDS)
4347

4448
server: $(SERVER_DEPENDS)
4549

50+
tools: $(TOOLS_DEPENDS)
51+
4652
clean:
4753
@echo " CLEAN map"
4854
@rm -rf *.o obj ../../@OMAP@@EXEEXT@
@@ -66,13 +72,22 @@ obj:
6672
@echo " MKDIR obj"
6773
@-mkdir obj
6874

75+
obj-gen:
76+
@echo " MDIR obj-gen"
77+
@-mkdir obj-gen
78+
6979
# executables
7080

7181
map-server: obj $(MAP_DIR_OBJ) $(COMMON_AR) $(LIBCONFIG_AR) $(RAPIDYAML_AR)
7282
@echo " LD @OMAP@@EXEEXT@"
7383
@@CXX@ @LDFLAGS@ -o ../../@OMAP@@EXEEXT@ $(MAP_DIR_OBJ) $(COMMON_AR) $(LIBCONFIG_AR) $(RAPIDYAML_AR) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@
7484

7585

86+
map-server-generator: obj-gen $(MAP_GEN_DIR_OBJ) $(COMMON_AR) $(LIBCONFIG_AR) $(RAPIDYAML_AR)
87+
@echo " LD map-server-generator@EXEEXT@"
88+
@@CXX@ @LDFLAGS@ -o ../../map-server-generator@EXEEXT@ $(MAP_GEN_DIR_OBJ) $(COMMON_AR) $(LIBCONFIG_AR) $(RAPIDYAML_AR) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@
89+
90+
7691
# map object files
7792
#cause this one failling otherwise
7893
obj/npc.o: npc.cpp $(MAP_H) $(COMMON_H) $(LIBCONFIG_H) $(RAPIDYAML_H)
@@ -83,6 +98,14 @@ obj/%.o: %.cpp $(MAP_H) $(COMMON_H) $(LIBCONFIG_H) $(RAPIDYAML_H)
8398
@echo " CXX $<"
8499
@@CXX@ @CXXFLAGS@ $(COMMON_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) $(RAPIDYAML_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
85100

101+
obj-gen/npc.o: npc.cpp $(MAP_H) $(COMMON_H) $(LIBCONFIG_H) $(RAPIDYAML_H)
102+
@echo " CXX $< (custom rule)"
103+
@@CXX@ @CXXFLAG_CLEARS@ $(TOOLS_FLAGS) $(COMMON_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) $(RAPIDYAML_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
104+
105+
obj-gen/%.o: %.cpp $(MAP_H) $(COMMON_H) $(LIBCONFIG_H) $(RAPIDYAML_H)
106+
@echo " CXX $<"
107+
@@CXX@ @CXXFLAGS@ $(TOOLS_FLAGS) $(COMMON_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) $(RAPIDYAML_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
108+
86109
# missing object files
87110
$(COMMON_AR):
88111
@$(MAKE) -C ../common server

src/map/battle.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10465,6 +10465,10 @@ void battle_adjust_conf()
1046510465
if (battle_config.custom_cell_stack_limit != 1)
1046610466
ShowWarning("Battle setting 'custom_cell_stack_limit' takes no effect as this server was compiled without Cell Stack Limit support.\n");
1046710467
#endif
10468+
10469+
#ifdef GENERATE_NAVI
10470+
battle_config.dynamic_mobs = 1;
10471+
#endif
1046810472
}
1046910473

1047010474
/*=====================================

src/map/map-server.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@
209209
<ClInclude Include="mapreg.hpp" />
210210
<ClInclude Include="mercenary.hpp" />
211211
<ClInclude Include="mob.hpp" />
212+
<ClInclude Include="navi.hpp" />
212213
<ClInclude Include="npc.hpp" />
213214
<ClInclude Include="packets.hpp" />
214215
<ClInclude Include="packets_struct.hpp" />
@@ -256,6 +257,7 @@
256257
<ClCompile Include="mob.cpp">
257258
<Optimization Condition="'$(Configuration)'=='Release'">Disabled</Optimization>
258259
</ClCompile>
260+
<ClCompile Include="navi.cpp" />
259261
<ClCompile Include="npc.cpp" />
260262
<ClCompile Include="npc_chat.cpp" />
261263
<ClCompile Include="party.cpp" />

src/map/map-server.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@
9595
<ClInclude Include="mob.hpp">
9696
<Filter>Header Files</Filter>
9797
</ClInclude>
98+
<ClInclude Include="navi.hpp">
99+
<Filter>Header Files</Filter>
100+
</ClInclude>
98101
<ClInclude Include="npc.hpp">
99102
<Filter>Header Files</Filter>
100103
</ClInclude>
@@ -226,6 +229,9 @@
226229
<ClCompile Include="mob.cpp">
227230
<Filter>Source Files</Filter>
228231
</ClCompile>
232+
<ClCompile Include="navi.cpp">
233+
<Filter>Source Files</Filter>
234+
</ClCompile>
229235
<ClCompile Include="npc.cpp">
230236
<Filter>Source Files</Filter>
231237
</ClCompile>

src/map/map.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <stdlib.h>
77
#include <math.h>
88

9+
#include "../config/core.hpp"
10+
911
#include "../common/cbasetypes.hpp"
1012
#include "../common/cli.hpp"
1113
#include "../common/core.hpp"
@@ -41,6 +43,7 @@
4143
#include "mapreg.hpp"
4244
#include "mercenary.hpp"
4345
#include "mob.hpp"
46+
#include "navi.hpp"
4447
#include "npc.hpp"
4548
#include "party.hpp"
4649
#include "path.hpp"
@@ -4868,7 +4871,9 @@ void do_final(void){
48684871
do_final_battle();
48694872
do_final_chrif();
48704873
do_final_clan();
4874+
#ifndef GENERATE_NAVI
48714875
do_final_clif();
4876+
#endif
48724877
do_final_npc();
48734878
do_final_quest();
48744879
do_final_achievement();
@@ -5203,7 +5208,9 @@ int do_init(int argc, char *argv[])
52035208
do_init_instance();
52045209
do_init_chrif();
52055210
do_init_clan();
5211+
#ifndef GENERATE_NAVI
52065212
do_init_clif();
5213+
#endif
52075214
do_init_script();
52085215
do_init_itemdb();
52095216
do_init_channel();
@@ -5235,6 +5242,11 @@ int do_init(int argc, char *argv[])
52355242

52365243
ShowStatus("Server is '" CL_GREEN "ready" CL_RESET "' and listening on port '" CL_WHITE "%d" CL_RESET "'.\n\n", map_port);
52375244

5245+
#ifdef GENERATE_NAVI
5246+
navi_create_lists();
5247+
runflag = CORE_ST_STOP;
5248+
#endif
5249+
52385250
if( runflag != CORE_ST_STOP )
52395251
{
52405252
shutdown_callback = do_shutdown;

src/map/map.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "../common/timer.hpp"
2020
#include "../config/core.hpp"
2121

22+
#include "navi.hpp"
2223
#include "script.hpp"
2324

2425
struct npc_data;
@@ -812,6 +813,13 @@ struct map_data {
812813

813814
/* speeds up clif_updatestatus processing by causing hpmeter to run only when someone with the permission can view it */
814815
unsigned short hpmeter_visible;
816+
#ifdef GENERATE_NAVI
817+
struct {
818+
std::vector<const struct npc_data *> npcs;
819+
std::vector<const struct navi_link *> warps_into;
820+
std::vector<const struct navi_link *> warps_outof;
821+
} navi;
822+
#endif
815823
};
816824

817825
/// Stores information about a remote map (for multi-mapserver setups).

0 commit comments

Comments
 (0)