From 6c935c2bbd90b4b5c3b39cc0eb49bbcd42de2ab6 Mon Sep 17 00:00:00 2001 From: ineed bots Date: Thu, 9 May 2024 20:42:19 -0600 Subject: [PATCH] fixed menu var leak --- maps/mp/bots/_menu.gsc | 50 ++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/maps/mp/bots/_menu.gsc b/maps/mp/bots/_menu.gsc index 35e61ff..66163ea 100644 --- a/maps/mp/bots/_menu.gsc +++ b/maps/mp/bots/_menu.gsc @@ -60,7 +60,6 @@ init_menu() self.menuinit = true; self.menuopen = false; - self.menu_player = undefined; self.submenu = "Main"; self.curs[ "Main" ][ "X" ] = 0; self AddOptions(); @@ -75,6 +74,12 @@ init_menu() self thread doGreetings(); } +destroyElemFixed() +{ + self.parent removechild( self ); + self destroyelem(); +} + kill_menu() { self notify( "bots_kill_menu" ); @@ -93,7 +98,7 @@ watchDisconnect() { if ( isdefined( self.menutexty[ i ] ) ) { - self.menutexty[ i ] destroy(); + self.menutexty[ i ] destroyElemFixed(); } } } @@ -104,7 +109,7 @@ watchDisconnect() { if ( isdefined( self.menutext[ i ] ) ) { - self.menutext[ i ] destroy(); + self.menutext[ i ] destroyElemFixed(); } } } @@ -113,12 +118,12 @@ watchDisconnect() { if ( isdefined( self.menu[ "X" ][ "Shader" ] ) ) { - self.menu[ "X" ][ "Shader" ] destroy(); + self.menu[ "X" ][ "Shader" ] destroyElemFixed(); } if ( isdefined( self.menu[ "X" ][ "Scroller" ] ) ) { - self.menu[ "X" ][ "Scroller" ] destroy(); + self.menu[ "X" ][ "Scroller" ] destroyElemFixed(); } } @@ -332,7 +337,7 @@ OpenSub( menu, menu2 ) { if ( isdefined( self.menutext[ i ] ) ) { - self.menutext[ i ] destroy(); + self.menutext[ i ] destroyElemFixed(); } } } @@ -341,12 +346,12 @@ OpenSub( menu, menu2 ) { if ( isdefined( self.menu[ "X" ][ "Shader" ] ) ) { - self.menu[ "X" ][ "Shader" ] destroy(); + self.menu[ "X" ][ "Shader" ] destroyElemFixed(); } if ( isdefined( self.menu[ "X" ][ "Scroller" ] ) ) { - self.menu[ "X" ][ "Scroller" ] destroy(); + self.menu[ "X" ][ "Scroller" ] destroyElemFixed(); } } @@ -402,7 +407,7 @@ OpenSub( menu, menu2 ) { if ( isdefined( self.menutexty[ i ] ) ) { - self.menutexty[ i ] destroy(); + self.menutexty[ i ] destroyElemFixed(); } } } @@ -426,18 +431,21 @@ CursMove( direction ) if ( self.submenu == "Main" ) { - self.menu[ "X" ][ "Scroller" ].x = self.menutext[ self.curs[ "Main" ][ "X" ] ].x; - self.menu[ "X" ][ "Scroller" ].y = self.menutext[ self.curs[ "Main" ][ "X" ] ].y; - if ( isdefined( self.menutext ) ) { - for ( i = 0; i < self.menutext.size; i++ ) + self.menu[ "X" ][ "Scroller" ].x = self.menutext[ self.curs[ "Main" ][ "X" ] ].x; + self.menu[ "X" ][ "Scroller" ].y = self.menutext[ self.curs[ "Main" ][ "X" ] ].y; + + if ( isdefined( self.menutext ) ) { - if ( isdefined( self.menutext[ i ] ) ) + for ( i = 0; i < self.menutext.size; i++ ) { - self.menutext[ i ].fontscale = 1.5; - self.menutext[ i ].color = ( 1, 1, 1 ); - self.menutext[ i ].glowalpha = 0; + if ( isdefined( self.menutext[ i ] ) ) + { + self.menutext[ i ].fontscale = 1.5; + self.menutext[ i ].color = ( 1, 1, 1 ); + self.menutext[ i ].glowalpha = 0; + } } } } @@ -578,7 +586,7 @@ ExitSub() { if ( isdefined( self.menutexty[ i ] ) ) { - self.menutexty[ i ] destroy(); + self.menutexty[ i ] destroyElemFixed(); } } } @@ -603,7 +611,7 @@ ExitMenu() { if ( isdefined( self.menutext[ i ] ) ) { - self.menutext[ i ] destroy(); + self.menutext[ i ] destroyElemFixed(); } } } @@ -612,12 +620,12 @@ ExitMenu() { if ( isdefined( self.menu[ "X" ][ "Shader" ] ) ) { - self.menu[ "X" ][ "Shader" ] destroy(); + self.menu[ "X" ][ "Shader" ] destroyElemFixed(); } if ( isdefined( self.menu[ "X" ][ "Scroller" ] ) ) { - self.menu[ "X" ][ "Scroller" ] destroy(); + self.menu[ "X" ][ "Scroller" ] destroyElemFixed(); } }