Fixed cookie memory leak, changed cookies to only be created once.
This commit is contained in:
parent
92bffae62c
commit
bc7a019e8f
@ -25,25 +25,20 @@ ClassOnCookiesCreate()
|
|||||||
// Forward event to sub-modules.
|
// Forward event to sub-modules.
|
||||||
ClassOverlayOnCookiesCreate();
|
ClassOverlayOnCookiesCreate();
|
||||||
|
|
||||||
// Close cookie handles if they already exist.
|
// Create cookie handles only if they don't exist.
|
||||||
if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_HUMANS] != INVALID_HANDLE)
|
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_HUMANS] = RegClientCookie("zr_humanclass", "The last human class selected.", CookieAccess_Protected);
|
||||||
|
}
|
||||||
|
if (g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES] == INVALID_HANDLE)
|
||||||
|
{
|
||||||
g_hClassCookieClassSelected[ZR_CLASS_TEAM_ZOMBIES] = RegClientCookie("zr_zombieclass", "The last zombie class selected.", CookieAccess_Protected);
|
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)
|
||||||
|
{
|
||||||
g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS] = RegClientCookie("zr_adminclass", "The last admin mode class selected.", CookieAccess_Protected);
|
g_hClassCookieClassSelected[ZR_CLASS_TEAM_ADMINS] = RegClientCookie("zr_adminclass", "The last admin mode class selected.", CookieAccess_Protected);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when all modules are done loading.
|
* Called when all modules are done loading.
|
||||||
|
@ -76,15 +76,12 @@ ClassOverlayOnCommandsHook()
|
|||||||
*/
|
*/
|
||||||
ClassOverlayOnCookiesCreate()
|
ClassOverlayOnCookiesCreate()
|
||||||
{
|
{
|
||||||
// Close cookie handle if it already exist.
|
// Create cookie handle only if it don't exist.
|
||||||
if (g_hOverlayEnabledCookie != INVALID_HANDLE)
|
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);
|
g_hOverlayEnabledCookie = RegClientCookie(CLASSOVERLAY_COOKIE_ENABLED, "The toggle state of the class overlay.", CookieAccess_Protected);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client is joining the server.
|
* Client is joining the server.
|
||||||
|
@ -70,14 +70,11 @@ ZMarketOnCommandsCreate()
|
|||||||
|
|
||||||
ZMarketOnCookiesCreate()
|
ZMarketOnCookiesCreate()
|
||||||
{
|
{
|
||||||
// Close auto-rebuy cookie handle if it already exist.
|
// Create auto-rebuy cookie handle if doesn't exist.
|
||||||
if (g_hZMarketAutoRebuyCookie != INVALID_HANDLE)
|
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);
|
g_hZMarketAutoRebuyCookie = RegClientCookie(ZMARKET_COOKIE_AUTOREBUY, "The toggle state of auto-rebuy.", CookieAccess_Protected);
|
||||||
|
}
|
||||||
|
|
||||||
decl String:rebuycookiename[32];
|
decl String:rebuycookiename[32];
|
||||||
decl String:rebuycookiedesc[64];
|
decl String:rebuycookiedesc[64];
|
||||||
@ -89,16 +86,13 @@ ZMarketOnCookiesCreate()
|
|||||||
Format(rebuycookiename, sizeof(rebuycookiename), "%s_%d", ZMARKET_COOKIE_REBUY, x);
|
Format(rebuycookiename, sizeof(rebuycookiename), "%s_%d", ZMARKET_COOKIE_REBUY, x);
|
||||||
Format(rebuycookiedesc, sizeof(rebuycookiedesc), "Current loadout weapon for slot %d", x);
|
Format(rebuycookiedesc, sizeof(rebuycookiedesc), "Current loadout weapon for slot %d", x);
|
||||||
|
|
||||||
// Close loadout cookie handle if it already exist.
|
// Create loadout cookie handle if it doesn't exist.
|
||||||
if (g_hZMarketLoadoutCookie[x] != INVALID_HANDLE)
|
if (g_hZMarketLoadoutCookie[x] == INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
CloseHandle(g_hZMarketLoadoutCookie[x]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create loadout cookie.
|
|
||||||
g_hZMarketLoadoutCookie[x] = RegClientCookie(rebuycookiename, rebuycookiedesc, CookieAccess_Protected);
|
g_hZMarketLoadoutCookie[x] = RegClientCookie(rebuycookiename, rebuycookiedesc, CookieAccess_Protected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find ZMarket-specific offsets here.
|
* Find ZMarket-specific offsets here.
|
||||||
|
@ -54,15 +54,12 @@ ZHPOnCommandsCreate()
|
|||||||
*/
|
*/
|
||||||
ZHPOnCookiesCreate()
|
ZHPOnCookiesCreate()
|
||||||
{
|
{
|
||||||
// Close cookie handle if it already exist.
|
// Create cookie handle if it doesn't exist.
|
||||||
if (g_hZHPEnabledCookie != INVALID_HANDLE)
|
if (g_hZHPEnabledCookie == INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
CloseHandle(g_hZHPEnabledCookie);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create ZHP cookie.
|
|
||||||
g_hZHPEnabledCookie = RegClientCookie(ZHP_COOKIE_ENABLED, "The toggle state of ZHP.", CookieAccess_Protected);
|
g_hZHPEnabledCookie = RegClientCookie(ZHP_COOKIE_ENABLED, "The toggle state of ZHP.", CookieAccess_Protected);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client is joining the server.
|
* Client is joining the server.
|
||||||
|
Loading…
Reference in New Issue
Block a user