summaryrefslogtreecommitdiff
path: root/src/map/map.c
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/map/map.c
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/map/map.c')
-rw-r--r--src/map/map.c58
1 files changed, 32 insertions, 26 deletions
diff --git a/src/map/map.c b/src/map/map.c
index e77433181..87cc16577 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -62,10 +62,6 @@ MYSQL_RES* sql_res ;
MYSQL_ROW sql_row ;
char tmp_sql[65535]="";
-MYSQL lmysql_handle;
-MYSQL_RES* lsql_res ;
-MYSQL_ROW lsql_row ;
-
MYSQL logmysql_handle; //For the log database - fix by [Maeki]
MYSQL_RES* logsql_res ;
MYSQL_ROW logsql_row ;
@@ -81,6 +77,7 @@ char map_server_pw[32] = "ragnarok";
char map_server_db[32] = "ragnarok";
char default_codepage[32] = ""; //Feature by irmin.
int db_use_sqldbs = 0;
+int connection_ping_interval = 0;
int login_server_port = 3306;
char login_server_ip[16] = "127.0.0.1";
@@ -2054,6 +2051,7 @@ int map_calc_dir( struct block_list *src,int x,int y) {
*------------------------------------------
*/
int map_random_dir(struct block_list *bl, short *x, short *y) {
+ struct walkpath_data wpd;
short xi = *x-bl->x;
short yi = *y-bl->y;
short i=0, j;
@@ -2069,7 +2067,11 @@ int map_random_dir(struct block_list *bl, short *x, short *y) {
xi = bl->x + segment*dirx[j];
segment = (short)sqrt(dist2 - segment*segment); //The complement of the previously picked segment
yi = bl->y + segment*diry[j];
- } while (map_getcell(bl->m,xi,yi,CELL_CHKNOPASS) && (++i)<100);
+ } while ((
+ map_getcell(bl->m,xi,yi,CELL_CHKNOPASS) ||
+ path_search_real(&wpd,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH) == -1)
+ && (++i)<100);
+
if (i < 100) {
*x = xi;
*y = yi;
@@ -3414,6 +3416,8 @@ int inter_config_read(char *cfgName)
} else if(strcmpi(w1,"use_sql_db")==0){
db_use_sqldbs = battle_config_switch(w2);
ShowStatus ("Using SQL dbs: %s\n",w2);
+ } else if(strcmpi(w1,"connection_ping_interval")==0) {
+ connection_ping_interval = battle_config_switch(w2);
//Login Server SQL DB
} else if(strcmpi(w1,"login_server_ip")==0){
strcpy(login_server_ip, w2);
@@ -3498,20 +3502,6 @@ int map_sql_init(void){
ShowStatus("connect success! (Map Server Connection)\n");
}
- mysql_init(&lmysql_handle);
-
- //DB connection start
- ShowInfo("Connecting to the Login DB 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
- ShowSQL("DB error - %s\n",mysql_error(&lmysql_handle));
- exit(1);
- }
- else {
- ShowStatus ("connect success! (Login Server Connection)\n");
- }
-
if(mail_server_enable) { // mail system [Valaris]
mysql_init(&mail_handle);
ShowInfo("Connecting to the Mail DB Server....\n");
@@ -3534,10 +3524,6 @@ int map_sql_init(void){
ShowSQL("DB error - %s\n",mysql_error(&mmysql_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);
- }
}
return 0;
}
@@ -3546,9 +3532,6 @@ int map_sql_close(void){
mysql_close(&mmysql_handle);
ShowStatus("Close Map DB Connection....\n");
- mysql_close(&lmysql_handle);
- ShowStatus("Close Login DB Connection....\n");
-
if (log_config.sql_logs)
//Updating this if each time there's a log_config addition is too much of a hassle. [Skotlex]
/*&& (log_config.branch || log_config.drop || log_config.mvpdrop ||
@@ -3753,6 +3736,23 @@ void map_versionscreen(int flag) {
if (flag) exit(1);
}
+
+#ifndef TXT_ONLY
+/*======================================================
+ * Does a mysql_ping to all connection handles. [Skotlex]
+ *------------------------------------------------------
+ */
+int map_sql_ping(int tid, unsigned int tick, int id, int data)
+{
+ mysql_ping(&mmysql_handle);
+ if (log_config.sql_logs)
+ mysql_ping(&logmysql_handle);
+ if(mail_server_enable)
+ mysql_ping(&mail_handle);
+ return 0;
+}
+#endif
+
/*======================================================
* Map-Server Init and Command-line Arguments [Valaris]
*------------------------------------------------------
@@ -3895,6 +3895,12 @@ int do_init(int argc, char *argv[]) {
{
log_sql_init();
}
+
+ if (connection_ping_interval) {
+ add_timer_func_list(map_sql_ping, "map_sql_ping");
+ add_timer_interval(gettick()+connection_ping_interval*60*1000,
+ map_sql_ping, 0, 0, connection_ping_interval*60*1000);
+ }
#endif /* not TXT_ONLY */
npc_event_do_oninit(); // npcのOnInitイベント?行