extensions/sdktools/tempents.h
author Ruben Gonzalez <drifter01620@gmail.com>
Thu May 22 09:49:27 2014 -0400 (2014-05-22)
changeset 4378 568f4497ef4a
parent 2289 44045ead61cd
permissions -rw-r--r--
Update CS:GO team score gamedata.
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod SDKTools Extension
     5  * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     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.
    11  * 
    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
    15  * details.
    16  *
    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/>.
    19  *
    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>.
    28  *
    29  * Version: $Id$
    30  */
    31 
    32 #ifndef _INCLUDE_SOURCEMOD_TEMPENTS_H_
    33 #define _INCLUDE_SOURCEMOD_TEMPENTS_H_
    34 
    35 #include "extension.h"
    36 #include <irecipientfilter.h>
    37 #include <sh_list.h>
    38 #include <sh_string.h>
    39 #include <stdio.h>
    40 
    41 class TempEntityInfo
    42 {
    43 public:
    44 	TempEntityInfo(const char *name, void *me);
    45 public:
    46 	const char *GetName();
    47 	ServerClass *GetServerClass();
    48 	bool IsValidProp(const char *name);
    49 	bool TE_SetEntData(const char *name, int value);
    50 	bool TE_SetEntDataFloat(const char *name, float value);
    51 	bool TE_SetEntDataVector(const char *name, float vector[3]);
    52 	bool TE_SetEntDataFloatArray(const char *name, cell_t *array, int size);
    53 	bool TE_GetEntData(const char *name, int *value);
    54 	bool TE_GetEntDataFloat(const char *name, float *value);
    55 	bool TE_GetEntDataVector(const char *name, float vector[3]);
    56 	void Send(IRecipientFilter &filter, float delay);
    57 private:
    58 	int _FindOffset(const char *name, int *size=NULL);
    59 private:
    60 	void *m_Me;
    61 	ServerClass *m_Sc;
    62 	SourceHook::String m_Name;
    63 };
    64 
    65 class TempEntityManager
    66 {
    67 public:
    68 	TempEntityManager() : m_NameOffs(0), m_NextOffs(0), m_GetClassNameOffs(0), m_Loaded(false) {}
    69 public:
    70 	void Initialize();
    71 	bool IsAvailable();
    72 	void Shutdown();
    73 public:
    74 	TempEntityInfo *GetTempEntityInfo(const char *name);
    75 	const char *GetNameFromThisPtr(void *me);
    76 public:
    77 	void DumpList();
    78 	void DumpProps(FILE *fp);
    79 private:
    80 	SourceHook::List<TempEntityInfo *> m_TEList;
    81 	IBasicTrie *m_TempEntInfo;
    82 	void *m_ListHead;
    83 	int m_NameOffs;
    84 	int m_NextOffs;
    85 	int m_GetClassNameOffs;
    86 	bool m_Loaded;
    87 };
    88 
    89 struct TEHookInfo
    90 {
    91 	TempEntityInfo *te;
    92 	SourceHook::List<IPluginFunction *> lst;
    93 };
    94 
    95 class TempEntHooks : public IPluginsListener
    96 {
    97 public: //IPluginsListener
    98 	void OnPluginUnloaded(IPlugin *plugin);
    99 public:
   100 	void Initialize();
   101 	void Shutdown();
   102 	bool AddHook(const char *name, IPluginFunction *pFunc);
   103 	bool RemoveHook(const char *name, IPluginFunction *pFunc);
   104 	void OnPlaybackTempEntity(IRecipientFilter &filter, float delay, const void *pSender, const SendTable *pST, int classID);
   105 private:
   106 	void _IncRefCounter();
   107 	void _DecRefCounter();
   108 	size_t _FillInPlayers(int *pl_array, IRecipientFilter *pFilter);
   109 private:
   110 	IBasicTrie *m_TEHooks;
   111 	SourceHook::List<TEHookInfo *> m_HookInfo;
   112 	size_t m_HookCount;
   113 };
   114 
   115 extern TempEntityManager g_TEManager;
   116 extern TempEntHooks s_TempEntHooks;
   117 
   118 #endif //_INCLUDE_SOURCEMOD_TEMPENTS_H_