Fixed cookies being reset on some occasions and admin-dependant classes are saved properly as well.

This commit is contained in:
Greyscale 2010-02-19 17:41:24 -08:00
parent 4776bf4e04
commit 21c41688d7
8 changed files with 124 additions and 23 deletions

View File

@ -20,3 +20,5 @@ echo Starting compiler:
%SPCOMP% -i%SOURCEDIR% -i%SOURCEDIR%/include -i%SMINCLUDES% -o%BUILDDIR%/zombiereloaded.smx %SOURCEDIR%\zombiereloaded.sp
pause
compile.bat

View File

@ -55,6 +55,7 @@ ZR
..\src\zr\commands.inc
..\src\zr\config.inc
..\src\zr\cookies.inc
..\src\zr\credits.inc
..\src\zr\cvars.inc
..\src\zr\damage.inc
..\src\zr\debugtools.inc

View File

@ -223,6 +223,15 @@ public OnConfigsExecuted()
ClassOnModulesLoaded();
}
/**
* Client has just connected to the server.
*/
public OnClientConnected(client)
{
// Forward event to modules.
ClassOnClientConnected(client);
}
/**
* Client is joining the server.
*
@ -245,14 +254,32 @@ public OnClientPutInServer(client)
}
/**
* Client is authorized and fully in-game.
* Called once a client's saved cookies have been loaded from the database.
*
* @param client Client index.
* @param client Client index.
*/
public OnClientCookiesCached(client)
{
// Forward "OnCookiesCached" event to modules.
ClassOnCookiesCached(client);
WeaponsOnCookiesCached(client);
ZHPOnCookiesCached(client);
}
/**
* Called once a client is authorized and fully in-game, and
* after all post-connection authorizations have been performed.
*
* This callback is gauranteed to occur on all clients, and always
* after each OnClientPutInServer() call.
*
* @param client Client index.
* @noreturn
*/
public OnClientPostAdminCheck(client)
{
// Forward authorized event to modules that depend on client admin info.
ClassOnClientAuthorized(client);
ClassOnClientPostAdminCheck(client);
}
/**

View File

@ -10,6 +10,11 @@
* ============================================================================
*/
/**
* Keeps track of if a client has been authorized as an admin.
*/
new bool:g_bAdminChecked[MAXPLAYERS + 1];
/* ------------------------------------
*
* GAME EVENTS
@ -62,32 +67,71 @@ ClassOnMapStart()
ClassHealthRegenInit();
}
/**
* Client has just connected to the server.
*/
ClassOnClientConnected(client)
{
// Initialize the admin checked variable.
g_bAdminChecked[client] = false;
}
/**
* Called when a client connects to the server (OnClientPutInServer).
*/
ClassClientInit(client)
{
// Check if classes are loaded successfully and the client is valid.
if (ClassValidated && ZRIsClientValid(client))
{
// Forward event to sub-modules.
ClassOverlayClientInit(client);
}
// Reset spawn flag.
ClassPlayerSpawned[client] = false;
}
/**
* Event callback for authorized clients when they're connecting.
* (OnClientPostAdminCheck)
* Called once a client is authorized and fully in-game, and
* after all post-connection authorizations have been performed.
*
* @param client Client index.
* This callback is gauranteed to occur on all clients, and always
* after each OnClientPutInServer() call.
*
* @param client Client index.
* @noreturn
*/
ClassOnClientAuthorized(client)
ClassOnClientPostAdminCheck(client)
{
// Client has been checked.
g_bAdminChecked[client] = true;
// Below this depends on client cookies.
if (!AreClientCookiesCached(client))
return;
// Check if classes are loaded successfully and the client is valid.
if (ClassValidated && ZRIsClientValid(client))
if (ClassValidated)
{
// Set default class indexes on the player.
ClassClientSetDefaultIndexes(client);
}
}
/**
* Called once a client's saved cookies have been loaded from the database.
*
* @param client Client index.
*/
ClassOnCookiesCached(client)
{
// Check if classes are loaded successfully.
if (ClassValidated)
{
// Forward event to sub-modules.
ClassOverlayOnCookiesCached(client);
}
// Below this depends on client authorization.
if (!g_bAdminChecked[client])
return;
// Check if classes are loaded successfully and the client is valid.
if (ClassValidated)
{
// Set default class indexes on the player.
ClassClientSetDefaultIndexes(client);

View File

@ -79,11 +79,11 @@ ClassOverlayOnCookiesCreate()
}
/**
* Client is joining the server.
* Called once a client's saved cookies have been loaded from the database.
*
* @param client The client index.
* @param client Client index.
*/
ClassOverlayClientInit(client)
ClassOverlayOnCookiesCached(client)
{
// Get overlay toggle cvar values.
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);

View File

@ -318,6 +318,17 @@ WeaponsClientInit(client)
ZMarketClientInit(client);
}
/**
* Called once a client's saved cookies have been loaded from the database.
*
* @param client Client index.
*/
WeaponsOnCookiesCached(client)
{
// Forward event to sub-modules.
ZMarketOnCookiesCached(client);
}
/**
* Client is leaving the server.
*

View File

@ -109,7 +109,15 @@ ZMarketClientInit(client)
// Create a new array handle to store purchase count data for client.
g_hZMarketPurchaseCount[client] = CreateTrie();
}
/**
* Called once a client's saved cookies have been loaded from the database.
*
* @param client Client index.
*/
ZMarketOnCookiesCached(client)
{
// Initialize auto-rebuy data.
decl String:zmarketautorebuy[8];
GetClientCookie(client, g_hZMarketAutoRebuyCookie, zmarketautorebuy, sizeof(zmarketautorebuy));

View File

@ -67,6 +67,17 @@ ZHPOnCookiesCreate()
* @param client The client index.
*/
ZHPClientInit(client)
{
// Reset timer handle.
tZHP[client] = INVALID_HANDLE;
}
/**
* Called once a client's saved cookies have been loaded from the database.
*
* @param client Client index.
*/
ZHPOnCookiesCached(client)
{
// Get default client setting from cvar.
new bool:zhp = GetConVarBool(g_hCvarsList[CVAR_ZHP_DEFAULT]);
@ -81,9 +92,6 @@ ZHPClientInit(client)
// Set cookie to default value from cvar.
CookiesSetClientCookieBool(client, g_hZHPEnabledCookie, zhp);
}
// Reset timer handle.
tZHP[client] = INVALID_HANDLE;
}
/**