diff options
author | Haruna <haru@dotalux.com> | 2014-10-31 01:18:40 +0100 |
---|---|---|
committer | Haruna <haru@dotalux.com> | 2014-10-31 01:18:40 +0100 |
commit | 1d0452110f4b02f6d771c61d5c3a944f82b155f3 (patch) | |
tree | b36963aeb2f4924e49b5f4e80c270bf4275fb4c4 /src/login | |
parent | 72e18cdf9b612c476dd9ab2d45394c5e882e7dd1 (diff) | |
parent | 60becfc70e65ba7920079f990bfaa11851369f0c (diff) | |
download | hercules-1d0452110f4b02f6d771c61d5c3a944f82b155f3.tar.gz hercules-1d0452110f4b02f6d771c61d5c3a944f82b155f3.tar.bz2 hercules-1d0452110f4b02f6d771c61d5c3a944f82b155f3.tar.xz hercules-1d0452110f4b02f6d771c61d5c3a944f82b155f3.zip |
Merge pull request #378 from HerculesWS/hpmupdates
Char and login server preliminary support for the HPM system
Diffstat (limited to 'src/login')
-rw-r--r-- | src/login/HPMlogin.c | 53 | ||||
-rw-r--r-- | src/login/HPMlogin.h | 20 | ||||
-rw-r--r-- | src/login/Makefile.in | 4 | ||||
-rw-r--r-- | src/login/account_sql.c | 10 | ||||
-rw-r--r-- | src/login/login.c | 50 |
5 files changed, 119 insertions, 18 deletions
diff --git a/src/login/HPMlogin.c b/src/login/HPMlogin.c new file mode 100644 index 000000000..6b223d249 --- /dev/null +++ b/src/login/HPMlogin.c @@ -0,0 +1,53 @@ +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file + +#define HERCULES_CORE + +#include "HPMlogin.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "../common/HPM.h" +#include "../common/cbasetypes.h" +#include "../common/conf.h" +#include "../common/db.h" +#include "../common/des.h" +#include "../common/ers.h" +#include "../common/malloc.h" +#include "../common/mapindex.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" +#include "../common/socket.h" +#include "../common/strlib.h" +#include "../common/sysinfo.h" + +#include "../common/HPMDataCheck.h" + +bool HPM_login_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr) { + /* record address */ + switch( type ) { + default: + return false; + } + return true; +} + +void HPM_login_plugin_load_sub(struct hplugin *plugin) { +} + +void HPM_login_do_init(void) { +#if 0 // TODO (HPMDataCheck is disabled for the time being) + HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer); +#else + HPM->DataCheck = NULL; +#endif +} + +void HPM_login_do_final(void) { +#if 0 // TODO (HPMDataCheck is disabled for the time being) + HPM->datacheck_final(); +#endif +} diff --git a/src/login/HPMlogin.h b/src/login/HPMlogin.h new file mode 100644 index 000000000..6bdc0fb7b --- /dev/null +++ b/src/login/HPMlogin.h @@ -0,0 +1,20 @@ +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file + +#ifndef LOGIN_HPMLOGIN_H +#define LOGIN_HPMLOGIN_H + +#include "../common/cbasetypes.h" +#include "../common/HPM.h" + +struct hplugin; + +bool HPM_login_grabHPData(struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr); + +void HPM_login_plugin_load_sub(struct hplugin *plugin); + +void HPM_login_do_final(void); + +void HPM_login_do_init(void); + +#endif /* LOGIN_HPMLOGIN_H */ diff --git a/src/login/Makefile.in b/src/login/Makefile.in index a4aec59cf..9b1db69c2 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -22,9 +22,9 @@ MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o MT19937AR_H = $(MT19937AR_D)/mt19937ar.h MT19937AR_INCLUDE = -I$(MT19937AR_D) -LOGIN_C = account_sql.c ipban_sql.c login.c loginlog_sql.c +LOGIN_C = account_sql.c HPMlogin.c ipban_sql.c login.c loginlog_sql.c LOGIN_OBJ = $(addprefix obj_sql/, $(patsubst %.c,%.o,$(LOGIN_C))) -LOGIN_H = login.h account.h ipban.h loginlog.h +LOGIN_H = login.h account.h HPMlogin.h ipban.h loginlog.h HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 10852e5b1..5f9357c81 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -169,6 +169,10 @@ static bool account_db_sql_init(AccountDB* self) if( codepage[0] != '\0' && SQL_ERROR == SQL->SetEncoding(sql_handle, codepage) ) Sql_ShowDebug(sql_handle); + Sql_HerculesUpdateCheck(db->accounts); +#ifdef CONSOLE_INPUT + console->input->setSQL(db->accounts); +#endif return true; } @@ -655,11 +659,7 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo Sql* account_db_sql_up(AccountDB* self) { AccountDB_SQL* db = (AccountDB_SQL*)self; - Sql_HerculesUpdateCheck(db->accounts); -#ifdef CONSOLE_INPUT - console->input->setSQL(db->accounts); -#endif - return db->accounts; + return db ? db->accounts : NULL; } void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) { Sql* sql_handle = ((AccountDB_SQL*)self)->accounts; diff --git a/src/login/login.c b/src/login/login.c index 129049627..9aa2e778b 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -10,6 +10,7 @@ #include <stdlib.h> #include <string.h> +#include "HPMlogin.h" #include "account.h" #include "ipban.h" #include "loginlog.h" @@ -1737,6 +1738,10 @@ int do_final(void) { login_fd = -1; } + HPM_login_do_final(); + + HPM->event(HPET_POST_FINAL); + ShowStatus("Finished.\n"); return EXIT_SUCCESS; } @@ -1770,6 +1775,9 @@ void do_shutdown(void) } } +void login_hp_symbols(void) { + HPM->share(account_db_sql_up(accounts),"sql_handle"); +} //------------------------------ // Login server initialization @@ -1780,9 +1788,38 @@ int do_init(int argc, char** argv) // initialize engine (to accept config settings) account_engine[0].db = account_engine[0].constructor(); + accounts = account_engine[0].db; + if( accounts == NULL ) { + ShowFatalError("do_init: account engine 'sql' not found.\n"); + exit(EXIT_FAILURE); + } // read login-server configuration login_set_defaults(); + + HPM_login_do_init(); + HPM->symbol_defaults_sub = login_hp_symbols; + HPM->config_read(NULL, 0); +#if 0 + /* TODO: Move to common code */ + for( i = 1; i < argc; i++ ) { + const char* arg = argv[i]; + if( strcmp(arg, "--load-plugin") == 0 ) { + if( map->arg_next_value(arg, i, argc, true) ) { + RECREATE(load_extras, char *, ++load_extras_count); + load_extras[load_extras_count-1] = argv[++i]; + } + } + } + HPM->config_read((const char * const *)load_extras, load_extras_count); + if (load_extras) { + aFree(load_extras); + load_extras = NULL; + load_extras_count = 0; + } +#endif + HPM->event(HPET_PRE_INIT); + login_config_read((argc > 1) ? argv[1] : LOGIN_CONF_NAME); login_lan_config_read((argc > 2) ? argv[2] : LAN_CONF_NAME); @@ -1817,20 +1854,11 @@ int do_init(int argc, char** argv) } // Account database init - accounts = account_engine[0].db; - if( accounts == NULL ) { - ShowFatalError("do_init: account engine 'sql' not found.\n"); + if(!accounts->init(accounts)) { + ShowFatalError("do_init: Failed to initialize account engine 'sql'.\n"); exit(EXIT_FAILURE); - } else { - - if(!accounts->init(accounts)) { - ShowFatalError("do_init: Failed to initialize account engine 'sql'.\n"); - exit(EXIT_FAILURE); - } } - HPM->share(account_db_sql_up(accounts),"sql_handle"); - HPM->config_read(NULL, 0); HPM->event(HPET_INIT); // server port open & binding |