From cbe0d6b271a42f4afa3b6ea39e222d17f4882e7a Mon Sep 17 00:00:00 2001 From: Daegaladh Date: Mon, 11 Mar 2019 19:57:52 +0100 Subject: [PATCH] Splitted guild_skill_tree.txt into re and pre-re (#3841) Converted Guild Skill Tree database to YAML Please run csv2yaml to convert your existing databases if necessary. Thanks to @aleos89, @Atemo and @Lemongrass3110 --- db/guild_skill_tree.txt | 30 ---- db/guild_skill_tree.yml | 44 ++++++ db/import-tmpl/guild_skill_tree.txt | 13 -- db/import-tmpl/guild_skill_tree.yml | 36 +++++ db/pre-re/guild_skill_tree.yml | 123 ++++++++++++++++ db/re/guild_skill_tree.yml | 123 ++++++++++++++++ src/map/guild.cpp | 218 +++++++++++++++++++++------- src/map/guild.hpp | 4 +- src/map/map-server.vcxproj | 2 +- src/tool/csv2yaml.cpp | 51 ++++++- 10 files changed, 541 insertions(+), 103 deletions(-) delete mode 100644 db/guild_skill_tree.txt create mode 100644 db/guild_skill_tree.yml delete mode 100644 db/import-tmpl/guild_skill_tree.txt create mode 100644 db/import-tmpl/guild_skill_tree.yml create mode 100644 db/pre-re/guild_skill_tree.yml create mode 100644 db/re/guild_skill_tree.yml diff --git a/db/guild_skill_tree.txt b/db/guild_skill_tree.txt deleted file mode 100644 index 569d490ee0..0000000000 --- a/db/guild_skill_tree.txt +++ /dev/null @@ -1,30 +0,0 @@ -// Guild Skill Tree Database -// -// Structure of Database: -// SkillID,MaxLv,Prerequisite SkillID1,Prerequisite SkillLv1,PrereqSkillID2,PrereqSkillLv2,PrereqSkillID3,PrereqSkillLv3,PrereqSkillID4,PrereqSkillLv4,PrereqSkillID5,PrereqSkillLv5 //GUILD SKILLNAME#Skill Name# -// -// 01. SkillID Skill ID of the guild skill. -// 02. MaxLv Maximum level of the guild skill. -// 03. Prerequisite SkillID Guild skill required for the skill to become available. -// 04. Prerequisite SkillLv Level of the required guild skill. -// ... -// -// NOTE: MAX_GUILD_SKILL_REQUIRE (typically 5) ID/Lv pairs must be specified. - - -10000,1,0,0,0,0,0,0,0,0,0,0 //GD_APPROVAL#Official Guild Approval# -10001,1,10000,1,0,0,0,0,0,0,0,0 //GD_KAFRACONTRACT#Contract with Kafra# -10002,1,10000,1,0,0,0,0,0,0,0,0 //GD_GUARDRESEARCH#Guardian Research# -10003,3,0,0,0,0,0,0,0,0,0,0 //GD_GUARDUP#Strengthen Guardians# -10004,10,0,0,0,0,0,0,0,0,0,0 //GD_EXTENSION#Guild Extension# -10005,0,0,0,0,0,0,0,0,0,0,0 //GD_GLORYGUILD#Guilds Glory# -10006,5,0,0,0,0,0,0,0,0,0,0 //GD_LEADERSHIP#Great Leadership# -10007,5,0,0,0,0,0,0,0,0,0,0 //GD_GLORYWOUNDS#Glorious Wounds# -10008,5,10007,1,0,0,0,0,0,0,0,0 //GD_SOULCOLD#Cold Heart# -10009,5,10006,1,0,0,0,0,0,0,0,0 //GD_HAWKEYES#Sharp Gaze# -10010,1,10000,1,10004,2,0,0,0,0,0,0 //GD_BATTLEORDER#Battle Command# -10011,3,10000,1,10004,5,10010,1,0,0,0,0 //GD_REGENERATION#Regeneration# -10012,1,10011,1,0,0,0,0,0,0,0,0 //GD_RESTORE#Restoration# -10013,1,10000,1,10002,1,10004,5,10010,1,10011,1 //GD_EMERGENCYCALL#Urgent Call# -10014,1,0,0,0,0,0,0,0,0,0,0 //GD_DEVELOPMENT#Permanent Development# -10016,5,0,0,0,0,0,0,0,0,0,0 //GD_GUILD_STORAGE#Guild Storage Expansion# diff --git a/db/guild_skill_tree.yml b/db/guild_skill_tree.yml new file mode 100644 index 0000000000..c46ba0b476 --- /dev/null +++ b/db/guild_skill_tree.yml @@ -0,0 +1,44 @@ +# This file is a part of rAthena. +# Copyright(C) 2019 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 . +# +########################################################################### +# Guild Skill Database +########################################################################### +# +# Guild Skill Settings +# +########################################################################### +# Id - Skill ID of the guild skill. +########################################################################### +# MaxLevel - Maximum level of the guild skill. +########################################################################### +# Required - A list of required skills for the skill to become available. +# Id: Skill ID of the required guild skill. +# Level: Level of the required guild skill. +########################################################################### + +Header: + Type: GUILD_SKILL_TREE_DB + Version: 1 + +Footer: + Imports: + - Path: db/pre-re/guild_skill_tree.yml + Mode: Prerenewal + - Path: db/re/guild_skill_tree.yml + Mode: Renewal + - Path: db/import/guild_skill_tree.yml diff --git a/db/import-tmpl/guild_skill_tree.txt b/db/import-tmpl/guild_skill_tree.txt deleted file mode 100644 index 6d2c48c216..0000000000 --- a/db/import-tmpl/guild_skill_tree.txt +++ /dev/null @@ -1,13 +0,0 @@ -// Guild Skill Tree Database -// -// Structure of Database: -// SkillID,MaxLv,Prerequisite SkillID1,Prerequisite SkillLv1,PrereqSkillID2,PrereqSkillLv2,PrereqSkillID3,PrereqSkillLv3,PrereqSkillID4,PrereqSkillLv4,PrereqSkillID5,PrereqSkillLv5 //GUILD SKILLNAME#Skill Name# -// -// 01. SkillID Skill ID of the guild skill. -// 02. MaxLv Maximum level of the guild skill. -// 03. Prerequisite SkillID Guild skill required for the skill to become available. -// 04. Prerequisite SkillLv Level of the required guild skill. -// ... -// -// NOTE: MAX_GUILD_SKILL_REQUIRE (typically 5) ID/Lv pairs must be specified. - diff --git a/db/import-tmpl/guild_skill_tree.yml b/db/import-tmpl/guild_skill_tree.yml new file mode 100644 index 0000000000..96dcf42b01 --- /dev/null +++ b/db/import-tmpl/guild_skill_tree.yml @@ -0,0 +1,36 @@ +# This file is a part of rAthena. +# Copyright(C) 2019 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 . +# +########################################################################### +# Custom Guild Skill Database +########################################################################### +# +# Guild Skill Settings +# +########################################################################### +# Id - Skill ID of the guild skill. +########################################################################### +# MaxLevel - Maximum level of the guild skill. +########################################################################### +# Required - A list of required skills for the skill to become available. +# Id: Skill ID of the required guild skill. +# Level: Level of the required guild skill. +########################################################################### + +Header: + Type: GUILD_SKILL_TREE_DB + Version: 1 diff --git a/db/pre-re/guild_skill_tree.yml b/db/pre-re/guild_skill_tree.yml new file mode 100644 index 0000000000..d564e3c635 --- /dev/null +++ b/db/pre-re/guild_skill_tree.yml @@ -0,0 +1,123 @@ +# This file is a part of rAthena. +# Copyright(C) 2019 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 . +# +########################################################################### +# Pre-Renewal Guild Skill Database +########################################################################### +# +# Guild Skill Settings +# +########################################################################### +# Id - Skill ID of the guild skill. +########################################################################### +# MaxLevel - Maximum level of the guild skill. +########################################################################### +# Required - A list of required skills for the skill to become available. +# Id: Skill ID of the required guild skill. +# Level: Level of the required guild skill. +########################################################################### + +Header: + Type: GUILD_SKILL_TREE_DB + Version: 1 + +Body: + - Id: GD_APPROVAL + MaxLevel: 1 + + - Id: GD_KAFRACONTRACT + MaxLevel: 1 + Required: + - Id: GD_APPROVAL + Level: 1 + + - Id: GD_GUARDRESEARCH + MaxLevel: 1 + Required: + - Id: GD_APPROVAL + Level: 1 + + - Id: GD_GUARDUP + MaxLevel: 3 + + - Id: GD_EXTENSION + MaxLevel: 10 + + - Id: GD_GLORYGUILD + MaxLevel: 0 + + - Id: GD_LEADERSHIP + MaxLevel: 5 + + - Id: GD_GLORYWOUNDS + MaxLevel: 5 + + - Id: GD_SOULCOLD + MaxLevel: 5 + Required: + - Id: GD_GLORYWOUNDS + Level: 1 + + - Id: GD_HAWKEYES + MaxLevel: 5 + Required: + - Id: GD_LEADERSHIP + Level: 1 + + - Id: GD_BATTLEORDER + MaxLevel: 1 + Required: + - Id: GD_APPROVAL + Level: 1 + - Id: GD_EXTENSION + Level: 2 + + - Id: GD_REGENERATION + MaxLevel: 3 + Required: + - Id: GD_APPROVAL + Level: 1 + - Id: GD_EXTENSION + Level: 5 + - Id: GD_BATTLEORDER + Level: 1 + + - Id: GD_RESTORE + MaxLevel: 1 + Required: + - Id: GD_REGENERATION + Level: 1 + + - Id: GD_EMERGENCYCALL + MaxLevel: 1 + Required: + - Id: GD_APPROVAL + Level: 1 + - Id: GD_GUARDRESEARCH + Level: 1 + - Id: GD_EXTENSION + Level: 5 + - Id: GD_BATTLEORDER + Level: 1 + - Id: GD_REGENERATION + Level: 1 + + - Id: GD_DEVELOPMENT + MaxLevel: 1 + +# - Id: GD_GUILD_STORAGE +# MaxLevel: 5 diff --git a/db/re/guild_skill_tree.yml b/db/re/guild_skill_tree.yml new file mode 100644 index 0000000000..425d2942b0 --- /dev/null +++ b/db/re/guild_skill_tree.yml @@ -0,0 +1,123 @@ +# This file is a part of rAthena. +# Copyright(C) 2019 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 . +# +########################################################################### +# Renewal Guild Skill Database +########################################################################### +# +# Guild Skill Settings +# +########################################################################### +# Id - Skill ID of the guild skill. +########################################################################### +# MaxLevel - Maximum level of the guild skill. +########################################################################### +# Required - A list of required skills for the skill to become available. +# Id: Skill ID of the required guild skill. +# Level: Level of the required guild skill. +########################################################################### + +Header: + Type: GUILD_SKILL_TREE_DB + Version: 1 + +Body: + - Id: GD_APPROVAL + MaxLevel: 1 + + - Id: GD_KAFRACONTRACT + MaxLevel: 1 + Required: + - Id: GD_APPROVAL + Level: 1 + + - Id: GD_GUARDRESEARCH + MaxLevel: 1 + Required: + - Id: GD_APPROVAL + Level: 1 + + - Id: GD_GUARDUP + MaxLevel: 3 + + - Id: GD_EXTENSION + MaxLevel: 10 + + - Id: GD_GLORYGUILD + MaxLevel: 0 + + - Id: GD_LEADERSHIP + MaxLevel: 5 + + - Id: GD_GLORYWOUNDS + MaxLevel: 5 + + - Id: GD_SOULCOLD + MaxLevel: 5 + Required: + - Id: GD_GLORYWOUNDS + Level: 1 + + - Id: GD_HAWKEYES + MaxLevel: 5 + Required: + - Id: GD_LEADERSHIP + Level: 1 + + - Id: GD_BATTLEORDER + MaxLevel: 1 + Required: + - Id: GD_APPROVAL + Level: 1 + - Id: GD_EXTENSION + Level: 2 + + - Id: GD_REGENERATION + MaxLevel: 3 + Required: + - Id: GD_APPROVAL + Level: 1 + - Id: GD_EXTENSION + Level: 5 + - Id: GD_BATTLEORDER + Level: 1 + + - Id: GD_RESTORE + MaxLevel: 1 + Required: + - Id: GD_REGENERATION + Level: 1 + + - Id: GD_EMERGENCYCALL + MaxLevel: 1 + Required: + - Id: GD_APPROVAL + Level: 1 + - Id: GD_GUARDRESEARCH + Level: 1 + - Id: GD_EXTENSION + Level: 5 + - Id: GD_BATTLEORDER + Level: 1 + - Id: GD_REGENERATION + Level: 1 + + - Id: GD_DEVELOPMENT + MaxLevel: 1 + + - Id: GD_GUILD_STORAGE + MaxLevel: 5 diff --git a/src/map/guild.cpp b/src/map/guild.cpp index fa02410cbe..1a878d4a27 100644 --- a/src/map/guild.cpp +++ b/src/map/guild.cpp @@ -4,8 +4,10 @@ #include "guild.hpp" #include +#include #include "../common/cbasetypes.hpp" +#include "../common/database.hpp" #include "../common/ers.hpp" #include "../common/malloc.hpp" #include "../common/mapindex.hpp" @@ -13,6 +15,7 @@ #include "../common/showmsg.hpp" #include "../common/strlib.hpp" #include "../common/timer.hpp" +#include "../common/utilities.hpp" #include "../common/utils.hpp" #include "battle.hpp" @@ -28,6 +31,8 @@ #include "storage.hpp" #include "trade.hpp" +using namespace rathena; + static DBMap* guild_db; // int guild_id -> struct guild* static DBMap* castle_db; // int castle_id -> struct guild_castle* static DBMap* guild_expcache_db; // uint32 char_id -> struct guild_expcache* @@ -50,15 +55,139 @@ struct guild_expcache { }; static struct eri *expcache_ers; //For handling of guild exp payment. -#define MAX_GUILD_SKILL_REQUIRE 5 -struct s_guild_skill_tree { - int id; - int max; - struct{ - short id; - short lv; - }need[MAX_GUILD_SKILL_REQUIRE]; -} guild_skill_tree[MAX_GUILDSKILL]; +struct s_guild_skill_requirement{ + uint16 id; + uint16 lv; +}; + +struct s_guild_skill_tree{ + uint16 id; + uint16 max; + std::unordered_map> need; +}; + +class GuildSkillTreeDatabase : public TypesafeYamlDatabase{ +public: + GuildSkillTreeDatabase() : TypesafeYamlDatabase( "GUILD_SKILL_TREE_DB", 1 ){ + + } + + const std::string getDefaultLocation(); + uint64 parseBodyNode( const YAML::Node& node ); +}; + +const std::string GuildSkillTreeDatabase::getDefaultLocation(){ + return std::string(db_path) + "/guild_skill_tree.yml"; +} + +uint64 GuildSkillTreeDatabase::parseBodyNode( const YAML::Node &node ){ + std::string name; + + if( !this->asString( node, "Id", name ) ){ + return 0; + } + + uint16 skill_id; + + if( !( skill_id = skill_name2id( name.c_str() ) ) ){ + this->invalidWarning( node["Id"], "Invalid guild skill name \"%s\", skipping.\n", name.c_str() ); + return 0; + } + + if( !SKILL_CHK_GUILD( skill_id ) ){ + this->invalidWarning( node["Id"], "Guild skill \"%s\" with Id %u is out of the guild skill range [%u-%u], skipping.\n", name.c_str(), skill_id, GD_SKILLBASE, GD_MAX ); + return 0; + } + + std::shared_ptr skill = this->find( skill_id ); + bool exists = skill != nullptr; + + if( !exists ){ + if( !this->nodeExists( node, "MaxLevel" ) ){ + this->invalidWarning( node, "Missing node \"MaxLevel\", skipping.\n" ); + return 0; + } + + skill = std::make_shared(); + skill->id = skill_id; + } + + if( this->nodeExists( node, "MaxLevel" ) ){ + uint16 level; + + if( !this->asUInt16( node, "MaxLevel", level ) ){ + return 0; + } + + // Enable Guild's Glory when required for emblems + if( skill_id == GD_GLORYGUILD && battle_config.require_glory_guild && level == 0 ){ + level = 1; + } + + skill->max = level; + } + + if( this->nodeExists( node, "Required" ) ){ + for( const YAML::Node& requiredNode : node["Required"] ){ + std::string requiredName; + + if( !this->asString( requiredNode, "Id", requiredName ) ){ + return 0; + } + + uint16 requiredSkillId; + + if( !( requiredSkillId = skill_name2id( requiredName.c_str() ) ) ){ + this->invalidWarning( requiredNode["Id"], "Invalid required guild skill name \"%s\", skipping.\n", requiredName.c_str() ); + return 0; + } + + if( !SKILL_CHK_GUILD( requiredSkillId ) ){ + this->invalidWarning( requiredNode["Id"], "Required guild skill \"%s\" with Id %u is out of the guild skill range [%u-%u], skipping.\n", requiredName.c_str(), requiredSkillId, GD_SKILLBASE, GD_MAX ); + return 0; + } + + std::shared_ptr requirement = util::umap_find( skill->need, requiredSkillId ); + bool requirement_exists = requirement != nullptr; + + if( !requirement_exists ){ + if( !this->nodeExists( requiredNode, "Level" ) ){ + this->invalidWarning( requiredNode, "Missing node \"Level\", skipping.\n" ); + return 0; + } + + requirement = std::make_shared(); + requirement->id = requiredSkillId; + } + + if( this->nodeExists( requiredNode, "Level" ) ){ + uint16 requiredLevel; + + if( !this->asUInt16( requiredNode, "Level", requiredLevel ) ){ + return 0; + } + + if( requiredLevel == 0 ){ + continue; + } + + requirement->lv = requiredLevel; + } + + if( !requirement_exists ){ + skill->need[requiredSkillId] = requirement; + } + } + } + + if( !exists ){ + this->put( skill_id, skill ); + } + + return 1; +} + +GuildSkillTreeDatabase guild_skill_tree_db; TIMER_FUNC(guild_payexp_timer); static TIMER_FUNC(guild_send_xy_timer); @@ -68,7 +197,7 @@ struct npc_data **guild_flags; unsigned short guild_flags_count; /** - * Get guild skill index in guild_skill_tree + * Get guild skill index in guild structure of mmo.hpp * @param skill_id * @return Index in skill_tree or -1 **/ @@ -100,10 +229,14 @@ static TBL_PC* guild_sd_check(int guild_id, uint32 account_id, uint32 char_id) { } // Modified [Komurka] -int guild_skill_get_max (int id) { - if ((id = guild_skill_get_index(id)) < 0) +uint16 guild_skill_get_max( uint16 id ){ + std::shared_ptr skill = guild_skill_tree_db.find( id ); + + if( skill == nullptr ){ return 0; - return guild_skill_tree[id].max; + } + + return skill->max; } // Retrieve skill_lv learned by guild @@ -114,54 +247,28 @@ int guild_checkskill(struct guild *g, int id) { } /*========================================== - * guild_skill_tree.txt reading - from jA [Komurka] + * Guild skill check - from jA [Komurka] *------------------------------------------*/ -static bool guild_read_guildskill_tree_db(char* split[], int columns, int current) {// ,,,,,,,,,,, - int k, skill_id = atoi(split[0]); - short idx = -1; - - if ((idx = guild_skill_get_index(skill_id)) < 0) { - ShowError("guild_read_guildskill_tree_db: Invalid Guild skill '%s'.\n", split[1]); +bool guild_check_skill_require( struct guild *g, uint16 id ){ + if( g == nullptr ){ return false; } - guild_skill_tree[idx].id = skill_id; - guild_skill_tree[idx].max = atoi(split[1]); + std::shared_ptr skill = guild_skill_tree_db.find( id ); - if( guild_skill_tree[idx].id == GD_GLORYGUILD && battle_config.require_glory_guild && guild_skill_tree[idx].max == 0 ) {// enable guild's glory when required for emblems - guild_skill_tree[idx].max = 1; + if( skill == nullptr ){ + return false; } - for( k = 0; k < MAX_GUILD_SKILL_REQUIRE; k++ ) { - guild_skill_tree[idx].need[k].id = atoi(split[k*2+2]); - guild_skill_tree[idx].need[k].lv = atoi(split[k*2+3]); + for( const auto& pair : skill->need ){ + if( pair.second->lv > guild_checkskill( g, pair.second->id ) ){ + return false; + } } return true; } -/*========================================== - * Guild skill check - from jA [Komurka] - *------------------------------------------*/ -int guild_check_skill_require(struct guild *g,int id) { - uint8 i; - short idx = -1; - - if(g == NULL) - return 0; - - if ((idx = guild_skill_get_index(id)) < 0) - return 0; - - for(i=0;i guild_checkskill(g,guild_skill_tree[idx].need[i].id)) - return 0; - } - return 1; -} - static bool guild_read_castledb(char* str[], int columns, int current) {// ,,,[,] struct guild_castle *gc; int mapindex = mapindex_name2id(str[1]); @@ -2314,20 +2421,19 @@ void do_init_guild(void) { expcache_ers = ers_new(sizeof(struct guild_expcache),"guild.cpp::expcache_ers",ERS_OPT_NONE); guild_flags_count = 0; - - memset(guild_skill_tree,0,sizeof(guild_skill_tree)); for(i=0; i 0); - sv_readdb(dbsubpath1, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, &guild_read_guildskill_tree_db, i > 0); //guild skill tree [Komurka] - + aFree(dbsubpath1); } - + + guild_skill_tree_db.load(); + add_timer_func_list(guild_payexp_timer,"guild_payexp_timer"); add_timer_func_list(guild_send_xy_timer, "guild_send_xy_timer"); add_timer_interval(gettick()+GUILD_PAYEXP_INTERVAL,guild_payexp_timer,0,0,GUILD_PAYEXP_INTERVAL); diff --git a/src/map/guild.hpp b/src/map/guild.hpp index 164bf49a11..456c91afe9 100644 --- a/src/map/guild.hpp +++ b/src/map/guild.hpp @@ -26,10 +26,10 @@ struct guardian_data { struct guild_castle* castle; }; -int guild_skill_get_max(int id); +uint16 guild_skill_get_max(uint16 id); int guild_checkskill(struct guild *g,int id); -int guild_check_skill_require(struct guild *g,int id); // [Komurka] +bool guild_check_skill_require(struct guild *g,uint16 id); // [Komurka] int guild_checkcastles(struct guild *g); // [MouseJstr] bool guild_isallied(int guild_id, int guild_id2); //Checks alliance based on guild Ids. [Skotlex] diff --git a/src/map/map-server.vcxproj b/src/map/map-server.vcxproj index 7348425d09..6cd326dcce 100644 --- a/src/map/map-server.vcxproj +++ b/src/map/map-server.vcxproj @@ -301,7 +301,7 @@ - + diff --git a/src/tool/csv2yaml.cpp b/src/tool/csv2yaml.cpp index fe0037d4b2..7715cb92c8 100644 --- a/src/tool/csv2yaml.cpp +++ b/src/tool/csv2yaml.cpp @@ -36,12 +36,19 @@ int getch( void ){ } #endif +// Required constant and structure definitions +#define MAX_GUILD_SKILL_REQUIRE 5 + +// Forward declaration of conversion functions +static bool guild_read_guildskill_tree_db( char* split[], int columns, int current ); + bool fileExists( const std::string& path ); bool writeToFile( const YAML::Node& node, const std::string& path ); void prepareHeader( YAML::Node& node, const std::string& type, uint32 version ); bool askConfirmation( const char* fmt, ... ); YAML::Node body; +size_t counter; template bool process( const std::string& type, uint32 version, const std::vector& paths, const std::string& name, Func lambda ){ @@ -59,7 +66,7 @@ bool process( const std::string& type, uint32 version, const std::vector guild_skill_tree_paths = { + path_db, + path_db_import + }; + + if( process( "GUILD_SKILL_TREE_DB", 1, guild_skill_tree_paths, "guild_skill_tree", []( const std::string& path, const std::string& name_ext ) -> bool { + return sv_readdb( path.c_str(), name_ext.c_str(), ',', 2 + MAX_GUILD_SKILL_REQUIRE * 2, 2 + MAX_GUILD_SKILL_REQUIRE * 2, -1, &guild_read_guildskill_tree_db, false ); + } ) ){ + return 0; + } + // TODO: add implementations ;-) return 0; @@ -163,3 +181,34 @@ bool askConfirmation( const char* fmt, ... ){ return false; } } + +// Implementation of the conversion functions + +// Copied and adjusted from guild.cpp +// ,,,,,,,,,,, +static bool guild_read_guildskill_tree_db( char* split[], int columns, int current ){ + YAML::Node node; + + node["Id"] = (uint16)atoi(split[0]); + node["MaxLevel"] = (uint16)atoi(split[1]); + + for( int i = 0, j = 0; i < MAX_GUILD_SKILL_REQUIRE; i++ ){ + uint16 skill_id = atoi( split[i * 2 + 2] ); + uint16 skill_level = atoi( split[i * 2 + 3] ); + + if( skill_id == 0 || skill_level == 0 ){ + continue; + } + + YAML::Node req; + + req["Id"] = skill_id; + req["Level"] = skill_level; + + node["Required"][j++] = req; + } + + body[counter++] = node; + + return true; +}