Browse Source

Fixed an issue with progressbars (#3945)

Additionally if progress was being canceled and a message window was active, the user would be stuck, because no close button would show.

Fixes #3944

Thanks to @teededung, @cahya1992 and @Atemo
Lemongrass3110 6 years ago
parent
commit
fc92a97978
1 changed files with 20 additions and 7 deletions
  1. 20 7
      src/map/clif.cpp

+ 20 - 7
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)
-{
+/// 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;
+	}
+
 	int npc_id = sd->progressbar.npc_id;
+	bool closing = false;
 
-	if( gettick() < sd->progressbar.timeout && sd->st )
-		sd->st->state = END;
+	// 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