From e50df489b3950ab7d3debd73decdd52c4a074e96 Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Thu, 12 Feb 2015 19:03:34 +0100 Subject: [PATCH] Fix quitting minigames --- qcsrc/common/minigames/cl_minigames.qc | 14 +++++++++----- qcsrc/common/minigames/cl_minigames_hud.qc | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/qcsrc/common/minigames/cl_minigames.qc b/qcsrc/common/minigames/cl_minigames.qc index 6d250ac70..64a1aadb6 100644 --- a/qcsrc/common/minigames/cl_minigames.qc +++ b/qcsrc/common/minigames/cl_minigames.qc @@ -102,11 +102,11 @@ void HUD_MinigameMenu_CurrentButton(); bool auto_close_minigamemenu; void deactivate_minigame() { - if ( !active_minigame || active_minigame != self ) + if ( !active_minigame ) return; active_minigame.minigame_event(active_minigame,"deactivate"); entity e = world; - while( (e = findentity(e, owner, self)) ) + while( (e = findentity(e, owner, active_minigame)) ) if ( e.minigame_autoclean ) { minigame_autoclean_entity(e); @@ -124,6 +124,12 @@ void deactivate_minigame() HUD_MinigameMenu_CurrentButton(); } +void minigame_entremove() +{ + if ( self == active_minigame ) + deactivate_minigame(); +} + void activate_minigame(entity minigame) { if ( !minigame ) @@ -143,9 +149,7 @@ void activate_minigame(entity minigame) if ( active_minigame ) { - entity olds = minigame_self; deactivate_minigame(); - minigame_self = olds; } if ( minigame_self.owner != minigame ) @@ -211,7 +215,7 @@ void ent_read_minigame() if ( sf & MINIG_SF_CREATE ) { - self.entremove = deactivate_minigame; + self.entremove = minigame_entremove; self.descriptor = minigame_get_descriptor(ReadString_Raw()); if ( !self.descriptor ) dprint("Got a minigame without a client-side descriptor!\n"); diff --git a/qcsrc/common/minigames/cl_minigames_hud.qc b/qcsrc/common/minigames/cl_minigames_hud.qc index c578fb3c1..4bf4b1b3e 100644 --- a/qcsrc/common/minigames/cl_minigames_hud.qc +++ b/qcsrc/common/minigames/cl_minigames_hud.qc @@ -268,6 +268,7 @@ void HUD_MinigameMenu_ClickNoop() // Click action for Quit void HUD_MinigameMenu_ClickQuit() { + deactivate_minigame(); minigame_cmd("end"); } -- 2.39.2