summaryrefslogtreecommitdiff
path: root/src/char_sql
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-04-05 00:23:18 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-04-05 00:23:18 +0000
commit075bc5af11d62a9c4265942501836422194cbb6e (patch)
tree72af610618969a17795a5474861ebeb2fed12797 /src/char_sql
parent9ff9d769fa51c9ca4c85482d51eacb27522e9fe1 (diff)
downloadhercules-075bc5af11d62a9c4265942501836422194cbb6e.tar.gz
hercules-075bc5af11d62a9c4265942501836422194cbb6e.tar.bz2
hercules-075bc5af11d62a9c4265942501836422194cbb6e.tar.xz
hercules-075bc5af11d62a9c4265942501836422194cbb6e.zip
- Added inter config connection_ping_interval which specifies interval in hours at which mysql_ping's must be done on all connection handles to keep the mysql connection alive. Defaults to 0 (disabled)
- Removed login sql handle from the map server as it isn't used for anything. - Made the login sql handle on the char-sql server be used only when gm_read_method 1 is enabled. - Small fixes to npc_enable, added BL_NPC handling on status_get_sc. - Added a path_search check in map_random_dir, so that the random direction picked up doesn't goes through walls and all that. - Some changes to close-confine, status start will fail when the source is not found or it doesn't has sc-data. - pc_setoption no longer changes the character's class when mounting/dismounting, it only changes the view-class. - The peco-crash-fix from the char servers is still needed. This packet must be wrong! We likely need to sniff it. - Modified the char-txt server to modify the class of mounted characters to their non-mounted version. Added an upgrade_svn file to handle the class update on the sql tables. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5902 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql')
-rw-r--r--src/char_sql/char.c15
-rw-r--r--src/char_sql/char.h3
-rw-r--r--src/char_sql/inter.c45
3 files changed, 41 insertions, 22 deletions
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index dbd7e2dc9..4a17a3679 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -64,6 +64,7 @@ char pet_db[256] = "pet";
char gm_db[256] = "gm_accounts";
char friend_db[256] = "friends";
int db_use_sqldbs;
+int connection_ping_interval = 0;
char login_db_account_id[32] = "account_id";
char login_db_level[32] = "level";
@@ -1735,14 +1736,7 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) {
WFIFOW(fd,j+50) = DEFAULT_WALK_SPEED; // p->speed;
WFIFOW(fd,j+52) = p->class_;
WFIFOW(fd,j+54) = p->hair;
-
- // pecopeco knights/crusaders crash fix
- if (p->class_ == 13 || p->class_ == 21 ||
- p->class_ == 4014 || p->class_ == 4022 ||
- p->class_ == 4036 || p->class_ == 4044)
- WFIFOW(fd,j+56) = 0;
- else WFIFOW(fd,j+56) = p->weapon;
-
+ WFIFOW(fd,j+56) = p->option&0x20?0:p->weapon; //When the weapon is sent and your option is riding, the client crashes on login!?
WFIFOW(fd,j+58) = p->base_level;
WFIFOW(fd,j+60) = (p->skill_point > SHRT_MAX) ? SHRT_MAX : p->skill_point;
WFIFOW(fd,j+62) = p->head_bottom;
@@ -3813,7 +3807,8 @@ void do_final(void) {
online_char_db->destroy(online_char_db, NULL);
mysql_close(&mysql_handle);
- mysql_close(&lmysql_handle);
+ if(char_gm_read)
+ mysql_close(&lmysql_handle);
ShowInfo("ok! all done...\n");
}
@@ -3891,6 +3886,8 @@ void sql_config_read(const char *cfgName){ /* Kalaspuff, to get login_db */
}else if(strcmpi(w1,"use_sql_db")==0){ // added for sql item_db read for char server [Valaris]
db_use_sqldbs = config_switch(w2);
ShowStatus("Using SQL dbs: %s\n",w2);
+ } else if(strcmpi(w1,"connection_ping_interval")==0) {
+ connection_ping_interval = config_switch(w2);
//custom columns for login database
}else if(strcmpi(w1,"login_db_level")==0){
strcpy(login_db_level,w2);
diff --git a/src/char_sql/char.h b/src/char_sql/char.h
index 53550dcd3..51c4426db 100644
--- a/src/char_sql/char.h
+++ b/src/char_sql/char.h
@@ -59,6 +59,7 @@ int char_child(int parent_id, int child_id);
int request_accreg2(int account_id, int char_id);
int save_accreg2(unsigned char* buf, int len);
+extern bool char_gm_read;
extern int autosave_interval;
extern int save_log;
extern int charsave_method;
@@ -85,6 +86,8 @@ extern char party_db[256];
extern char pet_db[256];
extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris]
+extern int connection_ping_interval;
+
extern char login_db_level[32];
extern char login_db_account_id[32];
diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c
index 5a220ef7f..38fd1f289 100644
--- a/src/char_sql/inter.c
+++ b/src/char_sql/inter.c
@@ -303,6 +303,17 @@ int inter_log(char *fmt,...)
return 0;
}
+/*======================================================
+ * Does a mysql_ping to all connection handles. [Skotlex]
+ *------------------------------------------------------
+ */
+int inter_sql_ping(int tid, unsigned int tick, int id, int data)
+{
+ mysql_ping(&mysql_handle);
+ if(char_gm_read)
+ mysql_ping(&lmysql_handle);
+ return 0;
+}
// initialize
int inter_init(const char *file)
@@ -325,15 +336,17 @@ int inter_init(const char *file)
ShowStatus("Connect Success! (Character Server)\n");
}
- mysql_init(&lmysql_handle);
- ShowInfo("Connect Character DB server.... (login server)\n");
- if(!mysql_real_connect(&lmysql_handle, login_server_ip, login_server_id, login_server_pw,
- login_server_db ,login_server_port, (char *)NULL, 0)) {
- //pointer check
- ShowFatalError("%s\n",mysql_error(&lmysql_handle));
- exit(1);
- }else {
- ShowStatus ("Connect Success! (Login Server)\n");
+ if(char_gm_read) {
+ mysql_init(&lmysql_handle);
+ ShowInfo("Connect Character DB server.... (login server)\n");
+ if(!mysql_real_connect(&lmysql_handle, login_server_ip, login_server_id, login_server_pw,
+ login_server_db ,login_server_port, (char *)NULL, 0)) {
+ //pointer check
+ ShowFatalError("%s\n",mysql_error(&lmysql_handle));
+ exit(1);
+ }else {
+ ShowStatus ("Connect Success! (Login Server)\n");
+ }
}
if(strlen(default_codepage) > 0 ) {
sprintf( tmp_sql, "SET NAMES %s", default_codepage );
@@ -341,10 +354,11 @@ int inter_init(const char *file)
ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
}
- if (mysql_query(&lmysql_handle, tmp_sql)) {
- ShowSQL("DB error - %s\n",mysql_error(&lmysql_handle));
- ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
- }
+ if(char_gm_read)
+ if (mysql_query(&lmysql_handle, tmp_sql)) {
+ ShowSQL("DB error - %s\n",mysql_error(&lmysql_handle));
+ ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
+ }
}
wis_db = db_alloc(__FILE__,__LINE__,DB_INT,DB_OPT_RELEASE_DATA,sizeof(int));
inter_guild_sql_init();
@@ -357,6 +371,11 @@ int inter_init(const char *file)
//printf ("interserver timer initializing : %d sec...\n",autosave_interval);
//i=add_timer_interval(gettick()+autosave_interval,inter_save_timer,0,0,autosave_interval);
+ if (connection_ping_interval) {
+ add_timer_func_list(inter_sql_ping, "inter_sql_ping");
+ add_timer_interval(gettick()+connection_ping_interval*60*1000,
+ inter_sql_ping, 0, 0, connection_ping_interval*60*1000);
+ }
return 0;
}