extensions/cstrike/extension.h
author Drifter <rgr_02@comcast.net>
Sat May 26 18:31:23 2012 -0400 (2012-05-26)
changeset 3519 a116c415c73e
parent 3359 7c8cc9db0328
child 4246 6307fc19783f
permissions -rw-r--r--
Added support for CS:GO to cstrike extension (bug 5299, r=asherkin).
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod Counter-Strike:Source 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_EXTENSION_PROPER_H_
    33 #define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
    34 
    35 /**
    36  * @file extension.h
    37  * @brief Sample extension code header.
    38  */
    39 
    40 #include "smsdk_ext.h"
    41 #include "CDetour/detours.h"
    42 #include <IBinTools.h>
    43 #include <ISDKTools.h>
    44 
    45 int CallPriceForward(int client, const char *weapon_name, int price);
    46 
    47 #if SOURCE_ENGINE == SE_CSGO
    48 #define WEAPON_C4 49
    49 #define WEAPON_KNIFE 42
    50 #define WEAPON_KNIFE_GG 41
    51 #define WEAPON_KEVLAR 50
    52 #define WEAPON_ASSAULTSUIT 51
    53 #define WEAPON_NIGHTVISION 52
    54 #define WEAPON_DEFUSER 53
    55 #else
    56 #define WEAPON_C4 6
    57 #define WEAPON_KNIFE 28
    58 #define WEAPON_SHIELD 30
    59 #define WEAPON_KEVLAR 31
    60 #define WEAPON_ASSAULTSUIT 32
    61 #define WEAPON_NIGHTVISION 33
    62 #endif
    63 
    64 /**
    65  * @brief Sample implementation of the SDK Extension.
    66  * Note: Uncomment one of the pre-defined virtual functions in order to use it.
    67  */
    68 class CStrike : 
    69 	public SDKExtension,
    70 	public ICommandTargetProcessor,
    71 	public IPluginsListener
    72 {
    73 public:
    74 	/**
    75 	 * @brief This is called after the initial loading sequence has been processed.
    76 	 *
    77 	 * @param error		Error message buffer.
    78 	 * @param maxlength	Size of error message buffer.
    79 	 * @param late		Whether or not the module was loaded after map load.
    80 	 * @return			True to succeed loading, false to fail.
    81 	 */
    82 	virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
    83 	
    84 	/**
    85 	 * @brief This is called right before the extension is unloaded.
    86 	 */
    87 	virtual void SDK_OnUnload();
    88 
    89 	/**
    90 	 * @brief This is called once all known extensions have been loaded.
    91 	 * Note: It is is a good idea to add natives here, if any are provided.
    92 	 */
    93 	virtual void SDK_OnAllLoaded();
    94 
    95 	/**
    96 	 * @brief Called when the pause state is changed.
    97 	 */
    98 	//virtual void SDK_OnPauseChange(bool paused);
    99 
   100 	/**
   101 	 * @brief this is called when Core wants to know if your extension is working.
   102 	 *
   103 	 * @param error		Error message buffer.
   104 	 * @param maxlength	Size of error message buffer.
   105 	 * @return			True if working, false otherwise.
   106 	 */
   107 	virtual bool QueryRunning(char *error, size_t maxlength);
   108 
   109 	void NotifyInterfaceDrop(SMInterface *pInterface);
   110 	bool QueryInterfaceDrop(SMInterface *pInterface);
   111 
   112 	const char *GetExtensionVerString();
   113 	const char *GetExtensionDateString();
   114 public:
   115 	bool ProcessCommandTarget(cmd_target_info_t *info);
   116 public: //IPluginsListener
   117 	void OnPluginLoaded(IPlugin *plugin);
   118 	void OnPluginUnloaded(IPlugin *plugin);
   119 public:
   120 #if defined SMEXT_CONF_METAMOD
   121 	/**
   122 	 * @brief Called when Metamod is attached, before the extension version is called.
   123 	 *
   124 	 * @param error			Error buffer.
   125 	 * @param maxlength		Maximum size of error buffer.
   126 	 * @param late			Whether or not Metamod considers this a late load.
   127 	 * @return				True to succeed, false to fail.
   128 	 */
   129 	virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
   130 
   131 	/**
   132 	 * @brief Called when Metamod is detaching, after the extension version is called.
   133 	 * NOTE: By default this is blocked unless sent from SourceMod.
   134 	 *
   135 	 * @param error			Error buffer.
   136 	 * @param maxlength		Maximum size of error buffer.
   137 	 * @return				True to succeed, false to fail.
   138 	 */
   139 	//virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
   140 
   141 	/**
   142 	 * @brief Called when Metamod's pause state is changing.
   143 	 * NOTE: By default this is blocked unless sent from SourceMod.
   144 	 *
   145 	 * @param paused		Pause state being set.
   146 	 * @param error			Error buffer.
   147 	 * @param maxlength		Maximum size of error buffer.
   148 	 * @return				True to succeed, false to fail.
   149 	 */
   150 	//virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
   151 #endif
   152 private:
   153 	bool m_WeaponPriceDetourEnabled;
   154 	bool m_TerminateRoundDetourEnabled;
   155 	bool m_HandleBuyDetourEnabled;
   156 	bool m_CSWeaponDetourEnabled;
   157 };
   158 
   159 /* Interfaces from SourceMod */
   160 extern IBinTools *g_pBinTools;
   161 extern IGameConfig *g_pGameConf;
   162 extern ISDKTools *g_pSDKTools;
   163 extern int g_msgHintText;
   164 extern bool g_pIgnoreTerminateDetour;
   165 extern bool g_pIgnoreCSWeaponDropDetour;
   166 extern bool g_pTerminateRoundDetoured;
   167 extern bool g_pCSWeaponDropDetoured;
   168 extern int weaponNameOffset;
   169 
   170 #endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_