merged branch-1.1.0 back into trunk

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401960
This commit is contained in:
David Anderson 2008-03-26 03:52:37 +00:00
parent 3bcd296d99
commit c5af41d983
52 changed files with 8062 additions and 39 deletions

124
extensions/regex/CRegEx.cpp Normal file
View File

@ -0,0 +1,124 @@
#include "pcre.h"
#include "CRegEx.h"
#include <sh_string.h>
#include "extension.h"
RegEx::RegEx()
{
mErrorOffset = 0;
mError = NULL;
re = NULL;
mFree = true;
subject = NULL;
mSubStrings = 0;
}
void RegEx::Clear ()
{
mErrorOffset = 0;
mError = NULL;
if (re)
pcre_free(re);
re = NULL;
mFree = true;
if (subject)
delete [] subject;
subject = NULL;
mSubStrings = 0;
}
RegEx::~RegEx()
{
Clear();
}
bool RegEx::isFree(bool set, bool val)
{
if (set)
{
mFree = val;
return true;
} else {
return mFree;
}
}
int RegEx::Compile(const char *pattern, int iFlags)
{
if (!mFree)
Clear();
re = pcre_compile(pattern, iFlags, &mError, &mErrorOffset, NULL);
if (re == NULL)
{
return 0;
}
mFree = false;
return 1;
}
int RegEx::Match(const char *str)
{
int rc = 0;
if (mFree || re == NULL)
return -1;
this->ClearMatch();
//save str
subject = new char[strlen(str)+1];
strcpy(subject, str);
rc = pcre_exec(re, NULL, subject, (int)strlen(subject), 0, 0, ovector, 30);
if (rc < 0)
{
if (rc == PCRE_ERROR_NOMATCH)
{
return 0;
} else {
mErrorOffset = rc;
return -1;
}
}
mSubStrings = rc;
return 1;
}
void RegEx::ClearMatch()
{
// Clears match results
mErrorOffset = 0;
mError = NULL;
if (subject)
delete [] subject;
subject = NULL;
mSubStrings = 0;
}
const char *RegEx::GetSubstring(int s, char buffer[], int max)
{
int i = 0;
if (s >= mSubStrings || s < 0)
return NULL;
char *substr_a = subject + ovector[2*s];
int substr_l = ovector[2*s+1] - ovector[2*s];
for (i = 0; i<substr_l; i++)
{
if (i >= max)
break;
buffer[i] = substr_a[i];
}
buffer[i] = '\0';
return buffer;
}

28
extensions/regex/CRegEx.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef _INCLUDE_CREGEX_H
#define _INCLUDE_CREGEX_H
class RegEx
{
public:
RegEx();
~RegEx();
bool isFree(bool set=false, bool val=false);
void Clear();
int Compile(const char *pattern, int iFlags);
int Match(const char *str);
void ClearMatch();
const char *GetSubstring(int s, char buffer[], int max);
public:
int mErrorOffset;
const char *mError;
int mSubStrings;
private:
pcre *re;
bool mFree;
int ovector[30];
char *subject;
};
#endif //_INCLUDE_CREGEX_H

View File

@ -0,0 +1,89 @@
#(C)2004-2007 AlliedModders LLC
#
# This sample Makefile is designed for SourceMod extensions that
# are built against Metamod:Source 1.4.2, Episode 1 of the HL2SDK.
#
SMSDK = ../..
SRCDS = ~/srcds
SOURCEMM = ../../../sourcemm
HL2SDK = ../../../hl2sdk
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################
PROJECT = regex
#Uncomment for SourceMM-enabled extensions
LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
OBJECTS = sdk/smsdk_ext.cpp extension.cpp CRegEx.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
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$(SOURCEMM) -I$(SOURCEMM)/sourcehook -I$(SOURCEMM)/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 -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -Wno-uninitialized
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) -f Makefile.ep1 extension
extension: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
debug:
$(MAKE) -f Makefile.ep1 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)

View File

@ -0,0 +1,91 @@
#(C)2004-2007 AlliedModders LLC
#
# This sample Makefile is designed for SourceMod extensions that
# are built against Metamod:Source 1.6.0, Episode 2 of the HL2SDK.
#
SMSDK = ../..
SRCDS = ~/srcds
SOURCEMM = ../../../sourcemm
HL2SDK = ../../../hl2sdk-ob
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################
PROJECT = regex
#Uncomment for SourceMM-enabled extensions
LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
OBJECTS = sdk/smsdk_ext.cpp extension.cpp CRegEx.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
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$(SOURCEMM) -I$(SOURCEMM)/sourcehook -I$(SOURCEMM)/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 -mfpmath=sse \
-msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -Wno-uninitialized -DORANGEBOX_BUILD
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)/orangebox/bin/vstdlib_i486.so vstdlib_i486.so
ln -sf $(SRCDS)/orangebox/bin/tier0_i486.so tier0_i486.so
$(MAKE) -f Makefile.ep1 extension
extension: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
debug:
$(MAKE) -f Makefile.ep1 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)

View File

@ -0,0 +1,90 @@
#(C)2004-2007 AlliedModders LLC
#
# This sample Makefile is designed for SourceMod extensions that
# are built against Metamod:Source 1.6.0, Episode 1 of the HL2SDK.
SMSDK = ../..
SRCDS = ~/srcds
SOURCEMM = ../../../sourcemm-1.4.2
HL2SDK = ../../../hl2sdk
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################
PROJECT = regex
#Uncomment for SourceMM-enabled extensions
LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
OBJECTS = sdk/smsdk_ext.cpp extension.cpp CRegEx.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
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$(SOURCEMM) -I$(SOURCEMM)/sourcehook -I$(SOURCEMM)/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 -mfpmath=sse \
-msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -Wno-uninitialized
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) -f Makefile.orig extension
extension: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
debug:
$(MAKE) -f Makefile.orig 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)

View File

@ -0,0 +1,188 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Sample 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "extension.h"
#include <sh_string.h>
#include "pcre.h"
#include "CRegEx.h"
using namespace SourceHook;
/**
* @file extension.cpp
* @brief Implement extension code here.
*/
RegexExtension g_RegexExtension; /**< Global singleton for extension's main interface */
SMEXT_LINK(&g_RegexExtension);
RegexHandler g_RegexHandler;
HandleType_t g_RegexHandle=0;
bool RegexExtension::SDK_OnLoad(char *error, size_t err_max, bool late)
{
g_pShareSys->AddNatives(myself,regex_natives);
g_RegexHandle = g_pHandleSys->CreateType("Regex", &g_RegexHandler, 0, NULL, NULL, myself->GetIdentity(), NULL);
return true;
}
void RegexExtension::SDK_OnUnload()
{
g_pHandleSys->RemoveType(g_RegexHandle, myself->GetIdentity());
}
static cell_t CompileRegex(IPluginContext *pCtx, const cell_t *params)
{
char *regex;
pCtx->LocalToString(params[1], &regex);
RegEx *x = new RegEx();
if (x->Compile(regex, params[2]) == 0)
{
cell_t *eOff;
pCtx->LocalToPhysAddr(params[5], &eOff);
const char *err = x->mError;
*eOff = x->mErrorOffset;
pCtx->StringToLocal(params[3], params[4], err ? err:"unknown");
return 0;
}
return g_pHandleSys->CreateHandle(g_RegexHandle, (void*)x, pCtx->GetIdentity(), myself->GetIdentity(), NULL);
}
static cell_t MatchRegex(IPluginContext *pCtx, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
HandleSecurity sec;
sec.pOwner = NULL;
sec.pIdentity = myself->GetIdentity();
RegEx *x;
if ((err=g_pHandleSys->ReadHandle(hndl, g_RegexHandle, &sec, (void **)&x)) != HandleError_None)
{
return pCtx->ThrowNativeError("Invalid file handle %x (error %d)", hndl, err);
}
if (!x)
{
pCtx->ThrowNativeError("Regex data not found\n");
return 0;
}
char *str;
pCtx->LocalToString(params[2], &str);
int e = x->Match(str);
if (e == -1)
{
/* there was a match error. move on. */
cell_t *res;
pCtx->LocalToPhysAddr(params[3], &res);
*res = x->mErrorOffset;
/* only clear the match results, since the regex object
may still be referenced later */
x->ClearMatch();
return -1;
}
else if (e == 0)
{
/* only clear the match results, since the regex object
may still be referenced later */
x->ClearMatch();
return 0;
}
else
{
return x->mSubStrings;
}
}
static cell_t GetRegexSubString(IPluginContext *pCtx, const cell_t *params)
{
Handle_t hndl=static_cast<Handle_t>(params[1]);
HandleError err;
HandleSecurity sec;
sec.pOwner=NULL;
sec.pIdentity=myself->GetIdentity();
RegEx *x;
if ((err=g_pHandleSys->ReadHandle(hndl, g_RegexHandle, &sec, (void **)&x)) != HandleError_None)
{
return pCtx->ThrowNativeError("Invalid file handle %x (error %d)", hndl, err);
}
if (!x)
{
pCtx->ThrowNativeError("Regex data not found\n");
return 0;
}
static char buffer[4096];
const char *ret=x->GetSubstring(params[2], buffer, sizeof(buffer));
if(!ret)
{
return 0;
}
pCtx->StringToLocalUTF8(params[3], params[4], ret, NULL);
return 1;
}
void RegexHandler::OnHandleDestroy(HandleType_t type, void *object)
{
RegEx *x = (RegEx *)object;
x->Clear();
delete x;
}
const sp_nativeinfo_t regex_natives[] =
{
{"GetRegexSubString", GetRegexSubString},
{"MatchRegex", MatchRegex},
{"CompileRegex", CompileRegex},
{NULL, NULL},
};

View File

@ -0,0 +1,133 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Sample 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
/**
* @file extension.h
* @brief Sample extension code header.
*/
#include "smsdk_ext.h"
/**
* @brief Sample implementation of the SDK Extension.
* Note: Uncomment one of the pre-defined virtual functions in order to use it.
*/
class RegexExtension : 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 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
};
class RegexHandler: public IHandleTypeDispatch
{
public:
void OnHandleDestroy(HandleType_t type, void *object);
};
extern RegexHandler g_RegexHandler;
extern HandleType_t g_RegexHandle;
// Natives
extern const sp_nativeinfo_t regex_natives[];
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "regex", "sdk.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug - Episode 1|Win32 = Debug - Episode 1|Win32
Debug - Orange Box|Win32 = Debug - Orange Box|Win32
Release - Episode 1|Win32 = Release - Episode 1|Win32
Release - Orange Box|Win32 = Release - Orange Box|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode 1|Win32.ActiveCfg = Debug|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode 1|Win32.Build.0 = Debug|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.ActiveCfg = Release|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.Build.0 = Release|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,422 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="regex"
ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
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;..\..;..\systems;..\..\..\public;..\..\..\public\sourcepawn;&quot;$(SOURCEMM142)&quot;;&quot;$(SOURCEMM142)\sourcemm&quot;;&quot;$(SOURCEMM142)\sourcehook&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\game\server&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(HL2SDK)\tier1&quot;;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="false"
AdditionalDependencies="..\lib_win\pcre.lib &quot;$(HL2SDK)\lib\public\tier0.lib&quot; &quot;$(HL2SDK)\lib\public\tier1.lib&quot; &quot;$(HL2SDK)\lib\public\vstdlib.lib&quot; &quot;$(HL2SDK)\lib\public\mathlib.lib&quot;"
OutputFile="$(OutDir)\regex.ext.dll"
LinkIncremental="2"
IgnoreDefaultLibraryNames="LIBCMTD"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="0"
EnableCOMDATFolding="0"
ImportLibrary="$(OutDir)/sdk.lib"
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"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\;..\sdk;..\..;..\systems;..\..\..\public;..\..\..\public\sourcepawn;&quot;$(SOURCEMM142)&quot;;&quot;$(SOURCEMM142)\sourcemm&quot;;&quot;$(SOURCEMM142)\sourcehook&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public&quot;;&quot;$(HL2SDK)\public\engine&quot;;&quot;$(HL2SDK)\public\game\server&quot;;&quot;$(HL2SDK)\public\mathlib&quot;;&quot;$(HL2SDK)\public\tier0&quot;;&quot;$(HL2SDK)\public\tier1&quot;;&quot;$(HL2SDK)\public\vstdlib&quot;;&quot;$(HL2SDK)\tier1&quot;;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\lib_win\pcre.lib &quot;$(HL2SDK)\lib\public\tier0.lib&quot; &quot;$(HL2SDK)\lib\public\tier1.lib&quot; &quot;$(HL2SDK)\lib\public\vstdlib.lib&quot; &quot;$(HL2SDK)\lib\public\mathlib.lib&quot;"
OutputFile="$(OutDir)\regex.ext.dll"
LinkIncremental="1"
IgnoreDefaultLibraryNames="LIBCMT"
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>
<Configuration
Name="Debug - Orange Box|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;..\..;..\systems;..\..\..\public;..\..\..\public\sourcepawn;&quot;$(SOURCEMM16)&quot;;&quot;$(SOURCEMM16)\sourcemm&quot;;&quot;$(SOURCEMM16)\sourcehook&quot;;&quot;$(HL2SDKOB)\public\tier1&quot;;&quot;$(HL2SDKOB)\public&quot;;&quot;$(HL2SDKOB)\public\engine&quot;;&quot;$(HL2SDKOB)\public\game\server&quot;;&quot;$(HL2SDKOB)\public\mathlib&quot;;&quot;$(HL2SDKOB)\public\tier0&quot;;&quot;$(HL2SDKOB)\public\tier1&quot;;&quot;$(HL2SDKOB)\public\vstdlib&quot;;&quot;$(HL2SDKOB)\tier1&quot;;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="false"
AdditionalDependencies="..\lib_win\pcre.lib &quot;$(HL2SDKOB)\lib\public\tier0.lib&quot; &quot;$(HL2SDKOB)\lib\public\tier1.lib&quot; &quot;$(HL2SDKOB)\lib\public\vstdlib.lib&quot; &quot;$(HL2SDKOB)\lib\public\mathlib.lib&quot;"
OutputFile="$(OutDir)\regex.ext.dll"
LinkIncremental="2"
IgnoreDefaultLibraryNames="LIBCMTD"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="0"
EnableCOMDATFolding="0"
ImportLibrary="$(OutDir)/sdk.lib"
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 - Orange Box|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"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\;..\sdk;..\..;..\systems;..\..\..\public;..\..\..\public\sourcepawn;&quot;$(SOURCEMM16)&quot;;&quot;$(SOURCEMM16)\sourcemm&quot;;&quot;$(SOURCEMM16)\sourcehook&quot;;&quot;$(HL2SDKOB)\public\tier1&quot;;&quot;$(HL2SDKOB)\public&quot;;&quot;$(HL2SDKOB)\public\engine&quot;;&quot;$(HL2SDKOB)\public\game\server&quot;;&quot;$(HL2SDKOB)\public\mathlib&quot;;&quot;$(HL2SDKOB)\public\tier0&quot;;&quot;$(HL2SDKOB)\public\tier1&quot;;&quot;$(HL2SDKOB)\public\vstdlib&quot;;&quot;$(HL2SDKOB)\tier1&quot;;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\lib_win\pcre.lib &quot;$(HL2SDKOB)\lib\public\tier0.lib&quot; &quot;$(HL2SDKOB)\lib\public\tier1.lib&quot; &quot;$(HL2SDKOB)\lib\public\vstdlib.lib&quot; &quot;$(HL2SDKOB)\lib\public\mathlib.lib&quot;"
OutputFile="$(OutDir)\regex.ext.dll"
LinkIncremental="1"
IgnoreDefaultLibraryNames="LIBCMT"
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="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\CRegEx.cpp"
>
</File>
<File
RelativePath="..\extension.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\CRegEx.h"
>
</File>
<File
RelativePath="..\extension.h"
>
</File>
<File
RelativePath="..\pcre.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="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<Filter
Name="SourceMod SDK"
UniqueIdentifier="{31958233-BB2D-4e41-A8F9-CE8A4684F436}"
>
<File
RelativePath="..\sdk\smsdk_config.h"
>
</File>
<File
RelativePath="..\sdk\smsdk_ext.cpp"
>
</File>
<File
RelativePath="..\sdk\smsdk_ext.h"
>
</File>
</Filter>
<Filter
Name="Library Files"
>
<File
RelativePath="..\lib_win\pcre.lib"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

305
extensions/regex/pcre.h Normal file
View File

@ -0,0 +1,305 @@
/*************************************************
* Perl-Compatible Regular Expressions *
*************************************************/
/* This is the public header file for the PCRE library, to be #included by
applications that call the PCRE functions.
Copyright (c) 1997-2007 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the University of Cambridge nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------------
*/
#ifndef _PCRE_H
#define _PCRE_H
/* The current PCRE version information. */
#define PCRE_MAJOR 7
#define PCRE_MINOR 4
#define PCRE_PRERELEASE
#define PCRE_DATE 2007-09-21
/* When an application links to a PCRE DLL in Windows, the symbols that are
imported have to be identified as such. When building PCRE, the appropriate
export setting is defined in pcre_internal.h, which includes this file. So we
don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
#define PCRE_STATIC
#if defined(_WIN32) && !defined(PCRE_STATIC)
# ifndef PCRE_EXP_DECL
# define PCRE_EXP_DECL extern __declspec(dllimport)
# endif
# ifdef __cplusplus
# ifndef PCRECPP_EXP_DECL
# define PCRECPP_EXP_DECL extern __declspec(dllimport)
# endif
# ifndef PCRECPP_EXP_DEFN
# define PCRECPP_EXP_DEFN __declspec(dllimport)
# endif
# endif
#endif
/* By default, we use the standard "extern" declarations. */
#ifndef PCRE_EXP_DECL
# ifdef __cplusplus
# define PCRE_EXP_DECL extern "C"
# else
# define PCRE_EXP_DECL extern
# endif
#endif
#ifdef __cplusplus
# ifndef PCRECPP_EXP_DECL
# define PCRECPP_EXP_DECL extern
# endif
# ifndef PCRECPP_EXP_DEFN
# define PCRECPP_EXP_DEFN
# endif
#endif
/* Have to include stdlib.h in order to ensure that size_t is defined;
it is needed here for malloc. */
#include <stdlib.h>
/* Allow for C++ users */
#ifdef __cplusplus
extern "C" {
#endif
/* Options */
#define PCRE_CASELESS 0x00000001
#define PCRE_MULTILINE 0x00000002
#define PCRE_DOTALL 0x00000004
#define PCRE_EXTENDED 0x00000008
#define PCRE_ANCHORED 0x00000010
#define PCRE_DOLLAR_ENDONLY 0x00000020
#define PCRE_EXTRA 0x00000040
#define PCRE_NOTBOL 0x00000080
#define PCRE_NOTEOL 0x00000100
#define PCRE_UNGREEDY 0x00000200
#define PCRE_NOTEMPTY 0x00000400
#define PCRE_UTF8 0x00000800
#define PCRE_NO_AUTO_CAPTURE 0x00001000
#define PCRE_NO_UTF8_CHECK 0x00002000
#define PCRE_AUTO_CALLOUT 0x00004000
#define PCRE_PARTIAL 0x00008000
#define PCRE_DFA_SHORTEST 0x00010000
#define PCRE_DFA_RESTART 0x00020000
#define PCRE_FIRSTLINE 0x00040000
#define PCRE_DUPNAMES 0x00080000
#define PCRE_NEWLINE_CR 0x00100000
#define PCRE_NEWLINE_LF 0x00200000
#define PCRE_NEWLINE_CRLF 0x00300000
#define PCRE_NEWLINE_ANY 0x00400000
#define PCRE_NEWLINE_ANYCRLF 0x00500000
#define PCRE_BSR_ANYCRLF 0x00800000
#define PCRE_BSR_UNICODE 0x01000000
/* Exec-time and get/set-time error codes */
#define PCRE_ERROR_NOMATCH (-1)
#define PCRE_ERROR_NULL (-2)
#define PCRE_ERROR_BADOPTION (-3)
#define PCRE_ERROR_BADMAGIC (-4)
#define PCRE_ERROR_UNKNOWN_OPCODE (-5)
#define PCRE_ERROR_UNKNOWN_NODE (-5) /* For backward compatibility */
#define PCRE_ERROR_NOMEMORY (-6)
#define PCRE_ERROR_NOSUBSTRING (-7)
#define PCRE_ERROR_MATCHLIMIT (-8)
#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
#define PCRE_ERROR_BADUTF8 (-10)
#define PCRE_ERROR_BADUTF8_OFFSET (-11)
#define PCRE_ERROR_PARTIAL (-12)
#define PCRE_ERROR_BADPARTIAL (-13)
#define PCRE_ERROR_INTERNAL (-14)
#define PCRE_ERROR_BADCOUNT (-15)
#define PCRE_ERROR_DFA_UITEM (-16)
#define PCRE_ERROR_DFA_UCOND (-17)
#define PCRE_ERROR_DFA_UMLIMIT (-18)
#define PCRE_ERROR_DFA_WSSIZE (-19)
#define PCRE_ERROR_DFA_RECURSE (-20)
#define PCRE_ERROR_RECURSIONLIMIT (-21)
#define PCRE_ERROR_NULLWSLIMIT (-22) /* No longer actually used */
#define PCRE_ERROR_BADNEWLINE (-23)
/* Request types for pcre_fullinfo() */
#define PCRE_INFO_OPTIONS 0
#define PCRE_INFO_SIZE 1
#define PCRE_INFO_CAPTURECOUNT 2
#define PCRE_INFO_BACKREFMAX 3
#define PCRE_INFO_FIRSTBYTE 4
#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */
#define PCRE_INFO_FIRSTTABLE 5
#define PCRE_INFO_LASTLITERAL 6
#define PCRE_INFO_NAMEENTRYSIZE 7
#define PCRE_INFO_NAMECOUNT 8
#define PCRE_INFO_NAMETABLE 9
#define PCRE_INFO_STUDYSIZE 10
#define PCRE_INFO_DEFAULT_TABLES 11
#define PCRE_INFO_OKPARTIAL 12
#define PCRE_INFO_JCHANGED 13
#define PCRE_INFO_HASCRORLF 14
/* Request types for pcre_config(). Do not re-arrange, in order to remain
compatible. */
#define PCRE_CONFIG_UTF8 0
#define PCRE_CONFIG_NEWLINE 1
#define PCRE_CONFIG_LINK_SIZE 2
#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3
#define PCRE_CONFIG_MATCH_LIMIT 4
#define PCRE_CONFIG_STACKRECURSE 5
#define PCRE_CONFIG_UNICODE_PROPERTIES 6
#define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7
#define PCRE_CONFIG_BSR 8
/* Bit flags for the pcre_extra structure. Do not re-arrange or redefine
these bits, just add new ones on the end, in order to remain compatible. */
#define PCRE_EXTRA_STUDY_DATA 0x0001
#define PCRE_EXTRA_MATCH_LIMIT 0x0002
#define PCRE_EXTRA_CALLOUT_DATA 0x0004
#define PCRE_EXTRA_TABLES 0x0008
#define PCRE_EXTRA_MATCH_LIMIT_RECURSION 0x0010
/* Types */
struct real_pcre; /* declaration; the definition is private */
typedef struct real_pcre pcre;
/* When PCRE is compiled as a C++ library, the subject pointer type can be
replaced with a custom type. For conventional use, the public interface is a
const char *. */
#ifndef PCRE_SPTR
#define PCRE_SPTR const char *
#endif
/* The structure for passing additional data to pcre_exec(). This is defined in
such as way as to be extensible. Always add new fields at the end, in order to
remain compatible. */
typedef struct pcre_extra {
unsigned long int flags; /* Bits for which fields are set */
void *study_data; /* Opaque data from pcre_study() */
unsigned long int match_limit; /* Maximum number of calls to match() */
void *callout_data; /* Data passed back in callouts */
const unsigned char *tables; /* Pointer to character tables */
unsigned long int match_limit_recursion; /* Max recursive calls to match() */
} pcre_extra;
/* The structure for passing out data via the pcre_callout_function. We use a
structure so that new fields can be added on the end in future versions,
without changing the API of the function, thereby allowing old clients to work
without modification. */
typedef struct pcre_callout_block {
int version; /* Identifies version of block */
/* ------------------------ Version 0 ------------------------------- */
int callout_number; /* Number compiled into pattern */
int *offset_vector; /* The offset vector */
PCRE_SPTR subject; /* The subject being matched */
int subject_length; /* The length of the subject */
int start_match; /* Offset to start of this match attempt */
int current_position; /* Where we currently are in the subject */
int capture_top; /* Max current capture */
int capture_last; /* Most recently closed capture */
void *callout_data; /* Data passed in with the call */
/* ------------------- Added for Version 1 -------------------------- */
int pattern_position; /* Offset to next item in the pattern */
int next_item_length; /* Length of next item in the pattern */
/* ------------------------------------------------------------------ */
} pcre_callout_block;
/* Indirection for store get and free functions. These can be set to
alternative malloc/free functions if required. Special ones are used in the
non-recursive case for "frames". There is also an optional callout function
that is triggered by the (?) regex item. For Virtual Pascal, these definitions
have to take another form. */
#ifndef VPCOMPAT
PCRE_EXP_DECL void *(*pcre_malloc)(size_t);
PCRE_EXP_DECL void (*pcre_free)(void *);
PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
PCRE_EXP_DECL void (*pcre_stack_free)(void *);
PCRE_EXP_DECL int (*pcre_callout)(pcre_callout_block *);
#else /* VPCOMPAT */
PCRE_EXP_DECL void *pcre_malloc(size_t);
PCRE_EXP_DECL void pcre_free(void *);
PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
PCRE_EXP_DECL void pcre_stack_free(void *);
PCRE_EXP_DECL int pcre_callout(pcre_callout_block *);
#endif /* VPCOMPAT */
/* Exported PCRE functions */
PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
const unsigned char *);
PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
int *, const unsigned char *);
PCRE_EXP_DECL int pcre_config(int, void *);
PCRE_EXP_DECL int pcre_copy_named_substring(const pcre *, const char *,
int *, int, const char *, char *, int);
PCRE_EXP_DECL int pcre_copy_substring(const char *, int *, int, int, char *,
int);
PCRE_EXP_DECL int pcre_dfa_exec(const pcre *, const pcre_extra *,
const char *, int, int, int, int *, int , int *, int);
PCRE_EXP_DECL int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
int, int, int, int *, int);
PCRE_EXP_DECL void pcre_free_substring(const char *);
PCRE_EXP_DECL void pcre_free_substring_list(const char **);
PCRE_EXP_DECL int pcre_fullinfo(const pcre *, const pcre_extra *, int,
void *);
PCRE_EXP_DECL int pcre_get_named_substring(const pcre *, const char *,
int *, int, const char *, const char **);
PCRE_EXP_DECL int pcre_get_stringnumber(const pcre *, const char *);
PCRE_EXP_DECL int pcre_get_stringtable_entries(const pcre *, const char *,
char **, char **);
PCRE_EXP_DECL int pcre_get_substring(const char *, int *, int, int,
const char **);
PCRE_EXP_DECL int pcre_get_substring_list(const char *, int *, int,
const char ***);
PCRE_EXP_DECL int pcre_info(const pcre *, int *, int *);
PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
PCRE_EXP_DECL int pcre_refcount(pcre *, int);
PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
PCRE_EXP_DECL const char *pcre_version(void);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* End of pcre.h */

View File

@ -0,0 +1,79 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Sample 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <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 "Regex"
#define SMEXT_CONF_DESCRIPTION "Provides regex natives for plugins"
#define SMEXT_CONF_VERSION "SVN_FULL_VERSION"
#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
#define SMEXT_CONF_URL "http://www.sourcemod.net/"
#define SMEXT_CONF_LOGTAG "REGEX"
#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
/** Enable interfaces you want to use here by uncommenting lines */
//#define SMEXT_ENABLE_FORWARDSYS
#define SMEXT_ENABLE_HANDLESYS
//#define SMEXT_ENABLE_PLAYERHELPERS
//#define SMEXT_ENABLE_DBMANAGER
//#define SMEXT_ENABLE_GAMECONF
//#define SMEXT_ENABLE_MEMUTILS
//#define SMEXT_ENABLE_GAMEHELPERS
//#define SMEXT_ENABLE_TIMERSYS
//#define SMEXT_ENABLE_THREADER
//#define SMEXT_ENABLE_LIBSYS
//#define SMEXT_ENABLE_MENUS
//#define SMEXT_ENABLE_ADTFACTORY
//#define SMEXT_ENABLE_PLUGINSYS
//#define SMEXT_ENABLE_ADMINSYS
//#define SMEXT_ENABLE_TEXTPARSERS
#define SMEXT_ENABLE_USERMSGS
#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_

View File

@ -0,0 +1,455 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Base Extension Code
* 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <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.
*/
IExtension *myself = NULL; /**< Ourself */
IShareSys *g_pShareSys = NULL; /**< Share system */
IShareSys *sharesys = NULL; /**< Share system */
ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
ISourceMod *smutils = NULL; /**< SourceMod helpers */
#if defined SMEXT_ENABLE_FORWARDSYS
IForwardManager *g_pForwards = NULL; /**< Forward system */
IForwardManager *forwards = NULL; /**< Forward system */
#endif
#if defined SMEXT_ENABLE_HANDLESYS
IHandleSys *g_pHandleSys = NULL; /**< Handle system */
IHandleSys *handlesys = NULL; /**< Handle system */
#endif
#if defined SMEXT_ENABLE_PLAYERHELPERS
IPlayerManager *playerhelpers = NULL; /**< Player helpers */
#endif //SMEXT_ENABLE_PLAYERHELPERS
#if defined SMEXT_ENABLE_DBMANAGER
IDBManager *dbi = NULL; /**< DB Manager */
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_GAMECONF
IGameConfigManager *gameconfs = NULL; /**< Game config manager */
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_MEMUTILS
IMemoryUtils *memutils = NULL;
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_GAMEHELPERS
IGameHelpers *gamehelpers = NULL;
#endif
#if defined SMEXT_ENABLE_TIMERSYS
ITimerSystem *timersys = NULL;
#endif
#if defined SMEXT_ENABLE_ADTFACTORY
IADTFactory *adtfactory = NULL;
#endif
#if defined SMEXT_ENABLE_THREADER
IThreader *threader = NULL;
#endif
#if defined SMEXT_ENABLE_LIBSYS
ILibrarySys *libsys = NULL;
#endif
#if defined SMEXT_ENABLE_PLUGINSYS
SourceMod::IPluginManager *plsys;
#endif
#if defined SMEXT_ENABLE_MENUS
IMenuManager *menus = NULL;
#endif
#if defined SMEXT_ENABLE_ADMINSYS
IAdminSystem *adminsys = NULL;
#endif
#if defined SMEXT_ENABLE_TEXTPARSERS
ITextParsers *textparsers = NULL;
#endif
#if defined SMEXT_ENABLE_USERMSGS
IUserMessages *usermsgs = NULL;
#endif
/** 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 = sharesys = 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(SOURCEMOD, g_pSM);
smutils = g_pSM;
#if defined SMEXT_ENABLE_HANDLESYS
SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
handlesys = g_pHandleSys;
#endif
#if defined SMEXT_ENABLE_FORWARDSYS
SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
forwards = g_pForwards;
#endif
#if defined SMEXT_ENABLE_PLAYERHELPERS
SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
#endif
#if defined SMEXT_ENABLE_DBMANAGER
SM_GET_IFACE(DBI, dbi);
#endif
#if defined SMEXT_ENABLE_GAMECONF
SM_GET_IFACE(GAMECONFIG, gameconfs);
#endif
#if defined SMEXT_ENABLE_MEMUTILS
SM_GET_IFACE(MEMORYUTILS, memutils);
#endif
#if defined SMEXT_ENABLE_GAMEHELPERS
SM_GET_IFACE(GAMEHELPERS, gamehelpers);
#endif
#if defined SMEXT_ENABLE_TIMERSYS
SM_GET_IFACE(TIMERSYS, timersys);
#endif
#if defined SMEXT_ENABLE_ADTFACTORY
SM_GET_IFACE(ADTFACTORY, adtfactory);
#endif
#if defined SMEXT_ENABLE_THREADER
SM_GET_IFACE(THREADER, threader);
#endif
#if defined SMEXT_ENABLE_LIBSYS
SM_GET_IFACE(LIBRARYSYS, libsys);
#endif
#if defined SMEXT_ENABLE_PLUGINSYS
SM_GET_IFACE(PLUGINSYSTEM, plsys);
#endif
#if defined SMEXT_ENABLE_MENUS
SM_GET_IFACE(MENUMANAGER, menus);
#endif
#if defined SMEXT_ENABLE_ADMINSYS
SM_GET_IFACE(ADMINSYS, adminsys);
#endif
#if defined SMEXT_ENABLE_TEXTPARSERS
SM_GET_IFACE(TEXTPARSERS, textparsers);
#endif
#if defined SMEXT_ENABLE_USERMSGS
SM_GET_IFACE(USERMSGS, usermsgs);
#endif
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 defined METAMOD_PLAPI_VERSION
if (name && !strcmp(name, METAMOD_PLAPI_NAME))
#else
if (name && !strcmp(name, PLAPI_NAME))
#endif
{
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();
#if defined METAMOD_PLAPI_VERSION
GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
#else
GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
#endif
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

View File

@ -0,0 +1,327 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Base Extension Code
* 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <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>
#if defined SMEXT_ENABLE_FORWARDSYS
#include <IForwardSys.h>
#endif //SMEXT_ENABLE_FORWARDSYS
#if defined SMEXT_ENABLE_PLAYERHELPERS
#include <IPlayerHelpers.h>
#endif //SMEXT_ENABLE_PlAYERHELPERS
#if defined SMEXT_ENABLE_DBMANAGER
#include <IDBDriver.h>
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_GAMECONF
#include <IGameConfigs.h>
#endif
#if defined SMEXT_ENABLE_MEMUTILS
#include <IMemoryUtils.h>
#endif
#if defined SMEXT_ENABLE_GAMEHELPERS
#include <IGameHelpers.h>
#endif
#if defined SMEXT_ENABLE_TIMERSYS
#include <ITimerSystem.h>
#endif
#if defined SMEXT_ENABLE_ADTFACTORY
#include <IADTFactory.h>
#endif
#if defined SMEXT_ENABLE_THREADER
#include <IThreader.h>
#endif
#if defined SMEXT_ENABLE_LIBSYS
#include <ILibrarySys.h>
#endif
#if defined SMEXT_ENABLE_PLUGINSYS
#include <IPluginSys.h>
#endif
#if defined SMEXT_ENABLE_MENUS
#include <IMenuManager.h>
#endif
#if defined SMEXT_ENABLE_ADMINSYS
#include <IAdminSystem.h>
#endif
#if defined SMEXT_ENABLE_TEXTPARSERS
#include <ITextParsers.h>
#endif
#if defined SMEXT_ENABLE_USERMSGS
#include <IUserMessages.h>
#endif
#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 maxlength, 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 maxlength);
/** Called on pause */
virtual bool Pause(char *error, size_t maxlength);
/** Called on unpause */
virtual bool Unpause(char *error, size_t maxlength);
private:
bool m_SourceMMLoaded;
bool m_WeAreUnloaded;
bool m_WeGotPauseChange;
#endif
};
extern SDKExtension *g_pExtensionIface;
extern IExtension *myself;
extern IShareSys *g_pShareSys;
extern IShareSys *sharesys; /* Note: Newer name */
extern ISourceMod *g_pSM;
extern ISourceMod *smutils; /* Note: Newer name */
/* Optional interfaces are below */
#if defined SMEXT_ENABLE_FORWARDSYS
extern IForwardManager *g_pForwards;
extern IForwardManager *forwards; /* Note: Newer name */
#endif //SMEXT_ENABLE_FORWARDSYS
#if defined SMEXT_ENABLE_HANDLESYS
extern IHandleSys *g_pHandleSys;
extern IHandleSys *handlesys; /* Note: Newer name */
#endif //SMEXT_ENABLE_HANDLESYS
#if defined SMEXT_ENABLE_PLAYERHELPERS
extern IPlayerManager *playerhelpers;
#endif //SMEXT_ENABLE_PLAYERHELPERS
#if defined SMEXT_ENABLE_DBMANAGER
extern IDBManager *dbi;
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_GAMECONF
extern IGameConfigManager *gameconfs;
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_MEMUTILS
extern IMemoryUtils *memutils;
#endif
#if defined SMEXT_ENABLE_GAMEHELPERS
extern IGameHelpers *gamehelpers;
#endif
#if defined SMEXT_ENABLE_TIMERSYS
extern ITimerSystem *timersys;
#endif
#if defined SMEXT_ENABLE_ADTFACTORY
extern IADTFactory *adtfactory;
#endif
#if defined SMEXT_ENABLE_THREADER
extern IThreader *threader;
#endif
#if defined SMEXT_ENABLE_LIBSYS
extern ILibrarySys *libsys;
#endif
#if defined SMEXT_ENABLE_PLUGINSYS
extern SourceMod::IPluginManager *plsys;
#endif
#if defined SMEXT_ENABLE_MENUS
extern IMenuManager *menus;
#endif
#if defined SMEXT_ENABLE_ADMINSYS
extern IAdminSystem *adminsys;
#endif
#if defined SMEXT_ENABLE_USERMSGS
extern IUserMessages *usermsgs;
#endif
#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 != NULL && maxlength) \
{ \
size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
if (len >= maxlength) \
{ \
error[maxlength - 1] = '\0'; \
} \
} \
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 != NULL && maxlength) \
{ \
size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
if (len >= maxlength) \
{ \
error[maxlength - 1] = '\0'; \
} \
} \
return false; \
}
#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_

View File

@ -0,0 +1,88 @@
#(C)2004-2006 SourceMM Development Team
# Makefile written by David "BAILOPAN" Anderson
SMSDK = ../smsdk
SRCDS = ~/srcds_l/steaminstall
SOURCEMM = ../sourcemm
HL2SDK = ../hl2sdk
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################
PROJECT = game.tf2
#Uncomment for SourceMM-enabled extensions
LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.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
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$(SOURCEMM) -I$(SOURCEMM)/sourcehook -I$(SOURCEMM)/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 -mfpmath=sse -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) -f Makefile.ep1 extension
extension: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
debug:
$(MAKE) -f Makefile.ep1 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)

View File

@ -0,0 +1,88 @@
#(C)2004-2006 SourceMM Development Team
# Makefile written by David "BAILOPAN" Anderson
SMSDK = ../smsdk
SRCDS = ~/srcds_l/steaminstall
SOURCEMM = ../sourcemm
HL2SDK = ../hl2sdk-ob
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################
PROJECT = game.tf2
#Uncomment for SourceMM-enabled extensions
LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.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
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$(SOURCEMM) -I$(SOURCEMM)/sourcehook -I$(SOURCEMM)/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 -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -DORANGEBOX_BUILD
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)/orangebox/bin/vstdlib_i486.so vstdlib_i486.so
ln -sf $(SRCDS)/orangebox/bin/tier0_i486.so tier0_i486.so
$(MAKE) -f Makefile.ep2 extension
extension: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
debug:
$(MAKE) -f Makefile.ep2 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)

View File

@ -0,0 +1,88 @@
#(C)2004-2006 SourceMM Development Team
# Makefile written by David "BAILOPAN" Anderson
SMSDK = ../smsdk
SRCDS = ~/srcds_l/steaminstall
SOURCEMM = ../sourcemm
HL2SDK = ../hl2sdk
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################
PROJECT = game.tf2
#Uncomment for SourceMM-enabled extensions
LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.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
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$(SOURCEMM) -I$(SOURCEMM)/sourcehook -I$(SOURCEMM)/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 -mfpmath=sse -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) -f Makefile.orig extension
extension: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
debug:
$(MAKE) -f Makefile.orig 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)

View File

@ -0,0 +1,50 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Counter-Strike:Source 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "extension.h"
#include "RegNatives.h"
RegNatives g_RegNatives;
void RegNatives::Register(ICallWrapper *pWrapper)
{
m_List.push_back(pWrapper);
}
void RegNatives::UnregisterAll()
{
SourceHook::List<ICallWrapper *>::iterator iter;
for (iter=m_List.begin(); iter!=m_List.end(); iter++)
{
(*iter)->Destroy();
}
}

View File

@ -0,0 +1,48 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Counter-Strike:Source 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#ifndef _INCLUDE_TF2TOOLS_REGNATIVES_H_
#define _INCLUDE_TF2TOOLS_REGNATIVES_H_
#include <sh_list.h>
class RegNatives
{
public:
void Register(ICallWrapper *pWrapper);
void UnregisterAll();
private:
SourceHook::List<ICallWrapper *> m_List;
};
extern RegNatives g_RegNatives;
#endif //_INCLUDE_TF2TOOLS_REGNATIVES_H_

View File

@ -0,0 +1,229 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Counter-Strike:Source 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "extension.h"
#include "RegNatives.h"
#include "iplayerinfo.h"
/**
* @file extension.cpp
* @brief Implement extension code here.
*/
TF2Tools g_TF2Tools;
IGameConfig *g_pGameConf = NULL;
IBinTools *g_pBinTools = NULL;
SMEXT_LINK(&g_TF2Tools);
SendProp *playerSharedOffset;
extern sp_nativeinfo_t g_TFNatives[];
bool TF2Tools::SDK_OnLoad(char *error, size_t maxlength, bool late)
{
sharesys->AddDependency(myself, "bintools.ext", true, true);
char conf_error[255];
if (!gameconfs->LoadGameConfigFile("sm-tf2.games", &g_pGameConf, conf_error, sizeof(conf_error)))
{
if (error)
{
snprintf(error, maxlength, "Could not read sm-tf2.games.txt: %s", conf_error);
}
return false;
}
sharesys->AddNatives(myself, g_TFNatives);
sharesys->RegisterLibrary(myself, "tf2");
playerSharedOffset = gamehelpers->FindInSendTable("CTFPlayer", "DT_TFPlayerShared");
playerhelpers->RegisterCommandTargetProcessor(this);
return true;
}
bool TF2Tools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
return true;
}
void TF2Tools::SDK_OnUnload()
{
g_RegNatives.UnregisterAll();
gameconfs->CloseGameConfigFile(g_pGameConf);
}
void TF2Tools::SDK_OnAllLoaded()
{
SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools);
}
bool TF2Tools::QueryRunning(char *error, size_t maxlength)
{
SM_CHECK_IFACE(BINTOOLS, g_pBinTools);
return true;
}
bool TF2Tools::QueryInterfaceDrop(SMInterface *pInterface)
{
if (pInterface == g_pBinTools)
{
return false;
}
return IExtensionInterface::QueryInterfaceDrop(pInterface);
}
void TF2Tools::NotifyInterfaceDrop(SMInterface *pInterface)
{
g_RegNatives.UnregisterAll();
}
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
va_end(ap);
if (len >= maxlength)
{
buffer[maxlength - 1] = '\0';
return (maxlength - 1);
}
else
{
return len;
}
}
bool TF2Tools::ProcessCommandTarget(cmd_target_info_t *info)
{
int max_clients;
IPlayerInfo *pInfo;
unsigned int team_index = 0;
IGamePlayer *pPlayer, *pAdmin;
if ((info->flags & COMMAND_FILTER_NO_MULTI) == COMMAND_FILTER_NO_MULTI)
{
return false;
}
if (info->admin)
{
if ((pAdmin = playerhelpers->GetGamePlayer(info->admin)) == NULL)
{
return false;
}
if (!pAdmin->IsInGame())
{
return false;
}
}
else
{
pAdmin = NULL;
}
if (strcmp(info->pattern, "@red") == 0 )
{
team_index = 2;
}
else if (strcmp(info->pattern, "@blue") == 0)
{
team_index = 3;
}
else
{
return false;
}
info->num_targets = 0;
max_clients = playerhelpers->GetMaxClients();
for (int i = 1;
i <= max_clients && (cell_t)info->num_targets < info->max_targets;
i++)
{
if ((pPlayer = playerhelpers->GetGamePlayer(i)) == NULL)
{
continue;
}
if (!pPlayer->IsInGame())
{
continue;
}
if ((pInfo = pPlayer->GetPlayerInfo()) == NULL)
{
continue;
}
if (pInfo->GetTeamIndex() != (int)team_index)
{
continue;
}
if (playerhelpers->FilterCommandTarget(pAdmin, pPlayer, info->flags)
!= COMMAND_TARGET_VALID)
{
continue;
}
info->targets[info->num_targets] = i;
info->num_targets++;
}
if (info->num_targets == 0)
{
info->reason = COMMAND_TARGET_EMPTY_FILTER;
}
else
{
info->reason = COMMAND_TARGET_VALID;
}
info->target_name_style = COMMAND_TARGETNAME_RAW;
if (team_index == 2)
{
UTIL_Format(info->target_name, info->target_name_maxlength, "Red Team");
}
else if (team_index == 3)
{
UTIL_Format(info->target_name, info->target_name_maxlength, "Blue Team");
}
return true;
}

130
extensions/tf2/extension.h Normal file
View File

@ -0,0 +1,130 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Counter-Strike:Source 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
/**
* @file extension.h
* @brief Sample extension code header.
*/
#include "smsdk_ext.h"
#include <IBinTools.h>
/**
* @brief Sample implementation of the SDK Extension.
* Note: Uncomment one of the pre-defined virtual functions in order to use it.
*/
class TF2Tools :
public SDKExtension,
public ICommandTargetProcessor
{
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);
void NotifyInterfaceDrop(SMInterface *pInterface);
bool QueryInterfaceDrop(SMInterface *pInterface);
public:
bool ProcessCommandTarget(cmd_target_info_t *info);
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 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
};
extern IBinTools *g_pBinTools;
extern IGameConfig *g_pGameConf;
extern SendProp *playerSharedOffset;
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_

View File

@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tf2", "tf2.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug - Episode1|Win32 = Debug - Episode1|Win32
Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32
Debug - Orange Box|Win32 = Debug - Orange Box|Win32
Release - Episode 1|Win32 = Release - Episode 1|Win32
Release - Old Metamod|Win32 = Release - Old Metamod|Win32
Release - Orange Box|Win32 = Release - Orange Box|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode1|Win32.ActiveCfg = Debug - Episode1|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode1|Win32.Build.0 = Debug - Episode1|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32
{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,727 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="tf2"
ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
RootNamespace="tf2"
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\sourcepawn;..\..\..\public\extensions"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="tier0.lib"
OutputFile="$(OutDir)\game.tf2.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"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\game.tf2.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>
<Configuration
Name="Debug - Episode1|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\sourcepawn;..\..\..\public\extensions;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(HL2SDK)\tier1;$(SOURCEMM);$(SOURCEMM)\sourcemm;$(SOURCEMM)\sourcehook"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(HL2SDK)\lib\public\tier0.lib $(HL2SDK)\lib\public\tier1.lib $(HL2SDK)\lib\public\vstdlib.lib $(HL2SDK)\lib\public\mathlib.lib"
OutputFile="$(OutDir)\game.tf2.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="Debug - Orange Box|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\sourcepawn;..\..\..\public\extensions;$(HL2SDKOB)\public;$(HL2SDKOB)\public\dlls;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(HL2SDKOB)\public\vstdlib;$(HL2SDKOB)\tier1;$(SOURCEMM);$(SOURCEMM)\sourcemm;$(SOURCEMM)\sourcehook"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(HL2SDKOB)\lib\public\tier0.lib $(HL2SDKOB)\lib\public\tier1.lib $(HL2SDKOB)\lib\public\vstdlib.lib $(HL2SDKOB)\lib\public\mathlib.lib"
OutputFile="$(OutDir)\game.tf2.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="Debug - Old Metamod|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\sourcepawn;..\..\..\public\extensions;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(HL2SDK)\tier1;$(SOURCEMM142);$(SOURCEMM142)\sourcemm;$(SOURCEMM142)\sourcehook"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(HL2SDK)\lib\public\tier0.lib $(HL2SDK)\lib\public\tier1.lib $(HL2SDK)\lib\public\vstdlib.lib $(HL2SDK)\lib\public\mathlib.lib"
OutputFile="$(OutDir)\game.tf2.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 - Old Metamod|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"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(HL2SDK)\tier1;$(SOURCEMM142);$(SOURCEMM142)\sourcemm;$(SOURCEMM142)\sourcehook"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(HL2SDK)\lib\public\tier0.lib $(HL2SDK)\lib\public\tier1.lib $(HL2SDK)\lib\public\vstdlib.lib $(HL2SDK)\lib\public\mathlib.lib"
OutputFile="$(OutDir)\game.tf2.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>
<Configuration
Name="Release - Orange Box|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"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDKOB)\public;$(HL2SDKOB)\public\dlls;$(HL2SDKOB)\public\engine;$(HL2SDKOB)\public\tier0;$(HL2SDKOB)\public\tier1;$(HL2SDKOB)\public\vstdlib;$(HL2SDKOB)\tier1;$(SOURCEMM);$(SOURCEMM)\sourcemm;$(SOURCEMM)\sourcehook"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(HL2SDKOB)\lib\public\tier0.lib $(HL2SDKOB)\lib\public\tier1.lib $(HL2SDKOB)\lib\public\vstdlib.lib $(HL2SDKOB)\lib\public\mathlib.lib"
OutputFile="$(OutDir)\game.tf2.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>
<Configuration
Name="Release - Episode 1|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"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions;$(HL2SDK)\public;$(HL2SDK)\public\dlls;$(HL2SDK)\public\engine;$(HL2SDK)\public\tier0;$(HL2SDK)\public\tier1;$(HL2SDK)\public\vstdlib;$(HL2SDK)\tier1;$(SOURCEMM);$(SOURCEMM)\sourcemm;$(SOURCEMM)\sourcehook"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(HL2SDK)\lib\public\tier0.lib $(HL2SDK)\lib\public\tier1.lib $(HL2SDK)\lib\public\vstdlib.lib $(HL2SDK)\lib\public\mathlib.lib"
OutputFile="$(OutDir)\game.tf2.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="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\extension.cpp"
>
</File>
<File
RelativePath="..\natives.cpp"
>
</File>
<File
RelativePath="..\RegNatives.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\extension.h"
>
</File>
<File
RelativePath="..\RegNatives.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="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath="..\version.rc"
>
</File>
</Filter>
<Filter
Name="SourceMod SDK"
UniqueIdentifier="{31958233-BB2D-4e41-A8F9-CE8A4684F436}"
>
<File
RelativePath="..\sdk\smsdk_config.h"
>
</File>
<File
RelativePath="..\sdk\smsdk_ext.cpp"
>
</File>
<File
RelativePath="..\sdk\smsdk_ext.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

159
extensions/tf2/natives.cpp Normal file
View File

@ -0,0 +1,159 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Counter-Strike:Source 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include "extension.h"
#include "RegNatives.h"
#define REGISTER_NATIVE_ADDR(name, code) \
void *addr; \
if (!g_pGameConf->GetMemSig(name, &addr)) \
{ \
return pContext->ThrowNativeError("Failed to locate function"); \
} \
code; \
g_RegNatives.Register(pWrapper);
inline CBaseEntity *GetCBaseEntity(int num, bool onlyPlayers)
{
edict_t *pEdict = engine->PEntityOfEntIndex(num);
if (!pEdict || pEdict->IsFree())
{
return NULL;
}
if (num > 0 && num < playerhelpers->GetMaxClients())
{
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(pEdict);
if (!pPlayer || !pPlayer->IsConnected())
{
return NULL;
}
}
else if (onlyPlayers)
{
return NULL;
}
IServerUnknown *pUnk;
if ((pUnk=pEdict->GetUnknown()) == NULL)
{
return NULL;
}
return pUnk->GetBaseEntity();
}
// native TF2_Burn(client)
cell_t TF2_Burn(IPluginContext *pContext, const cell_t *params)
{
static ICallWrapper *pWrapper = NULL;
// CTFPlayerShared::Burn(CTFPlayer*)
if (!pWrapper)
{
REGISTER_NATIVE_ADDR("Burn",
PassInfo pass[1]; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].size = sizeof(CBaseEntity *); \
pass[0].type = PassType_Basic; \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 1))
}
CBaseEntity *pEntity;
if (!(pEntity=GetCBaseEntity(params[1], true)))
{
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
}
void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->GetOffset());
unsigned char vstk[sizeof(void *) + sizeof(CBaseEntity *)];
unsigned char *vptr = vstk;
*(void **)vptr = obj;
vptr += sizeof(void *);
*(CBaseEntity **)vptr = pEntity;
pWrapper->Execute(vstk, NULL);
return 1;
}
// native TF2_Invuln(client, bool:something, bool:anothersomething)
cell_t TF2_Invuln(IPluginContext *pContext, const cell_t *params)
{
static ICallWrapper *pWrapper = NULL;
//CTFPlayerShared::SetInvulnerable(bool, bool)
if (!pWrapper)
{
REGISTER_NATIVE_ADDR("Invuln",
PassInfo pass[2]; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].size = sizeof(bool); \
pass[0].type = PassType_Basic; \
pass[1].flags = PASSFLAG_BYVAL; \
pass[1].size = sizeof(bool); \
pass[1].type = PassType_Basic; \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 2))
}
CBaseEntity *pEntity;
if (!(pEntity=GetCBaseEntity(params[1], true)))
{
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
}
void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->GetOffset());
unsigned char vstk[sizeof(void *) + 2*sizeof(bool)];
unsigned char *vptr = vstk;
*(void **)vptr = obj;
vptr += sizeof(bool);
*(bool *)vptr = !!params[2];
vptr += sizeof(bool);
*(bool *)vptr = !!params[3];
pWrapper->Execute(vstk, NULL);
return 1;
}
sp_nativeinfo_t g_TFNatives[] =
{
{"TF2_Burn", TF2_Burn},
{"TF2_Invuln", TF2_Invuln},
{NULL, NULL}
};

View File

@ -0,0 +1,76 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Counter-Strike:Source 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <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.
*/
#include "svn_version.h"
/* Basic information exposed publicly */
#define SMEXT_CONF_NAME "TF2 Tools"
#define SMEXT_CONF_DESCRIPTION "TF2 extended functionality"
#define SMEXT_CONF_VERSION SVN_FULL_VERSION
#define SMEXT_CONF_AUTHOR "AlliedModders LLC"
#define SMEXT_CONF_URL "http://www.sourcemod.net/"
#define SMEXT_CONF_LOGTAG "TF2"
#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
/** Enable interfaces you want to use here by uncommenting lines */
//#define SMEXT_ENABLE_FORWARDSYS
//#define SMEXT_ENABLE_HANDLESYS
#define SMEXT_ENABLE_PLAYERHELPERS
//#define SMEXT_ENABLE_DBMANAGER
#define SMEXT_ENABLE_GAMECONF
//#define SMEXT_ENABLE_MEMUTILS
#define SMEXT_ENABLE_GAMEHELPERS
//#define SMEXT_ENABLE_TIMERSYS
//#define SMEXT_ENABLE_THREADER
//#define SMEXT_ENABLE_LIBSYS
//#define SMEXT_ENABLE_USERMSGS
#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_

View File

@ -0,0 +1,422 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Base Extension Code
* 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <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.
*/
IExtension *myself = NULL; /**< Ourself */
IShareSys *g_pShareSys = NULL; /**< Share system */
IShareSys *sharesys = NULL; /**< Share system */
ISourceMod *g_pSM = NULL; /**< SourceMod helpers */
ISourceMod *smutils = NULL; /**< SourceMod helpers */
#if defined SMEXT_ENABLE_FORWARDSYS
IForwardManager *g_pForwards = NULL; /**< Forward system */
IForwardManager *forwards = NULL; /**< Forward system */
#endif
#if defined SMEXT_ENABLE_HANDLESYS
IHandleSys *g_pHandleSys = NULL; /**< Handle system */
IHandleSys *handlesys = NULL; /**< Handle system */
#endif
#if defined SMEXT_ENABLE_PLAYERHELPERS
IPlayerManager *playerhelpers = NULL; /**< Player helpers */
#endif //SMEXT_ENABLE_PLAYERHELPERS
#if defined SMEXT_ENABLE_DBMANAGER
IDBManager *dbi = NULL; /**< DB Manager */
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_GAMECONF
IGameConfigManager *gameconfs = NULL; /**< Game config manager */
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_MEMUTILS
IMemoryUtils *memutils = NULL;
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_GAMEHELPERS
IGameHelpers *gamehelpers = NULL;
#endif
#if defined SMEXT_ENABLE_TIMERSYS
ITimerSystem *timersys = NULL;
#endif
#if defined SMEXT_ENABLE_ADTFACTORY
IADTFactory *adtfactory = NULL;
#endif
#if defined SMEXT_ENABLE_THREADER
IThreader *threader = NULL;
#endif
#if defined SMEXT_ENABLE_LIBSYS
ILibrarySys *libsys = NULL;
#endif
#if defined SMEXT_ENABLE_USERMSGS
IUserMessages *usermsgs = NULL;
#endif
/** 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 = sharesys = 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(SOURCEMOD, g_pSM);
smutils = g_pSM;
#if defined SMEXT_ENABLE_HANDLESYS
SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
handlesys = g_pHandleSys;
#endif
#if defined SMEXT_ENABLE_FORWARDSYS
SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
forwards = g_pForwards;
#endif
#if defined SMEXT_ENABLE_PLAYERHELPERS
SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
#endif
#if defined SMEXT_ENABLE_DBMANAGER
SM_GET_IFACE(DBI, dbi);
#endif
#if defined SMEXT_ENABLE_GAMECONF
SM_GET_IFACE(GAMECONFIG, gameconfs);
#endif
#if defined SMEXT_ENABLE_MEMUTILS
SM_GET_IFACE(MEMORYUTILS, memutils);
#endif
#if defined SMEXT_ENABLE_GAMEHELPERS
SM_GET_IFACE(GAMEHELPERS, gamehelpers);
#endif
#if defined SMEXT_ENABLE_TIMERSYS
SM_GET_IFACE(TIMERSYS, timersys);
#endif
#if defined SMEXT_ENABLE_ADTFACTORY
SM_GET_IFACE(ADTFACTORY, adtfactory);
#endif
#if defined SMEXT_ENABLE_THREADER
SM_GET_IFACE(THREADER, threader);
#endif
#if defined SMEXT_ENABLE_LIBSYS
SM_GET_IFACE(LIBRARYSYS, libsys);
#endif
#if defined SMEXT_ENABLE_USERMSGS
SM_GET_IFACE(USERMSGS, usermsgs);
#endif
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, METAMOD_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(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
GET_V_IFACE_CURRENT(GetEngineFactory, 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

View File

@ -0,0 +1,310 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Base Extension Code
* 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <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>
#if defined SMEXT_ENABLE_FORWARDSYS
#include <IForwardSys.h>
#endif //SMEXT_ENABLE_FORWARDSYS
#if defined SMEXT_ENABLE_PLAYERHELPERS
#include <IPlayerHelpers.h>
#endif //SMEXT_ENABLE_PlAYERHELPERS
#if defined SMEXT_ENABLE_DBMANAGER
#include <IDBDriver.h>
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_GAMECONF
#include <IGameConfigs.h>
#endif
#if defined SMEXT_ENABLE_MEMUTILS
#include <IMemoryUtils.h>
#endif
#if defined SMEXT_ENABLE_GAMEHELPERS
#include <IGameHelpers.h>
#endif
#if defined SMEXT_ENABLE_TIMERSYS
#include <ITimerSystem.h>
#endif
#if defined SMEXT_ENABLE_ADTFACTORY
#include <IADTFactory.h>
#endif
#if defined SMEXT_ENABLE_THREADER
#include <IThreader.h>
#endif
#if defined SMEXT_ENABLE_LIBSYS
#include <ILibrarySys.h>
#endif
#if defined SMEXT_ENABLE_USERMSGS
#include <IUserMessages.h>
#endif
#if defined SMEXT_CONF_METAMOD
#include <ISmmPlugin.h>
#include <eiface.h>
#endif
#if !defined METAMOD_PLAPI_VERSION
#include <metamod_wrappers.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 maxlength, 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 maxlength);
/** Called on pause */
virtual bool Pause(char *error, size_t maxlength);
/** Called on unpause */
virtual bool Unpause(char *error, size_t maxlength);
private:
bool m_SourceMMLoaded;
bool m_WeAreUnloaded;
bool m_WeGotPauseChange;
#endif
};
extern SDKExtension *g_pExtensionIface;
extern IExtension *myself;
extern IShareSys *g_pShareSys;
extern IShareSys *sharesys; /* Note: Newer name */
extern ISourceMod *g_pSM;
extern ISourceMod *smutils; /* Note: Newer name */
/* Optional interfaces are below */
#if defined SMEXT_ENABLE_FORWARDSYS
extern IForwardManager *g_pForwards;
extern IForwardManager *forwards; /* Note: Newer name */
#endif //SMEXT_ENABLE_FORWARDSYS
#if defined SMEXT_ENABLE_HANDLESYS
extern IHandleSys *g_pHandleSys;
extern IHandleSys *handlesys; /* Note: Newer name */
#endif //SMEXT_ENABLE_HANDLESYS
#if defined SMEXT_ENABLE_PLAYERHELPERS
extern IPlayerManager *playerhelpers;
#endif //SMEXT_ENABLE_PLAYERHELPERS
#if defined SMEXT_ENABLE_DBMANAGER
extern IDBManager *dbi;
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_GAMECONF
extern IGameConfigManager *gameconfs;
#endif //SMEXT_ENABLE_DBMANAGER
#if defined SMEXT_ENABLE_MEMUTILS
extern IMemoryUtils *memutils;
#endif
#if defined SMEXT_ENABLE_GAMEHELPERS
extern IGameHelpers *gamehelpers;
#endif
#if defined SMEXT_ENABLE_TIMERSYS
extern ITimerSystem *timersys;
#endif
#if defined SMEXT_ENABLE_ADTFACTORY
extern IADTFactory *adtfactory;
#endif
#if defined SMEXT_ENABLE_THREADER
extern IThreader *threader;
#endif
#if defined SMEXT_ENABLE_LIBSYS
extern ILibrarySys *libsys;
#endif
#if defined SMEXT_ENABLE_USERMSGS
extern IUserMessages *usermsgs;
#endif
#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 != NULL && maxlength) \
{ \
size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
if (len >= maxlength) \
{ \
error[maxlength - 1] = '\0'; \
} \
} \
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 != NULL && maxlength) \
{ \
size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
if (len >= maxlength) \
{ \
error[maxlength - 1] = '\0'; \
} \
} \
return false; \
}
#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_

View File

@ -0,0 +1,21 @@
"Games"
{
"tf"
{
"Signatures"
{
"Burn"
{
"library" "server"
"windows" "\x56\x8B\xF1\x8B\x4E\x7C\x8B\x01\x8B\x90\xF8\x00\x00\x00\xFF\xD2\x84\xC0\x2A\x2A\x2A\x2A\x2A\x2A\x8B\x46\x7C"
"linux" "@_ZN15CTFPlayerShared4BurnEP9CTFPlayer"
}
"Invuln"
{
"library" "server"
"windows" "\x8A\x44\x24\x04\x83\xEC\x20\x56\x8B\xF1\x8B\x4E\x08\x57\x8D\x7E\x08\xC1\xE9\x05\x80\xE1\x01\x3A\xC8\x75\x32\x84\xC0"
"linux" "@_ZN15CTFPlayerShared15SetInvulnerableEbb"
}
}
}
}

View File

@ -0,0 +1,42 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod SDKTools 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
/**
* Autogenerated by build scripts
*/
#ifndef _INCLUDE_SDKTOOLS_VERSION_H_
#define _INCLUDE_SDKTOOLS_VERSION_H_
#define SVN_FULL_VERSION "1.0.0.1336"
#define SVN_FILE_VERSION 1,0,0,1336
#endif //_INCLUDE_SDKTOOLS_VERSION_H_

View File

@ -0,0 +1,42 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod SDKTools 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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
/**
* Autogenerated by build scripts
*/
#ifndef _INCLUDE_SDKTOOLS_VERSION_H_
#define _INCLUDE_SDKTOOLS_VERSION_H_
#define SVN_FULL_VERSION "$PMAJOR$.$PMINOR$.$PREVISION$.$LOCAL_BUILD$"
#define SVN_FILE_VERSION $PMAJOR$,$PMINOR$,$PREVISION$,$LOCAL_BUILD$
#endif //_INCLUDE_SDKTOOLS_VERSION_H_

View File

@ -0,0 +1,55 @@
#include <sourcemod>
#include "tf2.inc"
public Plugin:myinfo =
{
name = "TF2 Test",
author = "pRED*",
description = "Test of Tf2 functions",
version = "1.0",
url = "www.sourcemod.net"
}
public OnPluginStart()
{
RegConsoleCmd("sm_burnme", Command_Burn);
RegConsoleCmd("sm_invuln", Command_Invuln);
}
public Action:Command_Burn(client, args)
{
if (client == 0)
{
return Plugin_Continue;
}
TF2_Burn(client);
return Plugin_Continue;
}
public Action:Command_Invuln(client, args)
{
if (client == 0)
{
return Plugin_Continue;
}
if (args < 2)
{
return Plugin_Continue;
}
decl String:text[10];
decl String:text2[10];
GetCmdArg(1, text, sizeof(text));
GetCmdArg(2, text2, sizeof(text2));
new bool:one = !!StringToInt(text);
new bool:two = !!StringToInt(text2);
TF2_Invuln(client, one, two)
return Plugin_Continue;
}

24
extensions/tf2/tf2.inc Normal file
View File

@ -0,0 +1,24 @@
#if defined _tf2_included
#endinput
#endif
#define _tf2_included
native TF2_Invuln(client, bool:something, bool:anothersomething);
native TF2_Burn(client);
/**
* Do not edit below this line!
*/
public Extension:__ext_tf2 =
{
name = "TF2 Tools",
file = "game.tf2.ext",
autoload = 0,
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};

104
extensions/tf2/version.rc Normal file
View File

@ -0,0 +1,104 @@
// Microsoft Visual C++ generated resource script.
//
//#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
#include "svn_version.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION SVN_FILE_VERSION
PRODUCTVERSION SVN_FILE_VERSION
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "SourceMod CS:S Extension"
VALUE "FileDescription", "SourceMod CS:S Extension"
VALUE "FileVersion", SVN_FULL_VERSION
VALUE "InternalName", "SourceMod CS:S Extension"
VALUE "LegalCopyright", "Copyright (c) 2004-2007, AlliedModders LLC"
VALUE "OriginalFilename", "game.cstrike.ext.dll"
VALUE "ProductName", "SourceMod CS:S Extension"
VALUE "ProductVersion", SVN_FULL_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -45,6 +45,8 @@ public Plugin:myinfo =
url = "http://www.sourcemod.net/"
};
new g_maxPlayers;
/* Forwards */
new Handle:hOnAdminMenuReady = INVALID_HANDLE;
new Handle:hOnAdminMenuCreated = INVALID_HANDLE;
@ -57,6 +59,8 @@ new TopMenuObject:obj_playercmds = INVALID_TOPMENUOBJECT;
new TopMenuObject:obj_servercmds = INVALID_TOPMENUOBJECT;
new TopMenuObject:obj_votingcmds = INVALID_TOPMENUOBJECT;
#include "adminmenu/dynamicmenu.sp"
public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max)
{
CreateNative("GetAdminTopMenu", __GetAdminTopMenu);
@ -91,28 +95,37 @@ public OnConfigsExecuted()
}
}
public OnMapStart()
{
g_maxPlayers = GetMaxClients();
ParseConfigs();
}
public OnAllPluginsLoaded()
{
hAdminMenu = CreateTopMenu(CategoryHandler);
hAdminMenu = CreateTopMenu(DefaultCategoryHandler);
obj_playercmds = AddToTopMenu(hAdminMenu,
"PlayerCommands",
TopMenuObject_Category,
CategoryHandler,
DefaultCategoryHandler,
INVALID_TOPMENUOBJECT);
obj_servercmds = AddToTopMenu(hAdminMenu,
"ServerCommands",
TopMenuObject_Category,
CategoryHandler,
DefaultCategoryHandler,
INVALID_TOPMENUOBJECT);
obj_votingcmds = AddToTopMenu(hAdminMenu,
"VotingCommands",
TopMenuObject_Category,
CategoryHandler,
DefaultCategoryHandler,
INVALID_TOPMENUOBJECT);
BuildDynamicMenu();
Call_StartForward(hOnAdminMenuCreated);
Call_PushCell(hAdminMenu);
Call_Finish();
@ -122,7 +135,7 @@ public OnAllPluginsLoaded()
Call_Finish();
}
public CategoryHandler(Handle:topmenu,
public DefaultCategoryHandler(Handle:topmenu,
TopMenuAction:action,
TopMenuObject:object_id,
param,

View File

@ -0,0 +1,520 @@
#define NAME_LENGTH 32
#define CMD_LENGTH 255
#define ARRAY_STRING_LENGTH 32
new Handle:g_kvMenu;
enum GroupCommands
{
Handle:groupListName,
Handle:groupListCommand
};
new g_groupList[GroupCommands];
new g_groupCount;
new Handle:g_configParser = INVALID_HANDLE;
enum Places
{
Place_Category,
Place_Item,
Place_ReplaceNum
};
new String:g_command[MAXPLAYERS+1][CMD_LENGTH];
new g_currentPlace[MAXPLAYERS+1][Places];
/**
* What to put in the 'info' menu field (for PlayerList and Player_Team menus only)
*/
enum PlayerMethod
{
ClientId, /** Client id number ( 1 - Maxplayers) */
UserId, /** Client userid */
Name, /** Client Name */
SteamId, /** Client Steamid */
IpAddress, /** Client's Ip Address */
UserId2 /** Userid (not prefixed with #) */
};
BuildDynamicMenu()
{
if (g_kvMenu != INVALID_HANDLE)
{
CloseHandle(g_kvMenu);
}
g_kvMenu = CreateKeyValues("Commands");
new String:file[256];
BuildPath(Path_SM, file, 255, "configs/dynamicmenu/menu.ini");
FileToKeyValues(g_kvMenu, file);
new String:name[NAME_LENGTH];
new String:buffer[NAME_LENGTH];
if (!KvGotoFirstSubKey(g_kvMenu))
{
return;
}
decl String:admin[30];
new TopMenuObject:categoryId;
new catId;
new id;
do
{
KvGetSectionName(g_kvMenu, buffer, sizeof(buffer));
KvGetString(g_kvMenu, "admin", admin, sizeof(admin),"sm_admin");
if ((categoryId =FindTopMenuCategory(hAdminMenu, buffer)) == INVALID_TOPMENUOBJECT)
{
categoryId = AddToTopMenu(hAdminMenu,
buffer,
TopMenuObject_Category,
DynamicMenuCategoryHandler,
INVALID_TOPMENUOBJECT,
admin,
ADMFLAG_GENERIC,
name);
}
if (!KvGetSectionSymbol(g_kvMenu, catId))
{
LogError("Key Id not found for section: %s", buffer);
break;
}
if (!KvGotoFirstSubKey(g_kvMenu))
{
return;
}
do
{
KvGetSectionName(g_kvMenu, buffer, sizeof(buffer));
KvGetString(g_kvMenu, "admin", admin, sizeof(admin),"");
if (admin[0] == '\0')
{
//No 'admin' keyvalue was found
//Use the first argument of the 'cmd' string instead
decl String:temp[64];
KvGetString(g_kvMenu, "cmd", temp, sizeof(temp),"");
BreakString(temp, admin, sizeof(admin));
}
if (!KvGetSectionSymbol(g_kvMenu, id))
{
LogError("Key Id not found for section: %s");
break;
}
decl String:keyId[64];
Format(keyId, sizeof(keyId), "%i %i", catId, id);
AddToTopMenu(hAdminMenu,
buffer,
TopMenuObject_Item,
DynamicMenuItemHandler,
categoryId,
admin,
ADMFLAG_GENERIC,
keyId);
} while (KvGotoNextKey(g_kvMenu));
KvGoBack(g_kvMenu);
} while (KvGotoNextKey(g_kvMenu));
KvRewind(g_kvMenu);
}
ParseConfigs()
{
if (g_configParser == INVALID_HANDLE)
{
g_configParser = SMC_CreateParser();
}
SMC_SetReaders(g_configParser, NewSection, KeyValue, EndSection);
if (g_groupList[groupListName] != INVALID_HANDLE)
{
CloseHandle(g_groupList[groupListName]);
}
if (g_groupList[groupListCommand] != INVALID_HANDLE)
{
CloseHandle(g_groupList[groupListCommand]);
}
g_groupList[groupListName] = CreateArray(ARRAY_STRING_LENGTH);
g_groupList[groupListCommand] = CreateArray(ARRAY_STRING_LENGTH);
decl String:configPath[256];
BuildPath(Path_SM, configPath, sizeof(configPath), "configs/dynamicmenu/adminmenu_grouping.txt");
if (!FileExists(configPath))
{
LogError("Unable to locate admin menu groups file, no groups loaded.");
return;
}
new line;
new SMCError:err = SMC_ParseFile(g_configParser, configPath, line);
if (err != SMCError_Okay)
{
decl String:error[256];
SMC_GetErrorString(err, error, sizeof(error));
LogError("Could not parse file (line %d, file \"%s\"):", line, configPath);
LogError("Parser encountered error: %s", error);
}
return;
}
public SMCResult:NewSection(Handle:smc, const String:name[], bool:opt_quotes)
{
}
public SMCResult:KeyValue(Handle:smc, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes)
{
PushArrayString(g_groupList[groupListName], key);
PushArrayString(g_groupList[groupListCommand], value);
}
public SMCResult:EndSection(Handle:smc)
{
g_groupCount = GetArraySize(g_groupList[groupListName]);
}
public DynamicMenuCategoryHandler(Handle:topmenu,
TopMenuAction:action,
TopMenuObject:object_id,
param,
String:buffer[],
maxlength)
{
if ((action == TopMenuAction_DisplayTitle) || (action == TopMenuAction_DisplayOption))
{
GetTopMenuObjName(topmenu, object_id, buffer, maxlength);
}
}
public DynamicMenuItemHandler(Handle:topmenu,
TopMenuAction:action,
TopMenuObject:object_id,
param,
String:buffer[],
maxlength)
{
if (action == TopMenuAction_DisplayOption)
{
GetTopMenuObjName(topmenu, object_id, buffer, maxlength);
}
else if (action == TopMenuAction_SelectOption)
{
new String:keyId[64];
new String:catId[64];
GetTopMenuInfoString(topmenu, object_id, keyId, sizeof(keyId));
new start = BreakString(keyId, catId, sizeof(catId));
new id = StringToInt(keyId[start]);
new category = StringToInt(catId);
KvJumpToKeySymbol(g_kvMenu, category);
KvJumpToKeySymbol(g_kvMenu, id);
KvGetString(g_kvMenu, "cmd", g_command[param], sizeof(g_command[]),"");
KvRewind(g_kvMenu);
g_currentPlace[param][Place_Category] = category;
g_currentPlace[param][Place_Item] = id;
ParamCheck(param);
}
}
public ParamCheck(client)
{
new String:buffer[6];
new String:buffer2[6];
KvJumpToKeySymbol(g_kvMenu, g_currentPlace[client][Place_Category]);
KvJumpToKeySymbol(g_kvMenu, g_currentPlace[client][Place_Item]);
new String:type[NAME_LENGTH];
if (g_currentPlace[client][Place_ReplaceNum] < 1)
{
g_currentPlace[client][Place_ReplaceNum] = 1;
}
Format(buffer, 5, "#%i", g_currentPlace[client][Place_ReplaceNum]);
Format(buffer2, 5, "@%i", g_currentPlace[client][Place_ReplaceNum]);
if (StrContains(g_command[client], buffer) != -1 || StrContains(g_command[client], buffer2) != -1)
{
//user has a parameter to fill. lets do it.
KvJumpToKey(g_kvMenu, buffer[1]); // Jump to current param
KvGetString(g_kvMenu, "type", type, sizeof(type),"list");
PrintToChatAll("Checking param %s - type %s", buffer[1], type);
new Handle:itemMenu = CreateMenu(Menu_Selection);
new String:title[NAME_LENGTH];
if (strncmp(type,"group",5)==0 && g_groupCount)
{
decl String:nameBuffer[ARRAY_STRING_LENGTH];
decl String:commandBuffer[ARRAY_STRING_LENGTH];
for (new i = 0; i<g_groupCount; i++)
{
GetArrayString(g_groupList[groupListName], i, nameBuffer, sizeof(nameBuffer));
GetArrayString(g_groupList[groupListCommand], i, commandBuffer, sizeof(commandBuffer));
AddMenuItem(itemMenu, commandBuffer, nameBuffer);
}
}
if (strncmp(type,"mapcycle",8) == 0)
{
decl String:path[200];
KvGetString(g_kvMenu, "path", path, sizeof(path),"mapcycle.txt");
new Handle:file = OpenFile(path, "rt");
new String:readData[128];
if(file != INVALID_HANDLE)
{
while(!IsEndOfFile(file) && ReadFileLine(file, readData, sizeof(readData)))
{
TrimString(readData);
if (IsMapValid(readData))
{
AddMenuItem(itemMenu, readData, readData);
}
}
}
}
else if (StrContains(type, "player") != -1)
{
PrintToChatAll("Building Player List");
new PlayerMethod:playermethod;
new String:method[NAME_LENGTH];
KvGetString(g_kvMenu, "method", method, sizeof(method),"name");
if (strncmp(method,"clientid",8)==0)
{
playermethod = ClientId;
}
else if (strncmp(method,"steamid",7)==0)
{
playermethod = SteamId;
}
else if (strncmp(method,"userid2",7)==0)
{
playermethod = UserId2;
}
else if (strncmp(method,"userid",6)==0)
{
playermethod = UserId;
}
else if (strncmp(method,"ip",2)==0)
{
playermethod = IpAddress;
}
else
{
playermethod = Name;
}
new String:nameBuffer[32];
new String:infoBuffer[32];
new String:temp[4];
//loop through players. Add name as text and name/userid/steamid as info
for (new i=1; i<=g_maxPlayers; i++)
{
if (IsClientInGame(i))
{
GetClientName(i, nameBuffer, 31);
switch (playermethod)
{
case UserId:
{
new userid = GetClientUserId(i);
Format(infoBuffer, sizeof(infoBuffer), "#%i", userid);
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
}
case UserId2:
{
new userid = GetClientUserId(i);
Format(infoBuffer, sizeof(infoBuffer), "%i", userid);
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
}
case SteamId:
{
GetClientAuthString(i, infoBuffer, sizeof(infoBuffer));
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
}
case IpAddress:
{
GetClientIP(i, infoBuffer, sizeof(infoBuffer));
AddMenuItem(itemMenu, infoBuffer, nameBuffer);
}
case Name:
{
AddMenuItem(itemMenu, nameBuffer, nameBuffer);
}
default: //assume client id
{
Format(temp,3,"%i",i);
AddMenuItem(itemMenu, temp, nameBuffer);
}
}
}
}
}
else if (strncmp(type,"onoff",5) == 0)
{
AddMenuItem(itemMenu, "1", "On");
AddMenuItem(itemMenu, "0", "Off");
}
else
{
//list menu
PrintToChatAll("Building List Menu");
new String:temp[6];
new String:value[64];
new String:text[64];
new i=1;
new bool:more = true;
new String:admin[NAME_LENGTH];
do
{
// load the i and i. options from kv and make a menu from them (i* = required admin level to view)
Format(temp,3,"%i",i);
KvGetString(g_kvMenu, temp, value, sizeof(value), "");
Format(temp,5,"%i.",i);
KvGetString(g_kvMenu, temp, text, sizeof(text), value);
Format(temp,5,"%i*",i);
KvGetString(g_kvMenu, temp, admin, sizeof(admin),"");
if (value[0]=='\0')
{
more = false;
}
else if (CheckCommandAccess(client, admin, 0))
{
AddMenuItem(itemMenu, value, text);
}
i++;
} while (more);
}
KvGetString(g_kvMenu, "title", title, sizeof(title),"Choose an Option");
SetMenuTitle(itemMenu, title);
DisplayMenu(itemMenu, client, MENU_TIME_FOREVER);
}
else
{
//nothing else need to be done. Run teh command.
new String:execute[7];
KvGetString(g_kvMenu, "execute", execute, sizeof(execute), "player");
DisplayTopMenu(hAdminMenu, client, TopMenuPosition_LastCategory);
if (execute[0]=='p') // assume 'player' type execute option
{
FakeClientCommand(client, g_command[client]);
}
else // assume 'server' type execute option
{
InsertServerCommand(g_command[client]);
ServerExecute();
}
g_command[client][0] = '\0';
g_currentPlace[client][Place_ReplaceNum] = 1;
}
KvRewind(g_kvMenu);
}
public Menu_Selection(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_End)
{
CloseHandle(menu);
}
if (action == MenuAction_Select)
{
new String:info[NAME_LENGTH];
/* Get item info */
new bool:found = GetMenuItem(menu, param2, info, sizeof(info));
if (!found)
{
return;
}
new String:buffer[6];
new String:infobuffer[NAME_LENGTH+2];
Format(infobuffer, sizeof(infobuffer), "\"%s\"", info);
Format(buffer, 5, "#%i", g_currentPlace[param1][Place_ReplaceNum]);
ReplaceString(g_command[param1], sizeof(g_command[]), buffer, infobuffer);
//replace #num with the selected option (quoted)
Format(buffer, 5, "@%i", g_currentPlace[param1][Place_ReplaceNum]);
ReplaceString(g_command[param1], sizeof(g_command[]), buffer, info);
//replace @num with the selected option (unquoted)
// Increment the parameter counter.
g_currentPlace[param1][Place_ReplaceNum]++;
ParamCheck(param1);
}
if (action == MenuAction_Cancel && param2 == MenuCancel_Exit)
{
//client exited we should go back to submenu i think
DisplayTopMenu(hAdminMenu, param1, TopMenuPosition_LastCategory);
}
}

141
plugins/include/regex.inc Normal file
View File

@ -0,0 +1,141 @@
#if defined _regex_included
#endinput
#endif
#define _regex_included
/**
* @section Flags for compiling regex expressions. These come directly from the
* pcre library and can be used in MatchRegex and CompileRegex.
*/
#define PCRE_CASELESS 0x00000001 /* Ignore Case */
#define PCRE_MULTILINE 0x00000002 /* Multilines (affects ^ and $ so that they match the start/end of a line rather than matching the start/end of the string). */
#define PCRE_DOTALL 0x00000004 /* Single line (affects . so that it matches any character, even new line characters). */
#define PCRE_EXTENDED 0x00000008 /* Pattern extension (ignore whitespace and # comments). */
#define PCRE_UNGREEDY 0x00000200 /* Invert greediness of quantifiers */
#define PCRE_UTF8 0x00000800 /* Use UTF-8 Chars */
#define PCRE_NO_UTF8_CHECK 0x00002000 /* Do not check the pattern for UTF-8 validity (only relevant if PCRE_UTF8 is set) */
/**
* Regex expression error codes.
*/
enum RegexError
{
REGEX_ERROR_NONE = 0, /* No error */
REGEX_ERROR_NOMATCH = -1, /* No match was found */
REGEX_ERROR_NULL = -2,
REGEX_ERROR_BADOPTION = -3,
REGEX_ERROR_BADMAGIC = -4,
REGEX_ERROR_UNKNOWN_OPCODE = -5,
REGEX_ERROR_NOMEMORY = -6,
REGEX_ERROR_NOSUBSTRING = -7,
REGEX_ERROR_MATCHLIMIT = -8,
REGEX_ERROR_CALLOUT = -9, /* Never used by PCRE itself */
REGEX_ERROR_BADUTF8 = -10,
REGEX_ERROR_BADUTF8_OFFSET = -11,
REGEX_ERROR_PARTIAL = -12,
REGEX_ERROR_BADPARTIAL = -13,
REGEX_ERROR_INTERNAL = -14,
REGEX_ERROR_BADCOUNT = -15,
REGEX_ERROR_DFA_UITEM = -16,
REGEX_ERROR_DFA_UCOND = -17,
REGEX_ERROR_DFA_UMLIMIT = -18,
REGEX_ERROR_DFA_WSSIZE = -19,
REGEX_ERROR_DFA_RECURSE = -20,
REGEX_ERROR_RECURSIONLIMIT = -21,
REGEX_ERROR_NULLWSLIMIT = -22, /* No longer actually used */
REGEX_ERROR_BADNEWLINE = -23
}
/**
* Precompile a regular expression. Use this if you intend on using the
* same expression multiple times. Pass the regex handle returned here to
* MatchRegex to check for matches.
*
* @param pattern The regular expression pattern.
* @param flags General flags for the regular expression.
* @param error Error message encountered, if applicable.
* @param maxLen Maximum string length of the error buffer.
* @param errcode Regex type error code encountered, if applicable.
* @return Valid regex handle on success, INVALID_HANDLE on failure.
*/
native Handle:CompileRegex(const String:pattern[], flags = 0, String:error[]="", maxLen = 0, &RegexError:errcode = REGEX_ERROR_NONE);
/**
* Matches a string against a pre-compiled regular expression pattern.
*
* @param str The string to check.
* @param regex Regex Handle from CompileRegex()
* @param ret Error code, if applicable.
* @return Number of substrings found or -1 on failure.
*
* @note Use the regex handle passed to this function to extract
* matches with GetRegexSubString().
*/
native MatchRegex(Handle:regex, const String:str[], &RegexError:ret = REGEX_ERROR_NONE);
/**
* Returns a matched substring from a regex handle.
* Substring ids start at 0 and end at substrings-1, where substrings is the number returned
* by MatchRegex
*
* @param regex The regex handle to extract data from.
* @param str_id The index of the expression to get - starts at 0, and ends at substrings - 1.
* @param buffer The buffer to set to the matching substring.
* @param maxLen The maximum string length of the buffer.
* @return True if a substring was found, False on fail/error
*/
native bool:GetRegexSubString(Handle:regex, str_id, String:buffer[], maxlen);
/**
* Matches a string against a regular expression pattern.
*
* @note If you intend on using the same regular expression pattern
* multiple times, consider using CompileRegex and MatchRegex
* instead of making this function reparse the expression each time.
*
* @param str The string to check.
* @param pattern The regular expression pattern.
* @param flags General flags for the regular expression.
* @param error Error message, if applicable.
* @param maxLen Maximum length of the error buffer.
* @return Number of substrings found or -1 on failure.
*/
stock SimpleRegexMatch(const String:str[], const String:pattern[], flags = 0, String:error[]="", maxLen = 0)
{
new Handle:regex = CompileRegex(pattern, flags, error, maxLen);
if (regex == INVALID_HANDLE)
{
return -1;
}
new substrings = MatchRegex(regex, str);
CloseHandle(regex);
return substrings;
}
/**
* @endsection
*/
/**
* Do not edit below this line!
*/
public Extension:__ext_regex =
{
name = "Regex Extension",
file = "regex.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};

362
plugins/mapmanager.sp Normal file
View File

@ -0,0 +1,362 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Map Management Plugin
* Provides all map related functionality, including map changing, map voting,
* and nextmap.
*
* SourceMod (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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#pragma semicolon 1
#include <sourcemod>
public Plugin:myinfo =
{
name = "Map Manager",
author = "AlliedModders LLC",
description = "Map Management",
version = SOURCEMOD_VERSION,
url = "http://www.sourcemod.net/"
};
#include "mapmanagement/globals.sp"
#include "mapmanagement/commands.sp"
#include "mapmanagement/events.sp"
#include "mapmanagement/functions.sp"
#include "mapmanagement/menus.sp"
#include "mapmanagement/timers.sp"
#include "mapmanagement/votes.sp"
public OnPluginStart()
{
LoadTranslations("mapmanager.phrases");
// Prepare nextmap functionality.
g_VGUIMenu = GetUserMessageId("VGUIMenu");
if (g_VGUIMenu == INVALID_MESSAGE_ID)
{
LogError("FATAL: Cannot find VGUIMenu user message id. MapManager crippled.");
g_NextMapEnabled = false;
}
HookUserMessage(g_VGUIMenu, UserMsg_VGUIMenu);
// Create all of the arrays, sized for a 64 character string.
new arraySize = ByteCountToCells(64);
g_MapCycle = CreateArray(arraySize);
g_MapList = CreateArray(arraySize);
g_MapHistory = CreateArray(arraySize);
g_NextVoteMaps = CreateArray(arraySize);
g_SelectedMaps = CreateArray(arraySize);
g_NominatedMaps = CreateArray(arraySize);
g_TeamScores = CreateArray(2);
// Hook say
RegConsoleCmd("say", Command_Say);
RegConsoleCmd("say_team", Command_Say);
// Register all commands.
RegAdminCmd("sm_map", Command_Map, ADMFLAG_CHANGEMAP, "sm_map <map> [r/e]");
RegAdminCmd("sm_setnextmap", Command_SetNextmap, ADMFLAG_CHANGEMAP, "sm_setnextmap <map>");
RegAdminCmd("sm_votemap", Command_Votemap, ADMFLAG_VOTE|ADMFLAG_CHANGEMAP, "sm_votemap <mapname> [mapname2] ... [mapname5] ");
RegAdminCmd("sm_maplist", Command_List, ADMFLAG_GENERIC, "sm_maplist");
RegAdminCmd("sm_nominate", Command_Addmap, ADMFLAG_CHANGEMAP, "sm_nominate <mapname> - Nominates a map for RockTheVote and MapChooser. Overrides existing nominations.");
RegAdminCmd("sm_mapvote", Command_Mapvote, ADMFLAG_CHANGEMAP, "sm_mapvote - Forces the MapChooser vote to occur.");
if (GetCommandFlags("nextmap") == INVALID_FCVAR_FLAGS)
{
RegServerCmd("nextmap", Command_Nextmap);
}
// Register all convars
g_Cvar_Nextmap = CreateConVar("sm_nextmap", "", "Sets the Next Map", FCVAR_NOTIFY);
g_Cvar_MapCount = CreateConVar("sm_mm_maps", "4", "Number of maps to be voted on at end of map or RTV. 2 to 6. (Def 4)", 0, true, 2.0, true, 6.0);
g_Cvar_Excludes = CreateConVar("sm_mm_exclude", "5", "Specifies how many past maps to exclude from end of map vote and RTV.", _, true, 0.0);
g_Cvar_MapChooser = CreateConVar("sm_mm_mapchooser", "0", "Enables MapChooser (End of Map voting)", 0, true, 0.0, true, 1.0);
g_Cvar_RockTheVote = CreateConVar("sm_mm_rockthevote", "0", "Enables RockTheVote (Player initiated map votes)", 0, true, 0.0, true, 1.0);
g_Cvar_Randomize = CreateConVar("sm_mm_randomize", "0", "Enabled Randomizer (Randomly picks the next map)", 0, true, 0.0, true, 1.0);
g_Cvar_Nominate = CreateConVar("sm_mm_nominate", "1", "Enables nomination system.", 0, true, 0.0, true, 1.0);
g_Cvar_VoteMap = CreateConVar("sm_mm_votemap", "0.60", "Percentage required for successful sm_votemap.", 0, true, 0.05, true, 1.0);
g_Cvar_RTVLimit = CreateConVar("sm_mm_rtvlimit", "0.60", "Required percentage of players needed to rockthevote", 0, true, 0.05, true, 1.0);
g_Cvar_MinPlayers = CreateConVar("sm_mm_minplayers", "0", "Number of players required before RTV will be enabled.", 0, true, 0.0, true, float(MAXPLAYERS));
g_Cvar_StartTime = CreateConVar("sm_mapvote_start", "3.0", "Specifies when to start the vote based on time remaining.", _, true, 1.0);
g_Cvar_StartRounds = CreateConVar("sm_mapvote_startround", "2.0", "Specifies when to start the vote based on rounds remaining.", _, true, 1.0);
g_Cvar_StartFrags = CreateConVar("sm_mapvote_startfrags", "5.0", "Specifies when to start the vote base on frags remaining.", _, true, 1.0);
g_Cvar_ExtendTimeMax = CreateConVar("sm_extendmap_maxtime", "90", "Specifies the maximum amount of time a map can be extended", _, true, 0.0);
g_Cvar_ExtendTimeStep = CreateConVar("sm_extendmap_timestep", "15", "Specifies how much many more minutes each extension makes", _, true, 5.0);
g_Cvar_ExtendRoundMax = CreateConVar("sm_extendmap_maxrounds", "30", "Specfies the maximum amount of rounds a map can be extended", _, true, 0.0);
g_Cvar_ExtendRoundStep = CreateConVar("sm_extendmap_roundstep", "5", "Specifies how many more rounds each extension makes", _, true, 5.0);
g_Cvar_ExtendFragMax = CreateConVar("sm_extendmap_maxfrags", "150", "Specfies the maximum frags allowed that a map can be extended.", _, true, 0.0);
g_Cvar_ExtendFragStep = CreateConVar("sm_extendmap_fragstep", "10", "Specifies how many more frags are allowed when map is extended.", _, true, 5.0);
g_Cvar_Mapfile = CreateConVar("sm_mapvote_file", "configs/maps.ini", "Map file to use. (Def sourcemod/configs/maps.ini)");
g_Cvar_ExcludeMaps = CreateConVar("sm_mapvote_exclude", "5", "Specifies how many past maps to exclude from the vote.", _, true, 0.0);
g_Cvar_IncludeMaps = CreateConVar("sm_mapvote_include", "5", "Specifies how many maps to include in the vote.", _, true, 2.0, true, 6.0);
g_Cvar_NoVoteMode = CreateConVar("sm_mapvote_novote", "1", "Specifies whether or not MapChooser should pick a map if no votes are received.", _, true, 0.0, true, 1.0);
g_Cvar_Extend = CreateConVar("sm_mapvote_extend", "1", "Specifies whether or not MapChooser will allow the map to be extended.", _, true, 0.0, true, 1.0);
// Find game convars
g_Cvar_Chattime = FindConVar("mp_chattime");
g_Cvar_Winlimit = FindConVar("mp_winlimit");
g_Cvar_Maxrounds = FindConVar("mp_maxrounds");
g_Cvar_Fraglimit = FindConVar("mp_fraglimit");
if (GetCommandFlags("nextmap") == INVALID_FCVAR_FLAGS)
{
RegServerCmd("nextmap", Command_Nextmap);
}
// Hook events
HookEvent("round_end", Event_RoundEnd); // We always require round_end
if (g_Cvar_Fraglimit != INVALID_HANDLE)
{
HookEvent("player_death", Event_PlayerDeath);
}
// Set to the current map so OnMapStart() will know what to do
decl String:currentMap[64];
GetCurrentMap(currentMap, 64);
SetNextmap(currentMap);
// Create necessary menus for TopMenu
g_Menu_Map = CreateMenu(MenuHandler_Map);
SetMenuTitle(g_Menu_Map, "Please select a map");
SetMenuExitBackButton(g_Menu_Map, true);
g_Menu_Votemap = CreateMenu(MenuHandler_VoteMap, MenuAction_DrawItem);
SetMenuTitle(g_Menu_Votemap, "Please select a map");
SetMenuExitBackButton(g_Menu_Votemap, true);
// Bind TopMenu commands to adminmenu_maplist.ini, in cases it doesn't exist in maplists.cfg
decl String:mapListPath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, mapListPath, sizeof(mapListPath), "configs/adminmenu_maplist.ini");
SetMapListCompatBind("sm_map menu", mapListPath);
SetMapListCompatBind("sm_votemap menu", mapListPath);
// Account for late loading
new Handle:topmenu;
if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
{
OnAdminMenuReady(topmenu);
}
AutoExecConfig(true, "mapmanager");
}
public OnAdminMenuReady(Handle:topmenu)
{
/* Block us from being called twice */
if (topmenu == hTopMenu)
{
return;
}
/* Save the Handle */
hTopMenu = topmenu;
new TopMenuObject:server_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_SERVERCOMMANDS);
if (server_commands != INVALID_TOPMENUOBJECT)
{
AddToTopMenu(hTopMenu,
"sm_map",
TopMenuObject_Item,
AdminMenu_Map,
server_commands,
"sm_map",
ADMFLAG_CHANGEMAP);
}
new TopMenuObject:voting_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_VOTINGCOMMANDS);
if (voting_commands != INVALID_TOPMENUOBJECT)
{
AddToTopMenu(hTopMenu,
"sm_votemap",
TopMenuObject_Item,
AdminMenu_VoteMap,
voting_commands,
"sm_votemap",
ADMFLAG_VOTE|ADMFLAG_CHANGEMAP);
}
}
public OnLibraryRemoved(const String:name[])
{
if (strcmp(name, "adminmenu") == 0)
{
hTopMenu = INVALID_HANDLE;
}
}
public OnConfigsExecuted()
{
// Add map logic here
// Get the current and last maps.
decl String:lastMap[64], String:currentMap[64];
GetConVarString(g_Cvar_Nextmap, lastMap, 64);
GetCurrentMap(currentMap, 64);
// Why am I doing this? If we switched to a new map, but it wasn't what we expected (Due to sm_map, sm_votemap, or
// some other plugin/command), we don't want to scramble the map cycle. Or for example, admin switches to a custom map
// not in mapcyclefile. So we keep it set to the last expected nextmap. - ferret
if (strcmp(lastMap, currentMap) == 0)
{
FindAndSetNextMap();
}
// Build map menus for sm_map, sm_votemap, and RTV.
BuildMapMenu(g_Menu_Map, list);
BuildMapMenu(g_Menu_VoteMap, list);
// If the Randomize option is on, randomize!
if (GetConVarBool(g_Cvar_Randomize))
{
CreateTimer(5.0, Timer_RandomizeNextmap);
}
// If MapChooser is active, start it up!
if (GetConVarBool(g_Cvar_MapChooser))
{
SetupTimeleftTimer();
SetConVarString(g_Cvar_Nextmap, "Pending Vote");
}
// If RockTheVote is active, start it up!
if (GetConVarBool(g_Cvar_RockTheVote))
{
BuildMapMenu(g_Menu_RTV, list);
CreateTimer(30.0, Timer_DelayRTV);
}
}
// Reinitialize all our various globals
public OnMapStart()
{
if (g_Nominate != INVALID_HANDLE)
{
ClearArray(g_Nominate);
}
if (g_TeamScores != INVALID_HANDLE)
{
ClearArray(g_TeamScores);
}
g_TotalRounds = 0;
g_RTV_Voters = 0;
g_RTV_Votes = 0;
g_RTV_VotesNeeded = 0;
g_RTV_Started = false;
g_RTV_Ended = false;
}
// Reset globals as necessary and kill timers
public OnMapEnd()
{
g_IntermissionCalled = false;
g_HasVoteStarted = false;
g_RTV_Allowed = false;
if (g_VoteTimer != INVALID_HANDLE)
{
KillTimer(g_VoteTimer);
g_VoteTimer = INVALID_HANDLE;
}
if (g_RetryTimer != INVALID_HANDLE)
{
KillTimer(g_RetryTimer);
g_RetryTimer = INVALID_HANDLE;
}
}
public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
{
if (IsFakeClient(client))
{
return true;
}
// If RTV is active, deal with vote counting.
if (GetConVarBool(g_Cvar_RockTheVote))
{
g_RTV_Voted[client] = false;
g_RTV_Voters++;
g_RTV_VotesNeeded = RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
}
// If Nominate is active, let the new client nominate
if (GetConVarBool(g_Cvar_Nominate))
{
g_Nominated[client] = false;
}
return true;
}
public OnClientDisconnect(client)
{
if (IsFakeClient(client))
{
return;
}
// If RTV is active, deal with vote counting.
if (GetConVarBool(g_Cvar_RockTheVote))
{
if(g_RTV_Voted[client])
{
g_RTV_Votes--;
}
g_RTV_Voters--;
g_RTV_VotesNeeded = RoundToFloor(float(g_RTV_Voters) * GetConVarFloat(g_Cvar_RTVLimit));
// If this client caused us to fall below the RTV threshold and its allowed be started, start it.
if (g_RTV_Votes && g_RTV_Voters && g_RTV_Votes >= g_RTV_VotesNeeded && g_RTV_Allowed && !g_RTV_Started)
{
g_RTV_Started = true;
CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
public OnMapTimeLeftChanged()
{
if (GetConVarBool(g_Cvar_MapChooser))
{
SetupTimeleftTimer();
}
}

View File

@ -0,0 +1,398 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Map Manager Plugin
* Contains callbacks for commands
*
* SourceMod (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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
public Action:Command_Say(client, args)
{
decl String:text[192];
if (GetCmdArgString(text, sizeof(text)) < 1)
{
return Plugin_Continue;
}
new startidx;
if (text[strlen(text)-1] == '"')
{
text[strlen(text)-1] = '\0';
startidx = 1;
}
decl String:message[8];
BreakString(text[startidx], message, sizeof(message));
if (strcmp(message, "nextmap", false) == 0)
{
decl String:map[32];
GetConVarString(g_Cvar_Nextmap, map, sizeof(map));
PrintToChat(client, "%t", "Next Map", map);
}
else
{
if (GetConVarBool(g_Cvar_RockTheVote) && (strcmp(text[startidx], "rtv", false) == 0 || strcmp(text[startidx], "rockthevote", false) == 0))
{
if (g_MapChanged)
{
ReplyToCommand(client, "[SM] %t", "Map change in progress");
return Plugin_Continue;
}
if (!g_RTV_Allowed)
{
PrintToChat(client, "[SM] %t", "RTV Not Allowed");
return Plugin_Continue;
}
if (g_RTV_Ended)
{
PrintToChat(client, "[SM] %t", "RTV Ended");
return Plugin_Continue;
}
if (g_RTV_Started)
{
PrintToChat(client, "[SM] %t", "RTV Started");
return Plugin_Continue;
}
if (GetClientCount(true) < GetConVarInt(g_Cvar_MinPlayers) && g_RTV_Votes == 0) // Should we keep checking g_Votes here?
{
PrintToChat(client, "[SM] %t", "Minimal Players Not Met");
return Plugin_Continue;
}
if (g_RTV_Voted[client])
{
PrintToChat(client, "[SM] %t", "Already Voted");
return Plugin_Continue;
}
new String:name[64];
GetClientName(client, name, sizeof(name));
g_RTV_Votes++;
g_RTV_Voted[client] = true;
PrintToChatAll("[SM] %t", "RTV Requested", name, g_RTV_Votes, g_RTV_VotesNeeded);
if (g_RTV_Votes >= g_RTV_VotesNeeded)
{
g_RTV_Started = true;
CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
}
}
else if (GetConVarBool(g_Cvar_Nominate) && strcmp(text[startidx], "nominate", false) == 0)
{
if (g_MapChanged)
{
ReplyToCommand(client, "[SM] %t", "Map change in progress");
return Plugin_Continue;
}
if (g_RTV_Started || g_HasVoteStarted)
{
ReplyToCommand(client, "[SM] %t", "Map vote in progress");
return Plugin_Continue;
}
if (g_Nominated[client])
{
PrintToChat(client, "[SM] %t", "Already Nominated");
return Plugin_Continue;
}
if (GetArraySize(g_Nominate) >= GetConVarInt(g_Cvar_Maps))
{
PrintToChat(client, "[SM] %t", "Max Nominations");
return Plugin_Continue;
}
DisplayMenu(g_Menu_Nominate, client, MENU_TIME_FOREVER);
}
}
return Plugin_Continue;
}
public Action:Command_Mapvote(client, args)
{
InitiateVote();
return Plugin_Handled;
}
public Action:Command_Nextmap(args)
{
decl String:map[64];
GetConVarString(g_Cvar_Nextmap, map, sizeof(map));
ReplyToCommand(0, "%t", "Next Map", map);
return Plugin_Handled;
}
public Action:Command_List(client, args)
{
PrintToConsole(client, "Map Cycle:");
decl String:currentMap[64];
GetCurrentMap(currentMap, 64);
decl String:mapName[64];
for (new i = 0; i < GetArraySize(g_MapCycle); i++)
{
GetArrayString(g_MapCycle, i, mapName, sizeof(mapName));
if (strcmp(mapName, currentMap) == 0)
{
PrintToConsole(client, "%s <========= Current map", mapName);
}
else if (strcmp(mapName, g_NextMap) == 0)
{
PrintToConsole(client, "%s <========= Next map", mapName);
}
else
{
PrintToConsole(client, "%s", mapName);
}
}
return Plugin_Handled;
}
public Action:Command_SetNextmap(client, args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_setnextmap <map>");
return Plugin_Handled;
}
if (g_MapChanged)
{
ReplyToCommand(client, "[SM] %t", "Map change in progress");
return Plugin_Handled;
}
decl String:map[64];
GetCmdArg(1, map, sizeof(map));
if (!IsMapValid(map))
{
ReplyToCommand(client, "[SM] %t", "Map was not found", map);
return Plugin_Handled;
}
ShowActivity(client, "%t", "Cvar changed", "sm_nextmap", map);
LogMessage("\"%L\" changed sm_nextmap to \"%s\"", client, map);
SetNextMap(map);
return Plugin_Handled;
}
public Action:Command_Map(client, args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_map <map> [r/e]");
return Plugin_Handled;
}
if (g_MapChanged)
{
ReplyToCommand(client, "[SM] %t", "Map change in progress");
return Plugin_Handled;
}
decl String:map[64];
GetCmdArg(1, map, sizeof(map));
if (!IsMapValid(map))
{
ReplyToCommand(client, "[SM] %t", "Map was not found", map);
return Plugin_Handled;
}
decl String:when[2];
if (args > 1)
{
GetCmdArg(2, when, sizeof(when));
when[0] = CharToLower(when[0]);
if (when[0] != 'r' && when[0] != 'e')
{
when[0] = 'i';
}
}
SetMapChange(client, map, when);
return Plugin_Handled;
}
public Action:Command_Votemap(client, args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_votemap [r/e] <mapname> [mapname2] ... [mapname5]");
return Plugin_Handled;
}
if (g_MapChanged)
{
ReplyToCommand(client, "[SM] %t", "Map change in progress");
return Plugin_Handled;
}
if (IsVoteInProgress())
{
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
return Plugin_Handled;
}
if (!TestVoteDelay(client))
{
return Plugin_Handled;
}
decl String:text[256];
GetCmdArgString(text, sizeof(text));
decl String:maps[5][64];
new mapCount;
new len, pos;
// Find out if the user specified "when"
decl String:when[64];
pos = BreakString(text[len], when, sizeof(when));
if (!IsMapValid(when))
{
when[0] = CharToLower(when[0]);
if (when[0] != 'r' && when[0] != 'e')
{
ReplyToCommand(client, "[SM] %t", "Map was not found", maps[mapCount]);
return Plugin_Handled;
}
}
else
{
strcpy(maps[mapCount], sizeof(maps[]), when);
mapCount++;
when[0] = 'i';
}
len += pos;
while (pos != -1 && mapCount < 5)
{
pos = BreakString(text[len], maps[mapCount], sizeof(maps[]));
if (!IsMapValid(maps[mapCount]))
{
ReplyToCommand(client, "[SM] %t", "Map was not found", maps[mapCount]);
return Plugin_Handled;
}
mapCount++;
len += pos;
}
g_VoteMapInUse = client;
g_Client_Data[client][0] = when[0];
DisplayVoteMapMenu(client, mapCount, maps);
return Plugin_Handled;
}
public Action:Command_Nominate(client, args)
{
if (args < 1)
{
ReplyToCommand(client, "[SM] Usage: sm_nominate <mapname>");
return Plugin_Handled;
}
if (!GetConVarBool(g_Cvar_Nominate))
{
ReplyToCommand(client, "[SM] Nominations are currently disabled.");
return Plugin_Handled;
}
decl String:mapname[64];
GetCmdArg(1, mapname, sizeof(mapname));
if (FindStringInArray(g_MapList, mapname) == -1)
{
ReplyToCommand(client, "%t", "Map was not found", mapname);
return Plugin_Handled;
}
if (GetArraySize(g_Nominated) > 0)
{
if (FindStringInArray(g_Nominated, mapname) != -1)
{
ReplyToCommand(client, "%t", "Map Already In Vote", mapname);
return Plugin_Handled;
}
ShiftArrayUp(g_Nominated, 0);
SetArrayString(g_Nominated, 0, mapname);
while (GetArraySize(g_Nominated) > GetConVarInt(g_Cvar_Maps))
{
RemoveFromArray(g_Nominated, GetConVarInt(g_Cvar_Maps));
}
}
else
{
PushArrayString(g_Nominated, mapname);
}
decl String:item[64];
for (new i = 0; i < GetMenuItemCount(g_Menu_Nominate); i++)
{
GetMenuItem(g_Menu_Nominate, i, item, sizeof(item));
if (strcmp(item, mapname) == 0)
{
RemoveMenuItem(g_Menu_Nominate, i);
break;
}
}
ReplyToCommand(client, "%t", "Map Inserted", mapname);
LogAction(client, -1, "\"%L\" inserted map \"%s\".", client, mapname);
return Plugin_Handled;
}

View File

@ -0,0 +1,166 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Map Manager Plugin
* Contains event callbacks
*
* SourceMod (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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
public Action:UserMsg_VGUIMenu(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
if (g_IntermissionCalled)
{
return Plugin_Handled;
}
decl String:type[15];
/* If we don't get a valid string, bail out. */
if (BfReadString(bf, type, sizeof(type)) < 0)
{
return Plugin_Handled;
}
if (BfReadByte(bf) == 1 && BfReadByte(bf) == 0 && (strcmp(type, "scores", false) == 0))
{
g_IntermissionCalled = true;
decl String:map[32];
new Float:fChatTime = GetConVarFloat(g_Cvar_Chattime);
if (fChatTime < 2.0)
{
SetConVarFloat(g_Cvar_Chattime, 2.0);
}
LogMessage("[MapManager] Changing map to '%s' due to map ending.", g_NextMap);
g_MapChanged = true;
CreateTimer(fChatTime - 1.0, Timer_ChangeMap);
}
return Plugin_Handled;
}
public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
if (g_MapChanged)
{
return;
}
if (g_MapChangeSet && g_MapChangeWhen == 'r')
{
LogMessage("[MapManager] Changing map to '%s' due to round ending.", g_NextMap);
g_MapChanged = true;
CreateTimer(1.0, Timer_ChangeMap);
return;
}
if (g_HasVoteStarted)
{
return;
}
new winner = GetEventInt(event, "winner");
if (winner == 0 || winner == 1)
{
return;
}
g_TotalRounds++;
new team[2], teamPos = -1;
for (new i; i < GetArraySize(g_TeamScores); i++)
{
GetArrayArray(g_TeamScores, i, team);
if (team[0] == winner)
{
teamPos = i;
break;
}
}
if (teamPos == -1)
{
team[0] = winner;
team[1] = 1;
PushArrayArray(g_TeamScores, team);
}
else
{
team[1]++;
SetArrayArray(g_TeamScores, teamPos, team);
}
if (g_Cvar_Winlimit != INVALID_HANDLE)
{
new winlimit = GetConVarInt(g_Cvar_Winlimit);
if (winlimit)
{
if (team[1] >= (winlimit - GetConVarInt(g_Cvar_StartRounds)))
{
InitiateVote();
}
}
}
if (g_Cvar_Maxrounds != INVALID_HANDLE)
{
new maxrounds = GetConVarInt(g_Cvar_Maxrounds);
if (maxrounds)
{
if (g_TotalRounds >= (maxrounds - GetConVarInt(g_Cvar_StartRounds)))
{
InitiateVote();
}
}
}
}
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
if (g_MapChanged || g_HasVoteStarted || g_Cvar_Fraglimit == INVALID_HANDLE)
{
return;
}
if (!GetConVarInt(g_Cvar_Fraglimit))
{
return;
}
new fragger = GetClientOfUserId(GetEventInt(event, "attacker"));
if (fragger && GetClientFrags(fragger) >= (GetConVarInt(g_Cvar_Fraglimit) - GetConVarInt(g_Cvar_StartFrags)))
{
InitiateVote();
}
}

View File

@ -0,0 +1,335 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Map Management Plugin
* Contains misc functions.
*
* SourceMod (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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
SetNextMap(String:map[])
{
strcopy(g_NextMap, sizeof(g_NextMap), map);
SetConVarString(g_Cvar_Nextmap, map);
}
SetMapChange(client, map, when, Float:time = 3.0)
{
g_MapChangeSet = true;
g_MapChangeWhen = when[0];
SetNextMap(map);
if (when[0] == 'r')
{
ShowActivity2(client, "[SM] ", "%t", "Changing map end of round", map);
LogAction(client, -1, "\"%L\" set end of round map change to \"%s\"", client, map);
}
else if (when[0] == 'e')
{
ShowActivity2(client, "[SM] ", "%t", "Set nextmap", map);
LogAction(client, -1, "\"%L\" set the next map to \"%s\"", client, map);
}
else
{
ShowActivity2(client, "[SM] ", "%t", "Change map", map);
LogAction(client, -1, "\"%L\" changed map to \"%s\"", client, map);
g_MapChanged = true;
CreateTimer(3.0, Timer_ChangeMap);
}
}
FindAndSetNextMap()
{
if (ReadMapList(g_MapList,
g_MapListSerial,
"mapcyclefile",
MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_NO_DEFAULT)
== INVALID_HANDLE)
{
if (g_MapListSerial == -1)
{
LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
SetFailState("Mapcycle Not Found");
}
}
new mapCount = GetArraySize(g_MapList);
decl String:mapName[32];
if (g_MapPos == -1)
{
decl String:current[64];
GetCurrentMap(current, 64);
for (new i = 0; i < mapCount; i++)
{
GetArrayString(g_MapList, i, mapName, sizeof(mapName));
if (strcmp(current, mapName, false) == 0)
{
g_MapPos = i;
break;
}
}
if (g_MapPos == -1)
g_MapPos = 0;
}
g_MapPos++;
if (g_MapPos >= mapCount)
g_MapPos = 0;
GetArrayString(g_MapList, g_MapPos, mapName, sizeof(mapName));
SetConVarString(g_Cvar_Nextmap, mapName);
}
Float:GetVotePercent(votes, totalVotes)
{
return FloatDiv(float(votes),float(totalVotes));
}
bool:TestVoteDelay(client)
{
new delay = CheckVoteDelay();
if (delay > 0)
{
if (delay > 60)
{
ReplyToCommand(client, "[SM] %t", "Vote Delay Minutes", delay % 60);
}
else
{
ReplyToCommand(client, "[SM] %t", "Vote Delay Seconds", delay);
}
return false;
}
return true;
}
BuildMapMenu()
{
if (g_MapMenu != INVALID_HANDLE)
{
CloseHandle(g_MapMenu);
g_MapMenu = INVALID_HANDLE;
}
g_MapMenu = CreateMenu(Handler_MapSelectMenu);
SetMenuTitle(g_MapMenu, "%t", "Nominate Title");
decl String:map[64];
for (new i = 0; i < GetArraySize(g_MapList); i++)
{
GetArrayString(g_MapList, i, map, sizeof(map));
AddMenuItem(g_MapMenu, map, map);
}
SetMenuExitButton(g_MapMenu, false);
}
SetupTimeleftTimer()
{
new time;
if (GetMapTimeLeft(time) && time > 0)
{
new startTime = GetConVarInt(g_Cvar_StartTime) * 60;
if (time - startTime < 0)
{
InitiateVote();
}
else
{
if (g_VoteTimer != INVALID_HANDLE)
{
KillTimer(g_VoteTimer);
g_VoteTimer = INVALID_HANDLE;
}
g_VoteTimer = CreateTimer(float(time - startTime), Timer_StartMapVote);
}
}
}
InitiateVote()
{
if (g_HasVoteStarted || g_RetryTimer != INVALID_HANDLE)
{
return;
}
if (IsVoteInProgress())
{
// Can't start a vote, try again in 5 seconds.
g_RetryTimer = CreateTimer(5.0, Timer_StartMapVote);
return;
}
g_HasVoteStarted = true;
g_VoteMenu = CreateMenu(Handler_MapVoteMenu, MenuAction:MENU_ACTIONS_ALL);
SetMenuTitle(g_VoteMenu, "Vote Nextmap");
decl String:map[32];
for (new i = 0; i < GetArraySize(g_NextMapList); i++)
{
GetArrayString(g_NextMapList, i, map, sizeof(map));
AddMenuItem(g_VoteMenu, map, map);
}
if (GetConVarBool(g_Cvar_Extend))
{
new bool:allowExtend, time;
if (GetMapTimeLimit(time) && time > 0 && time < GetConVarInt(g_Cvar_ExtendTimeMax))
{
allowExtend = true;
}
if (g_Cvar_Winlimit != INVALID_HANDLE && GetConVarInt(g_Cvar_Winlimit) < GetConVarInt(g_Cvar_ExtendRoundMax))
{
allowExtend = true;
}
if (g_Cvar_Maxrounds != INVALID_HANDLE && GetConVarInt(g_Cvar_Maxrounds) < GetConVarInt(g_Cvar_ExtendRoundMax))
{
allowExtend = true;
}
if (g_Cvar_Fraglimit != INVALID_HANDLE && GetConVarInt(g_Cvar_Fraglimit) < GetConVarInt(g_Cvar_ExtendFragMax))
{
allowExtend = true;
}
if (allowExtend)
{
AddMenuItem(g_VoteMenu, VOTE_EXTEND, "Extend Map");
}
}
SetMenuExitButton(g_VoteMenu, false);
VoteMenuToAll(g_VoteMenu, 20);
LogMessage("Voting for next map has started.");
PrintToChatAll("[SM] %t", "Nextmap Voting Started");
}
SetNextMap(const String:map[])
{
SetConVarString(g_Cvar_Nextmap, map);
PushArrayString(g_OldMapList, map);
if (GetArraySize(g_OldMapList) > GetConVarInt(g_Cvar_ExcludeMaps))
{
RemoveFromArray(g_OldMapList, 0);
}
PrintToChatAll("[SM] %t", "Nextmap Voting Finished", map);
LogMessage("Voting for next map has finished. Nextmap: %s.", map);
}
CreateNextVote()
{
if(g_NextMapList != INVALID_HANDLE)
{
ClearArray(g_NextMapList);
}
decl String:map[32];
new index, Handle:tempMaps = CloneArray(g_MapList);
GetCurrentMap(map, sizeof(map));
index = FindStringInArray(tempMaps, map);
if (index != -1)
{
RemoveFromArray(tempMaps, index);
}
if (GetConVarInt(g_Cvar_ExcludeMaps) && GetArraySize(tempMaps) > GetConVarInt(g_Cvar_ExcludeMaps))
{
for (new i = 0; i < GetArraySize(g_OldMapList); i++)
{
GetArrayString(g_OldMapList, i, map, sizeof(map));
index = FindStringInArray(tempMaps, map);
if (index != -1)
{
RemoveFromArray(tempMaps, index);
}
}
}
new limit = (GetConVarInt(g_Cvar_IncludeMaps) < GetArraySize(tempMaps) ? GetConVarInt(g_Cvar_IncludeMaps) : GetArraySize(tempMaps));
for (new i = 0; i < limit; i++)
{
new b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
GetArrayString(tempMaps, b, map, sizeof(map));
PushArrayString(g_NextMapList, map);
RemoveFromArray(tempMaps, b);
}
CloseHandle(tempMaps);
}
/*
new Handle:g_map_array = INVALID_HANDLE;
new g_map_serial = -1;
LoadMapList(Handle:menu)
{
new Handle:map_array;
if ((map_array = ReadMapList(g_map_array,
g_map_serial,
"sm_map menu",
MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_NO_DEFAULT|MAPLIST_FLAG_MAPSFOLDER))
!= INVALID_HANDLE)
{
g_map_array = map_array;
}
if (g_map_array == INVALID_HANDLE)
{
return 0;
}
RemoveAllMenuItems(menu);
decl String:map_name[64];
new map_count = GetArraySize(g_map_array);
for (new i = 0; i < map_count; i++)
{
GetArrayString(g_map_array, i, map_name, sizeof(map_name));
AddMenuItem(menu, map_name, map_name);
}
return map_count;
}
*/

View File

@ -0,0 +1,115 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Map Management Plugin
* Contains misc functions.
*
* SourceMod (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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
DisplayWhenMenu(client, bool:vote = false)
{
new Handle:
if (!vote)
{
menu = CreateMenu(MenuHandler_ChangeMap);
}
else
{
menu = CreateMenu(MenuHandler_VoteWhen);
}
decl String:title[100];
Format(title, sizeof(title), "%T:", "Map Change When", client);
SetMenuTitle(menu, title);
SetMenuExitBackButton(menu, true);
AddMenuItem(menu, "i", "Immediately");
AddMenuItem(menu, "r", "Round End");
AddMenuItem(menu, "e", "Map End");
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
DisplayConfirmVoteMenu(client)
{
new Handle:menu = CreateMenu(MenuHandler_Confirm);
decl String:title[100];
Format(title, sizeof(title), "%T:", "Confirm Vote", client);
SetMenuTitle(menu, title);
SetMenuExitBackButton(menu, true);
AddMenuItem(menu, "Confirm", "Start the Vote");
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
DisplayAcceptVoteMenu(String:map[])
{
new Handle:menu = CreateMenu(MenuHandler_Accept);
decl String:title[100];
Format(title, sizeof(title), "%T:", "Accept Vote", client);
SetMenuTitle(menu, title);
SetMenuExitBackButton(menu, true);
AddMenuItem(menu, map, "Accept Vote");
DisplayMenu(menu, g_VoteMapInUse, MENU_TIME_FOREVER);
}
DisplayVoteMapMenu(client, mapCount, String:maps[5][])
{
LogAction(client, -1, "\"%L\" initiated a map vote.", client);
ShowActivity2(client, "[SM] ", "%t", "Initiated Vote Map");
new Handle:menu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
if (mapCount == 1)
{
//strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), maps[0]);
SetMenuTitle(menu, "Change Map To");
AddMenuItem(menu, maps[0], "Yes");
AddMenuItem(menu, VOTE_NO, "No");
}
else
{
//g_voteInfo[VOTE_NAME][0] = '\0';
SetMenuTitle(menu, "Map Vote");
for (new i = 0; i < mapCount; i++)
{
AddMenuItem(menu, maps[i], maps[i]);
}
}
SetMenuExitButton(menu, false);
VoteMenuToAll(menu, 20);
}

View File

@ -0,0 +1,104 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Map Manager Plugin
* Contains globals and defines
*
* SourceMod (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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#define VOTE_EXTEND "##extend##"
#define VOTE_YES "###yes###"
#define VOTE_NO "###no###"
new Handle:hTopMenu = INVALID_HANDLE; // TopMenu
new Handle:g_MapCycle = INVALID_HANDLE; // mapcyclefile maps
new Handle:g_MapList = INVALID_HANDLE; // maplist.txt maps
new Handle:g_MapHistory = INVALID_HANDLE; // History of maps played
new Handle:g_NextVoteMaps = INVALID_HANDLE; // Array of maps for next RTV or MC vote
new Handle:g_NominatedMaps = INVALID_HANDLE; // Array of maps that have been nominated
new Handle:g_Menu_Map = INVALID_HANDLE; // Menu of maps used by sm_map in admin menu
new Handle:g_Menu_Votemap = INVALID_HANDLE; // Menu of maps used by sm_votemap in admin menu
new Handle:g_Menu_Nominate = INVALID_HANDLE; // Menu of maps used by Nomination system
new Handle:g_SelectedMaps; // List of maps chosen so far by a user in sm_votemap admin menu
new g_VoteMapInUse; // Client index of admin using sm_votemap
new String:g_Client_Data[MAXCLIENTS+1][64]; // Used to hold bits of client data during sm_votemap
new bool:g_MapChangeSet; // True if a command or vote has set the map
new bool:g_MapChanged; // True if a map change has been issued
new g_MapChangeWhen; // Either 'i' for immediate, 'r' for round end, or 'e' for end of map.
new UserMsg:g_VGUIMenu; // VGUI usermsg id for nextmap
new bool:g_NextMapEnabled = true // If set to false, all features requiring nextmap are disabled.
new bool:g_IntermissionCalled; // Has the end of map intermission begun?
new String:g_NextMap[64]; // All important! This is the next map!
new g_MapPos = -1; // Position in mapcycle
new bool:g_RTV_Voted[MAXPLAYERS+1] = {false, ...}; // Whether or not a player has voted for RTV
new bool:g_RTV_Allowed = false; // True if RTV is available to players. Used to delay rtv votes.
new bool:g_RTV_Started = false; // Indicates that the actual map vote has started
new bool:g_RTV_Ended = false; // Indicates that the actual map vote has concluded
new g_RTV_Voters = 0; // Total voters connected. Doesn't include fake clients.
new g_RTV_Votes = 0; // Total number of "say rtv" votes
new g_RTV_VotesNeeded = 0; // Necessary votes before map vote begins. (voters * percent_needed)
new bool:g_Nominated[MAXPLAYERS+1] = {false, ...}; // Whether or not a player has nominated a map
new Handle:g_TeamScores = INVALID_HANDLE; // Array of team scores
new g_TotalRounds; // Total rounds played this map
new bool:g_HasVoteStarted; // Whether or not MapChooser has begun
// ConVar handles
new Handle:g_Cvar_NextMap = INVALID_HANDLE;
new Handle:g_Cvar_VoteMap = INVALID_HANDLE;
new Handle:g_Cvar_Excludes = INVALID_HANDLE;
new Handle:g_Cvar_StartTime = INVALID_HANDLE;
new Handle:g_Cvar_StartRounds = INVALID_HANDLE;
new Handle:g_Cvar_StartFrags = INVALID_HANDLE;
new Handle:g_Cvar_ExtendTimeMax = INVALID_HANDLE;
new Handle:g_Cvar_ExtendTimeStep = INVALID_HANDLE;
new Handle:g_Cvar_ExtendRoundMax = INVALID_HANDLE;
new Handle:g_Cvar_ExtendRoundStep = INVALID_HANDLE;
new Handle:g_Cvar_ExtendFragMax = INVALID_HANDLE;
new Handle:g_Cvar_ExtendFragStep = INVALID_HANDLE;
new Handle:g_Cvar_Mapfile = INVALID_HANDLE;
new Handle:g_Cvar_ExcludeMaps = INVALID_HANDLE;
new Handle:g_Cvar_IncludeMaps = INVALID_HANDLE;
new Handle:g_Cvar_NoVoteMode = INVALID_HANDLE;
new Handle:g_Cvar_Extend = INVALID_HANDLE;
new Handle:g_VoteTimer = INVALID_HANDLE;
new Handle:g_RetryTimer = INVALID_HANDLE;
// VALVe ConVars
new Handle:g_Cvar_Chattime = INVALID_HANDLE;
new Handle:g_Cvar_Winlimit = INVALID_HANDLE;
new Handle:g_Cvar_Maxrounds = INVALID_HANDLE;
new Handle:g_Cvar_Fraglimit = INVALID_HANDLE;

263
plugins/mapmanager/menus.sp Normal file
View File

@ -0,0 +1,263 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Map Manager Plugin
* Contains menu callbacks
*
* SourceMod (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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
// Following callbacks are for sm_map
public AdminMenu_Map(Handle:topmenu,
TopMenuAction:action,
TopMenuObject:object_id,
param,
String:buffer[],
maxlength)
{
if (action == TopMenuAction_DisplayOption)
{
Format(buffer, maxlength, "%T", "Choose Map", param);
}
else if (action == TopMenuAction_SelectOption)
{
DisplayMenu(g_Menu_Map, param, MENU_TIME_FOREVER);
}
}
public MenuHandler_Map(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_Cancel)
{
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
{
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
}
}
else if (action == MenuAction_Select)
{
GetMenuItem(menu, param2, g_Client_Data[param1], sizeof(g_Client_Data[]));
DisplayWhenMenu(param1);
}
}
public MenuHandler_ChangeMap(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_Cancel)
{
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
{
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
}
}
else if (action == MenuAction_Select)
{
decl String:when[2];
GetMenuItem(menu, param2, when, sizeof(when));
SetMapChange(client, g_Client_Data[param1], when[0])
}
}
// Following callbacks are for sm_votemap
public AdminMenu_VoteMap(Handle:topmenu,
TopMenuAction:action,
TopMenuObject:object_id,
param,
String:buffer[],
maxlength)
{
if (action == TopMenuAction_DisplayOption)
{
Format(buffer, maxlength, "%T", "Map vote", param);
}
else if (action == TopMenuAction_SelectOption)
{
g_VoteMapInUse = param;
ClearArray(g_SelectedMaps);
DisplayMenu(g_Menu_Votemap, param, MENU_TIME_FOREVER);
}
else if (action == TopMenuAction_DrawOption)
{
/* disable this option if a vote is already running, theres no maps listed or someone else has already accessed this menu */
buffer[0] = (!IsNewVoteAllowed() || g_VoteMapInUse) ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
}
}
public MenuHandler_VoteMap(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_Cancel)
{
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
{
DisplayWhenMenu(param1, true);
}
else // no action was selected.
{
/* Re-enable the menu option */
g_VoteMapInUse = 0;
}
}
else if (action == MenuAction_DrawItem)
{
decl String:info[32];
GetMenuItem(menu, param2, info, sizeof(info));
if (FindStringInArray(g_SelectedMaps, info) != -1)
{
return ITEMDRAW_IGNORE;
}
else
{
return ITEMDRAW_DEFAULT;
}
}
else if (action == MenuAction_Select)
{
decl String:info[32];
GetMenuItem(menu, param2, info, sizeof(info));
PushArrayString(g_SelectedMaps, info);
/* Redisplay the list */
if (GetArraySize(g_SelectedMaps) < 5)
{
DisplayMenu(g_MapList, param1, MENU_TIME_FOREVER);
}
else
{
DisplayWhenMenu(param1, true);
}
}
return 0;
}
public MenuHandler_VoteWhen(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_End)
{
CloseHandle(menu);
}
else if (action == MenuAction_Cancel)
{
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
{
g_Menu_Info[param1][0] = 'i';
DisplayConfirmVoteMenu(param1);
}
else
{
g_VoteMapInUse = 0;
}
}
else if (action == MenuAction_Select)
{
GetMenuItem(menu, param2, g_Menu_Info[param1], sizeof(g_Menu_Info[]));
DisplayConfirmVoteMenu(param1);
}
}
public MenuHandler_Confirm(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_End)
{
CloseHandle(menu);
}
else if (action == MenuAction_Cancel)
{
g_VoteMapInUse = 0;
if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
{
DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
}
}
else if (action == MenuAction_Select)
{
decl String:maps[5][64];
new selectedmaps = GetArraySize(g_SelectedMaps);
for (new i = 0; i < selectedmaps; i++)
{
GetArrayString(g_SelectedMaps, i, maps[i], sizeof(maps[]));
}
DisplayVoteMapMenu(param1, selectedmaps, maps);
}
}
public MenuHandler_Accept(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_End)
{
CloseHandle(menu);
g_VoteMapInUse = 0;
}
else if (action == MenuAction_Select)
{
decl String:map[64]
GetMenuItem(menu, 1, map, sizeof(map));
SetMapChange(param1, map, g_Client_Data[param1][0])
}
}
public Handler_MapSelectMenu(Handle:menu, MenuAction:action, param1, param2)
{
switch (action)
{
case MenuAction_Select:
{
if (GetArraySize(g_RTVMapList) >= GetConVarInt(g_Cvar_Maps))
{
PrintToChat(param1, "[SM] %t", "Max Nominations");
return;
}
decl String:map[64], String:name[64];
GetMenuItem(menu, param2, map, sizeof(map));
if (FindStringInArray(g_RTVMapList, map) != -1)
{
PrintToChat(param1, "[SM] %t", "Map Already Nominated");
return;
}
GetClientName(param1, name, 64);
PushArrayString(g_RTVMapList, map);
RemoveMenuItem(menu, param2);
g_Nominated[param1] = true;
PrintToChatAll("[SM] %t", "Map Nominated", name, map);
}
}
}

View File

@ -0,0 +1,166 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Map Manager Plugin
* Contains timer callbacks
*
* SourceMod (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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
public Action:Timer_ChangeMap(Handle:timer)
{
ServerCommand("changelevel \"%s\"", g_NextMap);
PushArrayString(g_MapHistory, g_NextMap);
return Plugin_Stop;
}
public Action:Timer_RandomizeNextmap(Handle:timer)
{
decl String:map[64];
new exclusion = GetConVarInt(g_Cvar_ExcludeMaps);
if (exclusion > GetArraySize(g_MapCycle))
{
exclusion = GetArraySize(g_MapCycle) - 1;
}
new b = GetRandomInt(0, GetArraySize(g_MapCycle) - 1);
GetArrayString(g_MapCycle, b, map, sizeof(map));
while (FindStringInArray(g_MapHistory, map) != -1)
{
b = GetRandomInt(0, GetArraySize(g_MapCycle) - 1);
GetArrayString(g_MapCycle, b, map, sizeof(map));
}
SetNextmap(map);
LogMessage("[MapManager] Randomizer has chosen '%s' as the next map.", map);
return Plugin_Stop;
}
public Action:Timer_DelayRTV(Handle:timer)
{
g_RTVAllowed = true;
g_RTVStarted = false;
g_RTVEnded = false;
}
public Action:Timer_StartRTV(Handle:timer)
{
if (timer == g_RetryTimer)
{
g_RetryTimer = INVALID_HANDLE;
}
if (g_RetryTimer != INVALID_HANDLE)
{
return;
}
if (IsVoteInProgress())
{
// Can't start a vote, try again in 5 seconds.
g_RetryTimer = CreateTimer(5.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
return;
}
PrintToChatAll("[SM] %t", "RTV Vote Ready");
new Handle:MapVoteMenu = CreateMenu(Handler_MapMapVoteMenu, MenuAction:MENU_ACTIONS_ALL);
SetMenuTitle(MapVoteMenu, "Rock The Vote");
new Handle:tempMaps = CloneArray(g_MapList);
decl String:map[32];
GetCurrentMap(map, sizeof(map));
new index = FindStringInArray(tempMaps, map);
if (index != -1)
{
RemoveFromArray(tempMaps, index);
}
// We assume that g_RTVMapList is within the correct limits, based on the logic for nominations
for (new i = 0; i < GetArraySize(g_RTVMapList); i++)
{
GetArrayString(g_RTVMapList, i, map, sizeof(map));
AddMenuItem(MapVoteMenu, map, map);
index = FindStringInArray(tempMaps, map);
if (index != -1)
{
RemoveFromArray(tempMaps, index);
}
}
new limit = GetConVarInt(g_Cvar_Maps) - GetArraySize(g_RTVMapList);
if (limit > GetArraySize(tempMaps))
{
limit = GetArraySize(tempMaps);
}
for (new i = 0; i < limit; i++)
{
new b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
GetArrayString(tempMaps, b, map, sizeof(map));
PushArrayString(g_RTVMapList, map);
AddMenuItem(MapVoteMenu, map, map);
RemoveFromArray(tempMaps, b);
}
CloseHandle(tempMaps);
AddMenuItem(MapVoteMenu, "Don't Change", "Don't Change");
SetMenuExitButton(MapVoteMenu, false);
VoteMenuToAll(MapVoteMenu, 20);
LogMessage("[SM] Rockthevote was successfully started.");
}
public Action:Timer_StartMapVote(Handle:timer)
{
if (!GetArraySize(g_MapList))
{
return Plugin_Stop;
}
if (timer == g_RetryTimer)
{
g_RetryTimer = INVALID_HANDLE;
}
else
{
g_VoteTimer = INVALID_HANDLE;
}
InitiateVote();
return Plugin_Stop;
}

318
plugins/mapmanager/votes.sp Normal file
View File

@ -0,0 +1,318 @@
/**
* vim: set ts=4 :
* =============================================================================
* SourceMod Map Manager Plugin
* Contains vote callbacks
*
* SourceMod (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, version 3.0, as published by the
* Free Software Foundation.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
// sm_votemap
public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_End)
{
CloseHandle(menu);
}
else if (action == MenuAction_Display)
{
decl String:title[64];
GetMenuTitle(menu, title, sizeof(title));
decl String:map[64];
GetMenuItem(menu, 1, map, sizeof(map));
decl String:buffer[255];
Format(buffer, sizeof(buffer), "%T", title, param1, map);
new Handle:panel = Handle:param2;
SetPanelTitle(panel, buffer);
}
else if (action == MenuAction_DisplayItem)
{
decl String:display[64];
GetMenuItem(menu, param2, "", 0, _, display, sizeof(display));
if (strcmp(display, "No") == 0 || strcmp(display, "Yes") == 0)
{
decl String:buffer[255];
Format(buffer, sizeof(buffer), "%T", display, param1);
return RedrawMenuItem(buffer);
}
}
else if (action == MenuAction_VoteCancel && param1 == VoteCancel_NoVotes)
{
PrintToChatAll("[SM] %t", "No Votes Cast");
}
else if (action == MenuAction_VoteEnd)
{
decl String:item[64], String:display[64];
new Float:percent, Float:limit, votes, totalVotes;
GetMenuVoteInfo(param2, votes, totalVotes);
GetMenuItem(menu, param1, item, sizeof(item), _, display, sizeof(display));
if (strcmp(item, VOTE_NO) == 0 && param1 == 1)
{
votes = totalVotes - votes; // Reverse the votes to be in relation to the Yes option.
}
percent = GetVotePercent(votes, totalVotes);
limit = GetConVarFloat(g_Cvar_VoteMap);
// A multi-argument vote is "always successful", but have to check if its a Yes/No vote.
if ((strcmp(item, VOTE_YES) == 0 && FloatCompare(percent,limit) < 0 && param1 == 0) || (strcmp(item, VOTE_NO) == 0 && param1 == 1))
{
LogAction(-1, -1, "Vote failed.");
PrintToChatAll("[SM] %t", "Votemap Failed", RoundToNearest(100.0*limit), RoundToNearest(100.0*percent), totalVotes);
}
else
{
PrintToChatAll("[SM] %t", "Votemap Successful", RoundToNearest(100.0*percent), totalVotes);
if (g_VoteMapInUse && IsClientInGame(g_VoteMapInUse))
{
DisplayAcceptVoteMenu(item);
}
else
{
LogAction(-1, -1, "Changing map to %s due to vote.", item);
PrintToChatAll("[SM] %t", "Changing map", item);
SetMapChange(0, item, g_Client_Data[g_VoteMapInUse][0])
}
}
}
return 0;
}
public Handler_MapMapVoteMenu(Handle:menu, MenuAction:action, param1, param2)
{
switch (action)
{
case MenuAction_End:
{
CloseHandle(menu);
}
case MenuAction_Display:
{
decl String:oldTitle[255], String:buffer[255];
GetMenuTitle(menu, oldTitle, sizeof(oldTitle));
Format(buffer, sizeof(buffer), "%T", oldTitle, param1);
new Handle:panel = Handle:param2;
SetPanelTitle(panel, buffer);
}
case MenuAction_DisplayItem:
{
if (GetMenuItemCount(menu) - 1 == param2)
{
decl String:buffer[255];
Format(buffer, sizeof(buffer), "%T", "Don't Change", param1);
return RedrawMenuItem(buffer);
}
}
// Why am I commented out? Because BAIL hasn't decided yet if
// vote notification will be built into the Vote API.
/*case MenuAction_Select:
{
decl String:Name[32], String:Map[32];
GetClientName(param1, Name, sizeof(Name));
GetMenuItem(menu, param2, Map, sizeof(Map));
PrintToChatAll("[SM] %s has voted for map '%s'", Name, Map);
}*/
case MenuAction_VoteCancel:
{
if (param1 == VoteCancel_NoVotes)
{
PrintToChatAll("[SM] %t", "No Votes");
g_RTVEnded = true;
}
}
case MenuAction_VoteEnd:
{
new String:map[64];
GetMenuItem(menu, param1, map, sizeof(map));
if (GetMenuItemCount(menu) - 1 == param1) // This should always match the "Keep Current" option
{
PrintToChatAll("[SM] %t", "Current Map Stays");
LogMessage("[SM] Rockthevote has ended, current map kept.");
}
else
{
PrintToChatAll("[SM] %t", "Changing Maps", map);
LogMessage("[SM] Rockthevote has ended, changing to map %s.", map);
new Handle:dp;
CreateDataTimer(5.0, Timer_ChangeMap, dp);
WritePackString(dp, map);
}
g_RTVEnded = true;
}
}
return 0;
}
public Handler_MapVoteMenu(Handle:menu, MenuAction:action, param1, param2)
{
switch (action)
{
case MenuAction_End:
{
g_VoteMenu = INVALID_HANDLE;
CloseHandle(menu);
}
case MenuAction_Display:
{
decl String:buffer[255];
Format(buffer, sizeof(buffer), "%T", "Vote Nextmap", param1);
new Handle:panel = Handle:param2;
SetPanelTitle(panel, buffer);
}
case MenuAction_DisplayItem:
{
if (GetMenuItemCount(menu) - 1 == param2)
{
decl String:map[64], String:buffer[255];
GetMenuItem(menu, param2, map, sizeof(map));
if (strcmp(map, VOTE_EXTEND, false) == 0)
{
Format(buffer, sizeof(buffer), "%T", "Extend Map", param1);
return RedrawMenuItem(buffer);
}
}
}
// Why am I commented out? Because BAIL hasn't decided yet if
// vote notification will be built into the Vote API.
/*case MenuAction_Select:
{
decl String:Name[32], String:Map[32];
GetClientName(param1, Name, sizeof(Name));
GetMenuItem(menu, param2, Map, sizeof(Map));
PrintToChatAll("[SM] %s has voted for map '%s'", Name, Map);
}*/
case MenuAction_VoteCancel:
{
// If we receive 0 votes, pick at random.
if (param1 == VoteCancel_NoVotes && GetConVarBool(g_Cvar_NoVoteMode))
{
new count = GetMenuItemCount(menu);
new item = GetRandomInt(0, count - 1);
decl String:map[32];
GetMenuItem(menu, item, map, sizeof(map));
while (strcmp(map, VOTE_EXTEND, false) == 0)
{
item = GetRandomInt(0, count - 1);
GetMenuItem(menu, item, map, sizeof(map));
}
SetNextMap(map);
}
else
{
// We were actually cancelled. What should we do?
}
}
case MenuAction_VoteEnd:
{
decl String:map[32];
GetMenuItem(menu, param1, map, sizeof(map));
if (strcmp(map, VOTE_EXTEND, false) == 0)
{
new time;
if (GetMapTimeLimit(time))
{
if (time > 0 && time < GetConVarInt(g_Cvar_ExtendTimeMax))
{
ExtendMapTimeLimit(GetConVarInt(g_Cvar_ExtendTimeStep)*60);
}
}
if (g_Cvar_Winlimit != INVALID_HANDLE)
{
new winlimit = GetConVarInt(g_Cvar_Winlimit);
if (winlimit && winlimit < GetConVarInt(g_Cvar_ExtendRoundMax))
{
SetConVarInt(g_Cvar_Winlimit, winlimit + GetConVarInt(g_Cvar_ExtendRoundStep));
}
}
if (g_Cvar_Maxrounds != INVALID_HANDLE)
{
new maxrounds = GetConVarInt(g_Cvar_Maxrounds);
if (maxrounds && maxrounds < GetConVarInt(g_Cvar_ExtendRoundMax))
{
SetConVarInt(g_Cvar_Maxrounds, maxrounds + GetConVarInt(g_Cvar_ExtendRoundStep));
}
}
if (g_Cvar_Fraglimit != INVALID_HANDLE)
{
new fraglimit = GetConVarInt(g_Cvar_Fraglimit);
if (fraglimit && fraglimit < GetConVarInt(g_Cvar_ExtendFragMax))
{
SetConVarInt(g_Cvar_Fraglimit, fraglimit + GetConVarInt(g_Cvar_ExtendFragStep));
}
}
PrintToChatAll("[SM] %t", "Current Map Extended");
LogMessage("Voting for next map has finished. The current map has been extended.");
// We extended, so we'll have to vote again.
g_HasVoteStarted = false;
CreateNextVote();
SetupTimeleftTimer();
}
else
{
SetNextMap(map);
}
}
}
return 0;
}

View File

@ -0,0 +1,28 @@
#include <sourcemod>
public OnPluginStart()
{
RegServerCmd("test_goto", Test_Goto);
}
public Action:Test_Goto(args)
{
new bool:hello = false;
new String:crab[] = "space crab";
sample_label:
new String:yam[] = "yams";
PrintToServer("%s %s", crab, yam);
if (!hello)
{
new bool:what = true;
hello = what
goto sample_label;
}
return Plugin_Handled;
}

View File

@ -854,19 +854,10 @@ SC_FUNC void modstk(int delta)
/* set the stack to a hard offset from the frame */
SC_FUNC void setstk(cell value)
{
stgwrite("\tlctrl 5\n"); /* get FRM in PRI */
stgwrite("\tstackadjust ");
assert(value<=0); /* STK should always become <= FRM */
if (value<0) {
stgwrite("\tadd.c ");
outval(value, TRUE); /* add (negative) offset */
code_idx+=opcodes(1)+opargs(1);
// ??? write zeros in the space between STK and the value in PRI (the new stk)
// get value of STK in ALT
// zero PRI
// need new FILL opcode that takes a variable size
} /* if */
stgwrite("\tsctrl 4\n"); /* store in STK */
code_idx+=opcodes(2)+opargs(2);
}
SC_FUNC void modheap(int delta)

View File

@ -596,6 +596,7 @@ static OPCODEC opcodelist[] = {
{ 21, "sref.s.pri", sIN_CSEG, parm1 },
{ 67, "sshr", sIN_CSEG, parm0 },
{ 44, "stack", sIN_CSEG, parm1 },
{165, "stackadjust",sIN_CSEG, parm1 },
{ 0, "stksize", 0, noop },
{ 16, "stor.alt", sIN_CSEG, parm1 },
{ 23, "stor.i", sIN_CSEG, parm0 },

View File

@ -1209,6 +1209,28 @@ inline void WriteOp_Stack(JitWriter *jit)
}
}
inline void WriteOp_StackAdjust(JitWriter *jit)
{
cell_t val = jit->read_cell();
assert(val <= 0);
//lea edi, [ebx-val]
if (val < SCHAR_MAX && val > SCHAR_MIN)
{
IA32_Lea_DispRegImm8(jit, AMX_REG_STK, AMX_REG_FRM, val);
}
else
{
IA32_Lea_DispRegImm32(jit, AMX_REG_STK, AMX_REG_FRM, val);
}
/* We assume the compiler has generated good code --
* That is, we do not bother validating this amount!
*/
}
inline void WriteOp_Heap(JitWriter *jit)
{
//mov edx, [esi+hea]

View File

@ -124,8 +124,8 @@ typedef enum
OP_LOAD_ALT, //~!VERIFIED (load.pri)
OP_LOAD_S_PRI, //VERIFIED
OP_LOAD_S_ALT, //VERIFIED
OP_LREF_PRI, // !GEN :TODO: we will need this for dynarrays
OP_LREF_ALT, // !GEN :TODO: we will need this for dynarrays
OP_LREF_PRI, //VERIFIED
OP_LREF_ALT, //~VERIFIED
OP_LREF_S_PRI, //VERIFIED
OP_LREF_S_ALT, //~VERIFIED (lref.s.pri)
OP_LOAD_I, //VERIFIED
@ -138,8 +138,8 @@ typedef enum
OP_STOR_ALT, //~VERIFIED (stor.pri)
OP_STOR_S_PRI, //VERIFIED
OP_STOR_S_ALT, //~VERIFIED (stor.s.pri)
OP_SREF_PRI, // !GEN :TODO: we will need this for dynarrays
OP_SREF_ALT, // !GEN :TODO: we will need this for dynarrays
OP_SREF_PRI, //VERIFIED
OP_SREF_ALT, //~VERIFIED
OP_SREF_S_PRI, //VERIFIED
OP_SREF_S_ALT, //~VERIFIED (stor.s.alt)
OP_STOR_I, //VERIFIED
@ -286,6 +286,7 @@ typedef enum
OP_GENARRAY, //VERIFIED
OP_GENARRAY_Z, //-VERIFIED (not tested for 1D arrays)
OP_STRADJUST_PRI, //VERIFIED
OP_STACKADJUST, //:TODO: VERIFY
OP_FABS, //VERIFIED
OP_FLOAT, //VERIFIED
OP_FLOATADD, //VERIFIED
@ -301,22 +302,4 @@ typedef enum
OP_NUM_OPCODES
} OPCODE;
/*
* :TODO: List of ASM Opts
* from jit_x86.cpp
* DONE: Rest of opcodes including the SYSREQ.N inlined version (rev2)
* Including genarray and the 2 tracker ones
* DONE: ALL ungen opcodes (rev1)
* from opcode_helpers.cpp
* DONE: SYSREQ.N .C (rev2)
* MACRO OPCODES (rev2)
* ERROR CHECKS\{VERIFY ADDR} (rev2)
* ARRAY STUFF
* TODO: BrkDebug
* EXEC FUNCTION
* VERIFY ADDR
*
* Oh and ALIGN to 16BYTES all stuff that is called via CALL and frequently used jump labels like what's done with PROC.
*/
#endif //_INCLUDE_SOURCEPAWN_JIT_X86_OPCODE_INFO_H_

View File

@ -748,6 +748,11 @@
WriteOp_FloatCompare(jit);
break;
}
case OP_STACKADJUST:
{
WriteOp_StackAdjust(jit);
break;
}
#if defined USE_UNGEN_OPCODES
#include "ungen_opcode_switch.inc"
#endif