Skip to content
Permalink
Browse files
DB Import
Add folder import/ into db/ to load all customs
This folder is meant to hold all the customs file you wish override rA
one.
(In short it work like conf import)
related to tid:90199
  • Loading branch information
lighta committed Dec 31, 2013
1 parent 3f4c389 commit 28ecab5712302aad0a28109b39ce7799fc7991f9
File renamed without changes.
Empty file.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -72,11 +72,7 @@ char bonus_script_db[256] = "bonus_script";

// show loading/saving messages
int save_log = 1;

static DBMap* char_db_; /// int char_id -> struct mmo_charstatus*

char db_path[1024] = "db";

int db_use_sqldbs;

struct mmo_map_server {
@@ -5614,7 +5610,7 @@ int char_config_read(const char* cfgName)
} else if (strcmpi(w1, "char_del_option") == 0) {
char_del_option = atoi(w2);
} else if(strcmpi(w1,"db_path")==0) {
safestrncpy(db_path, w2, sizeof(db_path));
safestrncpy(db_path, w2, ARRAYLENGTH(db_path));
} else if (strcmpi(w1, "console") == 0) {
console = config_switch(w2);
} else if (strcmpi(w1, "fame_list_alchemist") == 0) {
@@ -725,7 +725,7 @@ int inter_guild_sql_init(void)
castle_db = idb_alloc(DB_OPT_RELEASE_DATA);

//Read exp file
sv_readdb("db", DBPATH"exp_guild.txt", ',', 1, 1, 100, exp_guild_parse_row);
sv_readdb("db", DBPATH"exp_guild.txt", ',', 1, 1, 100, exp_guild_parse_row, 0);

add_timer_func_list(guild_save_timer, "guild_save_timer");
add_timer(gettick() + 10000, guild_save_timer, 0, 0);
@@ -25,7 +25,7 @@
#include <unistd.h>
#else
#include "../common/winapi.h" // Console close event handling
#include <direct.h>
#include <direct.h> // _chdir
#endif


@@ -39,6 +39,7 @@ void (*shutdown_callback)(void) = NULL;
int runflag = CORE_ST_RUN;
int arg_c = 0;
char **arg_v = NULL;
char db_path[12] = "db"; /// relative path for db from server

char *SERVER_NAME = NULL;
char SERVER_TYPE = ATHENA_SERVER_NONE;
@@ -21,6 +21,7 @@ extern char **arg_v;
/// @see E_CORE_ST
extern int runflag;
extern char *SERVER_NAME;
extern char db_path[12]; /// relative path for db from servers

enum {
ATHENA_SERVER_NONE = 0, // not defined
@@ -968,18 +968,21 @@ const char* skip_escaped_c(const char* p)
}


/// Opens and parses a file containing delim-separated columns, feeding them to the specified callback function row by row.
/// Tracks the progress of the operation (current line number, number of successfully processed rows).
/// Returns 'true' if it was able to process the specified file, or 'false' if it could not be read.
///
/// @param directory Directory
/// @param filename File to process
/// @param delim Field delimiter
/// @param mincols Minimum number of columns of a valid row
/// @param maxcols Maximum number of columns of a valid row
/// @param parseproc User-supplied row processing function
/// @return true on success, false if file could not be opened
bool sv_readdb(const char* directory, const char* filename, char delim, int mincols, int maxcols, int maxrows, bool (*parseproc)(char* fields[], int columns, int current))
/**
* Opens and parses a file containing delim-separated columns, feeding them to the specified callback function row by row.
* Tracks the progress of the operation (current line number, number of successfully processed rows).
* Returns 'true' if it was able to process the specified file, or 'false' if it could not be read.
* @param directory : Directory
* @param filename : filename File to process
* @param delim : delim Field delimiter
* @param mincols : mincols Minimum number of columns of a valid row
* @param maxcols : maxcols Maximum number of columns of a valid row
* @param maxrows : maxcols Maximum number of columns of a valid row
* @param parseproc : parseproc User-supplied row processing function
* @param silent : should we display error if file not found ?
* @return true on success, false if file could not be opened
*/
bool sv_readdb(const char* directory, const char* filename, char delim, int mincols, int maxcols, int maxrows, bool (*parseproc)(char* fields[], int columns, int current), bool silent)
{
FILE* fp;
int lines = 0;
@@ -995,7 +998,7 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc
fp = fopen(path, "r");
if( fp == NULL )
{
ShowError("sv_readdb: can't read %s\n", path);
if(silent == 0) ShowError("sv_readdb: can't read %s\n", path);
return false;
}

@@ -128,7 +128,7 @@ const char* skip_escaped_c(const char* p);
/// Opens and parses a file containing delim-separated columns, feeding them to the specified callback function row by row.
/// Tracks the progress of the operation (current line number, number of successfully processed rows).
/// Returns 'true' if it was able to process the specified file, or 'false' if it could not be read.
bool sv_readdb(const char* directory, const char* filename, char delim, int mincols, int maxcols, int maxrows, bool (*parseproc)(char* fields[], int columns, int current));
bool sv_readdb(const char* directory, const char* filename, char delim, int mincols, int maxcols, int maxrows, bool (*parseproc)(char* fields[], int columns, int current), bool silent);


/// StringBuf - dynamic string
@@ -1778,6 +1778,8 @@ int login_config_read(const char* cfgName)

if(!strcmpi(w1,"timestamp_format"))
safestrncpy(timestamp_format, w2, 20);
else if(strcmpi(w1,"db_path")==0)
safestrncpy(db_path, w2, ARRAYLENGTH(db_path));
else if(!strcmpi(w1,"stdout_with_ansisequence"))
stdout_with_ansisequence = config_switch(w2);
else if(!strcmpi(w1,"console_silent")) {
@@ -1794,10 +1796,8 @@ int login_config_read(const char* cfgName)
}
else if( !strcmpi(w1, "login_port") ) {
login_config.login_port = (uint16)atoi(w2);
}
else if(!strcmpi(w1, "log_login"))
} else if(!strcmpi(w1, "log_login"))
login_config.log_login = (bool)config_switch(w2);

else if(!strcmpi(w1, "new_account"))
login_config.new_account_flag = (bool)config_switch(w2);
else if(!strcmpi(w1, "new_acc_length_limit"))
@@ -1835,26 +1835,20 @@ int login_config_read(const char* cfgName)
else if(!strcmpi(w1, "client_hash")) {
int group = 0;
char md5[33];

if (sscanf(w2, "%d, %32s", &group, md5) == 2) {
struct client_hash_node *nnode;
int i;
CREATE(nnode, struct client_hash_node, 1);

for (i = 0; i < 32; i += 2) {
char buf[3];
unsigned int byte;

memcpy(buf, &md5[i], 2);
buf[2] = 0;

sscanf(buf, "%x", &byte);
nnode->hash[i / 2] = (uint8)(byte & 0xFF);
}

nnode->group_id = group;
nnode->next = login_config.client_hash_nodes;

login_config.client_hash_nodes = nnode;
}
} else if(strcmpi(w1, "chars_per_account") == 0) { //maxchars per account [Sirius]
@@ -69,7 +69,7 @@ static int cashshop_parse_dbrow( char** str, const char* source, int line ){
* parses lines and sends them to parse_dbrow.
*/
static void cashshop_read_db_txt( void ){
const char* filename[] = { DBPATH"item_cash_db.txt", "item_cash_db2.txt" };
const char* filename[] = { DBPATH"item_cash_db.txt", "import/item_cash_db.txt" };
int fi;

for( fi = 0; fi < ARRAYLENGTH( filename ); ++fi ){

0 comments on commit 28ecab5

Please sign in to comment.