Fixed requiring dependencies at the wrong time.
3 * =============================================================================
4 * SourceMod Client Preferences Extension
5 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
32 #ifndef _INCLUDE_SOURCEMOD_CLIENTPREFS_COOKIE_H_
33 #define _INCLUDE_SOURCEMOD_CLIENTPREFS_COOKIE_H_
35 #include "extension.h"
37 #include "sm_trie_tpl.h"
40 #define MAX_NAME_LENGTH 30
41 #define MAX_DESC_LENGTH 255
42 #define MAX_VALUE_LENGTH 100
46 CookieAccess_Public, /**< Visible and Changeable by users */
47 CookieAccess_Protected, /**< Read only to users */
48 CookieAccess_Private, /**< Completely hidden cookie */
55 CookieData(const char *value)
57 strncpy(this->value, value, MAX_VALUE_LENGTH);
58 this->value[MAX_VALUE_LENGTH-1] = '\0';
61 char value[MAX_VALUE_LENGTH];
68 Cookie(const char *name, const char *description, CookieAccess access)
70 strncpy(this->name, name, MAX_NAME_LENGTH);
71 this->name[MAX_NAME_LENGTH-1] = '\0';
72 strncpy(this->description, description, MAX_DESC_LENGTH);
73 this->description[MAX_DESC_LENGTH-1] = '\0';
75 this->access = access;
79 for (int i=0; i<=MAXCLIENTS; i++)
87 for (int i=0; i<=MAXCLIENTS; i++)
96 char name[MAX_NAME_LENGTH];
97 char description[MAX_DESC_LENGTH];
99 CookieData *data[MAXCLIENTS+1];
103 class CookieManager : public IClientListener, public IPluginsListener
109 void OnClientAuthorized(int client, const char *authstring);
110 void OnClientDisconnecting(int client);
112 bool GetCookieValue(Cookie *pCookie, int client, char **value);
113 bool SetCookieValue(Cookie *pCookie, int client, char *value);
117 void ClientConnectCallback(int client, IQuery *data);
118 void InsertCookieCallback(Cookie *pCookie, int dbId);
119 void SelectIdCallback(Cookie *pCookie, IQuery *data);
121 Cookie *FindCookie(const char *name);
122 Cookie *CreateCookie(const char *name, const char *description, CookieAccess access);
124 bool AreClientCookiesCached(int client);
126 IForward *cookieDataLoadedForward;
128 SourceHook::List<Cookie *> cookieList;
130 IBaseMenu *clientMenu;
132 void OnPluginDestroyed(IPlugin *plugin);
135 KTrie<Cookie *> cookieTrie;
136 SourceHook::List<CookieData *> clientData[MAXCLIENTS];
138 bool connected[MAXCLIENTS+1];
139 bool statsLoaded[MAXCLIENTS+1];
142 extern CookieManager g_CookieManager;
144 #endif // _INCLUDE_SOURCEMOD_CLIENTPREFS_COOKIE_H_