Added skeleton SDK Tools extension.
It's no where near done - DON'T BOTHER USING IT :o --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40789
This commit is contained in:
parent
d417dea968
commit
f7aa15c06c
87
extensions/sdktools/Makefile
Normal file
87
extensions/sdktools/Makefile
Normal file
@ -0,0 +1,87 @@
|
||||
#(C)2004-2006 SourceMM Development Team
|
||||
# Makefile written by David "BAILOPAN" Anderson
|
||||
|
||||
SMSDK = ../..
|
||||
SRCDS = ~/srcds
|
||||
SOURCEMM = ../../../../sourcemm
|
||||
|
||||
#####################################
|
||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||
#####################################
|
||||
|
||||
PROJECT = sample
|
||||
|
||||
#Uncomment for SourceMM-enabled extensions
|
||||
#LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
|
||||
|
||||
OBJECTS = sdk/smsdk_ext.cpp extension.cpp
|
||||
|
||||
##############################################
|
||||
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
|
||||
##############################################
|
||||
|
||||
C_OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing
|
||||
C_DEBUG_FLAGS = -g -ggdb3
|
||||
CPP_GCC4_FLAGS = -fvisibility=hidden -fvisibility-inlines-hidden
|
||||
CPP = gcc-4.1
|
||||
|
||||
HL2PUB = $(HL2SDK)/public
|
||||
HL2LIB = $(HL2SDK)/linux_sdk
|
||||
HL2SDK = $(SOURCEMM)/hl2sdk
|
||||
SMM_TRUNK = $(SOURCEMM)/trunk
|
||||
|
||||
LINK = $(LINK_HL2) -static-libgcc
|
||||
|
||||
INCLUDE = -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \
|
||||
-I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SMM_TRUNK) -I$(SMM_TRUNK)/sourcehook -I$(SMM_TRUNK)/sourcemm \
|
||||
-I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \
|
||||
|
||||
CFLAGS = -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -fPIC -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H
|
||||
CPPFLAGS = -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
|
||||
|
||||
################################################
|
||||
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
|
||||
################################################
|
||||
|
||||
ifeq "$(DEBUG)" "true"
|
||||
BIN_DIR = Debug
|
||||
CFLAGS += $(C_DEBUG_FLAGS)
|
||||
else
|
||||
BIN_DIR = Release
|
||||
CFLAGS += $(C_OPT_FLAGS)
|
||||
endif
|
||||
|
||||
|
||||
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
|
||||
ifeq "$(GCC_VERSION)" "4"
|
||||
CPPFLAGS += $(CPP_GCC4_FLAGS)
|
||||
endif
|
||||
|
||||
BINARY = $(PROJECT).ext.so
|
||||
|
||||
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
|
||||
|
||||
$(BIN_DIR)/%.o: %.cpp
|
||||
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||
|
||||
all:
|
||||
mkdir -p $(BIN_DIR)/sdk
|
||||
ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so
|
||||
ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so
|
||||
$(MAKE) extension
|
||||
|
||||
extension: $(OBJ_LINUX)
|
||||
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
|
||||
|
||||
debug:
|
||||
$(MAKE) all DEBUG=true
|
||||
|
||||
default: all
|
||||
|
||||
clean:
|
||||
rm -rf Release/*.o
|
||||
rm -rf Release/sdk/*.o
|
||||
rm -rf Release/$(BINARY)
|
||||
rm -rf Debug/*.o
|
||||
rm -rf Debug/sdk/*.o
|
||||
rm -rf Debug/$(BINARY)
|
64
extensions/sdktools/extension.cpp
Normal file
64
extensions/sdktools/extension.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ===============================================================
|
||||
* SourceMod SDK Tools Extension
|
||||
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
||||
* ===============================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include "extension.h"
|
||||
|
||||
/**
|
||||
* @file extension.cpp
|
||||
* @brief Implement extension code here.
|
||||
*/
|
||||
|
||||
SDKTools g_SdkTools; /**< Global singleton for extension's main interface */
|
||||
IServerGameEnts *gameents = NULL;
|
||||
IBinTools *g_pBinTools = NULL;
|
||||
IPlayerManager *g_pPlayers = NULL;
|
||||
|
||||
SMEXT_LINK(&g_SdkTools);
|
||||
|
||||
bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
{
|
||||
SM_GET_IFACE(PLAYERMANAGER, g_pPlayers);
|
||||
|
||||
g_pShareSys->AddDependency(myself, "bintools.ext", true, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
||||
{
|
||||
GET_V_IFACE_CURRENT(serverFactory, gameents, IServerGameEnts, INTERFACEVERSION_SERVERGAMEENTS);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDKTools::SDK_OnAllLoaded()
|
||||
{
|
||||
SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools);
|
||||
}
|
||||
|
||||
bool SDKTools::QueryRunning(char *error, size_t maxlength)
|
||||
{
|
||||
SM_CHECK_IFACE(BINTOOLS, g_pBinTools);
|
||||
|
||||
return true;
|
||||
}
|
116
extensions/sdktools/extension.h
Normal file
116
extensions/sdktools/extension.h
Normal file
@ -0,0 +1,116 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ===============================================================
|
||||
* SourceMod SDK Tools Extension
|
||||
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
||||
* ===============================================================
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
||||
#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
||||
|
||||
/**
|
||||
* @file extension.h
|
||||
* @brief SDK Tools extension code header.
|
||||
*/
|
||||
|
||||
#include "smsdk_ext.h"
|
||||
#include <IBinTools.h>
|
||||
#include <IPlayerHelpers.h>
|
||||
|
||||
/**
|
||||
* @brief Implementation of the SDK Tools extension.
|
||||
* Note: Uncomment one of the pre-defined virtual functions in order to use it.
|
||||
*/
|
||||
class SDKTools : public SDKExtension
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief This is called after the initial loading sequence has been processed.
|
||||
*
|
||||
* @param error Error message buffer.
|
||||
* @param maxlength Size of error message buffer.
|
||||
* @param late Whether or not the module was loaded after map load.
|
||||
* @return True to succeed loading, false to fail.
|
||||
*/
|
||||
virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
|
||||
|
||||
/**
|
||||
* @brief This is called right before the extension is unloaded.
|
||||
*/
|
||||
//virtual void SDK_OnUnload();
|
||||
|
||||
/**
|
||||
* @brief This is called once all known extensions have been loaded.
|
||||
* Note: It is is a good idea to add natives here, if any are provided.
|
||||
*/
|
||||
virtual void SDK_OnAllLoaded();
|
||||
|
||||
/**
|
||||
* @brief Called when the pause state is changed.
|
||||
*/
|
||||
//virtual void SDK_OnPauseChange(bool paused);
|
||||
|
||||
/**
|
||||
* @brief this is called when Core wants to know if your extension is working.
|
||||
*
|
||||
* @param error Error message buffer.
|
||||
* @param maxlength Size of error message buffer.
|
||||
* @return True if working, false otherwise.
|
||||
*/
|
||||
virtual bool QueryRunning(char *error, size_t maxlength);
|
||||
public:
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
/**
|
||||
* @brief Called when Metamod is attached, before the extension version is called.
|
||||
*
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @param late Whether or not Metamod considers this a late load.
|
||||
* @return True to succeed, false to fail.
|
||||
*/
|
||||
virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late);
|
||||
|
||||
/**
|
||||
* @brief Called when Metamod is detaching, after the extension version is called.
|
||||
* NOTE: By default this is blocked unless sent from SourceMod.
|
||||
*
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @return True to succeed, false to fail.
|
||||
*/
|
||||
//virtual bool SDK_OnMetamodUnload(char *error, size_t maxlen);
|
||||
|
||||
/**
|
||||
* @brief Called when Metamod's pause state is changing.
|
||||
* NOTE: By default this is blocked unless sent from SourceMod.
|
||||
*
|
||||
* @param paused Pause state being set.
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @return True to succeed, false to fail.
|
||||
*/
|
||||
//virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlen);
|
||||
#endif
|
||||
};
|
||||
|
||||
extern IServerGameEnts *gameents;
|
||||
extern IBinTools *g_pBinTools;
|
||||
extern IPlayerManager *g_pPlayers;
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
20
extensions/sdktools/msvc8/sdktools.sln
Normal file
20
extensions/sdktools/msvc8/sdktools.sln
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdktools", "sdktools.vcproj", "{7A740927-C751-4312-BF9D-6367F8C508F8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7A740927-C751-4312-BF9D-6367F8C508F8}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{7A740927-C751-4312-BF9D-6367F8C508F8}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{7A740927-C751-4312-BF9D-6367F8C508F8}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{7A740927-C751-4312-BF9D-6367F8C508F8}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
240
extensions/sdktools/msvc8/sdktools.vcproj
Normal file
240
extensions/sdktools/msvc8/sdktools.vcproj
Normal file
@ -0,0 +1,240 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="sdktools"
|
||||
ProjectGUID="{7A740927-C751-4312-BF9D-6367F8C508F8}"
|
||||
RootNamespace="sdk"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\sdktools.ext.dll"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\sdktools.ext.dll"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{3FC90E55-360F-4370-ACE2-67D7691AFB97}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\extension.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{046AC4F8-1F40-462f-B652-698F87CDCA5F}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\extension.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{4B7443F9-4DC9-4e59-BC1B-465800502EBC}"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="SourceMod SDK"
|
||||
UniqueIdentifier="{223A2FA5-451B-4af5-9E85-162BF3598F7B}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\sdk\smsdk_config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\sdk\smsdk_ext.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\$(InputName)1.obj"
|
||||
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\$(InputName)1.obj"
|
||||
XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\sdk\smsdk_ext.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
48
extensions/sdktools/sdk/smsdk_config.h
Normal file
48
extensions/sdktools/sdk/smsdk_config.h
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ===============================================================
|
||||
* SourceMod, Copyright (C) 2004-2007 AlliedModders LLC.
|
||||
* All rights reserved.
|
||||
* ===============================================================
|
||||
*
|
||||
* This file is part of the SourceMod/SourcePawn SDK. This file may only be
|
||||
* used or modified under the Terms and Conditions of its License Agreement,
|
||||
* which is found in public/licenses/LICENSE.txt. As of this notice, derivative
|
||||
* works must be licensed under the GNU General Public License (version 2 or
|
||||
* greater). A copy of the GPL is included under public/licenses/GPL.txt.
|
||||
*
|
||||
* To view the latest information, see: http://www.sourcemod.net/license.php
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
|
||||
#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
|
||||
|
||||
/**
|
||||
* @file smsdk_config.h
|
||||
* @brief Contains macros for configuring basic extension information.
|
||||
*/
|
||||
|
||||
/* Basic information exposed publicly */
|
||||
#define SMEXT_CONF_NAME "SDK Tools"
|
||||
#define SMEXT_CONF_DESCRIPTION "Sample extension to help developers" /* :TODO: Describe this, heh */
|
||||
#define SMEXT_CONF_VERSION "0.0.0.0"
|
||||
#define SMEXT_CONF_AUTHOR "AlliedModders"
|
||||
#define SMEXT_CONF_URL "http://www.sourcemod.net/"
|
||||
#define SMEXT_CONF_LOGTAG "SDKTOOLS"
|
||||
#define SMEXT_CONF_LICENSE "GPL"
|
||||
#define SMEXT_CONF_DATESTRING __DATE__
|
||||
|
||||
/**
|
||||
* @brief Exposes plugin's main interface.
|
||||
*/
|
||||
#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
|
||||
|
||||
/**
|
||||
* @brief Sets whether or not this plugin required Metamod.
|
||||
* NOTE: Uncomment to enable, comment to disable.
|
||||
*/
|
||||
#define SMEXT_CONF_METAMOD
|
||||
|
||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
|
334
extensions/sdktools/sdk/smsdk_ext.cpp
Normal file
334
extensions/sdktools/sdk/smsdk_ext.cpp
Normal file
@ -0,0 +1,334 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ===============================================================
|
||||
* SourceMod, Copyright (C) 2004-2007 AlliedModders LLC.
|
||||
* All rights reserved.
|
||||
* ===============================================================
|
||||
*
|
||||
* This file is part of the SourceMod/SourcePawn SDK. This file may only be
|
||||
* used or modified under the Terms and Conditions of its License Agreement,
|
||||
* which is found in public/licenses/LICENSE.txt. As of this notice, derivative
|
||||
* works must be licensed under the GNU General Public License (version 2 or
|
||||
* greater). A copy of the GPL is included under public/licenses/GPL.txt.
|
||||
*
|
||||
* To view the latest information, see: http://www.sourcemod.net/license.php
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include "smsdk_ext.h"
|
||||
|
||||
/**
|
||||
* @file smsdk_ext.cpp
|
||||
* @brief Contains wrappers for making Extensions easier to write.
|
||||
*/
|
||||
|
||||
IShareSys *g_pShareSys = NULL; /**< Share system */
|
||||
IExtension *myself = NULL; /**< Ourself */
|
||||
IHandleSys *g_pHandleSys = NULL; /**< Handle system */
|
||||
ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
|
||||
IForwardManager *g_pForwards = NULL; /**< Forward system */
|
||||
|
||||
/** Exports the main interface */
|
||||
PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
|
||||
{
|
||||
return g_pExtensionIface;
|
||||
}
|
||||
|
||||
SDKExtension::SDKExtension()
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_SourceMMLoaded = false;
|
||||
m_WeAreUnloaded = false;
|
||||
m_WeGotPauseChange = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
|
||||
{
|
||||
g_pShareSys = sys;
|
||||
myself = me;
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_WeAreUnloaded = true;
|
||||
|
||||
if (!m_SourceMMLoaded)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
snprintf(error, maxlength, "Metamod attach failed");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
|
||||
SM_GET_IFACE(SOURCEMOD, g_pSM);
|
||||
SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
|
||||
|
||||
if (SDK_OnLoad(error, maxlength, late))
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_WeAreUnloaded = true;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SDKExtension::IsMetamodExtension()
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SDKExtension::OnExtensionPauseChange(bool state)
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_WeGotPauseChange = true;
|
||||
#endif
|
||||
SDK_OnPauseChange(state);
|
||||
}
|
||||
|
||||
void SDKExtension::OnExtensionsAllLoaded()
|
||||
{
|
||||
SDK_OnAllLoaded();
|
||||
}
|
||||
|
||||
void SDKExtension::OnExtensionUnload()
|
||||
{
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
m_WeAreUnloaded = true;
|
||||
#endif
|
||||
SDK_OnUnload();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionAuthor()
|
||||
{
|
||||
return SMEXT_CONF_AUTHOR;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionDateString()
|
||||
{
|
||||
return SMEXT_CONF_DATESTRING;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionDescription()
|
||||
{
|
||||
return SMEXT_CONF_DESCRIPTION;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionVerString()
|
||||
{
|
||||
return SMEXT_CONF_VERSION;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionName()
|
||||
{
|
||||
return SMEXT_CONF_NAME;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionTag()
|
||||
{
|
||||
return SMEXT_CONF_LOGTAG;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetExtensionURL()
|
||||
{
|
||||
return SMEXT_CONF_URL;
|
||||
}
|
||||
|
||||
bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDKExtension::SDK_OnUnload()
|
||||
{
|
||||
}
|
||||
|
||||
void SDKExtension::SDK_OnPauseChange(bool paused)
|
||||
{
|
||||
}
|
||||
|
||||
void SDKExtension::SDK_OnAllLoaded()
|
||||
{
|
||||
}
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
|
||||
PluginId g_PLID = 0; /**< Metamod plugin ID */
|
||||
ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
|
||||
SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
|
||||
ISmmAPI *g_SMAPI = NULL; /**< SourceMM API pointer */
|
||||
|
||||
IVEngineServer *engine = NULL; /**< IVEngineServer pointer */
|
||||
IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
|
||||
|
||||
/** Exposes the extension to Metamod */
|
||||
SMM_API void *PL_EXPOSURE(const char *name, int *code)
|
||||
{
|
||||
if (name && !strcmp(name, PLAPI_NAME))
|
||||
{
|
||||
if (code)
|
||||
{
|
||||
*code = IFACE_OK;
|
||||
}
|
||||
return static_cast<void *>(g_pExtensionIface);
|
||||
}
|
||||
|
||||
if (code)
|
||||
{
|
||||
*code = IFACE_FAILED;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
|
||||
{
|
||||
PLUGIN_SAVEVARS();
|
||||
|
||||
GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
|
||||
GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
|
||||
|
||||
m_SourceMMLoaded = true;
|
||||
|
||||
return SDK_OnMetamodLoad(ismm, error, maxlen, late);
|
||||
}
|
||||
|
||||
bool SDKExtension::Unload(char *error, size_t maxlen)
|
||||
{
|
||||
if (!m_WeAreUnloaded)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return SDK_OnMetamodUnload(error, maxlen);
|
||||
}
|
||||
|
||||
bool SDKExtension::Pause(char *error, size_t maxlen)
|
||||
{
|
||||
if (!m_WeGotPauseChange)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
snprintf(error, maxlen, "This extension must be paused by SourceMod.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_WeGotPauseChange = false;
|
||||
|
||||
return SDK_OnMetamodPauseChange(true, error, maxlen);
|
||||
}
|
||||
|
||||
bool SDKExtension::Unpause(char *error, size_t maxlen)
|
||||
{
|
||||
if (!m_WeGotPauseChange)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_WeGotPauseChange = false;
|
||||
|
||||
return SDK_OnMetamodPauseChange(false, error, maxlen);
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetAuthor()
|
||||
{
|
||||
return GetExtensionAuthor();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetDate()
|
||||
{
|
||||
return GetExtensionDateString();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetDescription()
|
||||
{
|
||||
return GetExtensionDescription();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetLicense()
|
||||
{
|
||||
return SMEXT_CONF_LICENSE;
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetLogTag()
|
||||
{
|
||||
return GetExtensionTag();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetName()
|
||||
{
|
||||
return GetExtensionName();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetURL()
|
||||
{
|
||||
return GetExtensionURL();
|
||||
}
|
||||
|
||||
const char *SDKExtension::GetVersion()
|
||||
{
|
||||
return GetExtensionVerString();
|
||||
}
|
||||
|
||||
bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Overload a few things to prevent libstdc++ linking */
|
||||
#if defined __linux__
|
||||
extern "C" void __cxa_pure_virtual(void)
|
||||
{
|
||||
}
|
||||
|
||||
void *operator new(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *operator new[](size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void operator delete(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void * ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
213
extensions/sdktools/sdk/smsdk_ext.h
Normal file
213
extensions/sdktools/sdk/smsdk_ext.h
Normal file
@ -0,0 +1,213 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* ===============================================================
|
||||
* SourceMod, Copyright (C) 2004-2007 AlliedModders LLC.
|
||||
* All rights reserved.
|
||||
* ===============================================================
|
||||
*
|
||||
* This file is part of the SourceMod/SourcePawn SDK. This file may only be
|
||||
* used or modified under the Terms and Conditions of its License Agreement,
|
||||
* which is found in public/licenses/LICENSE.txt. As of this notice, derivative
|
||||
* works must be licensed under the GNU General Public License (version 2 or
|
||||
* greater). A copy of the GPL is included under public/licenses/GPL.txt.
|
||||
*
|
||||
* To view the latest information, see: http://www.sourcemod.net/license.php
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
|
||||
#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
|
||||
|
||||
/**
|
||||
* @file smsdk_ext.h
|
||||
* @brief Contains wrappers for making Extensions easier to write.
|
||||
*/
|
||||
|
||||
#include "smsdk_config.h"
|
||||
#include <IExtensionSys.h>
|
||||
#include <IHandleSys.h>
|
||||
#include <sp_vm_api.h>
|
||||
#include <sm_platform.h>
|
||||
#include <ISourceMod.h>
|
||||
#include <IForwardSys.h>
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
#include <ISmmPlugin.h>
|
||||
#include <eiface.h>
|
||||
#endif
|
||||
|
||||
using namespace SourceMod;
|
||||
using namespace SourcePawn;
|
||||
|
||||
class SDKExtension :
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
public ISmmPlugin,
|
||||
#endif
|
||||
public IExtensionInterface
|
||||
{
|
||||
public:
|
||||
/** Constructor */
|
||||
SDKExtension();
|
||||
public:
|
||||
/**
|
||||
* @brief This is called after the initial loading sequence has been processed.
|
||||
*
|
||||
* @param error Error message buffer.
|
||||
* @param maxlength Size of error message buffer.
|
||||
* @param late Whether or not the module was loaded after map load.
|
||||
* @return True to succeed loading, false to fail.
|
||||
*/
|
||||
virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
|
||||
|
||||
/**
|
||||
* @brief This is called right before the extension is unloaded.
|
||||
*/
|
||||
virtual void SDK_OnUnload();
|
||||
|
||||
/**
|
||||
* @brief This is called once all known extensions have been loaded.
|
||||
*/
|
||||
virtual void SDK_OnAllLoaded();
|
||||
|
||||
/**
|
||||
* @brief Called when the pause state is changed.
|
||||
*/
|
||||
virtual void SDK_OnPauseChange(bool paused);
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
/**
|
||||
* @brief Called when Metamod is attached, before the extension version is called.
|
||||
*
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @param late Whether or not Metamod considers this a late load.
|
||||
* @return True to succeed, false to fail.
|
||||
*/
|
||||
virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
|
||||
|
||||
/**
|
||||
* @brief Called when Metamod is detaching, after the extension version is called.
|
||||
* NOTE: By default this is blocked unless sent from SourceMod.
|
||||
*
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @return True to succeed, false to fail.
|
||||
*/
|
||||
virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
|
||||
|
||||
/**
|
||||
* @brief Called when Metamod's pause state is changing.
|
||||
* NOTE: By default this is blocked unless sent from SourceMod.
|
||||
*
|
||||
* @param paused Pause state being set.
|
||||
* @param error Error buffer.
|
||||
* @param maxlength Maximum size of error buffer.
|
||||
* @return True to succeed, false to fail.
|
||||
*/
|
||||
virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
|
||||
#endif
|
||||
|
||||
public: // IExtensionInterface
|
||||
virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
|
||||
virtual void OnExtensionUnload();
|
||||
virtual void OnExtensionsAllLoaded();
|
||||
|
||||
/** Returns whether or not this is a Metamod-based extension */
|
||||
virtual bool IsMetamodExtension();
|
||||
|
||||
/**
|
||||
* @brief Called when the pause state changes.
|
||||
*
|
||||
* @param state True if being paused, false if being unpaused.
|
||||
*/
|
||||
virtual void OnExtensionPauseChange(bool state);
|
||||
|
||||
/** Returns name */
|
||||
virtual const char *GetExtensionName();
|
||||
/** Returns URL */
|
||||
virtual const char *GetExtensionURL();
|
||||
/** Returns log tag */
|
||||
virtual const char *GetExtensionTag();
|
||||
/** Returns author */
|
||||
virtual const char *GetExtensionAuthor();
|
||||
/** Returns version string */
|
||||
virtual const char *GetExtensionVerString();
|
||||
/** Returns description string */
|
||||
virtual const char *GetExtensionDescription();
|
||||
/** Returns date string */
|
||||
virtual const char *GetExtensionDateString();
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
public: // ISmmPlugin
|
||||
/** Called when the extension is attached to Metamod. */
|
||||
virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late);
|
||||
/** Returns the author to MM */
|
||||
virtual const char *GetAuthor();
|
||||
/** Returns the name to MM */
|
||||
virtual const char *GetName();
|
||||
/** Returns the description to MM */
|
||||
virtual const char *GetDescription();
|
||||
/** Returns the URL to MM */
|
||||
virtual const char *GetURL();
|
||||
/** Returns the license to MM */
|
||||
virtual const char *GetLicense();
|
||||
/** Returns the version string to MM */
|
||||
virtual const char *GetVersion();
|
||||
/** Returns the date string to MM */
|
||||
virtual const char *GetDate();
|
||||
/** Returns the logtag to MM */
|
||||
virtual const char *GetLogTag();
|
||||
/** Called on unload */
|
||||
virtual bool Unload(char *error, size_t maxlen);
|
||||
/** Called on pause */
|
||||
virtual bool Pause(char *error, size_t maxlen);
|
||||
/** Called on unpause */
|
||||
virtual bool Unpause(char *error, size_t maxlen);
|
||||
private:
|
||||
bool m_SourceMMLoaded;
|
||||
bool m_WeAreUnloaded;
|
||||
bool m_WeGotPauseChange;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern SDKExtension *g_pExtensionIface;
|
||||
|
||||
extern IShareSys *g_pShareSys;
|
||||
extern IExtension *myself;
|
||||
extern IHandleSys *g_pHandleSys;
|
||||
extern ISourceMod *g_pSM;
|
||||
extern IForwardManager *g_pForwards;
|
||||
|
||||
#if defined SMEXT_CONF_METAMOD
|
||||
PLUGIN_GLOBALVARS();
|
||||
extern IVEngineServer *engine;
|
||||
extern IServerGameDLL *gamedll;
|
||||
#endif
|
||||
|
||||
/** Creates a SourceMod interface macro pair */
|
||||
#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
|
||||
/** Automates retrieving SourceMod interfaces */
|
||||
#define SM_GET_IFACE(prefix, addr) \
|
||||
if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
|
||||
{ \
|
||||
if (error) \
|
||||
{ \
|
||||
snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
|
||||
return false; \
|
||||
} \
|
||||
}
|
||||
/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
|
||||
#define SM_GET_LATE_IFACE(prefix, addr) \
|
||||
g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
|
||||
/** Validates a SourceMod interface pointer */
|
||||
#define SM_CHECK_IFACE(prefix, addr) \
|
||||
if (!addr) \
|
||||
{ \
|
||||
if (error) \
|
||||
{ \
|
||||
snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
|
||||
return false; \
|
||||
} \
|
||||
}
|
||||
|
||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
|
Loading…
Reference in New Issue
Block a user