Skip to content

Commit

Permalink
Generate Reputation UI bson files (rathena#7340)
Browse files Browse the repository at this point in the history
  • Loading branch information
vstumpf authored Nov 27, 2022
1 parent bc49343 commit 4661016
Show file tree
Hide file tree
Showing 14 changed files with 449 additions and 11 deletions.
33 changes: 33 additions & 0 deletions db/import-tmpl/reputation_group.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is a part of rAthena.
# Copyright(C) 2022 rAthena Development Team
# https://rathena.org - https://github.com/rathena
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###########################################################################
# Reputation Group Database
###########################################################################
#
# Reputation Group Settings
#
###########################################################################
# - Id Client side group index.
# ScriptName Unused? Used for "ID" in client
# Name Visible name in window
# ReputeList List of Reputations
###########################################################################

Header:
Type: REPUTATION_GROUP_DB
Version: 1
43 changes: 43 additions & 0 deletions db/re/generator/reputation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This file is a part of rAthena.
# Copyright(C) 2022 rAthena Development Team
# https://rathena.org - https://github.com/rathena
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###########################################################################
# Reputation Database
###########################################################################
#
# Reputation Settings
#
###########################################################################
# - Id Client side index.
# Visibility Always = Always show
# Never = Never show
# Exist = Only show if greater than 0
###########################################################################

Header:
Type: REPUTATION_DB
Version: 1

Body:
- Id: 1
Visibility: Always
- Id: 2
Visibility: Always
- Id: 3
Visibility: Exist
- Id: 4
Visibility: Exist
51 changes: 51 additions & 0 deletions db/re/generator/reputation_group.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This file is a part of rAthena.
# Copyright(C) 2022 rAthena Development Team
# https://rathena.org - https://github.com/rathena
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###########################################################################
# Reputation Group Database
###########################################################################
#
# Reputation Group Settings
#
###########################################################################
# - Id Client side group index.
# ScriptName Unused? Used for "ID" in client
# Name Visible name in window
# ReputeList List of Reputations
###########################################################################

Header:
Type: REPUTATION_GROUP_DB
Version: 1

Body:
- Id: 1
ScriptName: MonsterGroup1
Name: Monster Friends
ReputeList:
- 1
- 2
- Id: 2
ScriptName: Arunafelts
Name: Arunafeltz
ReputeList:
- 3
- Id: 3
ScriptName: Isgard
Name: Isgard
ReputeList:
- 4
5 changes: 5 additions & 0 deletions db/re/reputation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ Body:
Variable: RepPointsIsgard
Minimum: -3000
Maximum: 3000

Footer:
Imports:
- Path: db/re/generator/reputation.yml
Generator: true
38 changes: 38 additions & 0 deletions db/re/reputation_group.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This file is a part of rAthena.
# Copyright(C) 2022 rAthena Development Team
# https://rathena.org - https://github.com/rathena
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###########################################################################
# Reputation Group Database
###########################################################################
#
# Reputation Group Settings
#
###########################################################################
# - Id Client side group index.
# ScriptName Unused? Used for "ID" in client
# Name Visible name in window
# ReputeList List of Reputations
###########################################################################

Header:
Type: REPUTATION_GROUP_DB
Version: 1

Footer:
Imports:
- Path: db/re/generator/reputation_group.yml
Generator: true
39 changes: 39 additions & 0 deletions db/reputation_group.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file is a part of rAthena.
# Copyright(C) 2022 rAthena Development Team
# https://rathena.org - https://github.com/rathena
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###########################################################################
# Reputation Group Database
###########################################################################
#
# Reputation Group Settings
#
###########################################################################
# - Id Client side group index.
# ScriptName Unused? Used for "ID" in client
# Name Visible name in window
# ReputeList List of Reputations
###########################################################################

Header:
Type: REPUTATION_GROUP_DB
Version: 1

Footer:
Imports:
- Path: db/re/reputation_group.yml
Mode: Renewal
- Path: db/import/reputation_group.yml
6 changes: 3 additions & 3 deletions doc/map_server_generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

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`.
Expand All @@ -21,6 +19,8 @@ On Windows, prefix with `/`

option | feature
---|---
generate-navi | create navigation files
`generate-navi` | create navigation files
`generate-reputation` | create reputation bson files
`generate-itemmoveinfo` | create itemmoveinfov5.txt


15 changes: 14 additions & 1 deletion src/common/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,16 @@ void YamlDatabase::parseImports( const ryml::Tree& rootNode ){
// Skip this import
continue;
}
}
}

if (this->nodeExists(node, "Generator")) {
bool isGenerator;
if (!this->asBool(node, "Generator", isGenerator)) {
continue;
}
if (!(shouldLoadGenerator && isGenerator))
continue; // skip import
}

this->load( importFile );
}
Expand Down Expand Up @@ -358,6 +367,10 @@ std::string YamlDatabase::getCurrentFile(){
return this->currentFile;
}

void YamlDatabase::setGenerator(bool shouldLoad) {
shouldLoadGenerator = shouldLoad;
}

void on_yaml_error( const char* msg, size_t len, ryml::Location loc, void *user_data ){
throw std::runtime_error( msg );
}
Expand Down
3 changes: 3 additions & 0 deletions src/common/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class YamlDatabase{
uint16 version;
uint16 minimumVersion;
std::string currentFile;
bool shouldLoadGenerator{false};

bool verifyCompatibility( const ryml::Tree& rootNode );
bool load( const std::string& path );
Expand Down Expand Up @@ -56,6 +57,8 @@ class YamlDatabase{
bool asUInt16Rate(const ryml::NodeRef& node, const std::string& name, uint16& out, uint16 maximum=10000);
bool asUInt32Rate(const ryml::NodeRef& node, const std::string& name, uint32& out, uint32 maximum=10000);

void setGenerator(bool shouldLoad);

virtual void loadingFinished();

public:
Expand Down
7 changes: 5 additions & 2 deletions src/map/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ RAPIDYAML_AR = ../../3rdparty/rapidyaml/obj/ryml.a
RAPIDYAML_H = $(shell find ../../3rdparty/rapidyaml/ -type f -name "*.h*")
RAPIDYAML_INCLUDE = -I../../3rdparty/rapidyaml/src -I../../3rdparty/rapidyaml/ext/c4core/src

NLOHMANN_H = $(shell find ../../3rdparty/json/include/nlohmann/ -type f -name "*.hpp")
NLOHMANN_INCLUDE = -I../../3rdparty/json/include

MAP_OBJ = $(shell ls *.cpp | sed -e "s/\.cpp/\.o/g")
#MAP_OBJ += $(shell ls *.c | sed -e "s/\.c/\.o/g")
MAP_DIR_OBJ = $(MAP_OBJ:%=obj/%)
Expand Down Expand Up @@ -116,9 +119,9 @@ obj-gen/npc.o: npc.cpp $(MAP_H) $(COMMON_H) $(LIBCONFIG_H) $(RAPIDYAML_H)
@echo " CXX $< (custom rule)"
@@CXX@ @CXXFLAG_CLEARS@ $(TOOLS_FLAGS) $(COMMON_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) $(RAPIDYAML_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<

obj-gen/%.o: %.cpp $(MAP_H) $(COMMON_H) $(LIBCONFIG_H) $(RAPIDYAML_H)
obj-gen/%.o: %.cpp $(MAP_H) $(COMMON_H) $(LIBCONFIG_H) $(RAPIDYAML_H) $(NLOHMANN_H)
@echo " CXX $<"
@@CXX@ @CXXFLAGS@ $(TOOLS_FLAGS) $(COMMON_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) $(RAPIDYAML_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
@@CXX@ @CXXFLAGS@ $(TOOLS_FLAGS) $(COMMON_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) $(RAPIDYAML_INCLUDE) $(NLOHMANN_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<

# missing object files
$(COMMON_AR):
Expand Down
9 changes: 5 additions & 4 deletions src/map/map-server-generator.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<DisableSpecificWarnings>4018;4200</DisableSpecificWarnings>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)\3rdparty\rapidyaml\src;$(SolutionDir)\3rdparty\rapidyaml\ext\c4core\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)\3rdparty\rapidyaml\src;$(SolutionDir)\3rdparty\rapidyaml\ext\c4core\src;$(SolutionDir)\3rdparty\json\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -128,7 +128,7 @@
<PreprocessorDefinitions>$(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)</PreprocessorDefinitions>
<DisableSpecificWarnings>4018</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(SolutionDir)\3rdparty\rapidyaml\src;$(SolutionDir)\3rdparty\rapidyaml\ext\c4core\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)\3rdparty\rapidyaml\src;$(SolutionDir)\3rdparty\rapidyaml\ext\c4core\src;$(SolutionDir)\3rdparty\json\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -147,7 +147,7 @@
<PreprocessorDefinitions>$(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)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DisableSpecificWarnings>4018</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir)\3rdparty\rapidyaml\src;$(SolutionDir)\3rdparty\rapidyaml\ext\c4core\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)\3rdparty\rapidyaml\src;$(SolutionDir)\3rdparty\rapidyaml\ext\c4core\src;$(SolutionDir)\3rdparty\json\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -169,7 +169,7 @@
<PreprocessorDefinitions>$(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)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DisableSpecificWarnings>4018</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(SolutionDir)\3rdparty\rapidyaml\src;$(SolutionDir)\3rdparty\rapidyaml\ext\c4core\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)\3rdparty\rapidyaml\src;$(SolutionDir)\3rdparty\rapidyaml\ext\c4core\src;$(SolutionDir)\3rdparty\json\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down Expand Up @@ -368,5 +368,6 @@
<Copy SourceFiles="$(SolutionDir)db\import-tmpl\status.yml" DestinationFolder="$(SolutionDir)db\import\" ContinueOnError="true" Condition="!Exists('$(SolutionDir)db\import\status.yml')" />
<Copy SourceFiles="$(SolutionDir)db\import-tmpl\stylist.yml" DestinationFolder="$(SolutionDir)db\import\" ContinueOnError="true" Condition="!Exists('$(SolutionDir)db\import\stylist.yml')" />
<MakeDir Directories="$(SolutionDir)generated\clientside\data\luafiles514\lua files\navigation\" ContinueOnError="true" Condition="!Exists('$(SolutionDir)generated\clientside\data\luafiles514\lua files\navigation\')" />
<MakeDir Directories="$(SolutionDir)generated\clientside\data\contentdata\" ContinueOnError="true" Condition="!Exists('$(SolutionDir)generated\clientside\data\contentdata\')" />
</Target>
</Project>
5 changes: 5 additions & 0 deletions src/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ int enable_grf = 0; //To enable/disable reading maps from GRF files, bypassing m
struct s_generator_options {
bool navi;
bool itemmoveinfo;
bool reputation;
} gen_options;
#endif

Expand Down Expand Up @@ -5106,6 +5107,8 @@ int mapgenerator_get_options(int argc, char** argv) {
gen_options.navi = true;
} else if (strcmp(arg, "generate-itemmoveinfo") == 0) {
gen_options.itemmoveinfo = true;
} else if (strcmp(arg, "generate-reputation") == 0) {
gen_options.reputation = true;
} else {
// pass through to default get_options
continue;
Expand Down Expand Up @@ -5297,6 +5300,8 @@ int do_init(int argc, char *argv[])
navi_create_lists();
if (gen_options.itemmoveinfo)
itemdb_gen_itemmoveinfo();
if (gen_options.reputation)
pc_reputation_generate();
runflag = CORE_ST_STOP;
#endif

Expand Down
Loading

0 comments on commit 4661016

Please sign in to comment.