From 4af314500ee1716fab12a25983720e2a2bd52b35 Mon Sep 17 00:00:00 2001 From: lighta Date: Thu, 9 Jan 2014 00:08:00 -0500 Subject: [PATCH] Check_db Add a check_db on char-serv startup to ensure all sql-tables was loaded correctly and avoid error on runtime. Fix OnInterIfInitOnce being executed on reloadscript, (now only done at server startup) --- conf/char_athena.conf | 3 + npc/re/scripts_main.conf | 3 + npc/scripts_test.conf | 1 + npc/test/OnInterInit.txt | 8 ++ src/char/char.c | 241 ++++++++++++++++++++++++++++++++++++++- src/char/char.h | 1 + src/common/showmsg.c | 10 -- src/login/login.c | 3 +- src/login/login.h | 1 + src/map/chrif.c | 9 +- src/map/elemental.c | 2 - src/map/map.c | 1 + src/map/map.h | 1 + src/map/npc.c | 1 - 14 files changed, 268 insertions(+), 17 deletions(-) create mode 100644 npc/scripts_test.conf create mode 100644 npc/test/OnInterInit.txt diff --git a/conf/char_athena.conf b/conf/char_athena.conf index 7c975c0b26..2770bf291e 100644 --- a/conf/char_athena.conf +++ b/conf/char_athena.conf @@ -201,4 +201,7 @@ char_movetoused: yes // Allow users to move characters as often as they like? char_moves_unlimited: no +// Should we check if sql-tables are correct on server startup ? +char_checkdb: yes + import: conf/import/char_conf.txt diff --git a/npc/re/scripts_main.conf b/npc/re/scripts_main.conf index ddbfd97941..8ee4d70147 100644 --- a/npc/re/scripts_main.conf +++ b/npc/re/scripts_main.conf @@ -41,6 +41,9 @@ import: npc/re/scripts_mapflags.conf import: npc/re/scripts_monsters.conf import: npc/re/scripts_warps.conf +// Test for regressions and such +//import: npc/scripts_test.conf + // ------------------- Custom Script Files ---------------------- // - Your NPCs go in this file! import: npc/scripts_custom.conf diff --git a/npc/scripts_test.conf b/npc/scripts_test.conf new file mode 100644 index 0000000000..74fe172368 --- /dev/null +++ b/npc/scripts_test.conf @@ -0,0 +1 @@ +npc: npc/test/OnInterInit.txt diff --git a/npc/test/OnInterInit.txt b/npc/test/OnInterInit.txt new file mode 100644 index 0000000000..775f3e6eb8 --- /dev/null +++ b/npc/test/OnInterInit.txt @@ -0,0 +1,8 @@ +- script OnInterChk -1,{ + OnInterIfInit: + debugmes "Loaded OnInterIfInit <-------"; + end; + OnInterIfInitOnce: + debugmes "Loaded OnInterIfInitOnce <-------"; + end; +} diff --git a/src/char/char.c b/src/char/char.c index 79eced8608..74d746a5d1 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -112,6 +112,7 @@ int char_del_option = 2; // Character deletion type, email = 1, birthdate = 2 (d int log_char = 1; // loggin char or not [devil] int log_inter = 1; // loggin inter or not [devil] +int char_check_db = 1; ///cheking sql-table at begining ? // Advanced subnet check [LuzZza] struct s_subnet { @@ -4842,7 +4843,7 @@ int parse_console(const char* buf) if( n == 2 && strcmpi("server", type) == 0 ){ if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 ){ - runflag = 0; + runflag = CHARSERVER_ST_SHUTDOWN; } else if( strcmpi("alive", command) == 0 || strcmpi("status", command) == 0 ) ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n"); @@ -5384,6 +5385,235 @@ int char_lan_config_read(const char *lancfgName) return 0; } +/** + * Check if our table are all ok in sqlserver + * Char tables to check + * @return 0:fail, 1:success + */ +bool char_checkdb(void){ + int i; + const char* sqltable[] = { + char_db, hotkey_db, scdata_db, cart_db, inventory_db, charlog_db, storage_db, reg_db, skill_db, interlog_db, memo_db, + guild_db, guild_alliance_db, guild_castle_db, guild_expulsion_db, guild_member_db, guild_skill_db, guild_position_db, guild_storage_db, + party_db, pet_db, friend_db, mail_db, auction_db, quest_db, homunculus_db, skill_homunculus_db, mercenary_db, mercenary_owner_db, + elemental_db, ragsrvinfo_db, skillcooldown_db, bonus_script_db + }; + ShowInfo("Start checking DB integrity\n"); + for (i=0; ibattle_status.mdef + sd->battle_status.int_ / (5-i); //Caster's FLEE + (Caster's Base Level / (5 - Elemental Summon Skill Level) ele.flee = sd->status.base_level / (5-i); - //Caster's HIT + (Caster's Base Level) - ele.hit = sd->battle_status.hit + sd->status.base_level; //per individual bonuses switch(db->class_){ diff --git a/src/map/map.c b/src/map/map.c index 75c7f3d11c..1fad24aada 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3983,6 +3983,7 @@ void do_shutdown(void) int do_init(int argc, char *argv[]) { + runflag = MAPSERVER_ST_STARTING; #ifdef GCOLLECT GC_enable_incremental(); #endif diff --git a/src/map/map.h b/src/map/map.h index a1f28407be..bfaeb78ea7 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -21,6 +21,7 @@ struct Channel; enum E_MAPSERVER_ST { MAPSERVER_ST_RUNNING = CORE_ST_LAST, + MAPSERVER_ST_STARTING, MAPSERVER_ST_SHUTDOWN, MAPSERVER_ST_LAST }; diff --git a/src/map/npc.c b/src/map/npc.c index aa99716242..ab74460841 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -4038,7 +4038,6 @@ int npc_reload(void) { // Execute rest of the startup events if connected to char-server. [Lance] if(!CheckForCharServer()){ ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInit")); - ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInitOnce")); } return 0; }