Attempt to fix cookie memory leak.

This commit is contained in:
richard 2009-10-08 19:47:23 +02:00
parent 8bd7c09887
commit 7555b042b9
4 changed files with 46 additions and 3 deletions

View File

@ -25,6 +25,20 @@ ClassOnCookiesCreate()
// Forward event to sub-modules.
ClassOverlayOnCookiesCreate();
// Close cookie handles if they already exist.
if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS] != INVALID_HANDLE)
{
CloseHandle(g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS]);
}
if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES] != INVALID_HANDLE)
{
CloseHandle(g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES]);
}
if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS] != INVALID_HANDLE)
{
CloseHandle(g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS]);
}
// Create class index cookies.
g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS] = RegClientCookie("zr_humanclass", "The last human class selected.", CookieAccess_Protected);
g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES] = RegClientCookie("zr_zombieclass", "The last zombie class selected.", CookieAccess_Protected);

View File

@ -76,6 +76,12 @@ ClassOverlayOnCommandsHook()
*/
ClassOverlayOnCookiesCreate()
{
// Close cookie handle if it already exist.
if (g_hOverlayEnabledCookie != INVALID_HANDLE)
{
CloseHandle(g_hOverlayEnabledCookie);
}
// Create overlay cookie.
g_hOverlayEnabledCookie = RegClientCookie(CLASSOVERLAY_COOKIE_ENABLED, "The toggle state of the class overlay.", CookieAccess_Protected);
}

View File

@ -54,6 +54,11 @@ new Handle:g_hZMarketPurchaseCount[MAXPLAYERS + 1];
*/
new Handle:g_hZMarketAutoRebuyCookie = INVALID_HANDLE;
/**
* Cookie handle array for weapon loadouts.
*/
new Handle:g_hZMarketLoadoutCookie[WEAPONS_SLOTS_MAX + 1];
/**
* Create commands specific to ZMarket.
*/
@ -65,7 +70,13 @@ ZMarketOnCommandsCreate()
ZMarketOnCookiesCreate()
{
// Create all cookies.
// Close auto-rebuy cookie handle if it already exist.
if (g_hZMarketAutoRebuyCookie != INVALID_HANDLE)
{
CloseHandle(g_hZMarketAutoRebuyCookie);
}
// Create auto-rebuy cookie.
g_hZMarketAutoRebuyCookie = RegClientCookie(ZMARKET_COOKIE_AUTOREBUY, "The toggle state of auto-rebuy.", CookieAccess_Protected);
decl String:rebuycookiename[32];
@ -78,8 +89,14 @@ ZMarketOnCookiesCreate()
Format(rebuycookiename, sizeof(rebuycookiename), "%s_%d", ZMARKET_COOKIE_REBUY, x);
Format(rebuycookiedesc, sizeof(rebuycookiedesc), "Current loadout weapon for slot %d", x);
// Register client cookie.
RegClientCookie(rebuycookiename, rebuycookiedesc, CookieAccess_Protected);
// Close loadout cookie handle if it already exist.
if (g_hZMarketLoadoutCookie[x] != INVALID_HANDLE)
{
CloseHandle(g_hZMarketLoadoutCookie[x]);
}
// Create loadout cookie.
g_hZMarketLoadoutCookie[x] = RegClientCookie(rebuycookiename, rebuycookiedesc, CookieAccess_Protected);
}
}

View File

@ -54,6 +54,12 @@ ZHPOnCommandsCreate()
*/
ZHPOnCookiesCreate()
{
// Close cookie handle if it already exist.
if (g_hZHPEnabledCookie != INVALID_HANDLE)
{
CloseHandle(g_hZHPEnabledCookie);
}
// Create ZHP cookie.
g_hZHPEnabledCookie = RegClientCookie(ZHP_COOKIE_ENABLED, "The toggle state of ZHP.", CookieAccess_Protected);
}