|
@@ -5,6 +5,7 @@
|
|
#include <fstream>
|
|
#include <fstream>
|
|
#include <functional>
|
|
#include <functional>
|
|
#include <vector>
|
|
#include <vector>
|
|
|
|
+#include <unordered_map>
|
|
|
|
|
|
#ifdef WIN32
|
|
#ifdef WIN32
|
|
#include <conio.h>
|
|
#include <conio.h>
|
|
@@ -21,6 +22,9 @@
|
|
#include "../common/mmo.hpp"
|
|
#include "../common/mmo.hpp"
|
|
#include "../common/showmsg.hpp"
|
|
#include "../common/showmsg.hpp"
|
|
#include "../common/strlib.hpp"
|
|
#include "../common/strlib.hpp"
|
|
|
|
+#include "../common/utilities.hpp"
|
|
|
|
+
|
|
|
|
+using namespace rathena;
|
|
|
|
|
|
#ifndef WIN32
|
|
#ifndef WIN32
|
|
int getch( void ){
|
|
int getch( void ){
|
|
@@ -42,6 +46,12 @@ int getch( void ){
|
|
// Forward declaration of conversion functions
|
|
// Forward declaration of conversion functions
|
|
static bool guild_read_guildskill_tree_db( char* split[], int columns, int current );
|
|
static bool guild_read_guildskill_tree_db( char* split[], int columns, int current );
|
|
|
|
|
|
|
|
+// Constants for conversion
|
|
|
|
+std::unordered_map<uint16, std::string> aegis_skillnames;
|
|
|
|
+
|
|
|
|
+// Forward declaration of constant loading functions
|
|
|
|
+static bool parse_skill_constants( char* split[], int columns, int current );
|
|
|
|
+
|
|
bool fileExists( const std::string& path );
|
|
bool fileExists( const std::string& path );
|
|
bool writeToFile( const YAML::Node& node, 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 );
|
|
void prepareHeader( YAML::Node& node, const std::string& type, uint32 version );
|
|
@@ -98,6 +108,10 @@ int do_init( int argc, char** argv ){
|
|
const std::string path_db_mode = path_db + "/" + DBPATH;
|
|
const std::string path_db_mode = path_db + "/" + DBPATH;
|
|
const std::string path_db_import = path_db + "/" + DBIMPORT;
|
|
const std::string path_db_import = path_db + "/" + DBIMPORT;
|
|
|
|
|
|
|
|
+ // Loads required conversion constants
|
|
|
|
+ sv_readdb( path_db_mode.c_str(), "skill_db.txt", ',', 18, 18, -1, parse_skill_constants, false );
|
|
|
|
+ sv_readdb( path_db_import.c_str(), "skill_db.txt", ',', 18, 18, -1, parse_skill_constants, false );
|
|
|
|
+
|
|
std::vector<std::string> guild_skill_tree_paths = {
|
|
std::vector<std::string> guild_skill_tree_paths = {
|
|
path_db,
|
|
path_db,
|
|
path_db_import
|
|
path_db_import
|
|
@@ -182,6 +196,16 @@ bool askConfirmation( const char* fmt, ... ){
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Constant loading functions
|
|
|
|
+static bool parse_skill_constants( char* split[], int columns, int current ){
|
|
|
|
+ uint16 skill_id = atoi( split[0] );
|
|
|
|
+ char* name = trim( split[16] );
|
|
|
|
+
|
|
|
|
+ aegis_skillnames[skill_id] = std::string( name );
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
// Implementation of the conversion functions
|
|
// Implementation of the conversion functions
|
|
|
|
|
|
// Copied and adjusted from guild.cpp
|
|
// Copied and adjusted from guild.cpp
|
|
@@ -189,21 +213,37 @@ bool askConfirmation( const char* fmt, ... ){
|
|
static bool guild_read_guildskill_tree_db( char* split[], int columns, int current ){
|
|
static bool guild_read_guildskill_tree_db( char* split[], int columns, int current ){
|
|
YAML::Node node;
|
|
YAML::Node node;
|
|
|
|
|
|
- node["Id"] = (uint16)atoi(split[0]);
|
|
|
|
|
|
+ uint16 skill_id = (uint16)atoi(split[0]);
|
|
|
|
+
|
|
|
|
+ std::string* name = util::umap_find( aegis_skillnames, skill_id );
|
|
|
|
+
|
|
|
|
+ if( name == nullptr ){
|
|
|
|
+ ShowError( "Skill name for skill id %hu is not known.\n", skill_id );
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ node["Id"] = *name;
|
|
node["MaxLevel"] = (uint16)atoi(split[1]);
|
|
node["MaxLevel"] = (uint16)atoi(split[1]);
|
|
|
|
|
|
for( int i = 0, j = 0; i < MAX_GUILD_SKILL_REQUIRE; i++ ){
|
|
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] );
|
|
|
|
|
|
+ uint16 required_skill_id = atoi( split[i * 2 + 2] );
|
|
|
|
+ uint16 required_skill_level = atoi( split[i * 2 + 3] );
|
|
|
|
|
|
- if( skill_id == 0 || skill_level == 0 ){
|
|
|
|
|
|
+ if( required_skill_id == 0 || required_skill_level == 0 ){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ std::string* required_name = util::umap_find( aegis_skillnames, required_skill_id );
|
|
|
|
+
|
|
|
|
+ if( required_name == nullptr ){
|
|
|
|
+ ShowError( "Skill name for required skill id %hu is not known.\n", required_skill_id );
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
YAML::Node req;
|
|
YAML::Node req;
|
|
|
|
|
|
- req["Id"] = skill_id;
|
|
|
|
- req["Level"] = skill_level;
|
|
|
|
|
|
+ req["Id"] = *required_name;
|
|
|
|
+ req["Level"] = required_skill_level;
|
|
|
|
|
|
node["Required"][j++] = req;
|
|
node["Required"][j++] = req;
|
|
}
|
|
}
|