diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/clif.c | 16 | ||||
-rw-r--r-- | src/map/map.c | 58 | ||||
-rw-r--r-- | src/map/npc.c | 4 | ||||
-rw-r--r-- | src/map/pc.c | 46 | ||||
-rw-r--r-- | src/map/status.c | 45 |
5 files changed, 93 insertions, 76 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 7aa584d9c..417fd448b 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -7970,7 +7970,13 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) add_timer(gettick()+1000,clif_nighttimer,sd->bl.id,0);
// if(sd->status.class_ != sd->vd.class_)
-// clif_changelook(&sd->bl,LOOK_BASE,sd->vd.class_);
+// clif_refreshlook(&sd->bl,sd->bl.id,LOOK_BASE,sd->vd.class_,SELF);
+
+ if (sd->sc.option&OPTION_FALCON)
+ clif_status_load(&sd->bl, SI_FALCON, 1);
+ if (sd->sc.option&OPTION_RIDING)
+ clif_status_load(&sd->bl, SI_RIDING, 1);
+
if(sd->status.pet_id > 0 && sd->pd && sd->pet.intimate > 900)
clif_pet_emotion(sd->pd,(sd->pd->class_ - 100)*100 + 50 + pet_hungry_val(sd));
@@ -10592,9 +10598,11 @@ void clif_friendslist_send(struct map_session_data *sd) { memcpy(WFIFOP(sd->fd, 4 + 32 * i + 8), &sd->status.friends[i].name, NAME_LENGTH);
}
- WFIFOW(sd->fd,2) = 4 + 32 * i;
- WFIFOSET(sd->fd, WFIFOW(sd->fd,2));
-
+ if (i) {
+ WFIFOW(sd->fd,2) = 4 + 32 * i;
+ WFIFOSET(sd->fd, WFIFOW(sd->fd,2));
+ }
+
for (n = 0; n < i; n++)
{ //Sending the online players
if (map_charid2sd(sd->status.friends[n].char_id))
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イベント?行
diff --git a/src/map/npc.c b/src/map/npc.c index 936c04226..3c20b5691 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -116,10 +116,10 @@ int npc_enable(const char *name,int flag) nd->sc.option&=~OPTION_HIDE;
clif_changeoption(&nd->bl);
}else if (flag&4){
- nd->sc.option = OPTION_HIDE;
+ nd->sc.option|= OPTION_HIDE;
clif_changeoption(&nd->bl);
}else{ //Can't change the view_data to invisible class because the view_data for all npcs is shared! [Skotlex]
- nd->sc.option = OPTION_INVISIBLE;
+ nd->sc.option|= OPTION_INVISIBLE;
clif_changeoption(&nd->bl);
}
if(flag&3 && (nd->u.scr.xs > 0 || nd->u.scr.ys >0))
diff --git a/src/map/pc.c b/src/map/pc.c index 3854fe267..752917f61 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5613,49 +5613,33 @@ int pc_setoption(struct map_session_data *sd,int type) switch (sd->status.class_)
{
case JOB_KNIGHT:
- sd->status.class_ = sd->vd.class_ = JOB_KNIGHT2;
+ clif_changelook(&sd->bl,LOOK_BASE,JOB_KNIGHT2);
break;
case JOB_CRUSADER:
- sd->status.class_ = sd->vd.class_ = JOB_CRUSADER2;
+ clif_changelook(&sd->bl,LOOK_BASE,JOB_CRUSADER2);
break;
case JOB_LORD_KNIGHT:
- sd->status.class_ = sd->vd.class_ = JOB_LORD_KNIGHT2;
+ clif_changelook(&sd->bl,LOOK_BASE,JOB_LORD_KNIGHT2);
break;
case JOB_PALADIN:
- sd->status.class_ = sd->vd.class_ = JOB_PALADIN2;
+ clif_changelook(&sd->bl,LOOK_BASE,JOB_PALADIN2);
break;
case JOB_BABY_KNIGHT:
- sd->status.class_ = sd->vd.class_ = JOB_BABY_KNIGHT2;
+ clif_changelook(&sd->bl,LOOK_BASE,JOB_BABY_KNIGHT2);
break;
case JOB_BABY_CRUSADER:
- sd->status.class_ = sd->vd.class_ = JOB_BABY_CRUSADER2;
+ clif_changelook(&sd->bl,LOOK_BASE,JOB_BABY_CRUSADER2);
break;
}
+ clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color);
clif_status_load(&sd->bl,SI_RIDING,1);
status_calc_pc(sd,0); //Mounting/Umounting affects walk and attack speeds.
}
else if (!(type&OPTION_RIDING) && sd->sc.option&OPTION_RIDING && (sd->class_&MAPID_BASEMASK) == MAPID_SWORDMAN)
{ //We are going to dismount.
- switch (sd->status.class_)
- {
- case JOB_KNIGHT2:
- sd->status.class_ = sd->vd.class_ = JOB_KNIGHT;
- break;
- case JOB_CRUSADER2:
- sd->status.class_ = sd->vd.class_ = JOB_CRUSADER;
- break;
- case JOB_LORD_KNIGHT2:
- sd->status.class_ = sd->vd.class_ = JOB_LORD_KNIGHT;
- break;
- case JOB_PALADIN2:
- sd->status.class_ = sd->vd.class_ = JOB_PALADIN;
- break;
- case JOB_BABY_KNIGHT2:
- sd->status.class_ = sd->vd.class_ = JOB_BABY_KNIGHT;
- break;
- case JOB_BABY_CRUSADER2:
- sd->status.class_ = sd->vd.class_ = JOB_BABY_CRUSADER;
- break;
+ if (sd->vd.class_ != sd->status.class_) {
+ clif_changelook(&sd->bl,LOOK_BASE,sd->status.class_);
+ clif_changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color);
}
clif_status_load(&sd->bl,SI_RIDING,0);
status_calc_pc(sd,0); //Mounting/Umounting affects walk and attack speeds.
@@ -5669,13 +5653,11 @@ int pc_setoption(struct map_session_data *sd,int type) if (type&OPTION_FLYING && !(sd->sc.option&OPTION_FLYING)) //Flying ON
{
if (sd->status.class_==JOB_STAR_GLADIATOR)
- sd->status.class_ = sd->vd.class_ = JOB_STAR_GLADIATOR2;
+ clif_changelook(&sd->bl,LOOK_BASE,JOB_STAR_GLADIATOR2);
}
else if (!(type&OPTION_FLYING) && sd->sc.option&OPTION_FLYING) //Flying OFF
- {
- if (sd->status.class_==JOB_STAR_GLADIATOR2)
- sd->status.class_ = sd->vd.class_ = JOB_STAR_GLADIATOR;
- }
+ if (sd->vd.class_ != sd->status.class_)
+ clif_changelook(&sd->bl,LOOK_BASE,sd->status.class_);
sd->sc.option=type;
clif_changeoption(&sd->bl);
@@ -5727,7 +5709,7 @@ int pc_setcart(struct map_session_data *sd,int type) int pc_setfalcon(struct map_session_data *sd)
{
if(pc_checkskill(sd,HT_FALCON)>0){ // ファルコンマスタリ?スキル所持
- pc_setoption(sd,sd->sc.option|0x0010);
+ pc_setoption(sd,sd->sc.option|OPTION_FALCON);
}
return 0;
diff --git a/src/map/status.c b/src/map/status.c index 7df40765c..398360605 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1572,12 +1572,6 @@ int status_calc_pc(struct map_session_data* sd,int first) }
// ----- CLIENT-SIDE REFRESH -----
- if(first&1) { //Since this is the initial loading, the Falcon and Peco icons must be loaded. [Skotlex]
- if (sd->sc.option&OPTION_FALCON)
- clif_status_load(&sd->bl, SI_FALCON, 1);
- if (sd->sc.option&OPTION_RIDING)
- clif_status_load(&sd->bl, SI_RIDING, 1);
- }
if(first&4) {
calculating = 0;
return 0;
@@ -3313,6 +3307,28 @@ void status_set_viewdata(struct block_list *bl, int class_) {
TBL_PC* sd = (TBL_PC*)bl;
if (pcdb_checkid(class_)) {
+ if (sd->sc.option&OPTION_RIDING)
+ switch (class_)
+ { //Adapt class to a Mounted one.
+ case JOB_KNIGHT:
+ class_ = JOB_KNIGHT2;
+ break;
+ case JOB_CRUSADER:
+ class_ = JOB_CRUSADER2;
+ break;
+ case JOB_LORD_KNIGHT:
+ class_ = JOB_LORD_KNIGHT2;
+ break;
+ case JOB_PALADIN:
+ class_ = JOB_PALADIN2;
+ break;
+ case JOB_BABY_KNIGHT:
+ class_ = JOB_BABY_KNIGHT2;
+ break;
+ case JOB_BABY_CRUSADER:
+ class_ = JOB_BABY_CRUSADER2;
+ break;
+ }
sd->vd.class_ = class_;
clif_get_weapon_view(sd, &sd->vd.weapon, &sd->vd.shield);
sd->vd.head_top = sd->status.head_top;
@@ -3375,10 +3391,14 @@ void status_set_viewdata(struct block_list *bl, int class_) struct status_change *status_get_sc(struct block_list *bl)
{
nullpo_retr(NULL, bl);
- if(bl->type==BL_MOB)
- return &((struct mob_data*)bl)->sc;
- if(bl->type==BL_PC)
- return &((struct map_session_data*)bl)->sc;
+ switch (bl->type) {
+ case BL_MOB:
+ return &((TBL_MOB*)bl)->sc;
+ case BL_PC:
+ return &((TBL_PC*)bl)->sc;
+ case BL_NPC:
+ return &((TBL_NPC*)bl)->sc;
+ }
return NULL;
}
@@ -4344,7 +4364,7 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val {
struct block_list *src = val2?map_id2bl(val2):NULL;
struct status_change *sc2 = src?status_get_sc(src):NULL;
- if (src && sc2 && sc2->count) {
+ if (src && sc2) {
if (sc2->data[SC_CLOSECONFINE].timer == -1) //Start lock on caster.
sc_start4(src,SC_CLOSECONFINE,100,sc->data[type].val1,1,0,0,tick+1000);
else { //Increase count of locked enemies and refresh time.
@@ -4352,7 +4372,8 @@ int status_change_start(struct block_list *bl,int type,int rate,int val1,int val delete_timer(sc2->data[SC_CLOSECONFINE].timer, status_change_timer);
sc2->data[SC_CLOSECONFINE].timer = add_timer(gettick()+tick+1000, status_change_timer, src->id, SC_CLOSECONFINE);
}
- }
+ } else //Status failed.
+ return 0;
}
break;
case SC_KAITE:
|