Skip to content

Commit

Permalink
fixed menu var leak
Browse files Browse the repository at this point in the history
  • Loading branch information
ineed bots committed May 10, 2024
1 parent 1477323 commit 6c935c2
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions maps/mp/bots/_menu.gsc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -75,6 +74,12 @@ init_menu()
self thread doGreetings();
}

destroyElemFixed()
{
self.parent removechild( self );
self destroyelem();
}

kill_menu()
{
self notify( "bots_kill_menu" );
Expand All @@ -93,7 +98,7 @@ watchDisconnect()
{
if ( isdefined( self.menutexty[ i ] ) )
{
self.menutexty[ i ] destroy();
self.menutexty[ i ] destroyElemFixed();
}
}
}
Expand All @@ -104,7 +109,7 @@ watchDisconnect()
{
if ( isdefined( self.menutext[ i ] ) )
{
self.menutext[ i ] destroy();
self.menutext[ i ] destroyElemFixed();
}
}
}
Expand All @@ -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();
}
}

Expand Down Expand Up @@ -332,7 +337,7 @@ OpenSub( menu, menu2 )
{
if ( isdefined( self.menutext[ i ] ) )
{
self.menutext[ i ] destroy();
self.menutext[ i ] destroyElemFixed();
}
}
}
Expand All @@ -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();
}
}

Expand Down Expand Up @@ -402,7 +407,7 @@ OpenSub( menu, menu2 )
{
if ( isdefined( self.menutexty[ i ] ) )
{
self.menutexty[ i ] destroy();
self.menutexty[ i ] destroyElemFixed();
}
}
}
Expand All @@ -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;
}
}
}
}
Expand Down Expand Up @@ -578,7 +586,7 @@ ExitSub()
{
if ( isdefined( self.menutexty[ i ] ) )
{
self.menutexty[ i ] destroy();
self.menutexty[ i ] destroyElemFixed();
}
}
}
Expand All @@ -603,7 +611,7 @@ ExitMenu()
{
if ( isdefined( self.menutext[ i ] ) )
{
self.menutext[ i ] destroy();
self.menutext[ i ] destroyElemFixed();
}
}
}
Expand All @@ -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();
}
}

Expand Down

0 comments on commit 6c935c2

Please sign in to comment.