Added check to make sure player are alive to perform sm_slap, sm_burn, sm_slay.
3 * ================================================================
5 * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
6 * ================================================================
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License,
10 * version 3.0, as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to
21 * link the code of this program (as well as its derivative works) to
22 * "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any
23 * Game MODs that run on software by the Valve Corporation. You must
24 * obey the GNU General Public License in all respects for all other
25 * code used. Additionally, AlliedModders LLC grants this exception
26 * to all derivative works. AlliedModders LLC defines further
27 * exceptions, found in LICENSE.txt (as of this writing, version
28 * JULY-31-2007), or <http://www.sourcemod.net/license.php>.
33 #ifndef _INCLUDE_DATABASE_MANAGER_H_
34 #define _INCLUDE_DATABASE_MANAGER_H_
36 #include <IDBDriver.h>
37 #include "sm_globals.h"
38 #include <sh_vector.h>
39 #include <sh_string.h>
41 #include <ITextParsers.h>
42 #include "sm_memtable.h"
43 #include <IThreader.h>
44 #include "sm_simple_prioqueue.h"
45 #include "PluginSys.h"
47 using namespace SourceHook;
51 ConfDbInfo() : name(-1), driver(-1), host(-1), user(-1), pass(-1),
52 database(-1), realDriver(NULL)
61 IDBDriver *realDriver;
68 public IHandleTypeDispatch,
69 public ITextListener_SMC,
71 public IThreadWorkerCallbacks,
72 public IPluginsListener
77 const char *GetInterfaceName();
78 unsigned int GetInterfaceVersion();
79 public: //SMGlobalClass
80 void OnSourceModAllInitialized();
81 void OnSourceModLevelChange(const char *mapName);
82 void OnSourceModIdentityDropped(IdentityToken_t *pToken);
83 void OnSourceModShutdown();
84 public: //IHandleTypeDispatch
85 void OnHandleDestroy(HandleType_t type, void *object);
87 void AddDriver(IDBDriver *pDrivera);
88 void RemoveDriver(IDBDriver *pDriver);
89 const DatabaseInfo *FindDatabaseConf(const char *name);
90 bool Connect(const char *name, IDBDriver **pdr, IDatabase **pdb, bool persistent, char *error, size_t maxlength);
91 unsigned int GetDriverCount();
92 IDBDriver *GetDriver(unsigned int index);
93 Handle_t CreateHandle(DBHandleType type, void *ptr, IdentityToken_t *pToken);
94 HandleError ReadHandle(Handle_t hndl, DBHandleType type, void **ptr);
95 HandleError ReleaseHandle(Handle_t hndl, DBHandleType type, IdentityToken_t *token);
96 public: //ITextListener_SMC
97 void ReadSMC_ParseStart();
98 SMCParseResult ReadSMC_NewSection(const char *name, bool opt_quotes);
99 SMCParseResult ReadSMC_KeyValue(const char *key, const char *value, bool key_quotes, bool value_quotes);
100 SMCParseResult ReadSMC_LeavingSection();
101 void ReadSMC_ParseEnd(bool halted, bool failed);
103 void RunThread(IThreadHandle *pThread);
104 void OnTerminate(IThreadHandle *pThread, bool cancel);
105 public: //IThreadWorkerCallbacks
106 void OnWorkerStart(IThreadWorker *pWorker);
107 void OnWorkerStop(IThreadWorker *pWorker);
108 public: //IPluginsListener
109 void OnPluginUnloaded(IPlugin *plugin);
111 ConfDbInfo *GetDatabaseConf(const char *name);
112 IDBDriver *FindOrLoadDriver(const char *name);
113 IDBDriver *GetDefaultDriver();
114 const char *GetDefaultDriverName();
115 bool AddToThreadQueue(IDBThreadOperation *op, PrioQueueLevel prio);
119 inline HandleType_t GetDatabaseType()
121 return m_DatabaseType;
124 void KillWorkerThread();
126 CVector<IDBDriver *> m_drivers;
128 /* Threading stuff */
129 PrioQueue<IDBThreadOperation *> m_OpQueue;
130 Queue<IDBThreadOperation *> m_ThinkQueue;
131 CVector<bool> m_drSafety; /* which drivers are safe? */
132 IThreadWorker *m_pWorker; /* Worker thread object */
133 IMutex *m_pConfigLock; /* Configuration lock */
134 IMutex *m_pQueueLock; /* Queue safety lock */
135 IMutex *m_pThinkLock; /* Think-queue lock */
137 List<ConfDbInfo> m_confs;
138 HandleType_t m_DriverType;
139 HandleType_t m_DatabaseType;
141 BaseStringTable m_StrTab;
142 char m_Filename[PLATFORM_MAX_PATH];
143 unsigned int m_ParseLevel;
144 unsigned int m_ParseState;
145 IDBDriver *m_pDefault;
148 extern DBManager g_DBMan;
150 #endif //_INCLUDE_DATABASE_MANAGER_H_