diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 138ac59cd2..1923c326d5 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -10794,19 +10794,32 @@ void clif_progressbar_abort(struct map_session_data * sd) } -/// Notification from the client, that the progress bar has reached 100% (CZ_PROGRESS). -/// 02f1 -void clif_parse_progressbar(int fd, struct map_session_data * sd) -{ - int npc_id = sd->progressbar.npc_id; +/// Notification from the client, that the progress bar has reached 100%. +/// 02f1 (CZ_PROGRESS) +void clif_parse_progressbar(int fd, struct map_session_data * sd){ + // No progressbar active, ignore it + if( !sd->progressbar.npc_id ){ + return; + } - if( gettick() < sd->progressbar.timeout && sd->st ) - sd->st->state = END; + int npc_id = sd->progressbar.npc_id; + bool closing = false; + + // Check if the progress was canceled + if( gettick() < sd->progressbar.timeout && sd->st ){ + closing = true; + sd->st->state = CLOSE; // will result in END in npc_scriptcont + + // If a message window was open, offer a close button to the user + if( sd->st->mes_active ){ + clif_scriptclose( sd, npc_id ); + } + } sd->progressbar.npc_id = 0; sd->progressbar.timeout = 0; sd->state.workinprogress = WIP_DISABLE_NONE; - npc_scriptcont(sd, npc_id, false); + npc_scriptcont(sd, npc_id, closing); } /// Displays cast-like progress bar on a NPC