diff options
-rw-r--r-- | src/map/clif.c | 6 | ||||
-rw-r--r-- | src/map/pc.c | 2 | ||||
-rw-r--r-- | src/map/pc.h | 3 | ||||
-rw-r--r-- | src/map/script.c | 32 |
4 files changed, 19 insertions, 24 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 319be6b3e..42043c004 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1834,11 +1834,12 @@ void clif_selllist(struct map_session_data *sd) /// - set npcid of dialog window (0 by default) /// - if set to clear on next mes, clear contents /// - append this text -void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) -{ +void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) { int fd = sd->fd; int slen = strlen(mes) + 9; + sd->state.dialog = 1; + WFIFOHEAD(fd, slen); WFIFOW(fd,0)=0xb4; WFIFOW(fd,2)=slen; @@ -9328,6 +9329,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) } sd->state.warping = 0; + sd->state.dialog = 0;/* reset when warping, client dialog will go missing */ // look #if PACKETVER < 4 diff --git a/src/map/pc.c b/src/map/pc.c index 241e0fbb3..f6ee257bd 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1035,6 +1035,8 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim sd->queues = NULL; sd->queues_count = 0; + sd->state.dialog = 0; + // Event Timers for( i = 0; i < MAX_EVENTTIMER; i++ ) sd->eventtimer[i] = INVALID_TIMER; diff --git a/src/map/pc.h b/src/map/pc.h index 5207c4c34..5d7386575 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -174,6 +174,7 @@ struct map_session_data { unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not. unsigned int warping : 1;//states whether you're in the middle of a warp processing unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc(). + unsigned int dialog : 1; } state; struct { unsigned char no_weapon_damage, no_magic_damage, no_misc_damage; @@ -420,7 +421,7 @@ struct map_session_data { struct{ int m; //-1 - none, other: map index corresponding to map name. unsigned short index; //map index - }feel_map[3];// 0 - Sun; 1 - Moon; 2 - Stars + } feel_map[3];// 0 - Sun; 1 - Moon; 2 - Stars short hate_mob[3]; int pvp_timer; diff --git a/src/map/script.c b/src/map/script.c index 4b9c350f2..bd7d1a7b5 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3387,6 +3387,7 @@ static void script_detach_state(struct script_state* st, bool dequeue_event) if(st->rid && (sd = map_id2sd(st->rid))!=NULL) { sd->st = st->bk_st; sd->npc_id = st->bk_npcid; + sd->state.dialog = 0; if(st->bk_st) { //Remove tag for removal. st->bk_st = NULL; @@ -3406,9 +3407,7 @@ static void script_detach_state(struct script_state* st, bool dequeue_event) #endif npc_event_dequeue(sd); } - } - else if(st->bk_st) - {// rid was set to 0, before detaching the script state + } else if(st->bk_st) { // rid was set to 0, before detaching the script state ShowError("script_detach_state: Found previous script state without attached player (rid=%d, oid=%d, state=%d, bk_npcid=%d)\n", st->bk_st->rid, st->bk_st->oid, st->bk_st->state, st->bk_npcid); script_reportsrc(st->bk_st); @@ -3588,8 +3587,7 @@ void run_script_main(struct script_state *st) } } else { //Dispose of script. - if ((sd = map_id2sd(st->rid))!=NULL) - { //Restore previous stack and save char. + if ((sd = map_id2sd(st->rid))!=NULL) { //Restore previous stack and save char. if(sd->state.using_fake_npc){ clif->clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd); sd->state.using_fake_npc = 0; @@ -3923,22 +3921,17 @@ int script_reload() { /// If a dialog doesn't exist yet, one is created. /// /// mes "<message>"; -BUILDIN(mes) -{ +BUILDIN(mes) { TBL_PC* sd = script_rid2sd(st); if( sd == NULL ) return true; - if( !script_hasdata(st, 3) ) - {// only a single line detected in the script + if( !script_hasdata(st, 3) ) {// only a single line detected in the script clif->scriptmes(sd, st->oid, script_getstr(st, 2)); - } - else - {// parse multiple lines as they exist + } else {// parse multiple lines as they exist int i; - for( i = 2; script_hasdata(st, i); i++ ) - { + for( i = 2; script_hasdata(st, i); i++ ) { // send the message to the client clif->scriptmes(sd, st->oid, script_getstr(st, i)); } @@ -3970,15 +3963,14 @@ BUILDIN(next) /// The dialog is closed when the button is pressed. /// /// close; -BUILDIN(close) -{ +BUILDIN(close) { TBL_PC* sd; sd = script_rid2sd(st); if( sd == NULL ) return true; - st->state = CLOSE; + st->state = sd->state.dialog == 1 ? CLOSE : END; clif->scriptclose(sd, st->oid); return true; } @@ -3987,8 +3979,7 @@ BUILDIN(close) /// The dialog is closed and the script continues when the button is pressed. /// /// close2; -BUILDIN(close2) -{ +BUILDIN(close2) { TBL_PC* sd; sd = script_rid2sd(st); @@ -7802,8 +7793,7 @@ BUILDIN(getgroupid) /// Terminates the execution of this script instance. /// /// end -BUILDIN(end) -{ +BUILDIN(end) { st->state = END; return true; } |