Fixed cookie memory leak, changed cookies to only be created once.

This commit is contained in:
richard 2009-10-10 18:26:27 +02:00
parent 92bffae62c
commit bc7a019e8f
4 changed files with 19 additions and 36 deletions

View File

@ -25,24 +25,19 @@ ClassOnCookiesCreate()
// Forward event to sub-modules.
ClassOverlayOnCookiesCreate();
// Close cookie handles if they already exist.
if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS] != INVALID_HANDLE)
// Create cookie handles only if they don't exist.
if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS] == INVALID_HANDLE)
{
CloseHandle(g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS]);
g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS] = RegClientCookie("zr_humanclass", "The last human class selected.", CookieAccess_Protected);
}
if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES] != INVALID_HANDLE)
if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES] == INVALID_HANDLE)
{
CloseHandle(g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES]);
g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES] = RegClientCookie("zr_zombieclass", "The last zombie class selected.", CookieAccess_Protected);
}
if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS] != INVALID_HANDLE)
if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS] == INVALID_HANDLE)
{
CloseHandle(g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS]);
g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS] = RegClientCookie("zr_adminclass", "The last admin mode class selected.", CookieAccess_Protected);
}
// 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);
g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS] = RegClientCookie("zr_adminclass", "The last admin mode class selected.", CookieAccess_Protected);
}
/**

View File

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

View File

@ -70,15 +70,12 @@ ZMarketOnCommandsCreate()
ZMarketOnCookiesCreate()
{
// Close auto-rebuy cookie handle if it already exist.
if (g_hZMarketAutoRebuyCookie != INVALID_HANDLE)
// Create auto-rebuy cookie handle if doesn't exist.
if (g_hZMarketAutoRebuyCookie == INVALID_HANDLE)
{
CloseHandle(g_hZMarketAutoRebuyCookie);
g_hZMarketAutoRebuyCookie = RegClientCookie(ZMARKET_COOKIE_AUTOREBUY, "The toggle state of auto-rebuy.", CookieAccess_Protected);
}
// Create auto-rebuy cookie.
g_hZMarketAutoRebuyCookie = RegClientCookie(ZMARKET_COOKIE_AUTOREBUY, "The toggle state of auto-rebuy.", CookieAccess_Protected);
decl String:rebuycookiename[32];
decl String:rebuycookiedesc[64];
@ -89,14 +86,11 @@ ZMarketOnCookiesCreate()
Format(rebuycookiename, sizeof(rebuycookiename), "%s_%d", ZMARKET_COOKIE_REBUY, x);
Format(rebuycookiedesc, sizeof(rebuycookiedesc), "Current loadout weapon for slot %d", x);
// Close loadout cookie handle if it already exist.
if (g_hZMarketLoadoutCookie[x] != INVALID_HANDLE)
// Create loadout cookie handle if it doesn't exist.
if (g_hZMarketLoadoutCookie[x] == INVALID_HANDLE)
{
CloseHandle(g_hZMarketLoadoutCookie[x]);
g_hZMarketLoadoutCookie[x] = RegClientCookie(rebuycookiename, rebuycookiedesc, CookieAccess_Protected);
}
// Create loadout cookie.
g_hZMarketLoadoutCookie[x] = RegClientCookie(rebuycookiename, rebuycookiedesc, CookieAccess_Protected);
}
}

View File

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