Raised This Month: $51 Target: $400
 12% 

Can you help me Handle this please?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 11-11-2015 , 14:45   Can you help me Handle this please?
Reply With Quote #1

HaHa! good joke, right? Right? :-D :-D anyway...

Ciao guys!

I'd like consulte my handle problem with you. I am creating global hashmap in OnConfigsExecuted.
And to prevent handle leaks, I check created handle each time OnConfigsExecuted is called (I want to recreate or clear given hashmap).
But, once the handle (hashmap) is created, it gives invalid handle in next OnConfigsExecuted.

Something like this:
PHP Code:
new Handle:g_hMarkSettings[3];

public 
OnConfigsExecuted()
{
    
// iTeam contains enum values 1 and 2
    
if (g_hMarkSettings[iTeam] != INVALID_HANDLE) {
        
CloseHandle(g_hMarkSettings[iTeam]); // Here is invalid handle
    
}
    
    
g_hMarkSettings[iTeam] = CreateTrie();

Did I missed something?
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.

Last edited by KissLick; 11-11-2015 at 14:45.
KissLick is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-11-2015 , 15:20   Re: Can you help me Handle this please?
Reply With Quote #2

What is the value of iTeam in OnConfigsExecuted?

For that matter, shouldn't you be doing that in a loop and resetting all the g_hMarkSettings handles?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 11-11-2015 , 15:46   Re: Can you help me Handle this please?
Reply With Quote #3

Updated code
PHP Code:
enum TG_Team
{
    
TG_ErrorTeam = -1,
    
TG_NoneTeam// 0
    
TG_RedTeam// 1
    
TG_BlueTeam // 2
};

new 
Handle:g_hMarkSettings[3];

public 
OnConfigsExecuted()
{

    
// not sure here, but it seems working
    
for (new TG_Team:iTeam TG_RedTeamiTeam <= TG_BlueTeamiTeam++) {
        
        if (
g_hMarkSettings[iTeam] != INVALID_HANDLE) {
            
CloseHandle(g_hMarkSettings[iTeam]); // Here is invalid handle
        
}
        
        
g_hMarkSettings[iTeam] = CreateTrie();
        
        
// fill hashmap here
    
}

__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
StSatan
Senior Member
Join Date: Apr 2010
Old 11-11-2015 , 17:04   Re: Can you help me Handle this please?
Reply With Quote #4

Code:
enum TG_Team {     TG_ErrorTeam = -1,     TG_NoneTeam, // 0     TG_RedTeam, // 1     TG_BlueTeam // 2 }; Handle g_hMarkSettings[3] = { INVALID_HANDLE, ... }; public void OnMapEnd() {     for (int iTeam = _:TG_RedTeam; iTeam <= _:TG_BlueTeam; ++iTeam) {                 if (g_hMarkSettings[iTeam] != INVALID_HANDLE) {             CloseHandle(g_hMarkSettings[iTeam]); // Maybe call it when OnMapEnd fired?         }     } }

Last edited by StSatan; 11-11-2015 at 17:04.
StSatan is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 11-12-2015 , 17:15   Re: Can you help me Handle this please?
Reply With Quote #5

Yeah, that should solve the problem. But do you know why there is that problem?

I thought that handles "survive" map change (just like other global variables)...
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.

Last edited by KissLick; 11-12-2015 at 19:06.
KissLick is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 11-12-2015 , 20:26   Re: Can you help me Handle this please?
Reply With Quote #6

Quote:
Originally Posted by KissLick View Post
I thought that handles "survive" map change (just like other global variables)...
They do.
__________________
asherkin is online now
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode