merged branch-1.1.0 back into trunk
authorDavid Anderson <dvander@alliedmods.net>
Wed Mar 26 03:52:37 2008 +0000 (2008-03-26)
changeset 194513106cdc0a3c
parent 1944 17984feecafd
child 1946 dcbb191d32cc
merged branch-1.1.0 back into trunk
extensions/regex/CRegEx.cpp
extensions/regex/CRegEx.h
extensions/regex/Makefile.ep1
extensions/regex/Makefile.ep2
extensions/regex/Makefile.orig
extensions/regex/extension.cpp
extensions/regex/extension.h
extensions/regex/lib_linux/libpcre.a
extensions/regex/lib_win/pcre.lib
extensions/regex/msvc8/sdk.sln
extensions/regex/msvc8/sdk.vcproj
extensions/regex/pcre.h
extensions/regex/sdk/smsdk_config.h
extensions/regex/sdk/smsdk_ext.cpp
extensions/regex/sdk/smsdk_ext.h
extensions/tf2/Makefile.ep1
extensions/tf2/Makefile.ep2
extensions/tf2/Makefile.orig
extensions/tf2/RegNatives.cpp
extensions/tf2/RegNatives.h
extensions/tf2/extension.cpp
extensions/tf2/extension.h
extensions/tf2/msvc8/tf2.sln
extensions/tf2/msvc8/tf2.vcproj
extensions/tf2/natives.cpp
extensions/tf2/sdk/smsdk_config.h
extensions/tf2/sdk/smsdk_ext.cpp
extensions/tf2/sdk/smsdk_ext.h
extensions/tf2/sm-tf2.games.txt
extensions/tf2/svn_version.h
extensions/tf2/svn_version.tpl
extensions/tf2/tf2-test.sp
extensions/tf2/tf2.inc
extensions/tf2/version.rc
plugins/adminmenu.sp
plugins/adminmenu/dynamicmenu.sp
plugins/include/regex.inc
plugins/mapmanager.sp
plugins/mapmanager/commands.sp
plugins/mapmanager/events.sp
plugins/mapmanager/functions.sp
plugins/mapmanager/functions_menu.sp
plugins/mapmanager/globals.sp
plugins/mapmanager/menus.sp
plugins/mapmanager/timers.sp
plugins/mapmanager/votes.sp
plugins/testsuite/goto_test.sp
sourcepawn/compiler/sc4.c
sourcepawn/compiler/sc6.c
sourcepawn/jit/x86/jit_x86.cpp
sourcepawn/jit/x86/opcode_helpers.h
sourcepawn/jit/x86/opcode_switch.inc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/extensions/regex/CRegEx.cpp	Wed Mar 26 03:52:37 2008 +0000
     1.3 @@ -0,0 +1,124 @@
     1.4 +#include "pcre.h"
     1.5 +#include "CRegEx.h"
     1.6 +#include <sh_string.h>
     1.7 +#include "extension.h"
     1.8 +
     1.9 +RegEx::RegEx()
    1.10 +{
    1.11 +	mErrorOffset = 0;
    1.12 +	mError = NULL;
    1.13 +	re = NULL;
    1.14 +	mFree = true;
    1.15 +	subject = NULL;
    1.16 +	mSubStrings = 0;
    1.17 +}
    1.18 +
    1.19 +void RegEx::Clear ()
    1.20 +{
    1.21 +	mErrorOffset = 0;
    1.22 +	mError = NULL;
    1.23 +	if (re)
    1.24 +		pcre_free(re);
    1.25 +	re = NULL;
    1.26 +	mFree = true;
    1.27 +	if (subject)
    1.28 +		delete [] subject;
    1.29 +	subject = NULL;
    1.30 +	mSubStrings = 0;
    1.31 +}
    1.32 +
    1.33 +RegEx::~RegEx()
    1.34 +{
    1.35 +	Clear();
    1.36 +}
    1.37 +
    1.38 +bool RegEx::isFree(bool set, bool val)
    1.39 +{
    1.40 +	if (set)
    1.41 +	{
    1.42 +		mFree = val;
    1.43 +		return true;
    1.44 +	} else {
    1.45 +		return mFree;
    1.46 +	}
    1.47 +}
    1.48 +
    1.49 +int RegEx::Compile(const char *pattern, int iFlags)
    1.50 +{
    1.51 +	if (!mFree)
    1.52 +		Clear();
    1.53 +		
    1.54 +	re = pcre_compile(pattern, iFlags, &mError, &mErrorOffset, NULL);
    1.55 +
    1.56 +	if (re == NULL)
    1.57 +	{
    1.58 +		return 0;
    1.59 +	}
    1.60 +
    1.61 +	mFree = false;
    1.62 +
    1.63 +	return 1;
    1.64 +}
    1.65 +
    1.66 +int RegEx::Match(const char *str)
    1.67 +{
    1.68 +	int rc = 0;
    1.69 +
    1.70 +	if (mFree || re == NULL)
    1.71 +		return -1;
    1.72 +		
    1.73 +	this->ClearMatch();
    1.74 +
    1.75 +	//save str
    1.76 +	subject = new char[strlen(str)+1];
    1.77 +	strcpy(subject, str);
    1.78 +
    1.79 +	rc = pcre_exec(re, NULL, subject, (int)strlen(subject), 0, 0, ovector, 30);
    1.80 +
    1.81 +	if (rc < 0)
    1.82 +	{
    1.83 +		if (rc == PCRE_ERROR_NOMATCH)
    1.84 +		{
    1.85 +			return 0;
    1.86 +		} else {
    1.87 +			mErrorOffset = rc;
    1.88 +			return -1;
    1.89 +		}
    1.90 +	}
    1.91 +
    1.92 +	mSubStrings = rc;
    1.93 +
    1.94 +	return 1;
    1.95 +}
    1.96 +void RegEx::ClearMatch()
    1.97 +{
    1.98 +	// Clears match results
    1.99 +	mErrorOffset = 0;
   1.100 +	mError = NULL;
   1.101 +	if (subject)
   1.102 +		delete [] subject;
   1.103 +	subject = NULL;
   1.104 +	mSubStrings = 0;
   1.105 +}
   1.106 +
   1.107 +const char *RegEx::GetSubstring(int s, char buffer[], int max)
   1.108 +{
   1.109 +	int i = 0;
   1.110 +	if (s >= mSubStrings || s < 0)
   1.111 +		return NULL;
   1.112 +
   1.113 +	char *substr_a = subject + ovector[2*s];
   1.114 +	int substr_l = ovector[2*s+1] - ovector[2*s];
   1.115 +
   1.116 +	for (i = 0; i<substr_l; i++)
   1.117 +	{
   1.118 +		if (i >= max)
   1.119 +			break;
   1.120 +		buffer[i] = substr_a[i];
   1.121 +	}
   1.122 +
   1.123 +	buffer[i] = '\0';
   1.124 +
   1.125 +	return buffer;
   1.126 +}
   1.127 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/extensions/regex/CRegEx.h	Wed Mar 26 03:52:37 2008 +0000
     2.3 @@ -0,0 +1,28 @@
     2.4 +#ifndef _INCLUDE_CREGEX_H
     2.5 +#define _INCLUDE_CREGEX_H
     2.6 +
     2.7 +class RegEx
     2.8 +{
     2.9 +public:
    2.10 +	RegEx();
    2.11 +	~RegEx();
    2.12 +	bool isFree(bool set=false, bool val=false);
    2.13 +	void Clear();
    2.14 +
    2.15 +	int Compile(const char *pattern, int iFlags);
    2.16 +	int Match(const char *str);
    2.17 +	void ClearMatch();
    2.18 +	const char *GetSubstring(int s, char buffer[], int max);
    2.19 +public:
    2.20 +	int mErrorOffset;
    2.21 +	const char *mError;
    2.22 +	int mSubStrings;
    2.23 +private:
    2.24 +	pcre *re;
    2.25 +	bool mFree;
    2.26 +	int ovector[30];
    2.27 +	char *subject;
    2.28 +};
    2.29 +
    2.30 +#endif //_INCLUDE_CREGEX_H
    2.31 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/extensions/regex/Makefile.ep1	Wed Mar 26 03:52:37 2008 +0000
     3.3 @@ -0,0 +1,89 @@
     3.4 +#(C)2004-2007 AlliedModders LLC
     3.5 +#
     3.6 +# This sample Makefile is designed for SourceMod extensions that 
     3.7 +# are built against Metamod:Source 1.4.2, Episode 1 of the HL2SDK.
     3.8 +#
     3.9 +
    3.10 +SMSDK = ../..
    3.11 +SRCDS = ~/srcds
    3.12 +SOURCEMM = ../../../sourcemm
    3.13 +HL2SDK = ../../../hl2sdk
    3.14 +
    3.15 +#####################################
    3.16 +### EDIT BELOW FOR OTHER PROJECTS ###
    3.17 +#####################################
    3.18 +
    3.19 +PROJECT = regex
    3.20 +
    3.21 +#Uncomment for SourceMM-enabled extensions
    3.22 +LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so 
    3.23 +
    3.24 +OBJECTS = sdk/smsdk_ext.cpp extension.cpp CRegEx.cpp
    3.25 +
    3.26 +##############################################
    3.27 +### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
    3.28 +##############################################
    3.29 +
    3.30 +C_OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing
    3.31 +C_DEBUG_FLAGS = -g -ggdb3
    3.32 +CPP_GCC4_FLAGS = -fvisibility=hidden -fvisibility-inlines-hidden
    3.33 +CPP = gcc-4.1
    3.34 +
    3.35 +HL2PUB = $(HL2SDK)/public
    3.36 +HL2LIB = $(HL2SDK)/linux_sdk
    3.37 +
    3.38 +LINK = $(LINK_HL2) -static-libgcc
    3.39 +
    3.40 +INCLUDE = -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \
    3.41 +	-I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SOURCEMM) -I$(SOURCEMM)/sourcehook -I$(SOURCEMM)/sourcemm \
    3.42 +	-I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \
    3.43 +
    3.44 +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
    3.45 +CPPFLAGS = -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
    3.46 +
    3.47 +################################################
    3.48 +### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
    3.49 +################################################
    3.50 +
    3.51 +ifeq "$(DEBUG)" "true"
    3.52 +	BIN_DIR = Debug
    3.53 +	CFLAGS += $(C_DEBUG_FLAGS)
    3.54 +else
    3.55 +	BIN_DIR = Release
    3.56 +	CFLAGS += $(C_OPT_FLAGS)
    3.57 +endif
    3.58 +
    3.59 +
    3.60 +GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
    3.61 +ifeq "$(GCC_VERSION)" "4"
    3.62 +	CPPFLAGS += $(CPP_GCC4_FLAGS)
    3.63 +endif
    3.64 +
    3.65 +BINARY = $(PROJECT).ext.so
    3.66 +
    3.67 +OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
    3.68 +
    3.69 +$(BIN_DIR)/%.o: %.cpp
    3.70 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
    3.71 +
    3.72 +all:
    3.73 +	mkdir -p $(BIN_DIR)/sdk
    3.74 +	ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so
    3.75 +	ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so
    3.76 +	$(MAKE) -f Makefile.ep1 extension
    3.77 +
    3.78 +extension: $(OBJ_LINUX)
    3.79 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
    3.80 +
    3.81 +debug:	
    3.82 +	$(MAKE) -f Makefile.ep1 all DEBUG=true
    3.83 +
    3.84 +default: all
    3.85 +
    3.86 +clean:
    3.87 +	rm -rf Release/*.o
    3.88 +	rm -rf Release/sdk/*.o
    3.89 +	rm -rf Release/$(BINARY)
    3.90 +	rm -rf Debug/*.o
    3.91 +	rm -rf Debug/sdk/*.o
    3.92 +	rm -rf Debug/$(BINARY)
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/extensions/regex/Makefile.ep2	Wed Mar 26 03:52:37 2008 +0000
     4.3 @@ -0,0 +1,91 @@
     4.4 +#(C)2004-2007 AlliedModders LLC
     4.5 +#
     4.6 +# This sample Makefile is designed for SourceMod extensions that 
     4.7 +# are built against Metamod:Source 1.6.0, Episode 2 of the HL2SDK.
     4.8 +#
     4.9 +
    4.10 +SMSDK = ../..
    4.11 +SRCDS = ~/srcds
    4.12 +SOURCEMM = ../../../sourcemm
    4.13 +HL2SDK = ../../../hl2sdk-ob
    4.14 +
    4.15 +#####################################
    4.16 +### EDIT BELOW FOR OTHER PROJECTS ###
    4.17 +#####################################
    4.18 +
    4.19 +PROJECT = regex
    4.20 +
    4.21 +#Uncomment for SourceMM-enabled extensions
    4.22 +LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so 
    4.23 +
    4.24 +OBJECTS = sdk/smsdk_ext.cpp extension.cpp CRegEx.cpp
    4.25 +
    4.26 +##############################################
    4.27 +### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
    4.28 +##############################################
    4.29 +
    4.30 +C_OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing
    4.31 +C_DEBUG_FLAGS = -g -ggdb3
    4.32 +CPP_GCC4_FLAGS = -fvisibility=hidden -fvisibility-inlines-hidden
    4.33 +CPP = gcc-4.1
    4.34 +
    4.35 +HL2PUB = $(HL2SDK)/public
    4.36 +HL2LIB = $(HL2SDK)/linux_sdk
    4.37 +
    4.38 +LINK = $(LINK_HL2) -static-libgcc
    4.39 +
    4.40 +INCLUDE = -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \
    4.41 +	-I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SOURCEMM) -I$(SOURCEMM)/sourcehook -I$(SOURCEMM)/sourcemm \
    4.42 +	-I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \
    4.43 +
    4.44 +CFLAGS = -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
    4.45 +	-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -fPIC -mfpmath=sse \
    4.46 +	-msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -Wno-uninitialized -DORANGEBOX_BUILD
    4.47 +CPPFLAGS = -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
    4.48 +
    4.49 +################################################
    4.50 +### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
    4.51 +################################################
    4.52 +
    4.53 +ifeq "$(DEBUG)" "true"
    4.54 +	BIN_DIR = Debug
    4.55 +	CFLAGS += $(C_DEBUG_FLAGS)
    4.56 +else
    4.57 +	BIN_DIR = Release
    4.58 +	CFLAGS += $(C_OPT_FLAGS)
    4.59 +endif
    4.60 +
    4.61 +
    4.62 +GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
    4.63 +ifeq "$(GCC_VERSION)" "4"
    4.64 +	CPPFLAGS += $(CPP_GCC4_FLAGS)
    4.65 +endif
    4.66 +
    4.67 +BINARY = $(PROJECT).ext.so
    4.68 +
    4.69 +OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
    4.70 +
    4.71 +$(BIN_DIR)/%.o: %.cpp
    4.72 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
    4.73 +
    4.74 +all:
    4.75 +	mkdir -p $(BIN_DIR)/sdk
    4.76 +	ln -sf $(SRCDS)/orangebox/bin/vstdlib_i486.so vstdlib_i486.so
    4.77 +	ln -sf $(SRCDS)/orangebox/bin/tier0_i486.so tier0_i486.so
    4.78 +	$(MAKE) -f Makefile.ep1 extension
    4.79 +
    4.80 +extension: $(OBJ_LINUX)
    4.81 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
    4.82 +
    4.83 +debug:	
    4.84 +	$(MAKE) -f Makefile.ep1 all DEBUG=true
    4.85 +
    4.86 +default: all
    4.87 +
    4.88 +clean:
    4.89 +	rm -rf Release/*.o
    4.90 +	rm -rf Release/sdk/*.o
    4.91 +	rm -rf Release/$(BINARY)
    4.92 +	rm -rf Debug/*.o
    4.93 +	rm -rf Debug/sdk/*.o
    4.94 +	rm -rf Debug/$(BINARY)
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/extensions/regex/Makefile.orig	Wed Mar 26 03:52:37 2008 +0000
     5.3 @@ -0,0 +1,90 @@
     5.4 +#(C)2004-2007 AlliedModders LLC
     5.5 +#
     5.6 +# This sample Makefile is designed for SourceMod extensions that 
     5.7 +# are built against Metamod:Source 1.6.0, Episode 1 of the HL2SDK.
     5.8 +
     5.9 +SMSDK = ../..
    5.10 +SRCDS = ~/srcds
    5.11 +SOURCEMM = ../../../sourcemm-1.4.2
    5.12 +HL2SDK = ../../../hl2sdk
    5.13 +
    5.14 +#####################################
    5.15 +### EDIT BELOW FOR OTHER PROJECTS ###
    5.16 +#####################################
    5.17 +
    5.18 +PROJECT = regex
    5.19 +
    5.20 +#Uncomment for SourceMM-enabled extensions
    5.21 +LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so 
    5.22 +
    5.23 +OBJECTS = sdk/smsdk_ext.cpp extension.cpp CRegEx.cpp
    5.24 +
    5.25 +##############################################
    5.26 +### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
    5.27 +##############################################
    5.28 +
    5.29 +C_OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing
    5.30 +C_DEBUG_FLAGS = -g -ggdb3
    5.31 +CPP_GCC4_FLAGS = -fvisibility=hidden -fvisibility-inlines-hidden
    5.32 +CPP = gcc-4.1
    5.33 +
    5.34 +HL2PUB = $(HL2SDK)/public
    5.35 +HL2LIB = $(HL2SDK)/linux_sdk
    5.36 +
    5.37 +LINK = $(LINK_HL2) -static-libgcc
    5.38 +
    5.39 +INCLUDE = -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \
    5.40 +	-I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SOURCEMM) -I$(SOURCEMM)/sourcehook -I$(SOURCEMM)/sourcemm \
    5.41 +	-I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \
    5.42 +
    5.43 +CFLAGS = -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
    5.44 +	-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -fPIC -mfpmath=sse \
    5.45 +	-msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -Wno-uninitialized
    5.46 +CPPFLAGS = -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
    5.47 +
    5.48 +################################################
    5.49 +### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
    5.50 +################################################
    5.51 +
    5.52 +ifeq "$(DEBUG)" "true"
    5.53 +	BIN_DIR = Debug
    5.54 +	CFLAGS += $(C_DEBUG_FLAGS)
    5.55 +else
    5.56 +	BIN_DIR = Release
    5.57 +	CFLAGS += $(C_OPT_FLAGS)
    5.58 +endif
    5.59 +
    5.60 +
    5.61 +GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
    5.62 +ifeq "$(GCC_VERSION)" "4"
    5.63 +	CPPFLAGS += $(CPP_GCC4_FLAGS)
    5.64 +endif
    5.65 +
    5.66 +BINARY = $(PROJECT).ext.so
    5.67 +
    5.68 +OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
    5.69 +
    5.70 +$(BIN_DIR)/%.o: %.cpp
    5.71 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
    5.72 +
    5.73 +all:
    5.74 +	mkdir -p $(BIN_DIR)/sdk
    5.75 +	ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so
    5.76 +	ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so
    5.77 +	$(MAKE) -f Makefile.orig extension
    5.78 +
    5.79 +extension: $(OBJ_LINUX)
    5.80 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
    5.81 +
    5.82 +debug:	
    5.83 +	$(MAKE) -f Makefile.orig all DEBUG=true
    5.84 +
    5.85 +default: all
    5.86 +
    5.87 +clean:
    5.88 +	rm -rf Release/*.o
    5.89 +	rm -rf Release/sdk/*.o
    5.90 +	rm -rf Release/$(BINARY)
    5.91 +	rm -rf Debug/*.o
    5.92 +	rm -rf Debug/sdk/*.o
    5.93 +	rm -rf Debug/$(BINARY)
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/extensions/regex/extension.cpp	Wed Mar 26 03:52:37 2008 +0000
     6.3 @@ -0,0 +1,188 @@
     6.4 +/**
     6.5 + * vim: set ts=4 :
     6.6 + * =============================================================================
     6.7 + * SourceMod Sample Extension
     6.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
     6.9 + * =============================================================================
    6.10 + *
    6.11 + * This program is free software; you can redistribute it and/or modify it under
    6.12 + * the terms of the GNU General Public License, version 3.0, as published by the
    6.13 + * Free Software Foundation.
    6.14 + * 
    6.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
    6.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    6.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    6.18 + * details.
    6.19 + *
    6.20 + * You should have received a copy of the GNU General Public License along with
    6.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    6.22 + *
    6.23 + * As a special exception, AlliedModders LLC gives you permission to link the
    6.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    6.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    6.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
    6.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    6.28 + * this exception to all derivative works.  AlliedModders LLC defines further
    6.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    6.30 + * or <http://www.sourcemod.net/license.php>.
    6.31 + *
    6.32 + * Version: $Id$
    6.33 + */
    6.34 +
    6.35 +#include "extension.h"
    6.36 +
    6.37 +#include <sh_string.h>
    6.38 +#include "pcre.h"
    6.39 +#include "CRegEx.h"
    6.40 +using namespace SourceHook;
    6.41 +
    6.42 +/**
    6.43 + * @file extension.cpp
    6.44 + * @brief Implement extension code here.
    6.45 + */
    6.46 +
    6.47 +RegexExtension g_RegexExtension;		/**< Global singleton for extension's main interface */
    6.48 +
    6.49 +SMEXT_LINK(&g_RegexExtension);
    6.50 +
    6.51 +RegexHandler g_RegexHandler;
    6.52 +HandleType_t g_RegexHandle=0;
    6.53 +
    6.54 +
    6.55 +
    6.56 +bool RegexExtension::SDK_OnLoad(char *error, size_t err_max, bool late)
    6.57 +{
    6.58 +	g_pShareSys->AddNatives(myself,regex_natives);
    6.59 +	g_RegexHandle = g_pHandleSys->CreateType("Regex", &g_RegexHandler, 0, NULL, NULL, myself->GetIdentity(), NULL);
    6.60 +	return true;
    6.61 +}
    6.62 +
    6.63 +void RegexExtension::SDK_OnUnload()
    6.64 +{
    6.65 +	g_pHandleSys->RemoveType(g_RegexHandle, myself->GetIdentity());
    6.66 +
    6.67 +}
    6.68 +
    6.69 +static cell_t CompileRegex(IPluginContext *pCtx, const cell_t *params)
    6.70 +{
    6.71 +	char *regex;
    6.72 +	pCtx->LocalToString(params[1], &regex);
    6.73 +
    6.74 +	RegEx *x = new RegEx();
    6.75 +	
    6.76 +	if (x->Compile(regex, params[2]) == 0)
    6.77 +	{
    6.78 +		cell_t *eOff;
    6.79 +		pCtx->LocalToPhysAddr(params[5], &eOff);
    6.80 +		const char *err = x->mError;
    6.81 +		*eOff = x->mErrorOffset;
    6.82 +		pCtx->StringToLocal(params[3], params[4], err ? err:"unknown");
    6.83 +		return 0;
    6.84 +	}
    6.85 +
    6.86 +	return g_pHandleSys->CreateHandle(g_RegexHandle, (void*)x, pCtx->GetIdentity(), myself->GetIdentity(), NULL);
    6.87 +}
    6.88 +
    6.89 +
    6.90 +static cell_t MatchRegex(IPluginContext *pCtx, const cell_t *params)
    6.91 +{
    6.92 +	Handle_t hndl = static_cast<Handle_t>(params[1]);
    6.93 +	HandleError err;
    6.94 +	HandleSecurity sec;
    6.95 +	sec.pOwner = NULL;
    6.96 +	sec.pIdentity = myself->GetIdentity();
    6.97 +
    6.98 +	RegEx *x;
    6.99 +
   6.100 +	if ((err=g_pHandleSys->ReadHandle(hndl, g_RegexHandle, &sec, (void **)&x)) != HandleError_None)
   6.101 +	{
   6.102 +		return pCtx->ThrowNativeError("Invalid file handle %x (error %d)", hndl, err);
   6.103 +	}
   6.104 +
   6.105 +	if (!x)
   6.106 +	{
   6.107 +		pCtx->ThrowNativeError("Regex data not found\n");
   6.108 +
   6.109 +		return 0;
   6.110 +	}
   6.111 +
   6.112 +	char *str;
   6.113 +	pCtx->LocalToString(params[2], &str);
   6.114 +
   6.115 +	int e = x->Match(str);
   6.116 +
   6.117 +	if (e == -1)
   6.118 +	{
   6.119 +		/* there was a match error.  move on. */
   6.120 +		cell_t *res;
   6.121 +		pCtx->LocalToPhysAddr(params[3], &res);
   6.122 +		*res = x->mErrorOffset;
   6.123 +		/* only clear the match results, since the regex object
   6.124 +		   may still be referenced later */
   6.125 +		x->ClearMatch();
   6.126 +
   6.127 +		return -1;
   6.128 +	}
   6.129 +	else if (e == 0) 
   6.130 +	{
   6.131 +		/* only clear the match results, since the regex object
   6.132 +		   may still be referenced later */
   6.133 +		x->ClearMatch();
   6.134 +
   6.135 +		return 0;
   6.136 +	} 
   6.137 +	else 
   6.138 +	{
   6.139 +		return x->mSubStrings;
   6.140 +	}
   6.141 +}
   6.142 +
   6.143 +static cell_t GetRegexSubString(IPluginContext *pCtx, const cell_t *params)
   6.144 +{
   6.145 +	Handle_t hndl=static_cast<Handle_t>(params[1]);
   6.146 +	HandleError err;
   6.147 +	HandleSecurity sec;
   6.148 +	sec.pOwner=NULL;
   6.149 +	sec.pIdentity=myself->GetIdentity();
   6.150 +
   6.151 +	RegEx *x;
   6.152 +
   6.153 +	if ((err=g_pHandleSys->ReadHandle(hndl, g_RegexHandle, &sec, (void **)&x)) != HandleError_None)
   6.154 +	{
   6.155 +		return pCtx->ThrowNativeError("Invalid file handle %x (error %d)", hndl, err);
   6.156 +	}
   6.157 +
   6.158 +	if (!x)
   6.159 +	{
   6.160 +		pCtx->ThrowNativeError("Regex data not found\n");
   6.161 +		return 0;
   6.162 +	}
   6.163 +
   6.164 +	static char buffer[4096];
   6.165 +	const char *ret=x->GetSubstring(params[2], buffer, sizeof(buffer));
   6.166 +
   6.167 +	if(!ret)
   6.168 +	{
   6.169 +		return 0;
   6.170 +	}
   6.171 +
   6.172 +	pCtx->StringToLocalUTF8(params[3], params[4], ret, NULL);
   6.173 +
   6.174 +	return 1;
   6.175 +}
   6.176 +
   6.177 +void RegexHandler::OnHandleDestroy(HandleType_t type, void *object)
   6.178 +{
   6.179 +	RegEx *x = (RegEx *)object;
   6.180 +
   6.181 +	x->Clear();
   6.182 +	delete x;
   6.183 +}
   6.184 +
   6.185 +const sp_nativeinfo_t regex_natives[] = 
   6.186 +{
   6.187 +	{"GetRegexSubString",			GetRegexSubString},
   6.188 +	{"MatchRegex",					MatchRegex},
   6.189 +	{"CompileRegex",				CompileRegex},
   6.190 +	{NULL,							NULL},
   6.191 +};
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/extensions/regex/extension.h	Wed Mar 26 03:52:37 2008 +0000
     7.3 @@ -0,0 +1,133 @@
     7.4 +/**
     7.5 + * vim: set ts=4 :
     7.6 + * =============================================================================
     7.7 + * SourceMod Sample Extension
     7.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
     7.9 + * =============================================================================
    7.10 + *
    7.11 + * This program is free software; you can redistribute it and/or modify it under
    7.12 + * the terms of the GNU General Public License, version 3.0, as published by the
    7.13 + * Free Software Foundation.
    7.14 + * 
    7.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
    7.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    7.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    7.18 + * details.
    7.19 + *
    7.20 + * You should have received a copy of the GNU General Public License along with
    7.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    7.22 + *
    7.23 + * As a special exception, AlliedModders LLC gives you permission to link the
    7.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    7.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    7.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
    7.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    7.28 + * this exception to all derivative works.  AlliedModders LLC defines further
    7.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    7.30 + * or <http://www.sourcemod.net/license.php>.
    7.31 + *
    7.32 + * Version: $Id$
    7.33 + */
    7.34 +
    7.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
    7.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
    7.37 +
    7.38 +/**
    7.39 + * @file extension.h
    7.40 + * @brief Sample extension code header.
    7.41 + */
    7.42 +
    7.43 +#include "smsdk_ext.h"
    7.44 +
    7.45 +
    7.46 +/**
    7.47 + * @brief Sample implementation of the SDK Extension.
    7.48 + * Note: Uncomment one of the pre-defined virtual functions in order to use it.
    7.49 + */
    7.50 +class RegexExtension : public SDKExtension
    7.51 +{
    7.52 +public:
    7.53 +	/**
    7.54 +	 * @brief This is called after the initial loading sequence has been processed.
    7.55 +	 *
    7.56 +	 * @param error		Error message buffer.
    7.57 +	 * @param maxlength	Size of error message buffer.
    7.58 +	 * @param late		Whether or not the module was loaded after map load.
    7.59 +	 * @return			True to succeed loading, false to fail.
    7.60 +	 */
    7.61 +	virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
    7.62 +	
    7.63 +	/**
    7.64 +	 * @brief This is called right before the extension is unloaded.
    7.65 +	 */
    7.66 +	virtual void SDK_OnUnload();
    7.67 +
    7.68 +	/**
    7.69 +	 * @brief This is called once all known extensions have been loaded.
    7.70 +	 * Note: It is is a good idea to add natives here, if any are provided.
    7.71 +	 */
    7.72 +	//virtual void SDK_OnAllLoaded();
    7.73 +
    7.74 +	/**
    7.75 +	 * @brief Called when the pause state is changed.
    7.76 +	 */
    7.77 +	//virtual void SDK_OnPauseChange(bool paused);
    7.78 +
    7.79 +	/**
    7.80 +	 * @brief this is called when Core wants to know if your extension is working.
    7.81 +	 *
    7.82 +	 * @param error		Error message buffer.
    7.83 +	 * @param maxlength	Size of error message buffer.
    7.84 +	 * @return			True if working, false otherwise.
    7.85 +	 */
    7.86 +	//virtual bool QueryRunning(char *error, size_t maxlength);
    7.87 +public:
    7.88 +#if defined SMEXT_CONF_METAMOD
    7.89 +	/**
    7.90 +	 * @brief Called when Metamod is attached, before the extension version is called.
    7.91 +	 *
    7.92 +	 * @param error			Error buffer.
    7.93 +	 * @param maxlength		Maximum size of error buffer.
    7.94 +	 * @param late			Whether or not Metamod considers this a late load.
    7.95 +	 * @return				True to succeed, false to fail.
    7.96 +	 */
    7.97 +	//virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
    7.98 +
    7.99 +	/**
   7.100 +	 * @brief Called when Metamod is detaching, after the extension version is called.
   7.101 +	 * NOTE: By default this is blocked unless sent from SourceMod.
   7.102 +	 *
   7.103 +	 * @param error			Error buffer.
   7.104 +	 * @param maxlength		Maximum size of error buffer.
   7.105 +	 * @return				True to succeed, false to fail.
   7.106 +	 */
   7.107 +	//virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
   7.108 +
   7.109 +	/**
   7.110 +	 * @brief Called when Metamod's pause state is changing.
   7.111 +	 * NOTE: By default this is blocked unless sent from SourceMod.
   7.112 +	 *
   7.113 +	 * @param paused		Pause state being set.
   7.114 +	 * @param error			Error buffer.
   7.115 +	 * @param maxlength		Maximum size of error buffer.
   7.116 +	 * @return				True to succeed, false to fail.
   7.117 +	 */
   7.118 +	//virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
   7.119 +#endif
   7.120 +};
   7.121 +
   7.122 +
   7.123 +class RegexHandler: public IHandleTypeDispatch
   7.124 +{
   7.125 +public:
   7.126 +	void OnHandleDestroy(HandleType_t type, void *object);
   7.127 +};
   7.128 +
   7.129 +extern RegexHandler g_RegexHandler;
   7.130 +extern HandleType_t g_RegexHandle;
   7.131 +
   7.132 +
   7.133 +// Natives
   7.134 +extern const sp_nativeinfo_t regex_natives[];
   7.135 +
   7.136 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
     8.1 Binary file extensions/regex/lib_linux/libpcre.a has changed
     9.1 Binary file extensions/regex/lib_win/pcre.lib has changed
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/extensions/regex/msvc8/sdk.sln	Wed Mar 26 03:52:37 2008 +0000
    10.3 @@ -0,0 +1,26 @@
    10.4 +
    10.5 +Microsoft Visual Studio Solution File, Format Version 9.00
    10.6 +# Visual C++ Express 2005
    10.7 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "regex", "sdk.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
    10.8 +EndProject
    10.9 +Global
   10.10 +	GlobalSection(SolutionConfigurationPlatforms) = preSolution
   10.11 +		Debug - Episode 1|Win32 = Debug - Episode 1|Win32
   10.12 +		Debug - Orange Box|Win32 = Debug - Orange Box|Win32
   10.13 +		Release - Episode 1|Win32 = Release - Episode 1|Win32
   10.14 +		Release - Orange Box|Win32 = Release - Orange Box|Win32
   10.15 +	EndGlobalSection
   10.16 +	GlobalSection(ProjectConfigurationPlatforms) = postSolution
   10.17 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode 1|Win32.ActiveCfg = Debug|Win32
   10.18 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode 1|Win32.Build.0 = Debug|Win32
   10.19 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32
   10.20 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32
   10.21 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.ActiveCfg = Release|Win32
   10.22 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.Build.0 = Release|Win32
   10.23 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32
   10.24 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32
   10.25 +	EndGlobalSection
   10.26 +	GlobalSection(SolutionProperties) = preSolution
   10.27 +		HideSolutionNode = FALSE
   10.28 +	EndGlobalSection
   10.29 +EndGlobal
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/extensions/regex/msvc8/sdk.vcproj	Wed Mar 26 03:52:37 2008 +0000
    11.3 @@ -0,0 +1,422 @@
    11.4 +<?xml version="1.0" encoding="Windows-1252"?>
    11.5 +<VisualStudioProject
    11.6 +	ProjectType="Visual C++"
    11.7 +	Version="8.00"
    11.8 +	Name="regex"
    11.9 +	ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
   11.10 +	RootNamespace="sdk"
   11.11 +	Keyword="Win32Proj"
   11.12 +	>
   11.13 +	<Platforms>
   11.14 +		<Platform
   11.15 +			Name="Win32"
   11.16 +		/>
   11.17 +	</Platforms>
   11.18 +	<ToolFiles>
   11.19 +	</ToolFiles>
   11.20 +	<Configurations>
   11.21 +		<Configuration
   11.22 +			Name="Debug|Win32"
   11.23 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
   11.24 +			IntermediateDirectory="$(ConfigurationName)"
   11.25 +			ConfigurationType="2"
   11.26 +			CharacterSet="2"
   11.27 +			>
   11.28 +			<Tool
   11.29 +				Name="VCPreBuildEventTool"
   11.30 +			/>
   11.31 +			<Tool
   11.32 +				Name="VCCustomBuildTool"
   11.33 +			/>
   11.34 +			<Tool
   11.35 +				Name="VCXMLDataGeneratorTool"
   11.36 +			/>
   11.37 +			<Tool
   11.38 +				Name="VCWebServiceProxyGeneratorTool"
   11.39 +			/>
   11.40 +			<Tool
   11.41 +				Name="VCMIDLTool"
   11.42 +			/>
   11.43 +			<Tool
   11.44 +				Name="VCCLCompilerTool"
   11.45 +				Optimization="0"
   11.46 +				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;;"
   11.47 +				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
   11.48 +				MinimalRebuild="true"
   11.49 +				BasicRuntimeChecks="3"
   11.50 +				RuntimeLibrary="1"
   11.51 +				EnableEnhancedInstructionSet="1"
   11.52 +				RuntimeTypeInfo="false"
   11.53 +				UsePrecompiledHeader="0"
   11.54 +				WarningLevel="3"
   11.55 +				Detect64BitPortabilityProblems="false"
   11.56 +				DebugInformationFormat="4"
   11.57 +			/>
   11.58 +			<Tool
   11.59 +				Name="VCManagedResourceCompilerTool"
   11.60 +			/>
   11.61 +			<Tool
   11.62 +				Name="VCResourceCompilerTool"
   11.63 +			/>
   11.64 +			<Tool
   11.65 +				Name="VCPreLinkEventTool"
   11.66 +			/>
   11.67 +			<Tool
   11.68 +				Name="VCLinkerTool"
   11.69 +				IgnoreImportLibrary="false"
   11.70 +				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;"
   11.71 +				OutputFile="$(OutDir)\regex.ext.dll"
   11.72 +				LinkIncremental="2"
   11.73 +				IgnoreDefaultLibraryNames="LIBCMTD"
   11.74 +				GenerateDebugInformation="true"
   11.75 +				SubSystem="2"
   11.76 +				OptimizeReferences="0"
   11.77 +				EnableCOMDATFolding="0"
   11.78 +				ImportLibrary="$(OutDir)/sdk.lib"
   11.79 +				TargetMachine="1"
   11.80 +			/>
   11.81 +			<Tool
   11.82 +				Name="VCALinkTool"
   11.83 +			/>
   11.84 +			<Tool
   11.85 +				Name="VCManifestTool"
   11.86 +			/>
   11.87 +			<Tool
   11.88 +				Name="VCXDCMakeTool"
   11.89 +			/>
   11.90 +			<Tool
   11.91 +				Name="VCBscMakeTool"
   11.92 +			/>
   11.93 +			<Tool
   11.94 +				Name="VCFxCopTool"
   11.95 +			/>
   11.96 +			<Tool
   11.97 +				Name="VCAppVerifierTool"
   11.98 +			/>
   11.99 +			<Tool
  11.100 +				Name="VCWebDeploymentTool"
  11.101 +			/>
  11.102 +			<Tool
  11.103 +				Name="VCPostBuildEventTool"
  11.104 +			/>
  11.105 +		</Configuration>
  11.106 +		<Configuration
  11.107 +			Name="Release|Win32"
  11.108 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
  11.109 +			IntermediateDirectory="$(ConfigurationName)"
  11.110 +			ConfigurationType="2"
  11.111 +			CharacterSet="2"
  11.112 +			WholeProgramOptimization="1"
  11.113 +			>
  11.114 +			<Tool
  11.115 +				Name="VCPreBuildEventTool"
  11.116 +			/>
  11.117 +			<Tool
  11.118 +				Name="VCCustomBuildTool"
  11.119 +			/>
  11.120 +			<Tool
  11.121 +				Name="VCXMLDataGeneratorTool"
  11.122 +			/>
  11.123 +			<Tool
  11.124 +				Name="VCWebServiceProxyGeneratorTool"
  11.125 +			/>
  11.126 +			<Tool
  11.127 +				Name="VCMIDLTool"
  11.128 +			/>
  11.129 +			<Tool
  11.130 +				Name="VCCLCompilerTool"
  11.131 +				FavorSizeOrSpeed="1"
  11.132 +				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;;"
  11.133 +				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
  11.134 +				RuntimeLibrary="0"
  11.135 +				EnableEnhancedInstructionSet="1"
  11.136 +				RuntimeTypeInfo="false"
  11.137 +				UsePrecompiledHeader="0"
  11.138 +				WarningLevel="3"
  11.139 +				Detect64BitPortabilityProblems="false"
  11.140 +				DebugInformationFormat="3"
  11.141 +			/>
  11.142 +			<Tool
  11.143 +				Name="VCManagedResourceCompilerTool"
  11.144 +			/>
  11.145 +			<Tool
  11.146 +				Name="VCResourceCompilerTool"
  11.147 +			/>
  11.148 +			<Tool
  11.149 +				Name="VCPreLinkEventTool"
  11.150 +			/>
  11.151 +			<Tool
  11.152 +				Name="VCLinkerTool"
  11.153 +				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;"
  11.154 +				OutputFile="$(OutDir)\regex.ext.dll"
  11.155 +				LinkIncremental="1"
  11.156 +				IgnoreDefaultLibraryNames="LIBCMT"
  11.157 +				GenerateDebugInformation="true"
  11.158 +				SubSystem="2"
  11.159 +				OptimizeReferences="2"
  11.160 +				EnableCOMDATFolding="2"
  11.161 +				TargetMachine="1"
  11.162 +			/>
  11.163 +			<Tool
  11.164 +				Name="VCALinkTool"
  11.165 +			/>
  11.166 +			<Tool
  11.167 +				Name="VCManifestTool"
  11.168 +			/>
  11.169 +			<Tool
  11.170 +				Name="VCXDCMakeTool"
  11.171 +			/>
  11.172 +			<Tool
  11.173 +				Name="VCBscMakeTool"
  11.174 +			/>
  11.175 +			<Tool
  11.176 +				Name="VCFxCopTool"
  11.177 +			/>
  11.178 +			<Tool
  11.179 +				Name="VCAppVerifierTool"
  11.180 +			/>
  11.181 +			<Tool
  11.182 +				Name="VCWebDeploymentTool"
  11.183 +			/>
  11.184 +			<Tool
  11.185 +				Name="VCPostBuildEventTool"
  11.186 +			/>
  11.187 +		</Configuration>
  11.188 +		<Configuration
  11.189 +			Name="Debug - Orange Box|Win32"
  11.190 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
  11.191 +			IntermediateDirectory="$(ConfigurationName)"
  11.192 +			ConfigurationType="2"
  11.193 +			CharacterSet="2"
  11.194 +			>
  11.195 +			<Tool
  11.196 +				Name="VCPreBuildEventTool"
  11.197 +			/>
  11.198 +			<Tool
  11.199 +				Name="VCCustomBuildTool"
  11.200 +			/>
  11.201 +			<Tool
  11.202 +				Name="VCXMLDataGeneratorTool"
  11.203 +			/>
  11.204 +			<Tool
  11.205 +				Name="VCWebServiceProxyGeneratorTool"
  11.206 +			/>
  11.207 +			<Tool
  11.208 +				Name="VCMIDLTool"
  11.209 +			/>
  11.210 +			<Tool
  11.211 +				Name="VCCLCompilerTool"
  11.212 +				Optimization="0"
  11.213 +				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;;"
  11.214 +				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
  11.215 +				MinimalRebuild="true"
  11.216 +				BasicRuntimeChecks="3"
  11.217 +				RuntimeLibrary="1"
  11.218 +				EnableEnhancedInstructionSet="1"
  11.219 +				RuntimeTypeInfo="false"
  11.220 +				UsePrecompiledHeader="0"
  11.221 +				WarningLevel="3"
  11.222 +				Detect64BitPortabilityProblems="false"
  11.223 +				DebugInformationFormat="4"
  11.224 +			/>
  11.225 +			<Tool
  11.226 +				Name="VCManagedResourceCompilerTool"
  11.227 +			/>
  11.228 +			<Tool
  11.229 +				Name="VCResourceCompilerTool"
  11.230 +			/>
  11.231 +			<Tool
  11.232 +				Name="VCPreLinkEventTool"
  11.233 +			/>
  11.234 +			<Tool
  11.235 +				Name="VCLinkerTool"
  11.236 +				IgnoreImportLibrary="false"
  11.237 +				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;"
  11.238 +				OutputFile="$(OutDir)\regex.ext.dll"
  11.239 +				LinkIncremental="2"
  11.240 +				IgnoreDefaultLibraryNames="LIBCMTD"
  11.241 +				GenerateDebugInformation="true"
  11.242 +				SubSystem="2"
  11.243 +				OptimizeReferences="0"
  11.244 +				EnableCOMDATFolding="0"
  11.245 +				ImportLibrary="$(OutDir)/sdk.lib"
  11.246 +				TargetMachine="1"
  11.247 +			/>
  11.248 +			<Tool
  11.249 +				Name="VCALinkTool"
  11.250 +			/>
  11.251 +			<Tool
  11.252 +				Name="VCManifestTool"
  11.253 +			/>
  11.254 +			<Tool
  11.255 +				Name="VCXDCMakeTool"
  11.256 +			/>
  11.257 +			<Tool
  11.258 +				Name="VCBscMakeTool"
  11.259 +			/>
  11.260 +			<Tool
  11.261 +				Name="VCFxCopTool"
  11.262 +			/>
  11.263 +			<Tool
  11.264 +				Name="VCAppVerifierTool"
  11.265 +			/>
  11.266 +			<Tool
  11.267 +				Name="VCWebDeploymentTool"
  11.268 +			/>
  11.269 +			<Tool
  11.270 +				Name="VCPostBuildEventTool"
  11.271 +			/>
  11.272 +		</Configuration>
  11.273 +		<Configuration
  11.274 +			Name="Release - Orange Box|Win32"
  11.275 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
  11.276 +			IntermediateDirectory="$(ConfigurationName)"
  11.277 +			ConfigurationType="2"
  11.278 +			CharacterSet="2"
  11.279 +			WholeProgramOptimization="1"
  11.280 +			>
  11.281 +			<Tool
  11.282 +				Name="VCPreBuildEventTool"
  11.283 +			/>
  11.284 +			<Tool
  11.285 +				Name="VCCustomBuildTool"
  11.286 +			/>
  11.287 +			<Tool
  11.288 +				Name="VCXMLDataGeneratorTool"
  11.289 +			/>
  11.290 +			<Tool
  11.291 +				Name="VCWebServiceProxyGeneratorTool"
  11.292 +			/>
  11.293 +			<Tool
  11.294 +				Name="VCMIDLTool"
  11.295 +			/>
  11.296 +			<Tool
  11.297 +				Name="VCCLCompilerTool"
  11.298 +				FavorSizeOrSpeed="1"
  11.299 +				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;;"
  11.300 +				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
  11.301 +				RuntimeLibrary="0"
  11.302 +				EnableEnhancedInstructionSet="1"
  11.303 +				RuntimeTypeInfo="false"
  11.304 +				UsePrecompiledHeader="0"
  11.305 +				WarningLevel="3"
  11.306 +				Detect64BitPortabilityProblems="false"
  11.307 +				DebugInformationFormat="3"
  11.308 +			/>
  11.309 +			<Tool
  11.310 +				Name="VCManagedResourceCompilerTool"
  11.311 +			/>
  11.312 +			<Tool
  11.313 +				Name="VCResourceCompilerTool"
  11.314 +			/>
  11.315 +			<Tool
  11.316 +				Name="VCPreLinkEventTool"
  11.317 +			/>
  11.318 +			<Tool
  11.319 +				Name="VCLinkerTool"
  11.320 +				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;"
  11.321 +				OutputFile="$(OutDir)\regex.ext.dll"
  11.322 +				LinkIncremental="1"
  11.323 +				IgnoreDefaultLibraryNames="LIBCMT"
  11.324 +				GenerateDebugInformation="true"
  11.325 +				SubSystem="2"
  11.326 +				OptimizeReferences="2"
  11.327 +				EnableCOMDATFolding="2"
  11.328 +				TargetMachine="1"
  11.329 +			/>
  11.330 +			<Tool
  11.331 +				Name="VCALinkTool"
  11.332 +			/>
  11.333 +			<Tool
  11.334 +				Name="VCManifestTool"
  11.335 +			/>
  11.336 +			<Tool
  11.337 +				Name="VCXDCMakeTool"
  11.338 +			/>
  11.339 +			<Tool
  11.340 +				Name="VCBscMakeTool"
  11.341 +			/>
  11.342 +			<Tool
  11.343 +				Name="VCFxCopTool"
  11.344 +			/>
  11.345 +			<Tool
  11.346 +				Name="VCAppVerifierTool"
  11.347 +			/>
  11.348 +			<Tool
  11.349 +				Name="VCWebDeploymentTool"
  11.350 +			/>
  11.351 +			<Tool
  11.352 +				Name="VCPostBuildEventTool"
  11.353 +			/>
  11.354 +		</Configuration>
  11.355 +	</Configurations>
  11.356 +	<References>
  11.357 +	</References>
  11.358 +	<Files>
  11.359 +		<Filter
  11.360 +			Name="Source Files"
  11.361 +			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
  11.362 +			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
  11.363 +			>
  11.364 +			<File
  11.365 +				RelativePath="..\CRegEx.cpp"
  11.366 +				>
  11.367 +			</File>
  11.368 +			<File
  11.369 +				RelativePath="..\extension.cpp"
  11.370 +				>
  11.371 +			</File>
  11.372 +		</Filter>
  11.373 +		<Filter
  11.374 +			Name="Header Files"
  11.375 +			Filter="h;hpp;hxx;hm;inl;inc;xsd"
  11.376 +			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
  11.377 +			>
  11.378 +			<File
  11.379 +				RelativePath="..\CRegEx.h"
  11.380 +				>
  11.381 +			</File>
  11.382 +			<File
  11.383 +				RelativePath="..\extension.h"
  11.384 +				>
  11.385 +			</File>
  11.386 +			<File
  11.387 +				RelativePath="..\pcre.h"
  11.388 +				>
  11.389 +			</File>
  11.390 +		</Filter>
  11.391 +		<Filter
  11.392 +			Name="Resource Files"
  11.393 +			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
  11.394 +			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
  11.395 +			>
  11.396 +		</Filter>
  11.397 +		<Filter
  11.398 +			Name="SourceMod SDK"
  11.399 +			UniqueIdentifier="{31958233-BB2D-4e41-A8F9-CE8A4684F436}"
  11.400 +			>
  11.401 +			<File
  11.402 +				RelativePath="..\sdk\smsdk_config.h"
  11.403 +				>
  11.404 +			</File>
  11.405 +			<File
  11.406 +				RelativePath="..\sdk\smsdk_ext.cpp"
  11.407 +				>
  11.408 +			</File>
  11.409 +			<File
  11.410 +				RelativePath="..\sdk\smsdk_ext.h"
  11.411 +				>
  11.412 +			</File>
  11.413 +		</Filter>
  11.414 +		<Filter
  11.415 +			Name="Library Files"
  11.416 +			>
  11.417 +			<File
  11.418 +				RelativePath="..\lib_win\pcre.lib"
  11.419 +				>
  11.420 +			</File>
  11.421 +		</Filter>
  11.422 +	</Files>
  11.423 +	<Globals>
  11.424 +	</Globals>
  11.425 +</VisualStudioProject>
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/extensions/regex/pcre.h	Wed Mar 26 03:52:37 2008 +0000
    12.3 @@ -0,0 +1,305 @@
    12.4 +/*************************************************
    12.5 +*       Perl-Compatible Regular Expressions      *
    12.6 +*************************************************/
    12.7 +
    12.8 +/* This is the public header file for the PCRE library, to be #included by
    12.9 +applications that call the PCRE functions.
   12.10 +
   12.11 +           Copyright (c) 1997-2007 University of Cambridge
   12.12 +
   12.13 +-----------------------------------------------------------------------------
   12.14 +Redistribution and use in source and binary forms, with or without
   12.15 +modification, are permitted provided that the following conditions are met:
   12.16 +
   12.17 +    * Redistributions of source code must retain the above copyright notice,
   12.18 +      this list of conditions and the following disclaimer.
   12.19 +
   12.20 +    * Redistributions in binary form must reproduce the above copyright
   12.21 +      notice, this list of conditions and the following disclaimer in the
   12.22 +      documentation and/or other materials provided with the distribution.
   12.23 +
   12.24 +    * Neither the name of the University of Cambridge nor the names of its
   12.25 +      contributors may be used to endorse or promote products derived from
   12.26 +      this software without specific prior written permission.
   12.27 +
   12.28 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   12.29 +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   12.30 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   12.31 +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
   12.32 +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   12.33 +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   12.34 +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   12.35 +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   12.36 +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   12.37 +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   12.38 +POSSIBILITY OF SUCH DAMAGE.
   12.39 +-----------------------------------------------------------------------------
   12.40 +*/
   12.41 +
   12.42 +#ifndef _PCRE_H
   12.43 +#define _PCRE_H
   12.44 +
   12.45 +/* The current PCRE version information. */
   12.46 +
   12.47 +#define PCRE_MAJOR          7
   12.48 +#define PCRE_MINOR          4
   12.49 +#define PCRE_PRERELEASE     
   12.50 +#define PCRE_DATE           2007-09-21
   12.51 +
   12.52 +/* When an application links to a PCRE DLL in Windows, the symbols that are
   12.53 +imported have to be identified as such. When building PCRE, the appropriate
   12.54 +export setting is defined in pcre_internal.h, which includes this file. So we
   12.55 +don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
   12.56 +
   12.57 +#define PCRE_STATIC
   12.58 +
   12.59 +#if defined(_WIN32) && !defined(PCRE_STATIC)
   12.60 +#  ifndef PCRE_EXP_DECL
   12.61 +#    define PCRE_EXP_DECL  extern __declspec(dllimport)
   12.62 +#  endif
   12.63 +#  ifdef __cplusplus
   12.64 +#    ifndef PCRECPP_EXP_DECL
   12.65 +#      define PCRECPP_EXP_DECL  extern __declspec(dllimport)
   12.66 +#    endif
   12.67 +#    ifndef PCRECPP_EXP_DEFN
   12.68 +#      define PCRECPP_EXP_DEFN  __declspec(dllimport)
   12.69 +#    endif
   12.70 +#  endif
   12.71 +#endif
   12.72 +
   12.73 +/* By default, we use the standard "extern" declarations. */
   12.74 +
   12.75 +#ifndef PCRE_EXP_DECL
   12.76 +#  ifdef __cplusplus
   12.77 +#    define PCRE_EXP_DECL  extern "C"
   12.78 +#  else
   12.79 +#    define PCRE_EXP_DECL  extern
   12.80 +#  endif
   12.81 +#endif
   12.82 +
   12.83 +#ifdef __cplusplus
   12.84 +#  ifndef PCRECPP_EXP_DECL
   12.85 +#    define PCRECPP_EXP_DECL  extern
   12.86 +#  endif
   12.87 +#  ifndef PCRECPP_EXP_DEFN
   12.88 +#    define PCRECPP_EXP_DEFN
   12.89 +#  endif
   12.90 +#endif
   12.91 +
   12.92 +/* Have to include stdlib.h in order to ensure that size_t is defined;
   12.93 +it is needed here for malloc. */
   12.94 +
   12.95 +#include <stdlib.h>
   12.96 +
   12.97 +/* Allow for C++ users */
   12.98 +
   12.99 +#ifdef __cplusplus
  12.100 +extern "C" {
  12.101 +#endif
  12.102 +
  12.103 +/* Options */
  12.104 +
  12.105 +#define PCRE_CASELESS           0x00000001
  12.106 +#define PCRE_MULTILINE          0x00000002
  12.107 +#define PCRE_DOTALL             0x00000004
  12.108 +#define PCRE_EXTENDED           0x00000008
  12.109 +#define PCRE_ANCHORED           0x00000010
  12.110 +#define PCRE_DOLLAR_ENDONLY     0x00000020
  12.111 +#define PCRE_EXTRA              0x00000040
  12.112 +#define PCRE_NOTBOL             0x00000080
  12.113 +#define PCRE_NOTEOL             0x00000100
  12.114 +#define PCRE_UNGREEDY           0x00000200
  12.115 +#define PCRE_NOTEMPTY           0x00000400
  12.116 +#define PCRE_UTF8               0x00000800
  12.117 +#define PCRE_NO_AUTO_CAPTURE    0x00001000
  12.118 +#define PCRE_NO_UTF8_CHECK      0x00002000
  12.119 +#define PCRE_AUTO_CALLOUT       0x00004000
  12.120 +#define PCRE_PARTIAL            0x00008000
  12.121 +#define PCRE_DFA_SHORTEST       0x00010000
  12.122 +#define PCRE_DFA_RESTART        0x00020000
  12.123 +#define PCRE_FIRSTLINE          0x00040000
  12.124 +#define PCRE_DUPNAMES           0x00080000
  12.125 +#define PCRE_NEWLINE_CR         0x00100000
  12.126 +#define PCRE_NEWLINE_LF         0x00200000
  12.127 +#define PCRE_NEWLINE_CRLF       0x00300000
  12.128 +#define PCRE_NEWLINE_ANY        0x00400000
  12.129 +#define PCRE_NEWLINE_ANYCRLF    0x00500000
  12.130 +#define PCRE_BSR_ANYCRLF        0x00800000
  12.131 +#define PCRE_BSR_UNICODE        0x01000000
  12.132 +
  12.133 +/* Exec-time and get/set-time error codes */
  12.134 +
  12.135 +#define PCRE_ERROR_NOMATCH         (-1)
  12.136 +#define PCRE_ERROR_NULL            (-2)
  12.137 +#define PCRE_ERROR_BADOPTION       (-3)
  12.138 +#define PCRE_ERROR_BADMAGIC        (-4)
  12.139 +#define PCRE_ERROR_UNKNOWN_OPCODE  (-5)
  12.140 +#define PCRE_ERROR_UNKNOWN_NODE    (-5)  /* For backward compatibility */
  12.141 +#define PCRE_ERROR_NOMEMORY        (-6)
  12.142 +#define PCRE_ERROR_NOSUBSTRING     (-7)
  12.143 +#define PCRE_ERROR_MATCHLIMIT      (-8)
  12.144 +#define PCRE_ERROR_CALLOUT         (-9)  /* Never used by PCRE itself */
  12.145 +#define PCRE_ERROR_BADUTF8        (-10)
  12.146 +#define PCRE_ERROR_BADUTF8_OFFSET (-11)
  12.147 +#define PCRE_ERROR_PARTIAL        (-12)
  12.148 +#define PCRE_ERROR_BADPARTIAL     (-13)
  12.149 +#define PCRE_ERROR_INTERNAL       (-14)
  12.150 +#define PCRE_ERROR_BADCOUNT       (-15)
  12.151 +#define PCRE_ERROR_DFA_UITEM      (-16)
  12.152 +#define PCRE_ERROR_DFA_UCOND      (-17)
  12.153 +#define PCRE_ERROR_DFA_UMLIMIT    (-18)
  12.154 +#define PCRE_ERROR_DFA_WSSIZE     (-19)
  12.155 +#define PCRE_ERROR_DFA_RECURSE    (-20)
  12.156 +#define PCRE_ERROR_RECURSIONLIMIT (-21)
  12.157 +#define PCRE_ERROR_NULLWSLIMIT    (-22)  /* No longer actually used */
  12.158 +#define PCRE_ERROR_BADNEWLINE     (-23)
  12.159 +
  12.160 +/* Request types for pcre_fullinfo() */
  12.161 +
  12.162 +#define PCRE_INFO_OPTIONS            0
  12.163 +#define PCRE_INFO_SIZE               1
  12.164 +#define PCRE_INFO_CAPTURECOUNT       2
  12.165 +#define PCRE_INFO_BACKREFMAX         3
  12.166 +#define PCRE_INFO_FIRSTBYTE          4
  12.167 +#define PCRE_INFO_FIRSTCHAR          4  /* For backwards compatibility */
  12.168 +#define PCRE_INFO_FIRSTTABLE         5
  12.169 +#define PCRE_INFO_LASTLITERAL        6
  12.170 +#define PCRE_INFO_NAMEENTRYSIZE      7
  12.171 +#define PCRE_INFO_NAMECOUNT          8
  12.172 +#define PCRE_INFO_NAMETABLE          9
  12.173 +#define PCRE_INFO_STUDYSIZE         10
  12.174 +#define PCRE_INFO_DEFAULT_TABLES    11
  12.175 +#define PCRE_INFO_OKPARTIAL         12
  12.176 +#define PCRE_INFO_JCHANGED          13
  12.177 +#define PCRE_INFO_HASCRORLF         14
  12.178 +
  12.179 +/* Request types for pcre_config(). Do not re-arrange, in order to remain
  12.180 +compatible. */
  12.181 +
  12.182 +#define PCRE_CONFIG_UTF8                    0
  12.183 +#define PCRE_CONFIG_NEWLINE                 1
  12.184 +#define PCRE_CONFIG_LINK_SIZE               2
  12.185 +#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD  3
  12.186 +#define PCRE_CONFIG_MATCH_LIMIT             4
  12.187 +#define PCRE_CONFIG_STACKRECURSE            5
  12.188 +#define PCRE_CONFIG_UNICODE_PROPERTIES      6
  12.189 +#define PCRE_CONFIG_MATCH_LIMIT_RECURSION   7
  12.190 +#define PCRE_CONFIG_BSR                     8
  12.191 +
  12.192 +/* Bit flags for the pcre_extra structure. Do not re-arrange or redefine
  12.193 +these bits, just add new ones on the end, in order to remain compatible. */
  12.194 +
  12.195 +#define PCRE_EXTRA_STUDY_DATA             0x0001
  12.196 +#define PCRE_EXTRA_MATCH_LIMIT            0x0002
  12.197 +#define PCRE_EXTRA_CALLOUT_DATA           0x0004
  12.198 +#define PCRE_EXTRA_TABLES                 0x0008
  12.199 +#define PCRE_EXTRA_MATCH_LIMIT_RECURSION  0x0010
  12.200 +
  12.201 +/* Types */
  12.202 +
  12.203 +struct real_pcre;                 /* declaration; the definition is private  */
  12.204 +typedef struct real_pcre pcre;
  12.205 +
  12.206 +/* When PCRE is compiled as a C++ library, the subject pointer type can be
  12.207 +replaced with a custom type. For conventional use, the public interface is a
  12.208 +const char *. */
  12.209 +
  12.210 +#ifndef PCRE_SPTR
  12.211 +#define PCRE_SPTR const char *
  12.212 +#endif
  12.213 +
  12.214 +/* The structure for passing additional data to pcre_exec(). This is defined in
  12.215 +such as way as to be extensible. Always add new fields at the end, in order to
  12.216 +remain compatible. */
  12.217 +
  12.218 +typedef struct pcre_extra {
  12.219 +  unsigned long int flags;        /* Bits for which fields are set */
  12.220 +  void *study_data;               /* Opaque data from pcre_study() */
  12.221 +  unsigned long int match_limit;  /* Maximum number of calls to match() */
  12.222 +  void *callout_data;             /* Data passed back in callouts */
  12.223 +  const unsigned char *tables;    /* Pointer to character tables */
  12.224 +  unsigned long int match_limit_recursion; /* Max recursive calls to match() */
  12.225 +} pcre_extra;
  12.226 +
  12.227 +/* The structure for passing out data via the pcre_callout_function. We use a
  12.228 +structure so that new fields can be added on the end in future versions,
  12.229 +without changing the API of the function, thereby allowing old clients to work
  12.230 +without modification. */
  12.231 +
  12.232 +typedef struct pcre_callout_block {
  12.233 +  int          version;           /* Identifies version of block */
  12.234 +  /* ------------------------ Version 0 ------------------------------- */
  12.235 +  int          callout_number;    /* Number compiled into pattern */
  12.236 +  int         *offset_vector;     /* The offset vector */
  12.237 +  PCRE_SPTR    subject;           /* The subject being matched */
  12.238 +  int          subject_length;    /* The length of the subject */
  12.239 +  int          start_match;       /* Offset to start of this match attempt */
  12.240 +  int          current_position;  /* Where we currently are in the subject */
  12.241 +  int          capture_top;       /* Max current capture */
  12.242 +  int          capture_last;      /* Most recently closed capture */
  12.243 +  void        *callout_data;      /* Data passed in with the call */
  12.244 +  /* ------------------- Added for Version 1 -------------------------- */
  12.245 +  int          pattern_position;  /* Offset to next item in the pattern */
  12.246 +  int          next_item_length;  /* Length of next item in the pattern */
  12.247 +  /* ------------------------------------------------------------------ */
  12.248 +} pcre_callout_block;
  12.249 +
  12.250 +/* Indirection for store get and free functions. These can be set to
  12.251 +alternative malloc/free functions if required. Special ones are used in the
  12.252 +non-recursive case for "frames". There is also an optional callout function
  12.253 +that is triggered by the (?) regex item. For Virtual Pascal, these definitions
  12.254 +have to take another form. */
  12.255 +
  12.256 +#ifndef VPCOMPAT
  12.257 +PCRE_EXP_DECL void *(*pcre_malloc)(size_t);
  12.258 +PCRE_EXP_DECL void  (*pcre_free)(void *);
  12.259 +PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
  12.260 +PCRE_EXP_DECL void  (*pcre_stack_free)(void *);
  12.261 +PCRE_EXP_DECL int   (*pcre_callout)(pcre_callout_block *);
  12.262 +#else   /* VPCOMPAT */
  12.263 +PCRE_EXP_DECL void *pcre_malloc(size_t);
  12.264 +PCRE_EXP_DECL void  pcre_free(void *);
  12.265 +PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
  12.266 +PCRE_EXP_DECL void  pcre_stack_free(void *);
  12.267 +PCRE_EXP_DECL int   pcre_callout(pcre_callout_block *);
  12.268 +#endif  /* VPCOMPAT */
  12.269 +
  12.270 +/* Exported PCRE functions */
  12.271 +
  12.272 +PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
  12.273 +                  const unsigned char *);
  12.274 +PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
  12.275 +                  int *, const unsigned char *);
  12.276 +PCRE_EXP_DECL int  pcre_config(int, void *);
  12.277 +PCRE_EXP_DECL int  pcre_copy_named_substring(const pcre *, const char *,
  12.278 +                  int *, int, const char *, char *, int);
  12.279 +PCRE_EXP_DECL int  pcre_copy_substring(const char *, int *, int, int, char *,
  12.280 +                  int);
  12.281 +PCRE_EXP_DECL int  pcre_dfa_exec(const pcre *, const pcre_extra *,
  12.282 +                  const char *, int, int, int, int *, int , int *, int);
  12.283 +PCRE_EXP_DECL int  pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
  12.284 +                   int, int, int, int *, int);
  12.285 +PCRE_EXP_DECL void pcre_free_substring(const char *);
  12.286 +PCRE_EXP_DECL void pcre_free_substring_list(const char **);
  12.287 +PCRE_EXP_DECL int  pcre_fullinfo(const pcre *, const pcre_extra *, int,
  12.288 +                  void *);
  12.289 +PCRE_EXP_DECL int  pcre_get_named_substring(const pcre *, const char *,
  12.290 +                  int *, int, const char *, const char **);
  12.291 +PCRE_EXP_DECL int  pcre_get_stringnumber(const pcre *, const char *);
  12.292 +PCRE_EXP_DECL int  pcre_get_stringtable_entries(const pcre *, const char *,
  12.293 +                  char **, char **);
  12.294 +PCRE_EXP_DECL int  pcre_get_substring(const char *, int *, int, int,
  12.295 +                  const char **);
  12.296 +PCRE_EXP_DECL int  pcre_get_substring_list(const char *, int *, int,
  12.297 +                  const char ***);
  12.298 +PCRE_EXP_DECL int  pcre_info(const pcre *, int *, int *);
  12.299 +PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
  12.300 +PCRE_EXP_DECL int  pcre_refcount(pcre *, int);
  12.301 +PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
  12.302 +PCRE_EXP_DECL const char *pcre_version(void);
  12.303 +
  12.304 +#ifdef __cplusplus
  12.305 +}  /* extern "C" */
  12.306 +#endif
  12.307 +
  12.308 +#endif /* End of pcre.h */
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/extensions/regex/sdk/smsdk_config.h	Wed Mar 26 03:52:37 2008 +0000
    13.3 @@ -0,0 +1,79 @@
    13.4 +/**
    13.5 + * vim: set ts=4 :
    13.6 + * =============================================================================
    13.7 + * SourceMod Sample Extension
    13.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    13.9 + * =============================================================================
   13.10 + *
   13.11 + * This program is free software; you can redistribute it and/or modify it under
   13.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   13.13 + * Free Software Foundation.
   13.14 + * 
   13.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   13.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   13.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   13.18 + * details.
   13.19 + *
   13.20 + * You should have received a copy of the GNU General Public License along with
   13.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   13.22 + *
   13.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   13.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   13.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   13.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   13.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   13.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   13.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   13.30 + * or <http://www.sourcemod.net/license.php>.
   13.31 + *
   13.32 + * Version: $Id$
   13.33 + */
   13.34 +
   13.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
   13.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
   13.37 +
   13.38 +/**
   13.39 + * @file smsdk_config.h
   13.40 + * @brief Contains macros for configuring basic extension information.
   13.41 + */
   13.42 +
   13.43 +/* Basic information exposed publicly */
   13.44 +#define SMEXT_CONF_NAME			"Regex"
   13.45 +#define SMEXT_CONF_DESCRIPTION	"Provides regex natives for plugins"
   13.46 +#define SMEXT_CONF_VERSION		"SVN_FULL_VERSION"
   13.47 +#define SMEXT_CONF_AUTHOR		"AlliedModders LLC"
   13.48 +#define SMEXT_CONF_URL			"http://www.sourcemod.net/"
   13.49 +#define SMEXT_CONF_LOGTAG		"REGEX"
   13.50 +#define SMEXT_CONF_LICENSE		"GPL"
   13.51 +#define SMEXT_CONF_DATESTRING	__DATE__
   13.52 +
   13.53 +/** 
   13.54 + * @brief Exposes plugin's main interface.
   13.55 + */
   13.56 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
   13.57 +
   13.58 +/**
   13.59 + * @brief Sets whether or not this plugin required Metamod.
   13.60 + * NOTE: Uncomment to enable, comment to disable.
   13.61 + */
   13.62 +//#define SMEXT_CONF_METAMOD		
   13.63 +
   13.64 +/** Enable interfaces you want to use here by uncommenting lines */
   13.65 +//#define SMEXT_ENABLE_FORWARDSYS
   13.66 +#define SMEXT_ENABLE_HANDLESYS
   13.67 +//#define SMEXT_ENABLE_PLAYERHELPERS
   13.68 +//#define SMEXT_ENABLE_DBMANAGER
   13.69 +//#define SMEXT_ENABLE_GAMECONF
   13.70 +//#define SMEXT_ENABLE_MEMUTILS
   13.71 +//#define SMEXT_ENABLE_GAMEHELPERS
   13.72 +//#define SMEXT_ENABLE_TIMERSYS
   13.73 +//#define SMEXT_ENABLE_THREADER
   13.74 +//#define SMEXT_ENABLE_LIBSYS
   13.75 +//#define SMEXT_ENABLE_MENUS
   13.76 +//#define SMEXT_ENABLE_ADTFACTORY
   13.77 +//#define SMEXT_ENABLE_PLUGINSYS
   13.78 +//#define SMEXT_ENABLE_ADMINSYS
   13.79 +//#define SMEXT_ENABLE_TEXTPARSERS
   13.80 +#define SMEXT_ENABLE_USERMSGS
   13.81 +
   13.82 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/extensions/regex/sdk/smsdk_ext.cpp	Wed Mar 26 03:52:37 2008 +0000
    14.3 @@ -0,0 +1,455 @@
    14.4 +/**
    14.5 + * vim: set ts=4 :
    14.6 + * =============================================================================
    14.7 + * SourceMod Base Extension Code
    14.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    14.9 + * =============================================================================
   14.10 + *
   14.11 + * This program is free software; you can redistribute it and/or modify it under
   14.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   14.13 + * Free Software Foundation.
   14.14 + * 
   14.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   14.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   14.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   14.18 + * details.
   14.19 + *
   14.20 + * You should have received a copy of the GNU General Public License along with
   14.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   14.22 + *
   14.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   14.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   14.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   14.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   14.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   14.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   14.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   14.30 + * or <http://www.sourcemod.net/license.php>.
   14.31 + *
   14.32 + * Version: $Id$
   14.33 + */
   14.34 +
   14.35 +#include <stdio.h>
   14.36 +#include <malloc.h>
   14.37 +#include "smsdk_ext.h"
   14.38 +
   14.39 +/**
   14.40 + * @file smsdk_ext.cpp
   14.41 + * @brief Contains wrappers for making Extensions easier to write.
   14.42 + */
   14.43 +
   14.44 +IExtension *myself = NULL;				/**< Ourself */
   14.45 +IShareSys *g_pShareSys = NULL;			/**< Share system */
   14.46 +IShareSys *sharesys = NULL;				/**< Share system */
   14.47 +ISourceMod *g_pSM = NULL;				/**< SourceMod helpers */
   14.48 +ISourceMod *smutils = NULL;				/**< SourceMod helpers */
   14.49 +
   14.50 +#if defined SMEXT_ENABLE_FORWARDSYS
   14.51 +IForwardManager *g_pForwards = NULL;	/**< Forward system */
   14.52 +IForwardManager *forwards = NULL;		/**< Forward system */
   14.53 +#endif
   14.54 +#if defined SMEXT_ENABLE_HANDLESYS
   14.55 +IHandleSys *g_pHandleSys = NULL;		/**< Handle system */
   14.56 +IHandleSys *handlesys = NULL;			/**< Handle system */
   14.57 +#endif
   14.58 +#if defined SMEXT_ENABLE_PLAYERHELPERS
   14.59 +IPlayerManager *playerhelpers = NULL;	/**< Player helpers */
   14.60 +#endif //SMEXT_ENABLE_PLAYERHELPERS
   14.61 +#if defined SMEXT_ENABLE_DBMANAGER
   14.62 +IDBManager *dbi = NULL;					/**< DB Manager */
   14.63 +#endif //SMEXT_ENABLE_DBMANAGER
   14.64 +#if defined SMEXT_ENABLE_GAMECONF
   14.65 +IGameConfigManager *gameconfs = NULL;	/**< Game config manager */
   14.66 +#endif //SMEXT_ENABLE_DBMANAGER
   14.67 +#if defined SMEXT_ENABLE_MEMUTILS
   14.68 +IMemoryUtils *memutils = NULL;
   14.69 +#endif //SMEXT_ENABLE_DBMANAGER
   14.70 +#if defined SMEXT_ENABLE_GAMEHELPERS
   14.71 +IGameHelpers *gamehelpers = NULL;
   14.72 +#endif
   14.73 +#if defined SMEXT_ENABLE_TIMERSYS
   14.74 +ITimerSystem *timersys = NULL;
   14.75 +#endif
   14.76 +#if defined SMEXT_ENABLE_ADTFACTORY
   14.77 +IADTFactory *adtfactory = NULL;
   14.78 +#endif
   14.79 +#if defined SMEXT_ENABLE_THREADER
   14.80 +IThreader *threader = NULL;
   14.81 +#endif
   14.82 +#if defined SMEXT_ENABLE_LIBSYS
   14.83 +ILibrarySys *libsys = NULL;
   14.84 +#endif
   14.85 +#if defined SMEXT_ENABLE_PLUGINSYS
   14.86 +SourceMod::IPluginManager *plsys;
   14.87 +#endif
   14.88 +#if defined SMEXT_ENABLE_MENUS
   14.89 +IMenuManager *menus = NULL;
   14.90 +#endif
   14.91 +#if defined SMEXT_ENABLE_ADMINSYS
   14.92 +IAdminSystem *adminsys = NULL;
   14.93 +#endif
   14.94 +#if defined SMEXT_ENABLE_TEXTPARSERS
   14.95 +ITextParsers *textparsers = NULL;
   14.96 +#endif
   14.97 +#if defined SMEXT_ENABLE_USERMSGS
   14.98 +IUserMessages *usermsgs = NULL;
   14.99 +#endif
  14.100 +
  14.101 +/** Exports the main interface */
  14.102 +PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
  14.103 +{
  14.104 +	return g_pExtensionIface;
  14.105 +}
  14.106 +
  14.107 +SDKExtension::SDKExtension()
  14.108 +{
  14.109 +#if defined SMEXT_CONF_METAMOD
  14.110 +	m_SourceMMLoaded = false;
  14.111 +	m_WeAreUnloaded = false;
  14.112 +	m_WeGotPauseChange = false;
  14.113 +#endif
  14.114 +}
  14.115 +
  14.116 +bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
  14.117 +{
  14.118 +	g_pShareSys = sharesys = sys;
  14.119 +	myself = me;
  14.120 +
  14.121 +#if defined SMEXT_CONF_METAMOD
  14.122 +	m_WeAreUnloaded = true;
  14.123 +
  14.124 +	if (!m_SourceMMLoaded)
  14.125 +	{
  14.126 +		if (error)
  14.127 +		{
  14.128 +			snprintf(error, maxlength, "Metamod attach failed");
  14.129 +		}
  14.130 +		return false;
  14.131 +	}
  14.132 +#endif
  14.133 +	SM_GET_IFACE(SOURCEMOD, g_pSM);
  14.134 +	smutils = g_pSM;
  14.135 +#if defined SMEXT_ENABLE_HANDLESYS
  14.136 +	SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
  14.137 +	handlesys = g_pHandleSys;
  14.138 +#endif
  14.139 +#if defined SMEXT_ENABLE_FORWARDSYS
  14.140 +	SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
  14.141 +	forwards = g_pForwards;
  14.142 +#endif
  14.143 +#if defined SMEXT_ENABLE_PLAYERHELPERS
  14.144 +	SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
  14.145 +#endif
  14.146 +#if defined SMEXT_ENABLE_DBMANAGER
  14.147 +	SM_GET_IFACE(DBI, dbi);
  14.148 +#endif
  14.149 +#if defined SMEXT_ENABLE_GAMECONF
  14.150 +	SM_GET_IFACE(GAMECONFIG, gameconfs);
  14.151 +#endif
  14.152 +#if defined SMEXT_ENABLE_MEMUTILS
  14.153 +	SM_GET_IFACE(MEMORYUTILS, memutils);
  14.154 +#endif
  14.155 +#if defined SMEXT_ENABLE_GAMEHELPERS
  14.156 +	SM_GET_IFACE(GAMEHELPERS, gamehelpers);
  14.157 +#endif
  14.158 +#if defined SMEXT_ENABLE_TIMERSYS
  14.159 +	SM_GET_IFACE(TIMERSYS, timersys);
  14.160 +#endif
  14.161 +#if defined SMEXT_ENABLE_ADTFACTORY
  14.162 +	SM_GET_IFACE(ADTFACTORY, adtfactory);
  14.163 +#endif
  14.164 +#if defined SMEXT_ENABLE_THREADER
  14.165 +	SM_GET_IFACE(THREADER, threader);
  14.166 +#endif
  14.167 +#if defined SMEXT_ENABLE_LIBSYS
  14.168 +	SM_GET_IFACE(LIBRARYSYS, libsys);
  14.169 +#endif
  14.170 +#if defined SMEXT_ENABLE_PLUGINSYS
  14.171 +	SM_GET_IFACE(PLUGINSYSTEM, plsys);
  14.172 +#endif
  14.173 +#if defined SMEXT_ENABLE_MENUS
  14.174 +	SM_GET_IFACE(MENUMANAGER, menus);
  14.175 +#endif
  14.176 +#if defined SMEXT_ENABLE_ADMINSYS
  14.177 +	SM_GET_IFACE(ADMINSYS, adminsys);
  14.178 +#endif
  14.179 +#if defined SMEXT_ENABLE_TEXTPARSERS
  14.180 +	SM_GET_IFACE(TEXTPARSERS, textparsers);
  14.181 +#endif
  14.182 +#if defined SMEXT_ENABLE_USERMSGS
  14.183 +	SM_GET_IFACE(USERMSGS, usermsgs);
  14.184 +#endif
  14.185 +
  14.186 +	if (SDK_OnLoad(error, maxlength, late))
  14.187 +	{
  14.188 +#if defined SMEXT_CONF_METAMOD
  14.189 +		m_WeAreUnloaded = true;
  14.190 +#endif
  14.191 +		return true;
  14.192 +	}
  14.193 +
  14.194 +	return false;
  14.195 +}
  14.196 +
  14.197 +bool SDKExtension::IsMetamodExtension()
  14.198 +{
  14.199 +#if defined SMEXT_CONF_METAMOD
  14.200 +	return true;
  14.201 +#else
  14.202 +	return false;
  14.203 +#endif
  14.204 +}
  14.205 +
  14.206 +void SDKExtension::OnExtensionPauseChange(bool state)
  14.207 +{
  14.208 +#if defined SMEXT_CONF_METAMOD
  14.209 +	m_WeGotPauseChange = true;
  14.210 +#endif
  14.211 +	SDK_OnPauseChange(state);
  14.212 +}
  14.213 +
  14.214 +void SDKExtension::OnExtensionsAllLoaded()
  14.215 +{
  14.216 +	SDK_OnAllLoaded();
  14.217 +}
  14.218 +
  14.219 +void SDKExtension::OnExtensionUnload()
  14.220 +{
  14.221 +#if defined SMEXT_CONF_METAMOD
  14.222 +	m_WeAreUnloaded = true;
  14.223 +#endif
  14.224 +	SDK_OnUnload();
  14.225 +}
  14.226 +
  14.227 +const char *SDKExtension::GetExtensionAuthor()
  14.228 +{
  14.229 +	return SMEXT_CONF_AUTHOR;
  14.230 +}
  14.231 +
  14.232 +const char *SDKExtension::GetExtensionDateString()
  14.233 +{
  14.234 +	return SMEXT_CONF_DATESTRING;
  14.235 +}
  14.236 +
  14.237 +const char *SDKExtension::GetExtensionDescription()
  14.238 +{
  14.239 +	return SMEXT_CONF_DESCRIPTION;
  14.240 +}
  14.241 +
  14.242 +const char *SDKExtension::GetExtensionVerString()
  14.243 +{
  14.244 +	return SMEXT_CONF_VERSION;
  14.245 +}
  14.246 +
  14.247 +const char *SDKExtension::GetExtensionName()
  14.248 +{
  14.249 +	return SMEXT_CONF_NAME;
  14.250 +}
  14.251 +
  14.252 +const char *SDKExtension::GetExtensionTag()
  14.253 +{
  14.254 +	return SMEXT_CONF_LOGTAG;
  14.255 +}
  14.256 +
  14.257 +const char *SDKExtension::GetExtensionURL()
  14.258 +{
  14.259 +	return SMEXT_CONF_URL;
  14.260 +}
  14.261 +
  14.262 +bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
  14.263 +{
  14.264 +	return true;
  14.265 +}
  14.266 +
  14.267 +void SDKExtension::SDK_OnUnload()
  14.268 +{
  14.269 +}
  14.270 +
  14.271 +void SDKExtension::SDK_OnPauseChange(bool paused)
  14.272 +{
  14.273 +}
  14.274 +
  14.275 +void SDKExtension::SDK_OnAllLoaded()
  14.276 +{
  14.277 +}
  14.278 +
  14.279 +#if defined SMEXT_CONF_METAMOD
  14.280 +
  14.281 +PluginId g_PLID = 0;						/**< Metamod plugin ID */
  14.282 +ISmmPlugin *g_PLAPI = NULL;					/**< Metamod plugin API */
  14.283 +SourceHook::ISourceHook *g_SHPtr = NULL;	/**< SourceHook pointer */
  14.284 +ISmmAPI *g_SMAPI = NULL;					/**< SourceMM API pointer */
  14.285 +
  14.286 +IVEngineServer *engine = NULL;				/**< IVEngineServer pointer */
  14.287 +IServerGameDLL *gamedll = NULL;				/**< IServerGameDLL pointer */
  14.288 +
  14.289 +/** Exposes the extension to Metamod */
  14.290 +SMM_API void *PL_EXPOSURE(const char *name, int *code)
  14.291 +{
  14.292 +#if defined METAMOD_PLAPI_VERSION
  14.293 +	if (name && !strcmp(name, METAMOD_PLAPI_NAME))
  14.294 +#else
  14.295 +	if (name && !strcmp(name, PLAPI_NAME))
  14.296 +#endif
  14.297 +	{
  14.298 +		if (code)
  14.299 +		{
  14.300 +			*code = IFACE_OK;
  14.301 +		}
  14.302 +		return static_cast<void *>(g_pExtensionIface);
  14.303 +	}
  14.304 +
  14.305 +	if (code)
  14.306 +	{
  14.307 +		*code = IFACE_FAILED;
  14.308 +	}
  14.309 +
  14.310 +	return NULL;
  14.311 +}
  14.312 +
  14.313 +bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
  14.314 +{
  14.315 +	PLUGIN_SAVEVARS();
  14.316 +
  14.317 +#if defined METAMOD_PLAPI_VERSION
  14.318 +	GET_V_IFACE_ANY(serverFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
  14.319 +	GET_V_IFACE_CURRENT(engineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
  14.320 +#else
  14.321 +	GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
  14.322 +	GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
  14.323 +#endif
  14.324 +
  14.325 +	m_SourceMMLoaded = true;
  14.326 +
  14.327 +	return SDK_OnMetamodLoad(ismm, error, maxlen, late);
  14.328 +}
  14.329 +
  14.330 +bool SDKExtension::Unload(char *error, size_t maxlen)
  14.331 +{
  14.332 +	if (!m_WeAreUnloaded)
  14.333 +	{
  14.334 +		if (error)
  14.335 +		{
  14.336 +			snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
  14.337 +		}
  14.338 +		return false;
  14.339 +	}
  14.340 +
  14.341 +	return SDK_OnMetamodUnload(error, maxlen);
  14.342 +}
  14.343 +
  14.344 +bool SDKExtension::Pause(char *error, size_t maxlen)
  14.345 +{
  14.346 +	if (!m_WeGotPauseChange)
  14.347 +	{
  14.348 +		if (error)
  14.349 +		{
  14.350 +			snprintf(error, maxlen, "This extension must be paused by SourceMod.");
  14.351 +		}
  14.352 +		return false;
  14.353 +	}
  14.354 +
  14.355 +	m_WeGotPauseChange = false;
  14.356 +
  14.357 +	return SDK_OnMetamodPauseChange(true, error, maxlen);
  14.358 +}
  14.359 +
  14.360 +bool SDKExtension::Unpause(char *error, size_t maxlen)
  14.361 +{
  14.362 +	if (!m_WeGotPauseChange)
  14.363 +	{
  14.364 +		if (error)
  14.365 +		{
  14.366 +			snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
  14.367 +		}
  14.368 +		return false;
  14.369 +	}
  14.370 +
  14.371 +	m_WeGotPauseChange = false;
  14.372 +
  14.373 +	return SDK_OnMetamodPauseChange(false, error, maxlen);
  14.374 +}
  14.375 +
  14.376 +const char *SDKExtension::GetAuthor()
  14.377 +{
  14.378 +	return GetExtensionAuthor();
  14.379 +}
  14.380 +
  14.381 +const char *SDKExtension::GetDate()
  14.382 +{
  14.383 +	return GetExtensionDateString();
  14.384 +}
  14.385 +
  14.386 +const char *SDKExtension::GetDescription()
  14.387 +{
  14.388 +	return GetExtensionDescription();
  14.389 +}
  14.390 +
  14.391 +const char *SDKExtension::GetLicense()
  14.392 +{
  14.393 +	return SMEXT_CONF_LICENSE;
  14.394 +}
  14.395 +
  14.396 +const char *SDKExtension::GetLogTag()
  14.397 +{
  14.398 +	return GetExtensionTag();
  14.399 +}
  14.400 +
  14.401 +const char *SDKExtension::GetName()
  14.402 +{
  14.403 +	return GetExtensionName();
  14.404 +}
  14.405 +
  14.406 +const char *SDKExtension::GetURL()
  14.407 +{
  14.408 +	return GetExtensionURL();
  14.409 +}
  14.410 +
  14.411 +const char *SDKExtension::GetVersion()
  14.412 +{
  14.413 +	return GetExtensionVerString();
  14.414 +}
  14.415 +
  14.416 +bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
  14.417 +{
  14.418 +	return true;
  14.419 +}
  14.420 +
  14.421 +bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
  14.422 +{
  14.423 +	return true;
  14.424 +}
  14.425 +
  14.426 +bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
  14.427 +{
  14.428 +	return true;
  14.429 +}
  14.430 +
  14.431 +#endif
  14.432 +
  14.433 +/* Overload a few things to prevent libstdc++ linking */
  14.434 +#if defined __linux__
  14.435 +extern "C" void __cxa_pure_virtual(void)
  14.436 +{
  14.437 +}
  14.438 +
  14.439 +void *operator new(size_t size)
  14.440 +{
  14.441 +	return malloc(size);
  14.442 +}
  14.443 +
  14.444 +void *operator new[](size_t size) 
  14.445 +{
  14.446 +	return malloc(size);
  14.447 +}
  14.448 +
  14.449 +void operator delete(void *ptr) 
  14.450 +{
  14.451 +	free(ptr);
  14.452 +}
  14.453 +
  14.454 +void operator delete[](void * ptr)
  14.455 +{
  14.456 +	free(ptr);
  14.457 +}
  14.458 +#endif
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/extensions/regex/sdk/smsdk_ext.h	Wed Mar 26 03:52:37 2008 +0000
    15.3 @@ -0,0 +1,327 @@
    15.4 +/**
    15.5 + * vim: set ts=4 :
    15.6 + * =============================================================================
    15.7 + * SourceMod Base Extension Code
    15.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    15.9 + * =============================================================================
   15.10 + *
   15.11 + * This program is free software; you can redistribute it and/or modify it under
   15.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   15.13 + * Free Software Foundation.
   15.14 + * 
   15.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   15.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   15.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   15.18 + * details.
   15.19 + *
   15.20 + * You should have received a copy of the GNU General Public License along with
   15.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   15.22 + *
   15.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   15.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   15.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   15.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   15.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   15.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   15.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   15.30 + * or <http://www.sourcemod.net/license.php>.
   15.31 + *
   15.32 + * Version: $Id$
   15.33 + */
   15.34 +
   15.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
   15.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
   15.37 +
   15.38 +/**
   15.39 + * @file smsdk_ext.h
   15.40 + * @brief Contains wrappers for making Extensions easier to write.
   15.41 + */
   15.42 +
   15.43 +#include "smsdk_config.h"
   15.44 +#include <IExtensionSys.h>
   15.45 +#include <IHandleSys.h>
   15.46 +#include <sp_vm_api.h>
   15.47 +#include <sm_platform.h>
   15.48 +#include <ISourceMod.h>
   15.49 +#if defined SMEXT_ENABLE_FORWARDSYS
   15.50 +#include <IForwardSys.h>
   15.51 +#endif //SMEXT_ENABLE_FORWARDSYS
   15.52 +#if defined SMEXT_ENABLE_PLAYERHELPERS
   15.53 +#include <IPlayerHelpers.h>
   15.54 +#endif //SMEXT_ENABLE_PlAYERHELPERS
   15.55 +#if defined SMEXT_ENABLE_DBMANAGER
   15.56 +#include <IDBDriver.h>
   15.57 +#endif //SMEXT_ENABLE_DBMANAGER
   15.58 +#if defined SMEXT_ENABLE_GAMECONF
   15.59 +#include <IGameConfigs.h>
   15.60 +#endif
   15.61 +#if defined SMEXT_ENABLE_MEMUTILS
   15.62 +#include <IMemoryUtils.h>
   15.63 +#endif
   15.64 +#if defined SMEXT_ENABLE_GAMEHELPERS
   15.65 +#include <IGameHelpers.h>
   15.66 +#endif
   15.67 +#if defined SMEXT_ENABLE_TIMERSYS
   15.68 +#include <ITimerSystem.h>
   15.69 +#endif
   15.70 +#if defined SMEXT_ENABLE_ADTFACTORY
   15.71 +#include <IADTFactory.h>
   15.72 +#endif
   15.73 +#if defined SMEXT_ENABLE_THREADER
   15.74 +#include <IThreader.h>
   15.75 +#endif
   15.76 +#if defined SMEXT_ENABLE_LIBSYS
   15.77 +#include <ILibrarySys.h>
   15.78 +#endif
   15.79 +#if defined SMEXT_ENABLE_PLUGINSYS
   15.80 +#include <IPluginSys.h>
   15.81 +#endif
   15.82 +#if defined SMEXT_ENABLE_MENUS
   15.83 +#include <IMenuManager.h>
   15.84 +#endif
   15.85 +#if defined SMEXT_ENABLE_ADMINSYS
   15.86 +#include <IAdminSystem.h>
   15.87 +#endif
   15.88 +#if defined SMEXT_ENABLE_TEXTPARSERS
   15.89 +#include <ITextParsers.h>
   15.90 +#endif
   15.91 +#if defined SMEXT_ENABLE_USERMSGS
   15.92 +#include <IUserMessages.h>
   15.93 +#endif
   15.94 +
   15.95 +#if defined SMEXT_CONF_METAMOD
   15.96 +#include <ISmmPlugin.h>
   15.97 +#include <eiface.h>
   15.98 +#endif
   15.99 +
  15.100 +using namespace SourceMod;
  15.101 +using namespace SourcePawn;
  15.102 +
  15.103 +class SDKExtension : 
  15.104 +#if defined SMEXT_CONF_METAMOD
  15.105 +	public ISmmPlugin,
  15.106 +#endif
  15.107 +	public IExtensionInterface
  15.108 +{
  15.109 +public:
  15.110 +	/** Constructor */
  15.111 +	SDKExtension();
  15.112 +public:
  15.113 +	/**
  15.114 +	 * @brief This is called after the initial loading sequence has been processed.
  15.115 +	 *
  15.116 +	 * @param error		Error message buffer.
  15.117 +	 * @param maxlength	Size of error message buffer.
  15.118 +	 * @param late		Whether or not the module was loaded after map load.
  15.119 +	 * @return			True to succeed loading, false to fail.
  15.120 +	 */
  15.121 +	virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
  15.122 +	
  15.123 +	/**
  15.124 +	 * @brief This is called right before the extension is unloaded.
  15.125 +	 */
  15.126 +	virtual void SDK_OnUnload();
  15.127 +
  15.128 +	/**
  15.129 +	 * @brief This is called once all known extensions have been loaded.
  15.130 +	 */
  15.131 +	virtual void SDK_OnAllLoaded();
  15.132 +
  15.133 +	/**
  15.134 +	 * @brief Called when the pause state is changed.
  15.135 +	 */
  15.136 +	virtual void SDK_OnPauseChange(bool paused);
  15.137 +
  15.138 +#if defined SMEXT_CONF_METAMOD
  15.139 +	/**
  15.140 +	 * @brief Called when Metamod is attached, before the extension version is called.
  15.141 +	 *
  15.142 +	 * @param error			Error buffer.
  15.143 +	 * @param maxlength		Maximum size of error buffer.
  15.144 +	 * @param late			Whether or not Metamod considers this a late load.
  15.145 +	 * @return				True to succeed, false to fail.
  15.146 +	 */
  15.147 +	virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
  15.148 +
  15.149 +	/**
  15.150 +	 * @brief Called when Metamod is detaching, after the extension version is called.
  15.151 +	 * NOTE: By default this is blocked unless sent from SourceMod.
  15.152 +	 *
  15.153 +	 * @param error			Error buffer.
  15.154 +	 * @param maxlength		Maximum size of error buffer.
  15.155 +	 * @return				True to succeed, false to fail.
  15.156 +	 */
  15.157 +	virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
  15.158 +
  15.159 +	/**
  15.160 +	 * @brief Called when Metamod's pause state is changing.
  15.161 +	 * NOTE: By default this is blocked unless sent from SourceMod.
  15.162 +	 *
  15.163 +	 * @param paused		Pause state being set.
  15.164 +	 * @param error			Error buffer.
  15.165 +	 * @param maxlength		Maximum size of error buffer.
  15.166 +	 * @return				True to succeed, false to fail.
  15.167 +	 */
  15.168 +	virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
  15.169 +#endif
  15.170 +
  15.171 +public: //IExtensionInterface
  15.172 +	virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
  15.173 +	virtual void OnExtensionUnload();
  15.174 +	virtual void OnExtensionsAllLoaded();
  15.175 +
  15.176 +	/** Returns whether or not this is a Metamod-based extension */
  15.177 +	virtual bool IsMetamodExtension();
  15.178 +
  15.179 +	/**
  15.180 +	 * @brief Called when the pause state changes.
  15.181 +	 * 
  15.182 +	 * @param state			True if being paused, false if being unpaused.
  15.183 +	 */
  15.184 +	virtual void OnExtensionPauseChange(bool state);
  15.185 +
  15.186 +	/** Returns name */
  15.187 +	virtual const char *GetExtensionName();
  15.188 +	/** Returns URL */
  15.189 +	virtual const char *GetExtensionURL();
  15.190 +	/** Returns log tag */
  15.191 +	virtual const char *GetExtensionTag();
  15.192 +	/** Returns author */
  15.193 +	virtual const char *GetExtensionAuthor();
  15.194 +	/** Returns version string */
  15.195 +	virtual const char *GetExtensionVerString();
  15.196 +	/** Returns description string */
  15.197 +	virtual const char *GetExtensionDescription();
  15.198 +	/** Returns date string */
  15.199 +	virtual const char *GetExtensionDateString();
  15.200 +#if defined SMEXT_CONF_METAMOD
  15.201 +public: //ISmmPlugin
  15.202 +	/** Called when the extension is attached to Metamod. */
  15.203 +	virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
  15.204 +	/** Returns the author to MM */
  15.205 +	virtual const char *GetAuthor();
  15.206 +	/** Returns the name to MM */
  15.207 +	virtual const char *GetName();
  15.208 +	/** Returns the description to MM */
  15.209 +	virtual const char *GetDescription();
  15.210 +	/** Returns the URL to MM */
  15.211 +	virtual const char *GetURL();
  15.212 +	/** Returns the license to MM */
  15.213 +	virtual const char *GetLicense();
  15.214 +	/** Returns the version string to MM */
  15.215 +	virtual const char *GetVersion();
  15.216 +	/** Returns the date string to MM */
  15.217 +	virtual const char *GetDate();
  15.218 +	/** Returns the logtag to MM */
  15.219 +	virtual const char *GetLogTag();
  15.220 +	/** Called on unload */
  15.221 +	virtual bool Unload(char *error, size_t maxlength);
  15.222 +	/** Called on pause */
  15.223 +	virtual bool Pause(char *error, size_t maxlength);
  15.224 +	/** Called on unpause */
  15.225 +	virtual bool Unpause(char *error, size_t maxlength);
  15.226 +private:
  15.227 +	bool m_SourceMMLoaded;
  15.228 +	bool m_WeAreUnloaded;
  15.229 +	bool m_WeGotPauseChange;
  15.230 +#endif
  15.231 +};
  15.232 +
  15.233 +extern SDKExtension *g_pExtensionIface;
  15.234 +extern IExtension *myself;
  15.235 +
  15.236 +extern IShareSys *g_pShareSys;
  15.237 +extern IShareSys *sharesys;				/* Note: Newer name */
  15.238 +extern ISourceMod *g_pSM;
  15.239 +extern ISourceMod *smutils;				/* Note: Newer name */
  15.240 +
  15.241 +/* Optional interfaces are below */
  15.242 +#if defined SMEXT_ENABLE_FORWARDSYS
  15.243 +extern IForwardManager *g_pForwards;
  15.244 +extern IForwardManager *forwards;		/* Note: Newer name */
  15.245 +#endif //SMEXT_ENABLE_FORWARDSYS
  15.246 +#if defined SMEXT_ENABLE_HANDLESYS
  15.247 +extern IHandleSys *g_pHandleSys;
  15.248 +extern IHandleSys *handlesys;			/* Note: Newer name */
  15.249 +#endif //SMEXT_ENABLE_HANDLESYS
  15.250 +#if defined SMEXT_ENABLE_PLAYERHELPERS
  15.251 +extern IPlayerManager *playerhelpers;
  15.252 +#endif //SMEXT_ENABLE_PLAYERHELPERS
  15.253 +#if defined SMEXT_ENABLE_DBMANAGER
  15.254 +extern IDBManager *dbi;
  15.255 +#endif //SMEXT_ENABLE_DBMANAGER
  15.256 +#if defined SMEXT_ENABLE_GAMECONF
  15.257 +extern IGameConfigManager *gameconfs;
  15.258 +#endif //SMEXT_ENABLE_DBMANAGER
  15.259 +#if defined SMEXT_ENABLE_MEMUTILS
  15.260 +extern IMemoryUtils *memutils;
  15.261 +#endif
  15.262 +#if defined SMEXT_ENABLE_GAMEHELPERS
  15.263 +extern IGameHelpers *gamehelpers;
  15.264 +#endif
  15.265 +#if defined SMEXT_ENABLE_TIMERSYS
  15.266 +extern ITimerSystem *timersys;
  15.267 +#endif
  15.268 +#if defined SMEXT_ENABLE_ADTFACTORY
  15.269 +extern IADTFactory *adtfactory;
  15.270 +#endif
  15.271 +#if defined SMEXT_ENABLE_THREADER
  15.272 +extern IThreader *threader;
  15.273 +#endif
  15.274 +#if defined SMEXT_ENABLE_LIBSYS
  15.275 +extern ILibrarySys *libsys;
  15.276 +#endif
  15.277 +#if defined SMEXT_ENABLE_PLUGINSYS
  15.278 +extern SourceMod::IPluginManager *plsys;
  15.279 +#endif
  15.280 +#if defined SMEXT_ENABLE_MENUS
  15.281 +extern IMenuManager *menus;
  15.282 +#endif
  15.283 +#if defined SMEXT_ENABLE_ADMINSYS
  15.284 +extern IAdminSystem *adminsys;
  15.285 +#endif
  15.286 +#if defined SMEXT_ENABLE_USERMSGS
  15.287 +extern IUserMessages *usermsgs;
  15.288 +#endif
  15.289 +
  15.290 +#if defined SMEXT_CONF_METAMOD
  15.291 +PLUGIN_GLOBALVARS();
  15.292 +extern IVEngineServer *engine;
  15.293 +extern IServerGameDLL *gamedll;
  15.294 +#endif
  15.295 +
  15.296 +/** Creates a SourceMod interface macro pair */
  15.297 +#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
  15.298 +/** Automates retrieving SourceMod interfaces */
  15.299 +#define SM_GET_IFACE(prefix, addr) \
  15.300 +	if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
  15.301 +	{ \
  15.302 +		if (error != NULL && maxlength) \
  15.303 +		{ \
  15.304 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
  15.305 +			if (len >= maxlength) \
  15.306 +			{ \
  15.307 +				error[maxlength - 1] = '\0'; \
  15.308 +			} \
  15.309 +		} \
  15.310 +		return false; \
  15.311 +	}
  15.312 +/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
  15.313 +#define SM_GET_LATE_IFACE(prefix, addr) \
  15.314 +	g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
  15.315 +/** Validates a SourceMod interface pointer */
  15.316 +#define SM_CHECK_IFACE(prefix, addr) \
  15.317 +	if (!addr) \
  15.318 +	{ \
  15.319 +		if (error != NULL && maxlength) \
  15.320 +		{ \
  15.321 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
  15.322 +			if (len >= maxlength) \
  15.323 +			{ \
  15.324 +				error[maxlength - 1] = '\0'; \
  15.325 +			} \
  15.326 +		} \
  15.327 +		return false; \
  15.328 +	}
  15.329 +
  15.330 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/extensions/tf2/Makefile.ep1	Wed Mar 26 03:52:37 2008 +0000
    16.3 @@ -0,0 +1,88 @@
    16.4 +#(C)2004-2006 SourceMM Development Team
    16.5 +# Makefile written by David "BAILOPAN" Anderson
    16.6 +
    16.7 +SMSDK = ../smsdk
    16.8 +SRCDS = ~/srcds_l/steaminstall
    16.9 +SOURCEMM = ../sourcemm
   16.10 +HL2SDK = ../hl2sdk
   16.11 +
   16.12 +#####################################
   16.13 +### EDIT BELOW FOR OTHER PROJECTS ###
   16.14 +#####################################
   16.15 +
   16.16 +PROJECT = game.tf2
   16.17 +
   16.18 +#Uncomment for SourceMM-enabled extensions
   16.19 +LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so 
   16.20 +
   16.21 +OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp
   16.22 +
   16.23 +##############################################
   16.24 +### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
   16.25 +##############################################
   16.26 +
   16.27 +C_OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing
   16.28 +C_DEBUG_FLAGS = -g -ggdb3
   16.29 +CPP_GCC4_FLAGS = -fvisibility=hidden -fvisibility-inlines-hidden
   16.30 +CPP = gcc-4.1
   16.31 +
   16.32 +HL2PUB = $(HL2SDK)/public
   16.33 +HL2LIB = $(HL2SDK)/linux_sdk
   16.34 +
   16.35 +LINK = $(LINK_HL2) -static-libgcc
   16.36 +
   16.37 +INCLUDE = -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \
   16.38 +          -I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SOURCEMM) -I$(SOURCEMM)/sourcehook -I$(SOURCEMM)/sourcemm \
   16.39 +	  -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \
   16.40 +
   16.41 +CFLAGS = -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp \
   16.42 +	-Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp \
   16.43 +	-Wall -Werror -fPIC -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H
   16.44 +CPPFLAGS = -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
   16.45 +
   16.46 +################################################
   16.47 +### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
   16.48 +################################################
   16.49 +
   16.50 +ifeq "$(DEBUG)" "true"
   16.51 +	BIN_DIR = Debug
   16.52 +	CFLAGS += $(C_DEBUG_FLAGS)
   16.53 +else
   16.54 +	BIN_DIR = Release
   16.55 +	CFLAGS += $(C_OPT_FLAGS)
   16.56 +endif
   16.57 +
   16.58 +
   16.59 +GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
   16.60 +ifeq "$(GCC_VERSION)" "4"
   16.61 +	CPPFLAGS += $(CPP_GCC4_FLAGS)
   16.62 +endif
   16.63 +
   16.64 +BINARY = $(PROJECT).ext.so
   16.65 +
   16.66 +OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
   16.67 +
   16.68 +$(BIN_DIR)/%.o: %.cpp
   16.69 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
   16.70 +
   16.71 +all:
   16.72 +	mkdir -p $(BIN_DIR)/sdk
   16.73 +	ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so
   16.74 +	ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so
   16.75 +	$(MAKE) -f Makefile.ep1 extension
   16.76 +
   16.77 +extension: $(OBJ_LINUX)
   16.78 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
   16.79 +
   16.80 +debug:	
   16.81 +	$(MAKE) -f Makefile.ep1 all DEBUG=true
   16.82 +
   16.83 +default: all
   16.84 +
   16.85 +clean:
   16.86 +	rm -rf Release/*.o
   16.87 +	rm -rf Release/sdk/*.o
   16.88 +	rm -rf Release/$(BINARY)
   16.89 +	rm -rf Debug/*.o
   16.90 +	rm -rf Debug/sdk/*.o
   16.91 +	rm -rf Debug/$(BINARY)
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/extensions/tf2/Makefile.ep2	Wed Mar 26 03:52:37 2008 +0000
    17.3 @@ -0,0 +1,88 @@
    17.4 +#(C)2004-2006 SourceMM Development Team
    17.5 +# Makefile written by David "BAILOPAN" Anderson
    17.6 +
    17.7 +SMSDK = ../smsdk
    17.8 +SRCDS = ~/srcds_l/steaminstall
    17.9 +SOURCEMM = ../sourcemm
   17.10 +HL2SDK = ../hl2sdk-ob
   17.11 +
   17.12 +#####################################
   17.13 +### EDIT BELOW FOR OTHER PROJECTS ###
   17.14 +#####################################
   17.15 +
   17.16 +PROJECT = game.tf2
   17.17 +
   17.18 +#Uncomment for SourceMM-enabled extensions
   17.19 +LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so 
   17.20 +
   17.21 +OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp
   17.22 +
   17.23 +##############################################
   17.24 +### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
   17.25 +##############################################
   17.26 +
   17.27 +C_OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing
   17.28 +C_DEBUG_FLAGS = -g -ggdb3
   17.29 +CPP_GCC4_FLAGS = -fvisibility=hidden -fvisibility-inlines-hidden
   17.30 +CPP = gcc-4.1
   17.31 +
   17.32 +HL2PUB = $(HL2SDK)/public
   17.33 +HL2LIB = $(HL2SDK)/linux_sdk
   17.34 +
   17.35 +LINK = $(LINK_HL2) -static-libgcc
   17.36 +
   17.37 +INCLUDE = -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \
   17.38 +          -I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SOURCEMM) -I$(SOURCEMM)/sourcehook -I$(SOURCEMM)/sourcemm \
   17.39 +	  -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \
   17.40 +
   17.41 +CFLAGS = -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp \
   17.42 +	-Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp \
   17.43 +	-Wall -Werror -fPIC -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -DORANGEBOX_BUILD
   17.44 +CPPFLAGS = -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
   17.45 +
   17.46 +################################################
   17.47 +### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
   17.48 +################################################
   17.49 +
   17.50 +ifeq "$(DEBUG)" "true"
   17.51 +	BIN_DIR = Debug
   17.52 +	CFLAGS += $(C_DEBUG_FLAGS)
   17.53 +else
   17.54 +	BIN_DIR = Release
   17.55 +	CFLAGS += $(C_OPT_FLAGS)
   17.56 +endif
   17.57 +
   17.58 +
   17.59 +GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
   17.60 +ifeq "$(GCC_VERSION)" "4"
   17.61 +	CPPFLAGS += $(CPP_GCC4_FLAGS)
   17.62 +endif
   17.63 +
   17.64 +BINARY = $(PROJECT).ext.so
   17.65 +
   17.66 +OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
   17.67 +
   17.68 +$(BIN_DIR)/%.o: %.cpp
   17.69 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
   17.70 +
   17.71 +all:
   17.72 +	mkdir -p $(BIN_DIR)/sdk
   17.73 +	ln -sf $(SRCDS)/orangebox/bin/vstdlib_i486.so vstdlib_i486.so
   17.74 +	ln -sf $(SRCDS)/orangebox/bin/tier0_i486.so tier0_i486.so
   17.75 +	$(MAKE) -f Makefile.ep2 extension
   17.76 +
   17.77 +extension: $(OBJ_LINUX)
   17.78 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
   17.79 +
   17.80 +debug:	
   17.81 +	$(MAKE) -f Makefile.ep2 all DEBUG=true
   17.82 +
   17.83 +default: all
   17.84 +
   17.85 +clean:
   17.86 +	rm -rf Release/*.o
   17.87 +	rm -rf Release/sdk/*.o
   17.88 +	rm -rf Release/$(BINARY)
   17.89 +	rm -rf Debug/*.o
   17.90 +	rm -rf Debug/sdk/*.o
   17.91 +	rm -rf Debug/$(BINARY)
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/extensions/tf2/Makefile.orig	Wed Mar 26 03:52:37 2008 +0000
    18.3 @@ -0,0 +1,88 @@
    18.4 +#(C)2004-2006 SourceMM Development Team
    18.5 +# Makefile written by David "BAILOPAN" Anderson
    18.6 +
    18.7 +SMSDK = ../smsdk
    18.8 +SRCDS = ~/srcds_l/steaminstall
    18.9 +SOURCEMM = ../sourcemm
   18.10 +HL2SDK = ../hl2sdk
   18.11 +
   18.12 +#####################################
   18.13 +### EDIT BELOW FOR OTHER PROJECTS ###
   18.14 +#####################################
   18.15 +
   18.16 +PROJECT = game.tf2
   18.17 +
   18.18 +#Uncomment for SourceMM-enabled extensions
   18.19 +LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so 
   18.20 +
   18.21 +OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp
   18.22 +
   18.23 +##############################################
   18.24 +### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
   18.25 +##############################################
   18.26 +
   18.27 +C_OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing
   18.28 +C_DEBUG_FLAGS = -g -ggdb3
   18.29 +CPP_GCC4_FLAGS = -fvisibility=hidden -fvisibility-inlines-hidden
   18.30 +CPP = gcc-4.1
   18.31 +
   18.32 +HL2PUB = $(HL2SDK)/public
   18.33 +HL2LIB = $(HL2SDK)/linux_sdk
   18.34 +
   18.35 +LINK = $(LINK_HL2) -static-libgcc
   18.36 +
   18.37 +INCLUDE = -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/dlls -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \
   18.38 +          -I$(HL2PUB)/vstdlib -I$(HL2SDK)/tier1 -I$(SOURCEMM) -I$(SOURCEMM)/sourcehook -I$(SOURCEMM)/sourcemm \
   18.39 +	  -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn -I$(SMSDK)/public/extensions \
   18.40 +
   18.41 +CFLAGS = -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp \
   18.42 +	-Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp \
   18.43 +	-Wall -Werror -fPIC -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H
   18.44 +CPPFLAGS = -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
   18.45 +
   18.46 +################################################
   18.47 +### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
   18.48 +################################################
   18.49 +
   18.50 +ifeq "$(DEBUG)" "true"
   18.51 +	BIN_DIR = Debug
   18.52 +	CFLAGS += $(C_DEBUG_FLAGS)
   18.53 +else
   18.54 +	BIN_DIR = Release
   18.55 +	CFLAGS += $(C_OPT_FLAGS)
   18.56 +endif
   18.57 +
   18.58 +
   18.59 +GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
   18.60 +ifeq "$(GCC_VERSION)" "4"
   18.61 +	CPPFLAGS += $(CPP_GCC4_FLAGS)
   18.62 +endif
   18.63 +
   18.64 +BINARY = $(PROJECT).ext.so
   18.65 +
   18.66 +OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
   18.67 +
   18.68 +$(BIN_DIR)/%.o: %.cpp
   18.69 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
   18.70 +
   18.71 +all:
   18.72 +	mkdir -p $(BIN_DIR)/sdk
   18.73 +	ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so
   18.74 +	ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so
   18.75 +	$(MAKE) -f Makefile.orig extension
   18.76 +
   18.77 +extension: $(OBJ_LINUX)
   18.78 +	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
   18.79 +
   18.80 +debug:	
   18.81 +	$(MAKE) -f Makefile.orig all DEBUG=true
   18.82 +
   18.83 +default: all
   18.84 +
   18.85 +clean:
   18.86 +	rm -rf Release/*.o
   18.87 +	rm -rf Release/sdk/*.o
   18.88 +	rm -rf Release/$(BINARY)
   18.89 +	rm -rf Debug/*.o
   18.90 +	rm -rf Debug/sdk/*.o
   18.91 +	rm -rf Debug/$(BINARY)
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/extensions/tf2/RegNatives.cpp	Wed Mar 26 03:52:37 2008 +0000
    19.3 @@ -0,0 +1,50 @@
    19.4 +/**
    19.5 + * vim: set ts=4 :
    19.6 + * =============================================================================
    19.7 + * SourceMod Counter-Strike:Source Extension
    19.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    19.9 + * =============================================================================
   19.10 + *
   19.11 + * This program is free software; you can redistribute it and/or modify it under
   19.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   19.13 + * Free Software Foundation.
   19.14 + * 
   19.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   19.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   19.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   19.18 + * details.
   19.19 + *
   19.20 + * You should have received a copy of the GNU General Public License along with
   19.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   19.22 + *
   19.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   19.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   19.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   19.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   19.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   19.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   19.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   19.30 + * or <http://www.sourcemod.net/license.php>.
   19.31 + *
   19.32 + * Version: $Id$
   19.33 + */
   19.34 +
   19.35 +#include "extension.h"
   19.36 +#include "RegNatives.h"
   19.37 +
   19.38 +RegNatives g_RegNatives;
   19.39 +
   19.40 +void RegNatives::Register(ICallWrapper *pWrapper)
   19.41 +{
   19.42 +	m_List.push_back(pWrapper);
   19.43 +}
   19.44 +
   19.45 +void RegNatives::UnregisterAll()
   19.46 +{
   19.47 +	SourceHook::List<ICallWrapper *>::iterator iter;
   19.48 +
   19.49 +	for (iter=m_List.begin(); iter!=m_List.end(); iter++)
   19.50 +	{
   19.51 +		(*iter)->Destroy();
   19.52 +	}
   19.53 +}
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/extensions/tf2/RegNatives.h	Wed Mar 26 03:52:37 2008 +0000
    20.3 @@ -0,0 +1,48 @@
    20.4 +/**
    20.5 + * vim: set ts=4 :
    20.6 + * =============================================================================
    20.7 + * SourceMod Counter-Strike:Source Extension
    20.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    20.9 + * =============================================================================
   20.10 + *
   20.11 + * This program is free software; you can redistribute it and/or modify it under
   20.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   20.13 + * Free Software Foundation.
   20.14 + * 
   20.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   20.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   20.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   20.18 + * details.
   20.19 + *
   20.20 + * You should have received a copy of the GNU General Public License along with
   20.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   20.22 + *
   20.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   20.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   20.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   20.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   20.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   20.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   20.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   20.30 + * or <http://www.sourcemod.net/license.php>.
   20.31 + *
   20.32 + * Version: $Id$
   20.33 + */
   20.34 +
   20.35 +#ifndef _INCLUDE_TF2TOOLS_REGNATIVES_H_
   20.36 +#define _INCLUDE_TF2TOOLS_REGNATIVES_H_
   20.37 +
   20.38 +#include <sh_list.h>
   20.39 +
   20.40 +class RegNatives
   20.41 +{
   20.42 +public:
   20.43 +	void Register(ICallWrapper *pWrapper);
   20.44 +	void UnregisterAll();
   20.45 +private:
   20.46 +	SourceHook::List<ICallWrapper *> m_List;
   20.47 +};
   20.48 +
   20.49 +extern RegNatives g_RegNatives;
   20.50 +
   20.51 +#endif //_INCLUDE_TF2TOOLS_REGNATIVES_H_
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/extensions/tf2/extension.cpp	Wed Mar 26 03:52:37 2008 +0000
    21.3 @@ -0,0 +1,229 @@
    21.4 +/**
    21.5 + * vim: set ts=4 :
    21.6 + * =============================================================================
    21.7 + * SourceMod Counter-Strike:Source Extension
    21.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    21.9 + * =============================================================================
   21.10 + *
   21.11 + * This program is free software; you can redistribute it and/or modify it under
   21.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   21.13 + * Free Software Foundation.
   21.14 + * 
   21.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   21.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   21.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   21.18 + * details.
   21.19 + *
   21.20 + * You should have received a copy of the GNU General Public License along with
   21.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   21.22 + *
   21.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   21.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   21.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   21.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   21.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   21.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   21.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   21.30 + * or <http://www.sourcemod.net/license.php>.
   21.31 + *
   21.32 + * Version: $Id$
   21.33 + */
   21.34 +
   21.35 +#include "extension.h"
   21.36 +#include "RegNatives.h"
   21.37 +#include "iplayerinfo.h"
   21.38 +
   21.39 +/**
   21.40 + * @file extension.cpp
   21.41 + * @brief Implement extension code here.
   21.42 + */
   21.43 +
   21.44 +
   21.45 +TF2Tools g_TF2Tools;
   21.46 +IGameConfig *g_pGameConf = NULL;
   21.47 +
   21.48 +IBinTools *g_pBinTools = NULL;
   21.49 +
   21.50 +SMEXT_LINK(&g_TF2Tools);
   21.51 +
   21.52 +SendProp *playerSharedOffset;
   21.53 +
   21.54 +extern sp_nativeinfo_t g_TFNatives[];
   21.55 +
   21.56 +bool TF2Tools::SDK_OnLoad(char *error, size_t maxlength, bool late)
   21.57 +{
   21.58 +	sharesys->AddDependency(myself, "bintools.ext", true, true);
   21.59 +
   21.60 +	char conf_error[255];
   21.61 +	if (!gameconfs->LoadGameConfigFile("sm-tf2.games", &g_pGameConf, conf_error, sizeof(conf_error)))
   21.62 +	{
   21.63 +		if (error)
   21.64 +		{
   21.65 +			snprintf(error, maxlength, "Could not read sm-tf2.games.txt: %s", conf_error);
   21.66 +		}
   21.67 +		return false;
   21.68 +	}
   21.69 +
   21.70 +	sharesys->AddNatives(myself, g_TFNatives);
   21.71 +	sharesys->RegisterLibrary(myself, "tf2");
   21.72 +
   21.73 +	playerSharedOffset = gamehelpers->FindInSendTable("CTFPlayer", "DT_TFPlayerShared");
   21.74 +
   21.75 +	playerhelpers->RegisterCommandTargetProcessor(this);
   21.76 +
   21.77 +	return true;
   21.78 +}
   21.79 +
   21.80 +bool TF2Tools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
   21.81 +{
   21.82 +	GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
   21.83 +
   21.84 +	return true;
   21.85 +}
   21.86 +
   21.87 +void TF2Tools::SDK_OnUnload()
   21.88 +{
   21.89 +	g_RegNatives.UnregisterAll();
   21.90 +	gameconfs->CloseGameConfigFile(g_pGameConf);
   21.91 +}
   21.92 +
   21.93 +void TF2Tools::SDK_OnAllLoaded()
   21.94 +{
   21.95 +	SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools);
   21.96 +}
   21.97 +
   21.98 +bool TF2Tools::QueryRunning(char *error, size_t maxlength)
   21.99 +{
  21.100 +	SM_CHECK_IFACE(BINTOOLS, g_pBinTools);
  21.101 +
  21.102 +	return true;
  21.103 +}
  21.104 +
  21.105 +bool TF2Tools::QueryInterfaceDrop(SMInterface *pInterface)
  21.106 +{
  21.107 +	if (pInterface == g_pBinTools)
  21.108 +	{
  21.109 +		return false;
  21.110 +	}
  21.111 +
  21.112 +	return IExtensionInterface::QueryInterfaceDrop(pInterface);
  21.113 +}
  21.114 +
  21.115 +void TF2Tools::NotifyInterfaceDrop(SMInterface *pInterface)
  21.116 +{
  21.117 +	g_RegNatives.UnregisterAll();
  21.118 +}
  21.119 +
  21.120 +size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
  21.121 +{
  21.122 +	va_list ap;
  21.123 +	va_start(ap, fmt);
  21.124 +	size_t len = vsnprintf(buffer, maxlength, fmt, ap);
  21.125 +	va_end(ap);
  21.126 +
  21.127 +	if (len >= maxlength)
  21.128 +	{
  21.129 +		buffer[maxlength - 1] = '\0';
  21.130 +		return (maxlength - 1);
  21.131 +	}
  21.132 +	else
  21.133 +	{
  21.134 +		return len;
  21.135 +	}
  21.136 +}
  21.137 +
  21.138 +bool TF2Tools::ProcessCommandTarget(cmd_target_info_t *info)
  21.139 +{
  21.140 +	int max_clients;
  21.141 +	IPlayerInfo *pInfo;
  21.142 +	unsigned int team_index = 0;
  21.143 +	IGamePlayer *pPlayer, *pAdmin;
  21.144 +
  21.145 +	if ((info->flags & COMMAND_FILTER_NO_MULTI) == COMMAND_FILTER_NO_MULTI)
  21.146 +	{
  21.147 +		return false;
  21.148 +	}
  21.149 +
  21.150 +	if (info->admin)
  21.151 +	{
  21.152 +		if ((pAdmin = playerhelpers->GetGamePlayer(info->admin)) == NULL)
  21.153 +		{
  21.154 +			return false;
  21.155 +		}
  21.156 +		if (!pAdmin->IsInGame())
  21.157 +		{
  21.158 +			return false;
  21.159 +		}
  21.160 +	}
  21.161 +	else
  21.162 +	{
  21.163 +		pAdmin = NULL;
  21.164 +	}
  21.165 +
  21.166 +	if (strcmp(info->pattern, "@red") == 0 )
  21.167 +	{
  21.168 +		team_index = 2;
  21.169 +	}
  21.170 +	else if (strcmp(info->pattern, "@blue") == 0)
  21.171 +	{
  21.172 +		team_index = 3;
  21.173 +	}
  21.174 +	else
  21.175 +	{
  21.176 +		return false;
  21.177 +	}
  21.178 +
  21.179 +	info->num_targets = 0;
  21.180 +
  21.181 +	max_clients = playerhelpers->GetMaxClients();
  21.182 +	for (int i = 1; 
  21.183 +		 i <= max_clients && (cell_t)info->num_targets < info->max_targets; 
  21.184 +		 i++)
  21.185 +	{
  21.186 +		if ((pPlayer = playerhelpers->GetGamePlayer(i)) == NULL)
  21.187 +		{
  21.188 +			continue;
  21.189 +		}
  21.190 +		if (!pPlayer->IsInGame())
  21.191 +		{
  21.192 +			continue;
  21.193 +		}
  21.194 +		if ((pInfo = pPlayer->GetPlayerInfo()) == NULL)
  21.195 +		{
  21.196 +			continue;
  21.197 +		}
  21.198 +		if (pInfo->GetTeamIndex() != (int)team_index)
  21.199 +		{
  21.200 +			continue;
  21.201 +		}
  21.202 +		if (playerhelpers->FilterCommandTarget(pAdmin, pPlayer, info->flags) 
  21.203 +			!= COMMAND_TARGET_VALID)
  21.204 +		{
  21.205 +			continue;
  21.206 +		}
  21.207 +		info->targets[info->num_targets] = i;
  21.208 +		info->num_targets++;
  21.209 +	}
  21.210 +
  21.211 +	if (info->num_targets == 0)
  21.212 +	{
  21.213 +		info->reason = COMMAND_TARGET_EMPTY_FILTER;
  21.214 +	}
  21.215 +	else
  21.216 +	{
  21.217 +		info->reason = COMMAND_TARGET_VALID;
  21.218 +	}
  21.219 +
  21.220 +	info->target_name_style = COMMAND_TARGETNAME_RAW;
  21.221 +	if (team_index == 2)
  21.222 +	{
  21.223 +		UTIL_Format(info->target_name, info->target_name_maxlength, "Red Team");
  21.224 +	}
  21.225 +	else if (team_index == 3)
  21.226 +	{
  21.227 +		UTIL_Format(info->target_name, info->target_name_maxlength, "Blue Team");
  21.228 +	}
  21.229 +
  21.230 +	return true;
  21.231 +}
  21.232 +
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/extensions/tf2/extension.h	Wed Mar 26 03:52:37 2008 +0000
    22.3 @@ -0,0 +1,130 @@
    22.4 +/**
    22.5 + * vim: set ts=4 :
    22.6 + * =============================================================================
    22.7 + * SourceMod Counter-Strike:Source Extension
    22.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    22.9 + * =============================================================================
   22.10 + *
   22.11 + * This program is free software; you can redistribute it and/or modify it under
   22.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   22.13 + * Free Software Foundation.
   22.14 + * 
   22.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   22.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   22.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   22.18 + * details.
   22.19 + *
   22.20 + * You should have received a copy of the GNU General Public License along with
   22.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   22.22 + *
   22.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   22.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   22.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   22.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   22.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   22.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   22.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   22.30 + * or <http://www.sourcemod.net/license.php>.
   22.31 + *
   22.32 + * Version: $Id$
   22.33 + */
   22.34 +
   22.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
   22.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
   22.37 +
   22.38 +/**
   22.39 + * @file extension.h
   22.40 + * @brief Sample extension code header.
   22.41 + */
   22.42 +
   22.43 +#include "smsdk_ext.h"
   22.44 +#include <IBinTools.h>
   22.45 +
   22.46 +/**
   22.47 + * @brief Sample implementation of the SDK Extension.
   22.48 + * Note: Uncomment one of the pre-defined virtual functions in order to use it.
   22.49 + */
   22.50 +class TF2Tools : 
   22.51 +	public SDKExtension,
   22.52 +	public ICommandTargetProcessor
   22.53 +{
   22.54 +public:
   22.55 +	/**
   22.56 +	 * @brief This is called after the initial loading sequence has been processed.
   22.57 +	 *
   22.58 +	 * @param error		Error message buffer.
   22.59 +	 * @param maxlength	Size of error message buffer.
   22.60 +	 * @param late		Whether or not the module was loaded after map load.
   22.61 +	 * @return			True to succeed loading, false to fail.
   22.62 +	 */
   22.63 +	virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
   22.64 +	
   22.65 +	/**
   22.66 +	 * @brief This is called right before the extension is unloaded.
   22.67 +	 */
   22.68 +	virtual void SDK_OnUnload();
   22.69 +
   22.70 +	/**
   22.71 +	 * @brief This is called once all known extensions have been loaded.
   22.72 +	 * Note: It is is a good idea to add natives here, if any are provided.
   22.73 +	 */
   22.74 +	virtual void SDK_OnAllLoaded();
   22.75 +
   22.76 +	/**
   22.77 +	 * @brief Called when the pause state is changed.
   22.78 +	 */
   22.79 +	//virtual void SDK_OnPauseChange(bool paused);
   22.80 +
   22.81 +	/**
   22.82 +	 * @brief this is called when Core wants to know if your extension is working.
   22.83 +	 *
   22.84 +	 * @param error		Error message buffer.
   22.85 +	 * @param maxlength	Size of error message buffer.
   22.86 +	 * @return			True if working, false otherwise.
   22.87 +	 */
   22.88 +	virtual bool QueryRunning(char *error, size_t maxlength);
   22.89 +
   22.90 +	void NotifyInterfaceDrop(SMInterface *pInterface);
   22.91 +	bool QueryInterfaceDrop(SMInterface *pInterface);
   22.92 +public:
   22.93 +	bool ProcessCommandTarget(cmd_target_info_t *info);
   22.94 +public:
   22.95 +#if defined SMEXT_CONF_METAMOD
   22.96 +	/**
   22.97 +	 * @brief Called when Metamod is attached, before the extension version is called.
   22.98 +	 *
   22.99 +	 * @param error			Error buffer.
  22.100 +	 * @param maxlength		Maximum size of error buffer.
  22.101 +	 * @param late			Whether or not Metamod considers this a late load.
  22.102 +	 * @return				True to succeed, false to fail.
  22.103 +	 */
  22.104 +	virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
  22.105 +
  22.106 +	/**
  22.107 +	 * @brief Called when Metamod is detaching, after the extension version is called.
  22.108 +	 * NOTE: By default this is blocked unless sent from SourceMod.
  22.109 +	 *
  22.110 +	 * @param error			Error buffer.
  22.111 +	 * @param maxlength		Maximum size of error buffer.
  22.112 +	 * @return				True to succeed, false to fail.
  22.113 +	 */
  22.114 +	//virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
  22.115 +
  22.116 +	/**
  22.117 +	 * @brief Called when Metamod's pause state is changing.
  22.118 +	 * NOTE: By default this is blocked unless sent from SourceMod.
  22.119 +	 *
  22.120 +	 * @param paused		Pause state being set.
  22.121 +	 * @param error			Error buffer.
  22.122 +	 * @param maxlength		Maximum size of error buffer.
  22.123 +	 * @return				True to succeed, false to fail.
  22.124 +	 */
  22.125 +	//virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
  22.126 +#endif
  22.127 +};
  22.128 +
  22.129 +extern IBinTools *g_pBinTools;
  22.130 +extern IGameConfig *g_pGameConf;
  22.131 +extern SendProp *playerSharedOffset;
  22.132 +
  22.133 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/extensions/tf2/msvc8/tf2.sln	Wed Mar 26 03:52:37 2008 +0000
    23.3 @@ -0,0 +1,32 @@
    23.4 +
    23.5 +Microsoft Visual Studio Solution File, Format Version 9.00
    23.6 +# Visual Studio 2005
    23.7 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tf2", "tf2.vcproj", "{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
    23.8 +EndProject
    23.9 +Global
   23.10 +	GlobalSection(SolutionConfigurationPlatforms) = preSolution
   23.11 +		Debug - Episode1|Win32 = Debug - Episode1|Win32
   23.12 +		Debug - Old Metamod|Win32 = Debug - Old Metamod|Win32
   23.13 +		Debug - Orange Box|Win32 = Debug - Orange Box|Win32
   23.14 +		Release - Episode 1|Win32 = Release - Episode 1|Win32
   23.15 +		Release - Old Metamod|Win32 = Release - Old Metamod|Win32
   23.16 +		Release - Orange Box|Win32 = Release - Orange Box|Win32
   23.17 +	EndGlobalSection
   23.18 +	GlobalSection(ProjectConfigurationPlatforms) = postSolution
   23.19 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode1|Win32.ActiveCfg = Debug - Episode1|Win32
   23.20 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Episode1|Win32.Build.0 = Debug - Episode1|Win32
   23.21 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.ActiveCfg = Debug - Old Metamod|Win32
   23.22 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Old Metamod|Win32.Build.0 = Debug - Old Metamod|Win32
   23.23 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.ActiveCfg = Debug - Orange Box|Win32
   23.24 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Debug - Orange Box|Win32.Build.0 = Debug - Orange Box|Win32
   23.25 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.ActiveCfg = Release - Episode 1|Win32
   23.26 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Episode 1|Win32.Build.0 = Release - Episode 1|Win32
   23.27 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.ActiveCfg = Release - Old Metamod|Win32
   23.28 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Old Metamod|Win32.Build.0 = Release - Old Metamod|Win32
   23.29 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.ActiveCfg = Release - Orange Box|Win32
   23.30 +		{B3E797CF-4E77-4C9D-B8A8-7589B6902206}.Release - Orange Box|Win32.Build.0 = Release - Orange Box|Win32
   23.31 +	EndGlobalSection
   23.32 +	GlobalSection(SolutionProperties) = preSolution
   23.33 +		HideSolutionNode = FALSE
   23.34 +	EndGlobalSection
   23.35 +EndGlobal
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/extensions/tf2/msvc8/tf2.vcproj	Wed Mar 26 03:52:37 2008 +0000
    24.3 @@ -0,0 +1,727 @@
    24.4 +<?xml version="1.0" encoding="Windows-1252"?>
    24.5 +<VisualStudioProject
    24.6 +	ProjectType="Visual C++"
    24.7 +	Version="8.00"
    24.8 +	Name="tf2"
    24.9 +	ProjectGUID="{B3E797CF-4E77-4C9D-B8A8-7589B6902206}"
   24.10 +	RootNamespace="tf2"
   24.11 +	Keyword="Win32Proj"
   24.12 +	>
   24.13 +	<Platforms>
   24.14 +		<Platform
   24.15 +			Name="Win32"
   24.16 +		/>
   24.17 +	</Platforms>
   24.18 +	<ToolFiles>
   24.19 +	</ToolFiles>
   24.20 +	<Configurations>
   24.21 +		<Configuration
   24.22 +			Name="Debug|Win32"
   24.23 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
   24.24 +			IntermediateDirectory="$(ConfigurationName)"
   24.25 +			ConfigurationType="2"
   24.26 +			CharacterSet="2"
   24.27 +			>
   24.28 +			<Tool
   24.29 +				Name="VCPreBuildEventTool"
   24.30 +			/>
   24.31 +			<Tool
   24.32 +				Name="VCCustomBuildTool"
   24.33 +			/>
   24.34 +			<Tool
   24.35 +				Name="VCXMLDataGeneratorTool"
   24.36 +			/>
   24.37 +			<Tool
   24.38 +				Name="VCWebServiceProxyGeneratorTool"
   24.39 +			/>
   24.40 +			<Tool
   24.41 +				Name="VCMIDLTool"
   24.42 +			/>
   24.43 +			<Tool
   24.44 +				Name="VCCLCompilerTool"
   24.45 +				Optimization="0"
   24.46 +				AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions"
   24.47 +				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
   24.48 +				MinimalRebuild="true"
   24.49 +				BasicRuntimeChecks="3"
   24.50 +				RuntimeLibrary="1"
   24.51 +				EnableEnhancedInstructionSet="1"
   24.52 +				RuntimeTypeInfo="false"
   24.53 +				UsePrecompiledHeader="0"
   24.54 +				WarningLevel="3"
   24.55 +				Detect64BitPortabilityProblems="false"
   24.56 +				DebugInformationFormat="4"
   24.57 +			/>
   24.58 +			<Tool
   24.59 +				Name="VCManagedResourceCompilerTool"
   24.60 +			/>
   24.61 +			<Tool
   24.62 +				Name="VCResourceCompilerTool"
   24.63 +			/>
   24.64 +			<Tool
   24.65 +				Name="VCPreLinkEventTool"
   24.66 +			/>
   24.67 +			<Tool
   24.68 +				Name="VCLinkerTool"
   24.69 +				AdditionalDependencies="tier0.lib"
   24.70 +				OutputFile="$(OutDir)\game.tf2.ext.dll"
   24.71 +				LinkIncremental="2"
   24.72 +				GenerateDebugInformation="true"
   24.73 +				SubSystem="2"
   24.74 +				TargetMachine="1"
   24.75 +			/>
   24.76 +			<Tool
   24.77 +				Name="VCALinkTool"
   24.78 +			/>
   24.79 +			<Tool
   24.80 +				Name="VCManifestTool"
   24.81 +			/>
   24.82 +			<Tool
   24.83 +				Name="VCXDCMakeTool"
   24.84 +			/>
   24.85 +			<Tool
   24.86 +				Name="VCBscMakeTool"
   24.87 +			/>
   24.88 +			<Tool
   24.89 +				Name="VCFxCopTool"
   24.90 +			/>
   24.91 +			<Tool
   24.92 +				Name="VCAppVerifierTool"
   24.93 +			/>
   24.94 +			<Tool
   24.95 +				Name="VCWebDeploymentTool"
   24.96 +			/>
   24.97 +			<Tool
   24.98 +				Name="VCPostBuildEventTool"
   24.99 +			/>
  24.100 +		</Configuration>
  24.101 +		<Configuration
  24.102 +			Name="Release|Win32"
  24.103 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
  24.104 +			IntermediateDirectory="$(ConfigurationName)"
  24.105 +			ConfigurationType="2"
  24.106 +			CharacterSet="2"
  24.107 +			WholeProgramOptimization="1"
  24.108 +			>
  24.109 +			<Tool
  24.110 +				Name="VCPreBuildEventTool"
  24.111 +			/>
  24.112 +			<Tool
  24.113 +				Name="VCCustomBuildTool"
  24.114 +			/>
  24.115 +			<Tool
  24.116 +				Name="VCXMLDataGeneratorTool"
  24.117 +			/>
  24.118 +			<Tool
  24.119 +				Name="VCWebServiceProxyGeneratorTool"
  24.120 +			/>
  24.121 +			<Tool
  24.122 +				Name="VCMIDLTool"
  24.123 +			/>
  24.124 +			<Tool
  24.125 +				Name="VCCLCompilerTool"
  24.126 +				FavorSizeOrSpeed="1"
  24.127 +				AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\sourcepawn;..\..\..\public\extensions"
  24.128 +				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
  24.129 +				RuntimeLibrary="0"
  24.130 +				EnableEnhancedInstructionSet="1"
  24.131 +				RuntimeTypeInfo="false"
  24.132 +				UsePrecompiledHeader="0"
  24.133 +				WarningLevel="3"
  24.134 +				Detect64BitPortabilityProblems="false"
  24.135 +				DebugInformationFormat="3"
  24.136 +			/>
  24.137 +			<Tool
  24.138 +				Name="VCManagedResourceCompilerTool"
  24.139 +			/>
  24.140 +			<Tool
  24.141 +				Name="VCResourceCompilerTool"
  24.142 +			/>
  24.143 +			<Tool
  24.144 +				Name="VCPreLinkEventTool"
  24.145 +			/>
  24.146 +			<Tool
  24.147 +				Name="VCLinkerTool"
  24.148 +				OutputFile="$(OutDir)\game.tf2.ext.dll"
  24.149 +				LinkIncremental="1"
  24.150 +				GenerateDebugInformation="true"
  24.151 +				SubSystem="2"
  24.152 +				OptimizeReferences="2"
  24.153 +				EnableCOMDATFolding="2"
  24.154 +				TargetMachine="1"
  24.155 +			/>
  24.156 +			<Tool
  24.157 +				Name="VCALinkTool"
  24.158 +			/>
  24.159 +			<Tool
  24.160 +				Name="VCManifestTool"
  24.161 +			/>
  24.162 +			<Tool
  24.163 +				Name="VCXDCMakeTool"
  24.164 +			/>
  24.165 +			<Tool
  24.166 +				Name="VCBscMakeTool"
  24.167 +			/>
  24.168 +			<Tool
  24.169 +				Name="VCFxCopTool"
  24.170 +			/>
  24.171 +			<Tool
  24.172 +				Name="VCAppVerifierTool"
  24.173 +			/>
  24.174 +			<Tool
  24.175 +				Name="VCWebDeploymentTool"
  24.176 +			/>
  24.177 +			<Tool
  24.178 +				Name="VCPostBuildEventTool"
  24.179 +			/>
  24.180 +		</Configuration>
  24.181 +		<Configuration
  24.182 +			Name="Debug - Episode1|Win32"
  24.183 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
  24.184 +			IntermediateDirectory="$(ConfigurationName)"
  24.185 +			ConfigurationType="2"
  24.186 +			CharacterSet="2"
  24.187 +			>
  24.188 +			<Tool
  24.189 +				Name="VCPreBuildEventTool"
  24.190 +			/>
  24.191 +			<Tool
  24.192 +				Name="VCCustomBuildTool"
  24.193 +			/>
  24.194 +			<Tool
  24.195 +				Name="VCXMLDataGeneratorTool"
  24.196 +			/>
  24.197 +			<Tool
  24.198 +				Name="VCWebServiceProxyGeneratorTool"
  24.199 +			/>
  24.200 +			<Tool
  24.201 +				Name="VCMIDLTool"
  24.202 +			/>
  24.203 +			<Tool
  24.204 +				Name="VCCLCompilerTool"
  24.205 +				Optimization="0"
  24.206 +				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"
  24.207 +				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
  24.208 +				MinimalRebuild="true"
  24.209 +				BasicRuntimeChecks="3"
  24.210 +				RuntimeLibrary="1"
  24.211 +				EnableEnhancedInstructionSet="1"
  24.212 +				RuntimeTypeInfo="false"
  24.213 +				UsePrecompiledHeader="0"
  24.214 +				WarningLevel="3"
  24.215 +				Detect64BitPortabilityProblems="false"
  24.216 +				DebugInformationFormat="4"
  24.217 +			/>
  24.218 +			<Tool
  24.219 +				Name="VCManagedResourceCompilerTool"
  24.220 +			/>
  24.221 +			<Tool
  24.222 +				Name="VCResourceCompilerTool"
  24.223 +			/>
  24.224 +			<Tool
  24.225 +				Name="VCPreLinkEventTool"
  24.226 +			/>
  24.227 +			<Tool
  24.228 +				Name="VCLinkerTool"
  24.229 +				AdditionalDependencies="$(HL2SDK)\lib\public\tier0.lib $(HL2SDK)\lib\public\tier1.lib $(HL2SDK)\lib\public\vstdlib.lib $(HL2SDK)\lib\public\mathlib.lib"
  24.230 +				OutputFile="$(OutDir)\game.tf2.ext.dll"
  24.231 +				LinkIncremental="2"
  24.232 +				GenerateDebugInformation="true"
  24.233 +				SubSystem="2"
  24.234 +				TargetMachine="1"
  24.235 +			/>
  24.236 +			<Tool
  24.237 +				Name="VCALinkTool"
  24.238 +			/>
  24.239 +			<Tool
  24.240 +				Name="VCManifestTool"
  24.241 +			/>
  24.242 +			<Tool
  24.243 +				Name="VCXDCMakeTool"
  24.244 +			/>
  24.245 +			<Tool
  24.246 +				Name="VCBscMakeTool"
  24.247 +			/>
  24.248 +			<Tool
  24.249 +				Name="VCFxCopTool"
  24.250 +			/>
  24.251 +			<Tool
  24.252 +				Name="VCAppVerifierTool"
  24.253 +			/>
  24.254 +			<Tool
  24.255 +				Name="VCWebDeploymentTool"
  24.256 +			/>
  24.257 +			<Tool
  24.258 +				Name="VCPostBuildEventTool"
  24.259 +			/>
  24.260 +		</Configuration>
  24.261 +		<Configuration
  24.262 +			Name="Debug - Orange Box|Win32"
  24.263 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
  24.264 +			IntermediateDirectory="$(ConfigurationName)"
  24.265 +			ConfigurationType="2"
  24.266 +			CharacterSet="2"
  24.267 +			>
  24.268 +			<Tool
  24.269 +				Name="VCPreBuildEventTool"
  24.270 +			/>
  24.271 +			<Tool
  24.272 +				Name="VCCustomBuildTool"
  24.273 +			/>
  24.274 +			<Tool
  24.275 +				Name="VCXMLDataGeneratorTool"
  24.276 +			/>
  24.277 +			<Tool
  24.278 +				Name="VCWebServiceProxyGeneratorTool"
  24.279 +			/>
  24.280 +			<Tool
  24.281 +				Name="VCMIDLTool"
  24.282 +			/>
  24.283 +			<Tool
  24.284 +				Name="VCCLCompilerTool"
  24.285 +				Optimization="0"
  24.286 +				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"
  24.287 +				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
  24.288 +				MinimalRebuild="true"
  24.289 +				BasicRuntimeChecks="3"
  24.290 +				RuntimeLibrary="1"
  24.291 +				EnableEnhancedInstructionSet="1"
  24.292 +				RuntimeTypeInfo="false"
  24.293 +				UsePrecompiledHeader="0"
  24.294 +				WarningLevel="3"
  24.295 +				Detect64BitPortabilityProblems="false"
  24.296 +				DebugInformationFormat="4"
  24.297 +			/>
  24.298 +			<Tool
  24.299 +				Name="VCManagedResourceCompilerTool"
  24.300 +			/>
  24.301 +			<Tool
  24.302 +				Name="VCResourceCompilerTool"
  24.303 +			/>
  24.304 +			<Tool
  24.305 +				Name="VCPreLinkEventTool"
  24.306 +			/>
  24.307 +			<Tool
  24.308 +				Name="VCLinkerTool"
  24.309 +				AdditionalDependencies="$(HL2SDKOB)\lib\public\tier0.lib $(HL2SDKOB)\lib\public\tier1.lib $(HL2SDKOB)\lib\public\vstdlib.lib $(HL2SDKOB)\lib\public\mathlib.lib"
  24.310 +				OutputFile="$(OutDir)\game.tf2.ext.dll"
  24.311 +				LinkIncremental="2"
  24.312 +				GenerateDebugInformation="true"
  24.313 +				SubSystem="2"
  24.314 +				TargetMachine="1"
  24.315 +			/>
  24.316 +			<Tool
  24.317 +				Name="VCALinkTool"
  24.318 +			/>
  24.319 +			<Tool
  24.320 +				Name="VCManifestTool"
  24.321 +			/>
  24.322 +			<Tool
  24.323 +				Name="VCXDCMakeTool"
  24.324 +			/>
  24.325 +			<Tool
  24.326 +				Name="VCBscMakeTool"
  24.327 +			/>
  24.328 +			<Tool
  24.329 +				Name="VCFxCopTool"
  24.330 +			/>
  24.331 +			<Tool
  24.332 +				Name="VCAppVerifierTool"
  24.333 +			/>
  24.334 +			<Tool
  24.335 +				Name="VCWebDeploymentTool"
  24.336 +			/>
  24.337 +			<Tool
  24.338 +				Name="VCPostBuildEventTool"
  24.339 +			/>
  24.340 +		</Configuration>
  24.341 +		<Configuration
  24.342 +			Name="Debug - Old Metamod|Win32"
  24.343 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
  24.344 +			IntermediateDirectory="$(ConfigurationName)"
  24.345 +			ConfigurationType="2"
  24.346 +			CharacterSet="2"
  24.347 +			>
  24.348 +			<Tool
  24.349 +				Name="VCPreBuildEventTool"
  24.350 +			/>
  24.351 +			<Tool
  24.352 +				Name="VCCustomBuildTool"
  24.353 +			/>
  24.354 +			<Tool
  24.355 +				Name="VCXMLDataGeneratorTool"
  24.356 +			/>
  24.357 +			<Tool
  24.358 +				Name="VCWebServiceProxyGeneratorTool"
  24.359 +			/>
  24.360 +			<Tool
  24.361 +				Name="VCMIDLTool"
  24.362 +			/>
  24.363 +			<Tool
  24.364 +				Name="VCCLCompilerTool"
  24.365 +				Optimization="0"
  24.366 +				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"
  24.367 +				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
  24.368 +				MinimalRebuild="true"
  24.369 +				BasicRuntimeChecks="3"
  24.370 +				RuntimeLibrary="1"
  24.371 +				EnableEnhancedInstructionSet="1"
  24.372 +				RuntimeTypeInfo="false"
  24.373 +				UsePrecompiledHeader="0"
  24.374 +				WarningLevel="3"
  24.375 +				Detect64BitPortabilityProblems="false"
  24.376 +				DebugInformationFormat="4"
  24.377 +			/>
  24.378 +			<Tool
  24.379 +				Name="VCManagedResourceCompilerTool"
  24.380 +			/>
  24.381 +			<Tool
  24.382 +				Name="VCResourceCompilerTool"
  24.383 +			/>
  24.384 +			<Tool
  24.385 +				Name="VCPreLinkEventTool"
  24.386 +			/>
  24.387 +			<Tool
  24.388 +				Name="VCLinkerTool"
  24.389 +				AdditionalDependencies="$(HL2SDK)\lib\public\tier0.lib $(HL2SDK)\lib\public\tier1.lib $(HL2SDK)\lib\public\vstdlib.lib $(HL2SDK)\lib\public\mathlib.lib"
  24.390 +				OutputFile="$(OutDir)\game.tf2.ext.dll"
  24.391 +				LinkIncremental="2"
  24.392 +				GenerateDebugInformation="true"
  24.393 +				SubSystem="2"
  24.394 +				TargetMachine="1"
  24.395 +			/>
  24.396 +			<Tool
  24.397 +				Name="VCALinkTool"
  24.398 +			/>
  24.399 +			<Tool
  24.400 +				Name="VCManifestTool"
  24.401 +			/>
  24.402 +			<Tool
  24.403 +				Name="VCXDCMakeTool"
  24.404 +			/>
  24.405 +			<Tool
  24.406 +				Name="VCBscMakeTool"
  24.407 +			/>
  24.408 +			<Tool
  24.409 +				Name="VCFxCopTool"
  24.410 +			/>
  24.411 +			<Tool
  24.412 +				Name="VCAppVerifierTool"
  24.413 +			/>
  24.414 +			<Tool
  24.415 +				Name="VCWebDeploymentTool"
  24.416 +			/>
  24.417 +			<Tool
  24.418 +				Name="VCPostBuildEventTool"
  24.419 +			/>
  24.420 +		</Configuration>
  24.421 +		<Configuration
  24.422 +			Name="Release - Old Metamod|Win32"
  24.423 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
  24.424 +			IntermediateDirectory="$(ConfigurationName)"
  24.425 +			ConfigurationType="2"
  24.426 +			CharacterSet="2"
  24.427 +			WholeProgramOptimization="1"
  24.428 +			>
  24.429 +			<Tool
  24.430 +				Name="VCPreBuildEventTool"
  24.431 +			/>
  24.432 +			<Tool
  24.433 +				Name="VCCustomBuildTool"
  24.434 +			/>
  24.435 +			<Tool
  24.436 +				Name="VCXMLDataGeneratorTool"
  24.437 +			/>
  24.438 +			<Tool
  24.439 +				Name="VCWebServiceProxyGeneratorTool"
  24.440 +			/>
  24.441 +			<Tool
  24.442 +				Name="VCMIDLTool"
  24.443 +			/>
  24.444 +			<Tool
  24.445 +				Name="VCCLCompilerTool"
  24.446 +				FavorSizeOrSpeed="1"
  24.447 +				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"
  24.448 +				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
  24.449 +				RuntimeLibrary="0"
  24.450 +				EnableEnhancedInstructionSet="1"
  24.451 +				RuntimeTypeInfo="false"
  24.452 +				UsePrecompiledHeader="0"
  24.453 +				WarningLevel="3"
  24.454 +				Detect64BitPortabilityProblems="false"
  24.455 +				DebugInformationFormat="3"
  24.456 +			/>
  24.457 +			<Tool
  24.458 +				Name="VCManagedResourceCompilerTool"
  24.459 +			/>
  24.460 +			<Tool
  24.461 +				Name="VCResourceCompilerTool"
  24.462 +			/>
  24.463 +			<Tool
  24.464 +				Name="VCPreLinkEventTool"
  24.465 +			/>
  24.466 +			<Tool
  24.467 +				Name="VCLinkerTool"
  24.468 +				AdditionalDependencies="$(HL2SDK)\lib\public\tier0.lib $(HL2SDK)\lib\public\tier1.lib $(HL2SDK)\lib\public\vstdlib.lib $(HL2SDK)\lib\public\mathlib.lib"
  24.469 +				OutputFile="$(OutDir)\game.tf2.ext.dll"
  24.470 +				LinkIncremental="1"
  24.471 +				GenerateDebugInformation="true"
  24.472 +				SubSystem="2"
  24.473 +				OptimizeReferences="2"
  24.474 +				EnableCOMDATFolding="2"
  24.475 +				TargetMachine="1"
  24.476 +			/>
  24.477 +			<Tool
  24.478 +				Name="VCALinkTool"
  24.479 +			/>
  24.480 +			<Tool
  24.481 +				Name="VCManifestTool"
  24.482 +			/>
  24.483 +			<Tool
  24.484 +				Name="VCXDCMakeTool"
  24.485 +			/>
  24.486 +			<Tool
  24.487 +				Name="VCBscMakeTool"
  24.488 +			/>
  24.489 +			<Tool
  24.490 +				Name="VCFxCopTool"
  24.491 +			/>
  24.492 +			<Tool
  24.493 +				Name="VCAppVerifierTool"
  24.494 +			/>
  24.495 +			<Tool
  24.496 +				Name="VCWebDeploymentTool"
  24.497 +			/>
  24.498 +			<Tool
  24.499 +				Name="VCPostBuildEventTool"
  24.500 +			/>
  24.501 +		</Configuration>
  24.502 +		<Configuration
  24.503 +			Name="Release - Orange Box|Win32"
  24.504 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
  24.505 +			IntermediateDirectory="$(ConfigurationName)"
  24.506 +			ConfigurationType="2"
  24.507 +			CharacterSet="2"
  24.508 +			WholeProgramOptimization="1"
  24.509 +			>
  24.510 +			<Tool
  24.511 +				Name="VCPreBuildEventTool"
  24.512 +			/>
  24.513 +			<Tool
  24.514 +				Name="VCCustomBuildTool"
  24.515 +			/>
  24.516 +			<Tool
  24.517 +				Name="VCXMLDataGeneratorTool"
  24.518 +			/>
  24.519 +			<Tool
  24.520 +				Name="VCWebServiceProxyGeneratorTool"
  24.521 +			/>
  24.522 +			<Tool
  24.523 +				Name="VCMIDLTool"
  24.524 +			/>
  24.525 +			<Tool
  24.526 +				Name="VCCLCompilerTool"
  24.527 +				FavorSizeOrSpeed="1"
  24.528 +				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"
  24.529 +				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
  24.530 +				RuntimeLibrary="0"
  24.531 +				EnableEnhancedInstructionSet="1"
  24.532 +				RuntimeTypeInfo="false"
  24.533 +				UsePrecompiledHeader="0"
  24.534 +				WarningLevel="3"
  24.535 +				Detect64BitPortabilityProblems="false"
  24.536 +				DebugInformationFormat="3"
  24.537 +			/>
  24.538 +			<Tool
  24.539 +				Name="VCManagedResourceCompilerTool"
  24.540 +			/>
  24.541 +			<Tool
  24.542 +				Name="VCResourceCompilerTool"
  24.543 +			/>
  24.544 +			<Tool
  24.545 +				Name="VCPreLinkEventTool"
  24.546 +			/>
  24.547 +			<Tool
  24.548 +				Name="VCLinkerTool"
  24.549 +				AdditionalDependencies="$(HL2SDKOB)\lib\public\tier0.lib $(HL2SDKOB)\lib\public\tier1.lib $(HL2SDKOB)\lib\public\vstdlib.lib $(HL2SDKOB)\lib\public\mathlib.lib"
  24.550 +				OutputFile="$(OutDir)\game.tf2.ext.dll"
  24.551 +				LinkIncremental="1"
  24.552 +				GenerateDebugInformation="true"
  24.553 +				SubSystem="2"
  24.554 +				OptimizeReferences="2"
  24.555 +				EnableCOMDATFolding="2"
  24.556 +				TargetMachine="1"
  24.557 +			/>
  24.558 +			<Tool
  24.559 +				Name="VCALinkTool"
  24.560 +			/>
  24.561 +			<Tool
  24.562 +				Name="VCManifestTool"
  24.563 +			/>
  24.564 +			<Tool
  24.565 +				Name="VCXDCMakeTool"
  24.566 +			/>
  24.567 +			<Tool
  24.568 +				Name="VCBscMakeTool"
  24.569 +			/>
  24.570 +			<Tool
  24.571 +				Name="VCFxCopTool"
  24.572 +			/>
  24.573 +			<Tool
  24.574 +				Name="VCAppVerifierTool"
  24.575 +			/>
  24.576 +			<Tool
  24.577 +				Name="VCWebDeploymentTool"
  24.578 +			/>
  24.579 +			<Tool
  24.580 +				Name="VCPostBuildEventTool"
  24.581 +			/>
  24.582 +		</Configuration>
  24.583 +		<Configuration
  24.584 +			Name="Release - Episode 1|Win32"
  24.585 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
  24.586 +			IntermediateDirectory="$(ConfigurationName)"
  24.587 +			ConfigurationType="2"
  24.588 +			CharacterSet="2"
  24.589 +			WholeProgramOptimization="1"
  24.590 +			>
  24.591 +			<Tool
  24.592 +				Name="VCPreBuildEventTool"
  24.593 +			/>
  24.594 +			<Tool
  24.595 +				Name="VCCustomBuildTool"
  24.596 +			/>
  24.597 +			<Tool
  24.598 +				Name="VCXMLDataGeneratorTool"
  24.599 +			/>
  24.600 +			<Tool
  24.601 +				Name="VCWebServiceProxyGeneratorTool"
  24.602 +			/>
  24.603 +			<Tool
  24.604 +				Name="VCMIDLTool"
  24.605 +			/>
  24.606 +			<Tool
  24.607 +				Name="VCCLCompilerTool"
  24.608 +				FavorSizeOrSpeed="1"
  24.609 +				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"
  24.610 +				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CSTRIKE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD"
  24.611 +				RuntimeLibrary="0"
  24.612 +				EnableEnhancedInstructionSet="1"
  24.613 +				RuntimeTypeInfo="false"
  24.614 +				UsePrecompiledHeader="0"
  24.615 +				WarningLevel="3"
  24.616 +				Detect64BitPortabilityProblems="false"
  24.617 +				DebugInformationFormat="3"
  24.618 +			/>
  24.619 +			<Tool
  24.620 +				Name="VCManagedResourceCompilerTool"
  24.621 +			/>
  24.622 +			<Tool
  24.623 +				Name="VCResourceCompilerTool"
  24.624 +			/>
  24.625 +			<Tool
  24.626 +				Name="VCPreLinkEventTool"
  24.627 +			/>
  24.628 +			<Tool
  24.629 +				Name="VCLinkerTool"
  24.630 +				AdditionalDependencies="$(HL2SDK)\lib\public\tier0.lib $(HL2SDK)\lib\public\tier1.lib $(HL2SDK)\lib\public\vstdlib.lib $(HL2SDK)\lib\public\mathlib.lib"
  24.631 +				OutputFile="$(OutDir)\game.tf2.ext.dll"
  24.632 +				LinkIncremental="1"
  24.633 +				GenerateDebugInformation="true"
  24.634 +				SubSystem="2"
  24.635 +				OptimizeReferences="2"
  24.636 +				EnableCOMDATFolding="2"
  24.637 +				TargetMachine="1"
  24.638 +			/>
  24.639 +			<Tool
  24.640 +				Name="VCALinkTool"
  24.641 +			/>
  24.642 +			<Tool
  24.643 +				Name="VCManifestTool"
  24.644 +			/>
  24.645 +			<Tool
  24.646 +				Name="VCXDCMakeTool"
  24.647 +			/>
  24.648 +			<Tool
  24.649 +				Name="VCBscMakeTool"
  24.650 +			/>
  24.651 +			<Tool
  24.652 +				Name="VCFxCopTool"
  24.653 +			/>
  24.654 +			<Tool
  24.655 +				Name="VCAppVerifierTool"
  24.656 +			/>
  24.657 +			<Tool
  24.658 +				Name="VCWebDeploymentTool"
  24.659 +			/>
  24.660 +			<Tool
  24.661 +				Name="VCPostBuildEventTool"
  24.662 +			/>
  24.663 +		</Configuration>
  24.664 +	</Configurations>
  24.665 +	<References>
  24.666 +	</References>
  24.667 +	<Files>
  24.668 +		<Filter
  24.669 +			Name="Source Files"
  24.670 +			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
  24.671 +			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
  24.672 +			>
  24.673 +			<File
  24.674 +				RelativePath="..\extension.cpp"
  24.675 +				>
  24.676 +			</File>
  24.677 +			<File
  24.678 +				RelativePath="..\natives.cpp"
  24.679 +				>
  24.680 +			</File>
  24.681 +			<File
  24.682 +				RelativePath="..\RegNatives.cpp"
  24.683 +				>
  24.684 +			</File>
  24.685 +		</Filter>
  24.686 +		<Filter
  24.687 +			Name="Header Files"
  24.688 +			Filter="h;hpp;hxx;hm;inl;inc;xsd"
  24.689 +			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
  24.690 +			>
  24.691 +			<File
  24.692 +				RelativePath="..\extension.h"
  24.693 +				>
  24.694 +			</File>
  24.695 +			<File
  24.696 +				RelativePath="..\RegNatives.h"
  24.697 +				>
  24.698 +			</File>
  24.699 +		</Filter>
  24.700 +		<Filter
  24.701 +			Name="Resource Files"
  24.702 +			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
  24.703 +			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
  24.704 +			>
  24.705 +			<File
  24.706 +				RelativePath="..\version.rc"
  24.707 +				>
  24.708 +			</File>
  24.709 +		</Filter>
  24.710 +		<Filter
  24.711 +			Name="SourceMod SDK"
  24.712 +			UniqueIdentifier="{31958233-BB2D-4e41-A8F9-CE8A4684F436}"
  24.713 +			>
  24.714 +			<File
  24.715 +				RelativePath="..\sdk\smsdk_config.h"
  24.716 +				>
  24.717 +			</File>
  24.718 +			<File
  24.719 +				RelativePath="..\sdk\smsdk_ext.cpp"
  24.720 +				>
  24.721 +			</File>
  24.722 +			<File
  24.723 +				RelativePath="..\sdk\smsdk_ext.h"
  24.724 +				>
  24.725 +			</File>
  24.726 +		</Filter>
  24.727 +	</Files>
  24.728 +	<Globals>
  24.729 +	</Globals>
  24.730 +</VisualStudioProject>
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/extensions/tf2/natives.cpp	Wed Mar 26 03:52:37 2008 +0000
    25.3 @@ -0,0 +1,159 @@
    25.4 +/**
    25.5 + * vim: set ts=4 :
    25.6 + * =============================================================================
    25.7 + * SourceMod Counter-Strike:Source Extension
    25.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    25.9 + * =============================================================================
   25.10 + *
   25.11 + * This program is free software; you can redistribute it and/or modify it under
   25.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   25.13 + * Free Software Foundation.
   25.14 + * 
   25.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   25.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   25.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   25.18 + * details.
   25.19 + *
   25.20 + * You should have received a copy of the GNU General Public License along with
   25.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   25.22 + *
   25.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   25.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   25.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   25.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   25.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   25.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   25.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   25.30 + * or <http://www.sourcemod.net/license.php>.
   25.31 + *
   25.32 + * Version: $Id$
   25.33 + */
   25.34 +
   25.35 +#include "extension.h"
   25.36 +#include "RegNatives.h"
   25.37 +
   25.38 +#define REGISTER_NATIVE_ADDR(name, code) \
   25.39 +	void *addr; \
   25.40 +	if (!g_pGameConf->GetMemSig(name, &addr)) \
   25.41 +	{ \
   25.42 +		return pContext->ThrowNativeError("Failed to locate function"); \
   25.43 +	} \
   25.44 +	code; \
   25.45 +	g_RegNatives.Register(pWrapper);
   25.46 +
   25.47 +inline CBaseEntity *GetCBaseEntity(int num, bool onlyPlayers)
   25.48 +{
   25.49 +	edict_t *pEdict = engine->PEntityOfEntIndex(num);
   25.50 +	if (!pEdict || pEdict->IsFree())
   25.51 +	{
   25.52 +		return NULL;
   25.53 +	}
   25.54 +
   25.55 +	if (num > 0 && num < playerhelpers->GetMaxClients())
   25.56 +	{
   25.57 +		IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(pEdict);
   25.58 +		if (!pPlayer || !pPlayer->IsConnected())
   25.59 +		{
   25.60 +			return NULL;
   25.61 +		}
   25.62 +	}
   25.63 +	else if (onlyPlayers)
   25.64 +	{
   25.65 +		return NULL;
   25.66 +	}
   25.67 +
   25.68 +	IServerUnknown *pUnk;
   25.69 +	if ((pUnk=pEdict->GetUnknown()) == NULL)
   25.70 +	{
   25.71 +		return NULL;
   25.72 +	}
   25.73 +
   25.74 +	return pUnk->GetBaseEntity();
   25.75 +}
   25.76 +
   25.77 +
   25.78 +// native TF2_Burn(client)
   25.79 +cell_t TF2_Burn(IPluginContext *pContext, const cell_t *params)
   25.80 +{
   25.81 +	static ICallWrapper *pWrapper = NULL;
   25.82 +
   25.83 +	// CTFPlayerShared::Burn(CTFPlayer*)
   25.84 +	if (!pWrapper)
   25.85 +	{
   25.86 +		REGISTER_NATIVE_ADDR("Burn", 
   25.87 +			PassInfo pass[1]; \
   25.88 +			pass[0].flags = PASSFLAG_BYVAL; \
   25.89 +			pass[0].size = sizeof(CBaseEntity *); \
   25.90 +			pass[0].type = PassType_Basic; \
   25.91 +			pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 1))
   25.92 +	}
   25.93 +
   25.94 +	CBaseEntity *pEntity;
   25.95 +	if (!(pEntity=GetCBaseEntity(params[1], true)))
   25.96 +	{
   25.97 +		return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
   25.98 +	}
   25.99 +
  25.100 +	void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->GetOffset());
  25.101 +
  25.102 +	unsigned char vstk[sizeof(void *) + sizeof(CBaseEntity *)];
  25.103 +	unsigned char *vptr = vstk;
  25.104 +
  25.105 +	*(void **)vptr = obj;
  25.106 +	vptr += sizeof(void *);
  25.107 +	*(CBaseEntity **)vptr = pEntity;
  25.108 +
  25.109 +	pWrapper->Execute(vstk, NULL);
  25.110 +
  25.111 +	return 1;
  25.112 +}
  25.113 +
  25.114 +// native TF2_Invuln(client, bool:something, bool:anothersomething)
  25.115 +cell_t TF2_Invuln(IPluginContext *pContext, const cell_t *params)
  25.116 +{
  25.117 +	static ICallWrapper *pWrapper = NULL;
  25.118 +
  25.119 +	//CTFPlayerShared::SetInvulnerable(bool, bool)
  25.120 +	if (!pWrapper)
  25.121 +	{
  25.122 +		REGISTER_NATIVE_ADDR("Invuln", 
  25.123 +			PassInfo pass[2]; \
  25.124 +			pass[0].flags = PASSFLAG_BYVAL; \
  25.125 +			pass[0].size = sizeof(bool); \
  25.126 +			pass[0].type = PassType_Basic; \
  25.127 +			pass[1].flags = PASSFLAG_BYVAL; \
  25.128 +			pass[1].size = sizeof(bool); \
  25.129 +			pass[1].type = PassType_Basic; \
  25.130 +			pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 2))
  25.131 +	}
  25.132 +
  25.133 +	CBaseEntity *pEntity;
  25.134 +	if (!(pEntity=GetCBaseEntity(params[1], true)))
  25.135 +	{
  25.136 +		return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
  25.137 +	}
  25.138 +
  25.139 +	void *obj = (void *)((uint8_t *)pEntity + playerSharedOffset->GetOffset());
  25.140 +
  25.141 +	unsigned char vstk[sizeof(void *) + 2*sizeof(bool)];
  25.142 +	unsigned char *vptr = vstk;
  25.143 +
  25.144 +
  25.145 +	*(void **)vptr = obj;
  25.146 +	vptr += sizeof(bool);
  25.147 +	*(bool *)vptr = !!params[2];
  25.148 +	vptr += sizeof(bool);
  25.149 +	*(bool *)vptr = !!params[3];
  25.150 +
  25.151 +	pWrapper->Execute(vstk, NULL);
  25.152 +
  25.153 +	return 1;
  25.154 +}
  25.155 +
  25.156 +
  25.157 +sp_nativeinfo_t g_TFNatives[] = 
  25.158 +{
  25.159 +	{"TF2_Burn",						TF2_Burn},
  25.160 +	{"TF2_Invuln",					TF2_Invuln},
  25.161 +	{NULL,							NULL}
  25.162 +};
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/extensions/tf2/sdk/smsdk_config.h	Wed Mar 26 03:52:37 2008 +0000
    26.3 @@ -0,0 +1,76 @@
    26.4 +/**
    26.5 + * vim: set ts=4 :
    26.6 + * =============================================================================
    26.7 + * SourceMod Counter-Strike:Source Extension
    26.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    26.9 + * =============================================================================
   26.10 + *
   26.11 + * This program is free software; you can redistribute it and/or modify it under
   26.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   26.13 + * Free Software Foundation.
   26.14 + * 
   26.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   26.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   26.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   26.18 + * details.
   26.19 + *
   26.20 + * You should have received a copy of the GNU General Public License along with
   26.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   26.22 + *
   26.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   26.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   26.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   26.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   26.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   26.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   26.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   26.30 + * or <http://www.sourcemod.net/license.php>.
   26.31 + *
   26.32 + * Version: $Id$
   26.33 + */
   26.34 +
   26.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
   26.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
   26.37 +
   26.38 +/**
   26.39 + * @file smsdk_config.h
   26.40 + * @brief Contains macros for configuring basic extension information.
   26.41 + */
   26.42 +
   26.43 +#include "svn_version.h"
   26.44 +
   26.45 +/* Basic information exposed publicly */
   26.46 +#define SMEXT_CONF_NAME			"TF2 Tools"
   26.47 +#define SMEXT_CONF_DESCRIPTION	"TF2 extended functionality"
   26.48 +#define SMEXT_CONF_VERSION		SVN_FULL_VERSION
   26.49 +#define SMEXT_CONF_AUTHOR		"AlliedModders LLC"
   26.50 +#define SMEXT_CONF_URL			"http://www.sourcemod.net/"
   26.51 +#define SMEXT_CONF_LOGTAG		"TF2"
   26.52 +#define SMEXT_CONF_LICENSE		"GPL"
   26.53 +#define SMEXT_CONF_DATESTRING	__DATE__
   26.54 +
   26.55 +/** 
   26.56 + * @brief Exposes plugin's main interface.
   26.57 + */
   26.58 +#define SMEXT_LINK(name) SDKExtension *g_pExtensionIface = name;
   26.59 +
   26.60 +/**
   26.61 + * @brief Sets whether or not this plugin required Metamod.
   26.62 + * NOTE: Uncomment to enable, comment to disable.
   26.63 + */
   26.64 +#define SMEXT_CONF_METAMOD
   26.65 +
   26.66 +/** Enable interfaces you want to use here by uncommenting lines */
   26.67 +//#define SMEXT_ENABLE_FORWARDSYS
   26.68 +//#define SMEXT_ENABLE_HANDLESYS
   26.69 +#define SMEXT_ENABLE_PLAYERHELPERS
   26.70 +//#define SMEXT_ENABLE_DBMANAGER
   26.71 +#define SMEXT_ENABLE_GAMECONF
   26.72 +//#define SMEXT_ENABLE_MEMUTILS
   26.73 +#define SMEXT_ENABLE_GAMEHELPERS
   26.74 +//#define SMEXT_ENABLE_TIMERSYS
   26.75 +//#define SMEXT_ENABLE_THREADER
   26.76 +//#define SMEXT_ENABLE_LIBSYS
   26.77 +//#define SMEXT_ENABLE_USERMSGS
   26.78 +
   26.79 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_CONFIG_H_
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/extensions/tf2/sdk/smsdk_ext.cpp	Wed Mar 26 03:52:37 2008 +0000
    27.3 @@ -0,0 +1,422 @@
    27.4 +/**
    27.5 + * vim: set ts=4 :
    27.6 + * =============================================================================
    27.7 + * SourceMod Base Extension Code
    27.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    27.9 + * =============================================================================
   27.10 + *
   27.11 + * This program is free software; you can redistribute it and/or modify it under
   27.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   27.13 + * Free Software Foundation.
   27.14 + * 
   27.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   27.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   27.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   27.18 + * details.
   27.19 + *
   27.20 + * You should have received a copy of the GNU General Public License along with
   27.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   27.22 + *
   27.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   27.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   27.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   27.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   27.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   27.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   27.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   27.30 + * or <http://www.sourcemod.net/license.php>.
   27.31 + *
   27.32 + * Version: $Id$
   27.33 + */
   27.34 +
   27.35 +#include <stdio.h>
   27.36 +#include <malloc.h>
   27.37 +#include "smsdk_ext.h"
   27.38 +
   27.39 +/**
   27.40 + * @file smsdk_ext.cpp
   27.41 + * @brief Contains wrappers for making Extensions easier to write.
   27.42 + */
   27.43 +
   27.44 +IExtension *myself = NULL;				/**< Ourself */
   27.45 +IShareSys *g_pShareSys = NULL;			/**< Share system */
   27.46 +IShareSys *sharesys = NULL;				/**< Share system */
   27.47 +ISourceMod *g_pSM = NULL;				/**< SourceMod helpers */
   27.48 +ISourceMod *smutils = NULL;				/**< SourceMod helpers */
   27.49 +
   27.50 +#if defined SMEXT_ENABLE_FORWARDSYS
   27.51 +IForwardManager *g_pForwards = NULL;	/**< Forward system */
   27.52 +IForwardManager *forwards = NULL;		/**< Forward system */
   27.53 +#endif
   27.54 +#if defined SMEXT_ENABLE_HANDLESYS
   27.55 +IHandleSys *g_pHandleSys = NULL;		/**< Handle system */
   27.56 +IHandleSys *handlesys = NULL;			/**< Handle system */
   27.57 +#endif
   27.58 +#if defined SMEXT_ENABLE_PLAYERHELPERS
   27.59 +IPlayerManager *playerhelpers = NULL;	/**< Player helpers */
   27.60 +#endif //SMEXT_ENABLE_PLAYERHELPERS
   27.61 +#if defined SMEXT_ENABLE_DBMANAGER
   27.62 +IDBManager *dbi = NULL;					/**< DB Manager */
   27.63 +#endif //SMEXT_ENABLE_DBMANAGER
   27.64 +#if defined SMEXT_ENABLE_GAMECONF
   27.65 +IGameConfigManager *gameconfs = NULL;	/**< Game config manager */
   27.66 +#endif //SMEXT_ENABLE_DBMANAGER
   27.67 +#if defined SMEXT_ENABLE_MEMUTILS
   27.68 +IMemoryUtils *memutils = NULL;
   27.69 +#endif //SMEXT_ENABLE_DBMANAGER
   27.70 +#if defined SMEXT_ENABLE_GAMEHELPERS
   27.71 +IGameHelpers *gamehelpers = NULL;
   27.72 +#endif
   27.73 +#if defined SMEXT_ENABLE_TIMERSYS
   27.74 +ITimerSystem *timersys = NULL;
   27.75 +#endif
   27.76 +#if defined SMEXT_ENABLE_ADTFACTORY
   27.77 +IADTFactory *adtfactory = NULL;
   27.78 +#endif
   27.79 +#if defined SMEXT_ENABLE_THREADER
   27.80 +IThreader *threader = NULL;
   27.81 +#endif
   27.82 +#if defined SMEXT_ENABLE_LIBSYS
   27.83 +ILibrarySys *libsys = NULL;
   27.84 +#endif
   27.85 +#if defined SMEXT_ENABLE_USERMSGS
   27.86 +IUserMessages *usermsgs = NULL;
   27.87 +#endif
   27.88 +
   27.89 +/** Exports the main interface */
   27.90 +PLATFORM_EXTERN_C IExtensionInterface *GetSMExtAPI()
   27.91 +{
   27.92 +	return g_pExtensionIface;
   27.93 +}
   27.94 +
   27.95 +SDKExtension::SDKExtension()
   27.96 +{
   27.97 +#if defined SMEXT_CONF_METAMOD
   27.98 +	m_SourceMMLoaded = false;
   27.99 +	m_WeAreUnloaded = false;
  27.100 +	m_WeGotPauseChange = false;
  27.101 +#endif
  27.102 +}
  27.103 +
  27.104 +bool SDKExtension::OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late)
  27.105 +{
  27.106 +	g_pShareSys = sharesys = sys;
  27.107 +	myself = me;
  27.108 +
  27.109 +#if defined SMEXT_CONF_METAMOD
  27.110 +	m_WeAreUnloaded = true;
  27.111 +
  27.112 +	if (!m_SourceMMLoaded)
  27.113 +	{
  27.114 +		if (error)
  27.115 +		{
  27.116 +			snprintf(error, maxlength, "Metamod attach failed");
  27.117 +		}
  27.118 +		return false;
  27.119 +	}
  27.120 +#endif
  27.121 +	SM_GET_IFACE(SOURCEMOD, g_pSM);
  27.122 +	smutils = g_pSM;
  27.123 +#if defined SMEXT_ENABLE_HANDLESYS
  27.124 +	SM_GET_IFACE(HANDLESYSTEM, g_pHandleSys);
  27.125 +	handlesys = g_pHandleSys;
  27.126 +#endif
  27.127 +#if defined SMEXT_ENABLE_FORWARDSYS
  27.128 +	SM_GET_IFACE(FORWARDMANAGER, g_pForwards);
  27.129 +	forwards = g_pForwards;
  27.130 +#endif
  27.131 +#if defined SMEXT_ENABLE_PLAYERHELPERS
  27.132 +	SM_GET_IFACE(PLAYERMANAGER, playerhelpers);
  27.133 +#endif
  27.134 +#if defined SMEXT_ENABLE_DBMANAGER
  27.135 +	SM_GET_IFACE(DBI, dbi);
  27.136 +#endif
  27.137 +#if defined SMEXT_ENABLE_GAMECONF
  27.138 +	SM_GET_IFACE(GAMECONFIG, gameconfs);
  27.139 +#endif
  27.140 +#if defined SMEXT_ENABLE_MEMUTILS
  27.141 +	SM_GET_IFACE(MEMORYUTILS, memutils);
  27.142 +#endif
  27.143 +#if defined SMEXT_ENABLE_GAMEHELPERS
  27.144 +	SM_GET_IFACE(GAMEHELPERS, gamehelpers);
  27.145 +#endif
  27.146 +#if defined SMEXT_ENABLE_TIMERSYS
  27.147 +	SM_GET_IFACE(TIMERSYS, timersys);
  27.148 +#endif
  27.149 +#if defined SMEXT_ENABLE_ADTFACTORY
  27.150 +	SM_GET_IFACE(ADTFACTORY, adtfactory);
  27.151 +#endif
  27.152 +#if defined SMEXT_ENABLE_THREADER
  27.153 +	SM_GET_IFACE(THREADER, threader);
  27.154 +#endif
  27.155 +#if defined SMEXT_ENABLE_LIBSYS
  27.156 +	SM_GET_IFACE(LIBRARYSYS, libsys);
  27.157 +#endif
  27.158 +#if defined SMEXT_ENABLE_USERMSGS
  27.159 +	SM_GET_IFACE(USERMSGS, usermsgs);
  27.160 +#endif
  27.161 +
  27.162 +	if (SDK_OnLoad(error, maxlength, late))
  27.163 +	{
  27.164 +#if defined SMEXT_CONF_METAMOD
  27.165 +		m_WeAreUnloaded = true;
  27.166 +#endif
  27.167 +		return true;
  27.168 +	}
  27.169 +
  27.170 +	return false;
  27.171 +}
  27.172 +
  27.173 +bool SDKExtension::IsMetamodExtension()
  27.174 +{
  27.175 +#if defined SMEXT_CONF_METAMOD
  27.176 +	return true;
  27.177 +#else
  27.178 +	return false;
  27.179 +#endif
  27.180 +}
  27.181 +
  27.182 +void SDKExtension::OnExtensionPauseChange(bool state)
  27.183 +{
  27.184 +#if defined SMEXT_CONF_METAMOD
  27.185 +	m_WeGotPauseChange = true;
  27.186 +#endif
  27.187 +	SDK_OnPauseChange(state);
  27.188 +}
  27.189 +
  27.190 +void SDKExtension::OnExtensionsAllLoaded()
  27.191 +{
  27.192 +	SDK_OnAllLoaded();
  27.193 +}
  27.194 +
  27.195 +void SDKExtension::OnExtensionUnload()
  27.196 +{
  27.197 +#if defined SMEXT_CONF_METAMOD
  27.198 +	m_WeAreUnloaded = true;
  27.199 +#endif
  27.200 +	SDK_OnUnload();
  27.201 +}
  27.202 +
  27.203 +const char *SDKExtension::GetExtensionAuthor()
  27.204 +{
  27.205 +	return SMEXT_CONF_AUTHOR;
  27.206 +}
  27.207 +
  27.208 +const char *SDKExtension::GetExtensionDateString()
  27.209 +{
  27.210 +	return SMEXT_CONF_DATESTRING;
  27.211 +}
  27.212 +
  27.213 +const char *SDKExtension::GetExtensionDescription()
  27.214 +{
  27.215 +	return SMEXT_CONF_DESCRIPTION;
  27.216 +}
  27.217 +
  27.218 +const char *SDKExtension::GetExtensionVerString()
  27.219 +{
  27.220 +	return SMEXT_CONF_VERSION;
  27.221 +}
  27.222 +
  27.223 +const char *SDKExtension::GetExtensionName()
  27.224 +{
  27.225 +	return SMEXT_CONF_NAME;
  27.226 +}
  27.227 +
  27.228 +const char *SDKExtension::GetExtensionTag()
  27.229 +{
  27.230 +	return SMEXT_CONF_LOGTAG;
  27.231 +}
  27.232 +
  27.233 +const char *SDKExtension::GetExtensionURL()
  27.234 +{
  27.235 +	return SMEXT_CONF_URL;
  27.236 +}
  27.237 +
  27.238 +bool SDKExtension::SDK_OnLoad(char *error, size_t maxlength, bool late)
  27.239 +{
  27.240 +	return true;
  27.241 +}
  27.242 +
  27.243 +void SDKExtension::SDK_OnUnload()
  27.244 +{
  27.245 +}
  27.246 +
  27.247 +void SDKExtension::SDK_OnPauseChange(bool paused)
  27.248 +{
  27.249 +}
  27.250 +
  27.251 +void SDKExtension::SDK_OnAllLoaded()
  27.252 +{
  27.253 +}
  27.254 +
  27.255 +#if defined SMEXT_CONF_METAMOD
  27.256 +
  27.257 +PluginId g_PLID = 0;						/**< Metamod plugin ID */
  27.258 +ISmmPlugin *g_PLAPI = NULL;					/**< Metamod plugin API */
  27.259 +SourceHook::ISourceHook *g_SHPtr = NULL;	/**< SourceHook pointer */
  27.260 +ISmmAPI *g_SMAPI = NULL;					/**< SourceMM API pointer */
  27.261 +
  27.262 +IVEngineServer *engine = NULL;				/**< IVEngineServer pointer */
  27.263 +IServerGameDLL *gamedll = NULL;				/**< IServerGameDLL pointer */
  27.264 +
  27.265 +/** Exposes the extension to Metamod */
  27.266 +SMM_API void *PL_EXPOSURE(const char *name, int *code)
  27.267 +{
  27.268 +	if (name && !strcmp(name, METAMOD_PLAPI_NAME))
  27.269 +	{
  27.270 +		if (code)
  27.271 +		{
  27.272 +			*code = IFACE_OK;
  27.273 +		}
  27.274 +		return static_cast<void *>(g_pExtensionIface);
  27.275 +	}
  27.276 +
  27.277 +	if (code)
  27.278 +	{
  27.279 +		*code = IFACE_FAILED;
  27.280 +	}
  27.281 +
  27.282 +	return NULL;
  27.283 +}
  27.284 +
  27.285 +bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
  27.286 +{
  27.287 +	PLUGIN_SAVEVARS();
  27.288 +
  27.289 +	GET_V_IFACE_ANY(GetServerFactory, gamedll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
  27.290 +	GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
  27.291 +
  27.292 +	m_SourceMMLoaded = true;
  27.293 +
  27.294 +	return SDK_OnMetamodLoad(ismm, error, maxlen, late);
  27.295 +}
  27.296 +
  27.297 +bool SDKExtension::Unload(char *error, size_t maxlen)
  27.298 +{
  27.299 +	if (!m_WeAreUnloaded)
  27.300 +	{
  27.301 +		if (error)
  27.302 +		{
  27.303 +			snprintf(error, maxlen, "This extension must be unloaded by SourceMod.");
  27.304 +		}
  27.305 +		return false;
  27.306 +	}
  27.307 +
  27.308 +	return SDK_OnMetamodUnload(error, maxlen);
  27.309 +}
  27.310 +
  27.311 +bool SDKExtension::Pause(char *error, size_t maxlen)
  27.312 +{
  27.313 +	if (!m_WeGotPauseChange)
  27.314 +	{
  27.315 +		if (error)
  27.316 +		{
  27.317 +			snprintf(error, maxlen, "This extension must be paused by SourceMod.");
  27.318 +		}
  27.319 +		return false;
  27.320 +	}
  27.321 +
  27.322 +	m_WeGotPauseChange = false;
  27.323 +
  27.324 +	return SDK_OnMetamodPauseChange(true, error, maxlen);
  27.325 +}
  27.326 +
  27.327 +bool SDKExtension::Unpause(char *error, size_t maxlen)
  27.328 +{
  27.329 +	if (!m_WeGotPauseChange)
  27.330 +	{
  27.331 +		if (error)
  27.332 +		{
  27.333 +			snprintf(error, maxlen, "This extension must be unpaused by SourceMod.");
  27.334 +		}
  27.335 +		return false;
  27.336 +	}
  27.337 +
  27.338 +	m_WeGotPauseChange = false;
  27.339 +
  27.340 +	return SDK_OnMetamodPauseChange(false, error, maxlen);
  27.341 +}
  27.342 +
  27.343 +const char *SDKExtension::GetAuthor()
  27.344 +{
  27.345 +	return GetExtensionAuthor();
  27.346 +}
  27.347 +
  27.348 +const char *SDKExtension::GetDate()
  27.349 +{
  27.350 +	return GetExtensionDateString();
  27.351 +}
  27.352 +
  27.353 +const char *SDKExtension::GetDescription()
  27.354 +{
  27.355 +	return GetExtensionDescription();
  27.356 +}
  27.357 +
  27.358 +const char *SDKExtension::GetLicense()
  27.359 +{
  27.360 +	return SMEXT_CONF_LICENSE;
  27.361 +}
  27.362 +
  27.363 +const char *SDKExtension::GetLogTag()
  27.364 +{
  27.365 +	return GetExtensionTag();
  27.366 +}
  27.367 +
  27.368 +const char *SDKExtension::GetName()
  27.369 +{
  27.370 +	return GetExtensionName();
  27.371 +}
  27.372 +
  27.373 +const char *SDKExtension::GetURL()
  27.374 +{
  27.375 +	return GetExtensionURL();
  27.376 +}
  27.377 +
  27.378 +const char *SDKExtension::GetVersion()
  27.379 +{
  27.380 +	return GetExtensionVerString();
  27.381 +}
  27.382 +
  27.383 +bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
  27.384 +{
  27.385 +	return true;
  27.386 +}
  27.387 +
  27.388 +bool SDKExtension::SDK_OnMetamodUnload(char *error, size_t maxlength)
  27.389 +{
  27.390 +	return true;
  27.391 +}
  27.392 +
  27.393 +bool SDKExtension::SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength)
  27.394 +{
  27.395 +	return true;
  27.396 +}
  27.397 +
  27.398 +#endif
  27.399 +
  27.400 +/* Overload a few things to prevent libstdc++ linking */
  27.401 +#if defined __linux__
  27.402 +extern "C" void __cxa_pure_virtual(void)
  27.403 +{
  27.404 +}
  27.405 +
  27.406 +void *operator new(size_t size)
  27.407 +{
  27.408 +	return malloc(size);
  27.409 +}
  27.410 +
  27.411 +void *operator new[](size_t size) 
  27.412 +{
  27.413 +	return malloc(size);
  27.414 +}
  27.415 +
  27.416 +void operator delete(void *ptr) 
  27.417 +{
  27.418 +	free(ptr);
  27.419 +}
  27.420 +
  27.421 +void operator delete[](void * ptr)
  27.422 +{
  27.423 +	free(ptr);
  27.424 +}
  27.425 +#endif
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/extensions/tf2/sdk/smsdk_ext.h	Wed Mar 26 03:52:37 2008 +0000
    28.3 @@ -0,0 +1,310 @@
    28.4 +/**
    28.5 + * vim: set ts=4 :
    28.6 + * =============================================================================
    28.7 + * SourceMod Base Extension Code
    28.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    28.9 + * =============================================================================
   28.10 + *
   28.11 + * This program is free software; you can redistribute it and/or modify it under
   28.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   28.13 + * Free Software Foundation.
   28.14 + * 
   28.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   28.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   28.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   28.18 + * details.
   28.19 + *
   28.20 + * You should have received a copy of the GNU General Public License along with
   28.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   28.22 + *
   28.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   28.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   28.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   28.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   28.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   28.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   28.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   28.30 + * or <http://www.sourcemod.net/license.php>.
   28.31 + *
   28.32 + * Version: $Id$
   28.33 + */
   28.34 +
   28.35 +#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
   28.36 +#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
   28.37 +
   28.38 +/**
   28.39 + * @file smsdk_ext.h
   28.40 + * @brief Contains wrappers for making Extensions easier to write.
   28.41 + */
   28.42 +
   28.43 +#include "smsdk_config.h"
   28.44 +#include <IExtensionSys.h>
   28.45 +#include <IHandleSys.h>
   28.46 +#include <sp_vm_api.h>
   28.47 +#include <sm_platform.h>
   28.48 +#include <ISourceMod.h>
   28.49 +#if defined SMEXT_ENABLE_FORWARDSYS
   28.50 +#include <IForwardSys.h>
   28.51 +#endif //SMEXT_ENABLE_FORWARDSYS
   28.52 +#if defined SMEXT_ENABLE_PLAYERHELPERS
   28.53 +#include <IPlayerHelpers.h>
   28.54 +#endif //SMEXT_ENABLE_PlAYERHELPERS
   28.55 +#if defined SMEXT_ENABLE_DBMANAGER
   28.56 +#include <IDBDriver.h>
   28.57 +#endif //SMEXT_ENABLE_DBMANAGER
   28.58 +#if defined SMEXT_ENABLE_GAMECONF
   28.59 +#include <IGameConfigs.h>
   28.60 +#endif
   28.61 +#if defined SMEXT_ENABLE_MEMUTILS
   28.62 +#include <IMemoryUtils.h>
   28.63 +#endif
   28.64 +#if defined SMEXT_ENABLE_GAMEHELPERS
   28.65 +#include <IGameHelpers.h>
   28.66 +#endif
   28.67 +#if defined SMEXT_ENABLE_TIMERSYS
   28.68 +#include <ITimerSystem.h>
   28.69 +#endif
   28.70 +#if defined SMEXT_ENABLE_ADTFACTORY
   28.71 +#include <IADTFactory.h>
   28.72 +#endif
   28.73 +#if defined SMEXT_ENABLE_THREADER
   28.74 +#include <IThreader.h>
   28.75 +#endif
   28.76 +#if defined SMEXT_ENABLE_LIBSYS
   28.77 +#include <ILibrarySys.h>
   28.78 +#endif
   28.79 +#if defined SMEXT_ENABLE_USERMSGS
   28.80 +#include <IUserMessages.h>
   28.81 +#endif
   28.82 +
   28.83 +#if defined SMEXT_CONF_METAMOD
   28.84 +#include <ISmmPlugin.h>
   28.85 +#include <eiface.h>
   28.86 +#endif
   28.87 +
   28.88 +#if !defined METAMOD_PLAPI_VERSION
   28.89 +	#include <metamod_wrappers.h>
   28.90 +#endif
   28.91 +
   28.92 +using namespace SourceMod;
   28.93 +using namespace SourcePawn;
   28.94 +
   28.95 +class SDKExtension : 
   28.96 +#if defined SMEXT_CONF_METAMOD
   28.97 +	public ISmmPlugin,
   28.98 +#endif
   28.99 +	public IExtensionInterface
  28.100 +{
  28.101 +public:
  28.102 +	/** Constructor */
  28.103 +	SDKExtension();
  28.104 +public:
  28.105 +	/**
  28.106 +	 * @brief This is called after the initial loading sequence has been processed.
  28.107 +	 *
  28.108 +	 * @param error		Error message buffer.
  28.109 +	 * @param maxlength	Size of error message buffer.
  28.110 +	 * @param late		Whether or not the module was loaded after map load.
  28.111 +	 * @return			True to succeed loading, false to fail.
  28.112 +	 */
  28.113 +	virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
  28.114 +	
  28.115 +	/**
  28.116 +	 * @brief This is called right before the extension is unloaded.
  28.117 +	 */
  28.118 +	virtual void SDK_OnUnload();
  28.119 +
  28.120 +	/**
  28.121 +	 * @brief This is called once all known extensions have been loaded.
  28.122 +	 */
  28.123 +	virtual void SDK_OnAllLoaded();
  28.124 +
  28.125 +	/**
  28.126 +	 * @brief Called when the pause state is changed.
  28.127 +	 */
  28.128 +	virtual void SDK_OnPauseChange(bool paused);
  28.129 +
  28.130 +#if defined SMEXT_CONF_METAMOD
  28.131 +	/**
  28.132 +	 * @brief Called when Metamod is attached, before the extension version is called.
  28.133 +	 *
  28.134 +	 * @param error			Error buffer.
  28.135 +	 * @param maxlength		Maximum size of error buffer.
  28.136 +	 * @param late			Whether or not Metamod considers this a late load.
  28.137 +	 * @return				True to succeed, false to fail.
  28.138 +	 */
  28.139 +	virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
  28.140 +
  28.141 +	/**
  28.142 +	 * @brief Called when Metamod is detaching, after the extension version is called.
  28.143 +	 * NOTE: By default this is blocked unless sent from SourceMod.
  28.144 +	 *
  28.145 +	 * @param error			Error buffer.
  28.146 +	 * @param maxlength		Maximum size of error buffer.
  28.147 +	 * @return				True to succeed, false to fail.
  28.148 +	 */
  28.149 +	virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
  28.150 +
  28.151 +	/**
  28.152 +	 * @brief Called when Metamod's pause state is changing.
  28.153 +	 * NOTE: By default this is blocked unless sent from SourceMod.
  28.154 +	 *
  28.155 +	 * @param paused		Pause state being set.
  28.156 +	 * @param error			Error buffer.
  28.157 +	 * @param maxlength		Maximum size of error buffer.
  28.158 +	 * @return				True to succeed, false to fail.
  28.159 +	 */
  28.160 +	virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
  28.161 +#endif
  28.162 +
  28.163 +public: //IExtensionInterface
  28.164 +	virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
  28.165 +	virtual void OnExtensionUnload();
  28.166 +	virtual void OnExtensionsAllLoaded();
  28.167 +
  28.168 +	/** Returns whether or not this is a Metamod-based extension */
  28.169 +	virtual bool IsMetamodExtension();
  28.170 +
  28.171 +	/**
  28.172 +	 * @brief Called when the pause state changes.
  28.173 +	 * 
  28.174 +	 * @param state			True if being paused, false if being unpaused.
  28.175 +	 */
  28.176 +	virtual void OnExtensionPauseChange(bool state);
  28.177 +
  28.178 +	/** Returns name */
  28.179 +	virtual const char *GetExtensionName();
  28.180 +	/** Returns URL */
  28.181 +	virtual const char *GetExtensionURL();
  28.182 +	/** Returns log tag */
  28.183 +	virtual const char *GetExtensionTag();
  28.184 +	/** Returns author */
  28.185 +	virtual const char *GetExtensionAuthor();
  28.186 +	/** Returns version string */
  28.187 +	virtual const char *GetExtensionVerString();
  28.188 +	/** Returns description string */
  28.189 +	virtual const char *GetExtensionDescription();
  28.190 +	/** Returns date string */
  28.191 +	virtual const char *GetExtensionDateString();
  28.192 +#if defined SMEXT_CONF_METAMOD
  28.193 +public: //ISmmPlugin
  28.194 +	/** Called when the extension is attached to Metamod. */
  28.195 +	virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
  28.196 +	/** Returns the author to MM */
  28.197 +	virtual const char *GetAuthor();
  28.198 +	/** Returns the name to MM */
  28.199 +	virtual const char *GetName();
  28.200 +	/** Returns the description to MM */
  28.201 +	virtual const char *GetDescription();
  28.202 +	/** Returns the URL to MM */
  28.203 +	virtual const char *GetURL();
  28.204 +	/** Returns the license to MM */
  28.205 +	virtual const char *GetLicense();
  28.206 +	/** Returns the version string to MM */
  28.207 +	virtual const char *GetVersion();
  28.208 +	/** Returns the date string to MM */
  28.209 +	virtual const char *GetDate();
  28.210 +	/** Returns the logtag to MM */
  28.211 +	virtual const char *GetLogTag();
  28.212 +	/** Called on unload */
  28.213 +	virtual bool Unload(char *error, size_t maxlength);
  28.214 +	/** Called on pause */
  28.215 +	virtual bool Pause(char *error, size_t maxlength);
  28.216 +	/** Called on unpause */
  28.217 +	virtual bool Unpause(char *error, size_t maxlength);
  28.218 +private:
  28.219 +	bool m_SourceMMLoaded;
  28.220 +	bool m_WeAreUnloaded;
  28.221 +	bool m_WeGotPauseChange;
  28.222 +#endif
  28.223 +};
  28.224 +
  28.225 +extern SDKExtension *g_pExtensionIface;
  28.226 +extern IExtension *myself;
  28.227 +
  28.228 +extern IShareSys *g_pShareSys;
  28.229 +extern IShareSys *sharesys;				/* Note: Newer name */
  28.230 +extern ISourceMod *g_pSM;
  28.231 +extern ISourceMod *smutils;				/* Note: Newer name */
  28.232 +
  28.233 +/* Optional interfaces are below */
  28.234 +#if defined SMEXT_ENABLE_FORWARDSYS
  28.235 +extern IForwardManager *g_pForwards;
  28.236 +extern IForwardManager *forwards;		/* Note: Newer name */
  28.237 +#endif //SMEXT_ENABLE_FORWARDSYS
  28.238 +#if defined SMEXT_ENABLE_HANDLESYS
  28.239 +extern IHandleSys *g_pHandleSys;
  28.240 +extern IHandleSys *handlesys;			/* Note: Newer name */
  28.241 +#endif //SMEXT_ENABLE_HANDLESYS
  28.242 +#if defined SMEXT_ENABLE_PLAYERHELPERS
  28.243 +extern IPlayerManager *playerhelpers;
  28.244 +#endif //SMEXT_ENABLE_PLAYERHELPERS
  28.245 +#if defined SMEXT_ENABLE_DBMANAGER
  28.246 +extern IDBManager *dbi;
  28.247 +#endif //SMEXT_ENABLE_DBMANAGER
  28.248 +#if defined SMEXT_ENABLE_GAMECONF
  28.249 +extern IGameConfigManager *gameconfs;
  28.250 +#endif //SMEXT_ENABLE_DBMANAGER
  28.251 +#if defined SMEXT_ENABLE_MEMUTILS
  28.252 +extern IMemoryUtils *memutils;
  28.253 +#endif
  28.254 +#if defined SMEXT_ENABLE_GAMEHELPERS
  28.255 +extern IGameHelpers *gamehelpers;
  28.256 +#endif
  28.257 +#if defined SMEXT_ENABLE_TIMERSYS
  28.258 +extern ITimerSystem *timersys;
  28.259 +#endif
  28.260 +#if defined SMEXT_ENABLE_ADTFACTORY
  28.261 +extern IADTFactory *adtfactory;
  28.262 +#endif
  28.263 +#if defined SMEXT_ENABLE_THREADER
  28.264 +extern IThreader *threader;
  28.265 +#endif
  28.266 +#if defined SMEXT_ENABLE_LIBSYS
  28.267 +extern ILibrarySys *libsys;
  28.268 +#endif
  28.269 +#if defined SMEXT_ENABLE_USERMSGS
  28.270 +extern IUserMessages *usermsgs;
  28.271 +#endif
  28.272 +
  28.273 +#if defined SMEXT_CONF_METAMOD
  28.274 +PLUGIN_GLOBALVARS();
  28.275 +extern IVEngineServer *engine;
  28.276 +extern IServerGameDLL *gamedll;
  28.277 +#endif
  28.278 +
  28.279 +/** Creates a SourceMod interface macro pair */
  28.280 +#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
  28.281 +/** Automates retrieving SourceMod interfaces */
  28.282 +#define SM_GET_IFACE(prefix, addr) \
  28.283 +	if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
  28.284 +	{ \
  28.285 +		if (error != NULL && maxlength) \
  28.286 +		{ \
  28.287 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
  28.288 +			if (len >= maxlength) \
  28.289 +			{ \
  28.290 +				error[maxlength - 1] = '\0'; \
  28.291 +			} \
  28.292 +		} \
  28.293 +		return false; \
  28.294 +	}
  28.295 +/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
  28.296 +#define SM_GET_LATE_IFACE(prefix, addr) \
  28.297 +	g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
  28.298 +/** Validates a SourceMod interface pointer */
  28.299 +#define SM_CHECK_IFACE(prefix, addr) \
  28.300 +	if (!addr) \
  28.301 +	{ \
  28.302 +		if (error != NULL && maxlength) \
  28.303 +		{ \
  28.304 +			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
  28.305 +			if (len >= maxlength) \
  28.306 +			{ \
  28.307 +				error[maxlength - 1] = '\0'; \
  28.308 +			} \
  28.309 +		} \
  28.310 +		return false; \
  28.311 +	}
  28.312 +
  28.313 +#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/extensions/tf2/sm-tf2.games.txt	Wed Mar 26 03:52:37 2008 +0000
    29.3 @@ -0,0 +1,21 @@
    29.4 +"Games"
    29.5 +{
    29.6 +	"tf"
    29.7 +	{
    29.8 +		"Signatures"
    29.9 +		{
   29.10 +			"Burn"
   29.11 +			{
   29.12 +				"library"	"server"
   29.13 +				"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"
   29.14 +				"linux"		"@_ZN15CTFPlayerShared4BurnEP9CTFPlayer"
   29.15 +			}
   29.16 +			"Invuln"
   29.17 +			{
   29.18 +				"library"	"server"
   29.19 +				"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"
   29.20 +				"linux"		"@_ZN15CTFPlayerShared15SetInvulnerableEbb"
   29.21 +			}
   29.22 +		}
   29.23 +	}
   29.24 +}
   29.25 \ No newline at end of file
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/extensions/tf2/svn_version.h	Wed Mar 26 03:52:37 2008 +0000
    30.3 @@ -0,0 +1,42 @@
    30.4 +/**
    30.5 + * vim: set ts=4 :
    30.6 + * =============================================================================
    30.7 + * SourceMod SDKTools Extension
    30.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    30.9 + * =============================================================================
   30.10 + *
   30.11 + * This program is free software; you can redistribute it and/or modify it under
   30.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   30.13 + * Free Software Foundation.
   30.14 + * 
   30.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   30.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   30.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   30.18 + * details.
   30.19 + *
   30.20 + * You should have received a copy of the GNU General Public License along with
   30.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   30.22 + *
   30.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   30.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   30.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   30.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   30.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   30.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   30.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   30.30 + * or <http://www.sourcemod.net/license.php>.
   30.31 + *
   30.32 + * Version: $Id$
   30.33 + */
   30.34 +
   30.35 +/**
   30.36 + * Autogenerated by build scripts
   30.37 + */
   30.38 +
   30.39 +#ifndef _INCLUDE_SDKTOOLS_VERSION_H_
   30.40 +#define _INCLUDE_SDKTOOLS_VERSION_H_
   30.41 +
   30.42 +#define SVN_FULL_VERSION	"1.0.0.1336"
   30.43 +#define SVN_FILE_VERSION	1,0,0,1336
   30.44 +
   30.45 +#endif //_INCLUDE_SDKTOOLS_VERSION_H_
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/extensions/tf2/svn_version.tpl	Wed Mar 26 03:52:37 2008 +0000
    31.3 @@ -0,0 +1,42 @@
    31.4 +/**
    31.5 + * vim: set ts=4 :
    31.6 + * =============================================================================
    31.7 + * SourceMod SDKTools Extension
    31.8 + * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
    31.9 + * =============================================================================
   31.10 + *
   31.11 + * This program is free software; you can redistribute it and/or modify it under
   31.12 + * the terms of the GNU General Public License, version 3.0, as published by the
   31.13 + * Free Software Foundation.
   31.14 + * 
   31.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
   31.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   31.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   31.18 + * details.
   31.19 + *
   31.20 + * You should have received a copy of the GNU General Public License along with
   31.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   31.22 + *
   31.23 + * As a special exception, AlliedModders LLC gives you permission to link the
   31.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   31.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   31.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
   31.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   31.28 + * this exception to all derivative works.  AlliedModders LLC defines further
   31.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   31.30 + * or <http://www.sourcemod.net/license.php>.
   31.31 + *
   31.32 + * Version: $Id$
   31.33 + */
   31.34 +
   31.35 +/**
   31.36 + * Autogenerated by build scripts
   31.37 + */
   31.38 +
   31.39 +#ifndef _INCLUDE_SDKTOOLS_VERSION_H_
   31.40 +#define _INCLUDE_SDKTOOLS_VERSION_H_
   31.41 +
   31.42 +#define SVN_FULL_VERSION	"$PMAJOR$.$PMINOR$.$PREVISION$.$LOCAL_BUILD$"
   31.43 +#define SVN_FILE_VERSION	$PMAJOR$,$PMINOR$,$PREVISION$,$LOCAL_BUILD$
   31.44 +
   31.45 +#endif //_INCLUDE_SDKTOOLS_VERSION_H_
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/extensions/tf2/tf2-test.sp	Wed Mar 26 03:52:37 2008 +0000
    32.3 @@ -0,0 +1,55 @@
    32.4 +#include <sourcemod>
    32.5 +#include "tf2.inc"
    32.6 +
    32.7 +public Plugin:myinfo = 
    32.8 +{
    32.9 +	name = "TF2 Test",
   32.10 +	author = "pRED*",
   32.11 +	description = "Test of Tf2 functions",
   32.12 +	version = "1.0",
   32.13 +	url = "www.sourcemod.net"
   32.14 +}
   32.15 +
   32.16 +public OnPluginStart()
   32.17 +{
   32.18 +	RegConsoleCmd("sm_burnme", Command_Burn);
   32.19 +	RegConsoleCmd("sm_invuln", Command_Invuln);
   32.20 +}
   32.21 +
   32.22 +public Action:Command_Burn(client, args)
   32.23 +{
   32.24 +	if (client == 0)
   32.25 +	{
   32.26 +		return Plugin_Continue;
   32.27 +	}
   32.28 +	
   32.29 +	TF2_Burn(client);
   32.30 +	
   32.31 +	return Plugin_Continue;
   32.32 +}
   32.33 +
   32.34 +public Action:Command_Invuln(client, args)
   32.35 +{
   32.36 +	if (client == 0)
   32.37 +	{
   32.38 +		return Plugin_Continue;
   32.39 +	}
   32.40 +	
   32.41 +	if (args < 2)
   32.42 +	{
   32.43 +		return Plugin_Continue;	
   32.44 +	}
   32.45 +	
   32.46 +	decl String:text[10];
   32.47 +	decl String:text2[10];
   32.48 +	GetCmdArg(1, text, sizeof(text));
   32.49 +	GetCmdArg(2, text2, sizeof(text2));
   32.50 +	
   32.51 +	new bool:one = !!StringToInt(text);
   32.52 +	new bool:two = !!StringToInt(text2);
   32.53 +
   32.54 +	TF2_Invuln(client, one, two)
   32.55 +	
   32.56 +	return Plugin_Continue;
   32.57 +}
   32.58 +
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/extensions/tf2/tf2.inc	Wed Mar 26 03:52:37 2008 +0000
    33.3 @@ -0,0 +1,24 @@
    33.4 +#if defined _tf2_included
    33.5 + #endinput
    33.6 +#endif
    33.7 +#define _tf2_included
    33.8 +
    33.9 +
   33.10 +native TF2_Invuln(client, bool:something, bool:anothersomething);
   33.11 +
   33.12 +native TF2_Burn(client);
   33.13 +
   33.14 +/**
   33.15 + * Do not edit below this line!
   33.16 + */
   33.17 +public Extension:__ext_tf2 = 
   33.18 +{
   33.19 +	name = "TF2 Tools",
   33.20 +	file = "game.tf2.ext",
   33.21 +	autoload = 0,
   33.22 +#if defined REQUIRE_EXTENSIONS
   33.23 +	required = 1,
   33.24 +#else
   33.25 +	required = 0,
   33.26 +#endif
   33.27 +};
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/extensions/tf2/version.rc	Wed Mar 26 03:52:37 2008 +0000
    34.3 @@ -0,0 +1,104 @@
    34.4 +// Microsoft Visual C++ generated resource script.
    34.5 +//
    34.6 +//#include "resource.h"
    34.7 +
    34.8 +#define APSTUDIO_READONLY_SYMBOLS
    34.9 +/////////////////////////////////////////////////////////////////////////////
   34.10 +//
   34.11 +// Generated from the TEXTINCLUDE 2 resource.
   34.12 +//
   34.13 +#include "winres.h"
   34.14 +
   34.15 +#include "svn_version.h"
   34.16 +
   34.17 +/////////////////////////////////////////////////////////////////////////////
   34.18 +#undef APSTUDIO_READONLY_SYMBOLS
   34.19 +
   34.20 +/////////////////////////////////////////////////////////////////////////////
   34.21 +// English (U.S.) resources
   34.22 +
   34.23 +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
   34.24 +#ifdef _WIN32
   34.25 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
   34.26 +#pragma code_page(1252)
   34.27 +#endif //_WIN32
   34.28 +
   34.29 +/////////////////////////////////////////////////////////////////////////////
   34.30 +//
   34.31 +// Version
   34.32 +//
   34.33 +
   34.34 +VS_VERSION_INFO VERSIONINFO
   34.35 + FILEVERSION  SVN_FILE_VERSION
   34.36 + PRODUCTVERSION SVN_FILE_VERSION
   34.37 + FILEFLAGSMASK 0x17L
   34.38 +#ifdef _DEBUG
   34.39 + FILEFLAGS 0x1L
   34.40 +#else
   34.41 + FILEFLAGS 0x0L
   34.42 +#endif
   34.43 + FILEOS 0x4L
   34.44 + FILETYPE 0x2L
   34.45 + FILESUBTYPE 0x0L
   34.46 +BEGIN
   34.47 +    BLOCK "StringFileInfo"
   34.48 +    BEGIN
   34.49 +        BLOCK "000004b0"
   34.50 +        BEGIN
   34.51 +            VALUE "Comments", "SourceMod CS:S Extension"
   34.52 +            VALUE "FileDescription", "SourceMod CS:S Extension"
   34.53 +            VALUE "FileVersion", SVN_FULL_VERSION
   34.54 +            VALUE "InternalName", "SourceMod CS:S Extension"
   34.55 +            VALUE "LegalCopyright", "Copyright (c) 2004-2007, AlliedModders LLC"
   34.56 +            VALUE "OriginalFilename", "game.cstrike.ext.dll"
   34.57 +            VALUE "ProductName", "SourceMod CS:S Extension"
   34.58 +            VALUE "ProductVersion", SVN_FULL_VERSION
   34.59 +        END
   34.60 +    END
   34.61 +    BLOCK "VarFileInfo"
   34.62 +    BEGIN
   34.63 +        VALUE "Translation", 0x0, 1200
   34.64 +    END
   34.65 +END
   34.66 +
   34.67 +
   34.68 +#ifdef APSTUDIO_INVOKED
   34.69 +/////////////////////////////////////////////////////////////////////////////
   34.70 +//
   34.71 +// TEXTINCLUDE
   34.72 +//
   34.73 +
   34.74 +1 TEXTINCLUDE 
   34.75 +BEGIN
   34.76 +    "resource.h\0"
   34.77 +END
   34.78 +
   34.79 +2 TEXTINCLUDE 
   34.80 +BEGIN
   34.81 +    "#include ""winres.h""\r\n"
   34.82 +    "\0"
   34.83 +END
   34.84 +
   34.85 +3 TEXTINCLUDE 
   34.86 +BEGIN
   34.87 +    "\r\n"
   34.88 +    "\0"
   34.89 +END
   34.90 +
   34.91 +#endif    // APSTUDIO_INVOKED
   34.92 +
   34.93 +#endif    // English (U.S.) resources
   34.94 +/////////////////////////////////////////////////////////////////////////////
   34.95 +
   34.96 +
   34.97 +
   34.98 +#ifndef APSTUDIO_INVOKED
   34.99 +/////////////////////////////////////////////////////////////////////////////
  34.100 +//
  34.101 +// Generated from the TEXTINCLUDE 3 resource.
  34.102 +//
  34.103 +
  34.104 +
  34.105 +/////////////////////////////////////////////////////////////////////////////
  34.106 +#endif    // not APSTUDIO_INVOKED
  34.107 +
    35.1 --- a/plugins/adminmenu.sp	Fri Mar 21 04:26:53 2008 +0000
    35.2 +++ b/plugins/adminmenu.sp	Wed Mar 26 03:52:37 2008 +0000
    35.3 @@ -45,6 +45,8 @@
    35.4  	url = "http://www.sourcemod.net/"
    35.5  };
    35.6  
    35.7 +new g_maxPlayers;
    35.8 +
    35.9  /* Forwards */
   35.10  new Handle:hOnAdminMenuReady = INVALID_HANDLE;
   35.11  new Handle:hOnAdminMenuCreated = INVALID_HANDLE;
   35.12 @@ -57,6 +59,8 @@
   35.13  new TopMenuObject:obj_servercmds = INVALID_TOPMENUOBJECT;
   35.14  new TopMenuObject:obj_votingcmds = INVALID_TOPMENUOBJECT;
   35.15  
   35.16 +#include "adminmenu/dynamicmenu.sp"
   35.17 +
   35.18  public bool:AskPluginLoad(Handle:myself, bool:late, String:error[], err_max)
   35.19  {
   35.20  	CreateNative("GetAdminTopMenu", __GetAdminTopMenu);
   35.21 @@ -91,27 +95,36 @@
   35.22  	}
   35.23  }
   35.24  
   35.25 +public OnMapStart()
   35.26 +{
   35.27 +	g_maxPlayers = GetMaxClients();
   35.28 +	
   35.29 +	ParseConfigs();
   35.30 +}
   35.31 +
   35.32  public OnAllPluginsLoaded()
   35.33  {
   35.34 -	hAdminMenu = CreateTopMenu(CategoryHandler);
   35.35 +	hAdminMenu = CreateTopMenu(DefaultCategoryHandler);
   35.36  	
   35.37  	obj_playercmds = AddToTopMenu(hAdminMenu, 
   35.38  		"PlayerCommands",
   35.39  		TopMenuObject_Category,
   35.40 -		CategoryHandler,
   35.41 +		DefaultCategoryHandler,
   35.42  		INVALID_TOPMENUOBJECT);
   35.43  
   35.44  	obj_servercmds = AddToTopMenu(hAdminMenu,
   35.45  		"ServerCommands",
   35.46  		TopMenuObject_Category,
   35.47 -		CategoryHandler,
   35.48 +		DefaultCategoryHandler,
   35.49  		INVALID_TOPMENUOBJECT);
   35.50  
   35.51  	obj_votingcmds = AddToTopMenu(hAdminMenu,
   35.52  		"VotingCommands",
   35.53  		TopMenuObject_Category,
   35.54 -		CategoryHandler,
   35.55 +		DefaultCategoryHandler,
   35.56  		INVALID_TOPMENUOBJECT);
   35.57 +		
   35.58 +	BuildDynamicMenu();
   35.59  	
   35.60  	Call_StartForward(hOnAdminMenuCreated);
   35.61  	Call_PushCell(hAdminMenu);
   35.62 @@ -122,7 +135,7 @@
   35.63  	Call_Finish();
   35.64  }
   35.65  
   35.66 -public CategoryHandler(Handle:topmenu, 
   35.67 +public DefaultCategoryHandler(Handle:topmenu, 
   35.68  						TopMenuAction:action,
   35.69  						TopMenuObject:object_id,
   35.70  						param,
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/plugins/adminmenu/dynamicmenu.sp	Wed Mar 26 03:52:37 2008 +0000
    36.3 @@ -0,0 +1,520 @@
    36.4 +
    36.5 +#define NAME_LENGTH 32
    36.6 +#define CMD_LENGTH 255
    36.7 +
    36.8 +#define ARRAY_STRING_LENGTH 32
    36.9 +
   36.10 +new Handle:g_kvMenu;
   36.11 +
   36.12 +enum GroupCommands
   36.13 +{
   36.14 +	Handle:groupListName,
   36.15 +	Handle:groupListCommand	
   36.16 +};
   36.17 +
   36.18 +new g_groupList[GroupCommands];
   36.19 +new g_groupCount;
   36.20 +
   36.21 +new Handle:g_configParser = INVALID_HANDLE;
   36.22 +
   36.23 +enum Places
   36.24 +{
   36.25 +	Place_Category,
   36.26 +	Place_Item,
   36.27 +	Place_ReplaceNum	
   36.28 +};
   36.29 +
   36.30 +new String:g_command[MAXPLAYERS+1][CMD_LENGTH];
   36.31 +new g_currentPlace[MAXPLAYERS+1][Places];
   36.32 +
   36.33 +/**
   36.34 + * What to put in the 'info' menu field (for PlayerList and Player_Team menus only)
   36.35 + */
   36.36 +enum PlayerMethod
   36.37 +{		
   36.38 +	ClientId,				/** Client id number ( 1 - Maxplayers) */
   36.39 +	UserId,					/** Client userid */
   36.40 +	Name,					/** Client Name */
   36.41 +	SteamId,				/** Client Steamid */
   36.42 +	IpAddress,				/** Client's Ip Address */
   36.43 +	UserId2					/** Userid (not prefixed with #) */
   36.44 +};
   36.45 +
   36.46 +BuildDynamicMenu()
   36.47 +{
   36.48 +	if (g_kvMenu != INVALID_HANDLE)
   36.49 +	{
   36.50 +		CloseHandle(g_kvMenu);	
   36.51 +	}
   36.52 +	
   36.53 +	g_kvMenu = CreateKeyValues("Commands");
   36.54 +	new String:file[256];
   36.55 +	BuildPath(Path_SM, file, 255, "configs/dynamicmenu/menu.ini");
   36.56 +	FileToKeyValues(g_kvMenu, file);
   36.57 +	
   36.58 +	new String:name[NAME_LENGTH];
   36.59 +	new String:buffer[NAME_LENGTH];
   36.60 +	
   36.61 +	
   36.62 +	if (!KvGotoFirstSubKey(g_kvMenu))
   36.63 +	{
   36.64 +		return;
   36.65 +	}
   36.66 +	
   36.67 +	decl String:admin[30];
   36.68 +	
   36.69 +	new TopMenuObject:categoryId;
   36.70 +	
   36.71 +	new catId;
   36.72 +	new id;
   36.73 +	
   36.74 +	do
   36.75 +	{		
   36.76 +		KvGetSectionName(g_kvMenu, buffer, sizeof(buffer));
   36.77 +
   36.78 +		KvGetString(g_kvMenu, "admin", admin, sizeof(admin),"sm_admin");
   36.79 +				
   36.80 +		if ((categoryId =FindTopMenuCategory(hAdminMenu, buffer)) == INVALID_TOPMENUOBJECT)
   36.81 +		{
   36.82 +			categoryId = AddToTopMenu(hAdminMenu,
   36.83 +							buffer,
   36.84 +							TopMenuObject_Category,
   36.85 +							DynamicMenuCategoryHandler,
   36.86 +							INVALID_TOPMENUOBJECT,
   36.87 +							admin,
   36.88 +							ADMFLAG_GENERIC,
   36.89 +							name);
   36.90 +
   36.91 +		}
   36.92 +		
   36.93 +		if (!KvGetSectionSymbol(g_kvMenu, catId))
   36.94 +		{
   36.95 +			LogError("Key Id not found for section: %s", buffer);
   36.96 +			break;
   36.97 +		}
   36.98 +		
   36.99 +		if (!KvGotoFirstSubKey(g_kvMenu))
  36.100 +		{
  36.101 +			return;
  36.102 +		}
  36.103 +		
  36.104 +		do
  36.105 +		{		
  36.106 +			KvGetSectionName(g_kvMenu, buffer, sizeof(buffer));
  36.107 +
  36.108 +			KvGetString(g_kvMenu, "admin", admin, sizeof(admin),"");
  36.109 +			
  36.110 +			if (admin[0] == '\0')
  36.111 +			{
  36.112 +				//No 'admin' keyvalue was found
  36.113 +				//Use the first argument of the 'cmd' string instead
  36.114 +				
  36.115 +				decl String:temp[64];
  36.116 +				KvGetString(g_kvMenu, "cmd", temp, sizeof(temp),"");
  36.117 +				
  36.118 +				BreakString(temp, admin, sizeof(admin));
  36.119 +			}
  36.120 +							  
  36.121 +			if (!KvGetSectionSymbol(g_kvMenu, id))
  36.122 +			{
  36.123 +				LogError("Key Id not found for section: %s");
  36.124 +				break;
  36.125 +			}
  36.126 +			
  36.127 +			decl String:keyId[64];
  36.128 +			
  36.129 +			Format(keyId, sizeof(keyId), "%i %i", catId, id);
  36.130 +		
  36.131 +			AddToTopMenu(hAdminMenu,
  36.132 +							buffer,
  36.133 +							TopMenuObject_Item,
  36.134 +							DynamicMenuItemHandler,
  36.135 +  							categoryId,
  36.136 +  							admin,
  36.137 +  							ADMFLAG_GENERIC,
  36.138 +  							keyId);
  36.139 +		
  36.140 +		} while (KvGotoNextKey(g_kvMenu));
  36.141 +		
  36.142 +		KvGoBack(g_kvMenu);
  36.143 +		
  36.144 +	} while (KvGotoNextKey(g_kvMenu));
  36.145 +	
  36.146 +	KvRewind(g_kvMenu);	
  36.147 +}
  36.148 +
  36.149 +ParseConfigs()
  36.150 +{
  36.151 +	if (g_configParser == INVALID_HANDLE)
  36.152 +	{
  36.153 +		g_configParser = SMC_CreateParser();
  36.154 +	}
  36.155 +	
  36.156 +	SMC_SetReaders(g_configParser, NewSection, KeyValue, EndSection);
  36.157 +	
  36.158 +	if (g_groupList[groupListName] != INVALID_HANDLE)
  36.159 +	{
  36.160 +		CloseHandle(g_groupList[groupListName]);
  36.161 +	}
  36.162 +	
  36.163 +	if (g_groupList[groupListCommand] != INVALID_HANDLE)
  36.164 +	{
  36.165 +		CloseHandle(g_groupList[groupListCommand]);
  36.166 +	}
  36.167 +	
  36.168 +	g_groupList[groupListName] = CreateArray(ARRAY_STRING_LENGTH);
  36.169 +	g_groupList[groupListCommand] = CreateArray(ARRAY_STRING_LENGTH);
  36.170 +	
  36.171 +	decl String:configPath[256];
  36.172 +	BuildPath(Path_SM, configPath, sizeof(configPath), "configs/dynamicmenu/adminmenu_grouping.txt");
  36.173 +	
  36.174 +	if (!FileExists(configPath))
  36.175 +	{
  36.176 +		LogError("Unable to locate admin menu groups file, no groups loaded.");
  36.177 +			
  36.178 +		return;		
  36.179 +	}
  36.180 +	
  36.181 +	new line;
  36.182 +	new SMCError:err = SMC_ParseFile(g_configParser, configPath, line);
  36.183 +	if (err != SMCError_Okay)
  36.184 +	{
  36.185 +		decl String:error[256];
  36.186 +		SMC_GetErrorString(err, error, sizeof(error));
  36.187 +		LogError("Could not parse file (line %d, file \"%s\"):", line, configPath);
  36.188 +		LogError("Parser encountered error: %s", error);
  36.189 +	}
  36.190 +	
  36.191 +	return;
  36.192 +}
  36.193 +
  36.194 +public SMCResult:NewSection(Handle:smc, const String:name[], bool:opt_quotes)
  36.195 +{
  36.196 +
  36.197 +}
  36.198 +
  36.199 +public SMCResult:KeyValue(Handle:smc, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes)
  36.200 +{
  36.201 +	PushArrayString(g_groupList[groupListName], key);
  36.202 +	PushArrayString(g_groupList[groupListCommand], value);
  36.203 +}
  36.204 +
  36.205 +public SMCResult:EndSection(Handle:smc)
  36.206 +{
  36.207 +	g_groupCount = GetArraySize(g_groupList[groupListName]);
  36.208 +}
  36.209 +
  36.210 +public DynamicMenuCategoryHandler(Handle:topmenu, 
  36.211 +						TopMenuAction:action,
  36.212 +						TopMenuObject:object_id,
  36.213 +						param,
  36.214 +						String:buffer[],
  36.215 +						maxlength)
  36.216 +{
  36.217 +	if ((action == TopMenuAction_DisplayTitle) || (action == TopMenuAction_DisplayOption))
  36.218 +	{
  36.219 +		GetTopMenuObjName(topmenu, object_id, buffer, maxlength);
  36.220 +	}
  36.221 +}
  36.222 +
  36.223 +public DynamicMenuItemHandler(Handle:topmenu, 
  36.224 +					  TopMenuAction:action,
  36.225 +					  TopMenuObject:object_id,
  36.226 +					  param,
  36.227 +					  String:buffer[],
  36.228 +					  maxlength)
  36.229 +{
  36.230 +	if (action == TopMenuAction_DisplayOption)
  36.231 +	{
  36.232 +		GetTopMenuObjName(topmenu, object_id, buffer, maxlength);
  36.233 +	}
  36.234 +	else if (action == TopMenuAction_SelectOption)
  36.235 +	{	
  36.236 +		new String:keyId[64];
  36.237 +		new String:catId[64];
  36.238 +		GetTopMenuInfoString(topmenu, object_id, keyId, sizeof(keyId));
  36.239 +		
  36.240 +		new start = BreakString(keyId, catId, sizeof(catId));
  36.241 +		
  36.242 +		new id = StringToInt(keyId[start]);
  36.243 +		new category = StringToInt(catId);
  36.244 +		
  36.245 +		KvJumpToKeySymbol(g_kvMenu, category);
  36.246 +		KvJumpToKeySymbol(g_kvMenu, id);
  36.247 +		
  36.248 +		KvGetString(g_kvMenu, "cmd", g_command[param], sizeof(g_command[]),"");
  36.249 +		KvRewind(g_kvMenu);
  36.250 +					
  36.251 +		g_currentPlace[param][Place_Category] = category;
  36.252 +		g_currentPlace[param][Place_Item] = id;
  36.253 +		
  36.254 +		ParamCheck(param);
  36.255 +	}
  36.256 +}
  36.257 +
  36.258 +public ParamCheck(client)
  36.259 +{
  36.260 +	new String:buffer[6];
  36.261 +	new String:buffer2[6];
  36.262 +
  36.263 +	KvJumpToKeySymbol(g_kvMenu, g_currentPlace[client][Place_Category]);
  36.264 +	KvJumpToKeySymbol(g_kvMenu, g_currentPlace[client][Place_Item]);
  36.265 +	
  36.266 +	new String:type[NAME_LENGTH];
  36.267 +		
  36.268 +	if (g_currentPlace[client][Place_ReplaceNum] < 1)
  36.269 +	{
  36.270 +		g_currentPlace[client][Place_ReplaceNum] = 1;
  36.271 +	}
  36.272 +	
  36.273 +	Format(buffer, 5, "#%i", g_currentPlace[client][Place_ReplaceNum]);
  36.274 +	Format(buffer2, 5, "@%i", g_currentPlace[client][Place_ReplaceNum]);
  36.275 +	
  36.276 +	if (StrContains(g_command[client], buffer) != -1 || StrContains(g_command[client], buffer2) != -1)
  36.277 +	{
  36.278 +		//user has a parameter to fill. lets do it.	
  36.279 +		KvJumpToKey(g_kvMenu, buffer[1]); // Jump to current param
  36.280 +		KvGetString(g_kvMenu, "type", type, sizeof(type),"list");
  36.281 +		
  36.282 +		PrintToChatAll("Checking param %s - type %s", buffer[1], type);
  36.283 +		
  36.284 +		new Handle:itemMenu = CreateMenu(Menu_Selection);
  36.285 +		
  36.286 +		new String:title[NAME_LENGTH];
  36.287 +			
  36.288 +		if (strncmp(type,"group",5)==0 && g_groupCount)
  36.289 +		{	
  36.290 +			decl String:nameBuffer[ARRAY_STRING_LENGTH];
  36.291 +			decl String:commandBuffer[ARRAY_STRING_LENGTH];
  36.292 +		
  36.293 +			for (new i = 0; i<g_groupCount; i++)
  36.294 +			{			
  36.295 +				GetArrayString(g_groupList[groupListName], i, nameBuffer, sizeof(nameBuffer));
  36.296 +				GetArrayString(g_groupList[groupListCommand], i, commandBuffer, sizeof(commandBuffer));
  36.297 +				AddMenuItem(itemMenu, commandBuffer, nameBuffer);
  36.298 +			}
  36.299 +		}
  36.300 +		
  36.301 +		if (strncmp(type,"mapcycle",8) == 0)
  36.302 +		{
  36.303 +			decl String:path[200];
  36.304 +			KvGetString(g_kvMenu, "path", path, sizeof(path),"mapcycle.txt");
  36.305 +		
  36.306 +			new Handle:file = OpenFile(path, "rt");
  36.307 +			new String:readData[128];
  36.308 +			
  36.309 +			if(file != INVALID_HANDLE)
  36.310 +			{
  36.311 +				while(!IsEndOfFile(file) && ReadFileLine(file, readData, sizeof(readData)))
  36.312 +				{
  36.313 +					TrimString(readData);
  36.314 +					
  36.315 +					if (IsMapValid(readData))
  36.316 +					{
  36.317 +						AddMenuItem(itemMenu, readData, readData);
  36.318 +					}
  36.319 +				}
  36.320 +			}
  36.321 +		}
  36.322 +		else if (StrContains(type, "player") != -1)
  36.323 +		{
  36.324 +			PrintToChatAll("Building Player List");
  36.325 +			
  36.326 +			new PlayerMethod:playermethod;
  36.327 +			new String:method[NAME_LENGTH];
  36.328 +			
  36.329 +			KvGetString(g_kvMenu, "method", method, sizeof(method),"name");
  36.330 +			
  36.331 +			if (strncmp(method,"clientid",8)==0)
  36.332 +			{
  36.333 +				playermethod = ClientId;
  36.334 +			}
  36.335 +			else if (strncmp(method,"steamid",7)==0)
  36.336 +			{
  36.337 +				playermethod = SteamId;
  36.338 +			}
  36.339 +			else if (strncmp(method,"userid2",7)==0)
  36.340 +			{
  36.341 +				playermethod = UserId2;
  36.342 +			}
  36.343 +			else if (strncmp(method,"userid",6)==0)
  36.344 +			{
  36.345 +				playermethod = UserId;
  36.346 +			}
  36.347 +			else if (strncmp(method,"ip",2)==0)
  36.348 +			{
  36.349 +				playermethod = IpAddress;
  36.350 +			}
  36.351 +			else
  36.352 +			{
  36.353 +				playermethod = Name;
  36.354 +			}
  36.355 +	
  36.356 +			
  36.357 +			new String:nameBuffer[32];
  36.358 +			new String:infoBuffer[32];
  36.359 +			new String:temp[4];
  36.360 +			
  36.361 +			//loop through players. Add name as text and name/userid/steamid as info
  36.362 +			for (new i=1; i<=g_maxPlayers; i++)
  36.363 +			{
  36.364 +				if (IsClientInGame(i))
  36.365 +				{			
  36.366 +					GetClientName(i, nameBuffer, 31);
  36.367 +					
  36.368 +					switch (playermethod)
  36.369 +					{
  36.370 +						case UserId:
  36.371 +						{
  36.372 +							new userid = GetClientUserId(i);
  36.373 +							Format(infoBuffer, sizeof(infoBuffer), "#%i", userid);
  36.374 +							AddMenuItem(itemMenu, infoBuffer, nameBuffer);	
  36.375 +						}
  36.376 +						case UserId2:
  36.377 +						{
  36.378 +							new userid = GetClientUserId(i);
  36.379 +							Format(infoBuffer, sizeof(infoBuffer), "%i", userid);
  36.380 +							AddMenuItem(itemMenu, infoBuffer, nameBuffer);							
  36.381 +						}
  36.382 +						case SteamId:
  36.383 +						{
  36.384 +							GetClientAuthString(i, infoBuffer, sizeof(infoBuffer));
  36.385 +							AddMenuItem(itemMenu, infoBuffer, nameBuffer);							
  36.386 +						}	
  36.387 +						case IpAddress:
  36.388 +						{
  36.389 +							GetClientIP(i, infoBuffer, sizeof(infoBuffer));
  36.390 +							AddMenuItem(itemMenu, infoBuffer, nameBuffer);							
  36.391 +						}
  36.392 +						case Name:
  36.393 +						{
  36.394 +							AddMenuItem(itemMenu, nameBuffer, nameBuffer);
  36.395 +						}	
  36.396 +						default: //assume client id
  36.397 +						{
  36.398 +							Format(temp,3,"%i",i);
  36.399 +							AddMenuItem(itemMenu, temp, nameBuffer);						
  36.400 +						}								
  36.401 +					}
  36.402 +				}
  36.403 +			}
  36.404 +		}
  36.405 +		else if (strncmp(type,"onoff",5) == 0)
  36.406 +		{
  36.407 +			AddMenuItem(itemMenu, "1", "On");
  36.408 +			AddMenuItem(itemMenu, "0", "Off");
  36.409 +		}		
  36.410 +		else
  36.411 +		{
  36.412 +			//list menu
  36.413 +			
  36.414 +			PrintToChatAll("Building List Menu");
  36.415 +
  36.416 +			new String:temp[6];
  36.417 +			new String:value[64];
  36.418 +			new String:text[64];
  36.419 +			new i=1;
  36.420 +			new bool:more = true;
  36.421 +					
  36.422 +			new String:admin[NAME_LENGTH];
  36.423 +						
  36.424 +			do
  36.425 +			{
  36.426 +				// load the i and i. options from kv and make a menu from them (i* = required admin level to view)
  36.427 +				Format(temp,3,"%i",i);
  36.428 +				KvGetString(g_kvMenu, temp, value, sizeof(value), "");
  36.429 +				
  36.430 +				Format(temp,5,"%i.",i);
  36.431 +				KvGetString(g_kvMenu, temp, text, sizeof(text), value);
  36.432 +				
  36.433 +				Format(temp,5,"%i*",i);
  36.434 +				KvGetString(g_kvMenu, temp, admin, sizeof(admin),"");	
  36.435 +				
  36.436 +				if (value[0]=='\0')
  36.437 +				{
  36.438 +					more = false;
  36.439 +				}
  36.440 +				else if (CheckCommandAccess(client, admin, 0))
  36.441 +				{
  36.442 +					AddMenuItem(itemMenu, value, text);
  36.443 +				}
  36.444 +				
  36.445 +				i++;
  36.446 +								
  36.447 +			} while (more);
  36.448 +		
  36.449 +		}
  36.450 +		
  36.451 +		KvGetString(g_kvMenu, "title", title, sizeof(title),"Choose an Option");
  36.452 +		SetMenuTitle(itemMenu, title);
  36.453 +		
  36.454 +		DisplayMenu(itemMenu, client, MENU_TIME_FOREVER);
  36.455 +	}
  36.456 +	else
  36.457 +	{	
  36.458 +		//nothing else need to be done. Run teh command.
  36.459 +		new String:execute[7];
  36.460 +		KvGetString(g_kvMenu, "execute", execute, sizeof(execute), "player");
  36.461 +		
  36.462 +		DisplayTopMenu(hAdminMenu, client, TopMenuPosition_LastCategory);
  36.463 +		
  36.464 +		if (execute[0]=='p') // assume 'player' type execute option
  36.465 +		{
  36.466 +			FakeClientCommand(client, g_command[client]);
  36.467 +		}
  36.468 +		else // assume 'server' type execute option
  36.469 +		{
  36.470 +			InsertServerCommand(g_command[client]);
  36.471 +			ServerExecute();
  36.472 +		}
  36.473 +
  36.474 +		g_command[client][0] = '\0';
  36.475 +		g_currentPlace[client][Place_ReplaceNum] = 1;
  36.476 +	}
  36.477 +	
  36.478 +	KvRewind(g_kvMenu);
  36.479 +}
  36.480 +
  36.481 +public Menu_Selection(Handle:menu, MenuAction:action, param1, param2)
  36.482 +{
  36.483 +	if (action == MenuAction_End)
  36.484 +	{
  36.485 +		CloseHandle(menu);
  36.486 +	}
  36.487 +	
  36.488 +	if (action == MenuAction_Select)
  36.489 +	{
  36.490 +		new String:info[NAME_LENGTH];
  36.491 + 
  36.492 +		/* Get item info */
  36.493 +		new bool:found = GetMenuItem(menu, param2, info, sizeof(info));
  36.494 +		
  36.495 +		if (!found)
  36.496 +		{
  36.497 +			return;
  36.498 +		}
  36.499 +		
  36.500 +		new String:buffer[6];
  36.501 +		new String:infobuffer[NAME_LENGTH+2];
  36.502 +		Format(infobuffer, sizeof(infobuffer), "\"%s\"", info);
  36.503 +		
  36.504 +		Format(buffer, 5, "#%i", g_currentPlace[param1][Place_ReplaceNum]);
  36.505 +		ReplaceString(g_command[param1], sizeof(g_command[]), buffer, infobuffer);
  36.506 +		//replace #num with the selected option (quoted)
  36.507 +		
  36.508 +		Format(buffer, 5, "@%i", g_currentPlace[param1][Place_ReplaceNum]);
  36.509 +		ReplaceString(g_command[param1], sizeof(g_command[]), buffer, info);
  36.510 +		//replace @num with the selected option (unquoted)
  36.511 +		
  36.512 +		// Increment the parameter counter.
  36.513 +		g_currentPlace[param1][Place_ReplaceNum]++;
  36.514 +		
  36.515 +		ParamCheck(param1);
  36.516 +	}
  36.517 +	
  36.518 +	if (action == MenuAction_Cancel && param2 == MenuCancel_Exit)
  36.519 +	{
  36.520 +		//client exited we should go back to submenu i think
  36.521 +		DisplayTopMenu(hAdminMenu, param1, TopMenuPosition_LastCategory);
  36.522 +	}
  36.523 +}
  36.524 \ No newline at end of file
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/plugins/include/regex.inc	Wed Mar 26 03:52:37 2008 +0000
    37.3 @@ -0,0 +1,141 @@
    37.4 +#if defined _regex_included
    37.5 +  #endinput
    37.6 +#endif
    37.7 +#define _regex_included
    37.8 +
    37.9 +/**
   37.10 + * @section 	Flags for compiling regex expressions.  These come directly from the 
   37.11 + * pcre library and can be used in MatchRegex and CompileRegex.
   37.12 + */
   37.13 +#define PCRE_CASELESS           0x00000001 /* Ignore Case */
   37.14 +#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). */
   37.15 +#define PCRE_DOTALL             0x00000004 /* Single line (affects . so that it matches any character, even new line characters). */
   37.16 +#define PCRE_EXTENDED           0x00000008 /* Pattern extension (ignore whitespace and # comments). */
   37.17 +#define PCRE_UNGREEDY           0x00000200 /* Invert greediness of quantifiers */
   37.18 +#define PCRE_UTF8               0x00000800 /* Use UTF-8 Chars */
   37.19 +#define PCRE_NO_UTF8_CHECK      0x00002000 /* Do not check the pattern for UTF-8 validity (only relevant if PCRE_UTF8 is set) */
   37.20 +
   37.21 +
   37.22 +/**
   37.23 + * Regex expression error codes.
   37.24 + */
   37.25 +enum RegexError
   37.26 +{
   37.27 +	REGEX_ERROR_NONE = 0,				/* No error */
   37.28 +	REGEX_ERROR_NOMATCH = -1,			/* No match was found */
   37.29 +	REGEX_ERROR_NULL = -2,
   37.30 +	REGEX_ERROR_BADOPTION = -3,
   37.31 +	REGEX_ERROR_BADMAGIC = -4,
   37.32 +	REGEX_ERROR_UNKNOWN_OPCODE = -5,
   37.33 +	REGEX_ERROR_NOMEMORY = -6,
   37.34 +	REGEX_ERROR_NOSUBSTRING = -7,
   37.35 +	REGEX_ERROR_MATCHLIMIT = -8,
   37.36 +	REGEX_ERROR_CALLOUT = -9,  			/* Never used by PCRE itself */
   37.37 +	REGEX_ERROR_BADUTF8 = -10,
   37.38 +	REGEX_ERROR_BADUTF8_OFFSET = -11,
   37.39 +	REGEX_ERROR_PARTIAL = -12,
   37.40 +	REGEX_ERROR_BADPARTIAL = -13,
   37.41 +	REGEX_ERROR_INTERNAL = -14,
   37.42 +	REGEX_ERROR_BADCOUNT = -15,
   37.43 +	REGEX_ERROR_DFA_UITEM = -16,
   37.44 +	REGEX_ERROR_DFA_UCOND = -17,
   37.45 +	REGEX_ERROR_DFA_UMLIMIT = -18,
   37.46 +	REGEX_ERROR_DFA_WSSIZE = -19,
   37.47 +	REGEX_ERROR_DFA_RECURSE = -20,
   37.48 +	REGEX_ERROR_RECURSIONLIMIT = -21,
   37.49 +	REGEX_ERROR_NULLWSLIMIT = -22,  	/* No longer actually used */
   37.50 +	REGEX_ERROR_BADNEWLINE = -23
   37.51 +}
   37.52 +
   37.53 +/**
   37.54 + * Precompile a regular expression.  Use this if you intend on using the 
   37.55 + * same expression multiple times.  Pass the regex handle returned here to
   37.56 + * MatchRegex to check for matches.
   37.57 + *
   37.58 + * @param pattern		The regular expression pattern.
   37.59 + * @param flags			General flags for the regular expression.
   37.60 + * @param error			Error message encountered, if applicable.
   37.61 + * @param maxLen		Maximum string length of the error buffer.
   37.62 + * @param errcode		Regex type error code encountered, if applicable.
   37.63 + * @return				Valid regex handle on success, INVALID_HANDLE on failure.
   37.64 + */
   37.65 +native Handle:CompileRegex(const String:pattern[], flags = 0, String:error[]="", maxLen = 0, &RegexError:errcode = REGEX_ERROR_NONE);
   37.66 +
   37.67 +/**
   37.68 + * Matches a string against a pre-compiled regular expression pattern.
   37.69 + *
   37.70 + * @param str			The string to check.
   37.71 + * @param regex			Regex Handle from CompileRegex()
   37.72 + * @param ret			Error code, if applicable.
   37.73 + * @return				Number of substrings found or -1 on failure.
   37.74 + *
   37.75 + * @note				Use the regex handle passed to this function to extract
   37.76 + *						matches with GetRegexSubString().
   37.77 + */
   37.78 +native MatchRegex(Handle:regex, const String:str[], &RegexError:ret = REGEX_ERROR_NONE);
   37.79 +
   37.80 +/**
   37.81 + * Returns a matched substring from a regex handle.
   37.82 + * Substring ids start at 0 and end at substrings-1, where substrings is the number returned 
   37.83 + * by MatchRegex
   37.84 + *
   37.85 + * @param regex			The regex handle to extract data from.
   37.86 + * @param str_id		The index of the expression to get - starts at 0, and ends at substrings - 1.
   37.87 + * @param buffer		The buffer to set to the matching substring.
   37.88 + * @param maxLen		The maximum string length of the buffer.
   37.89 + * @return				True if a substring was found, False on fail/error
   37.90 + */
   37.91 +native bool:GetRegexSubString(Handle:regex, str_id, String:buffer[], maxlen);
   37.92 +
   37.93 +/**
   37.94 + * Matches a string against a regular expression pattern.
   37.95 + *
   37.96 + * @note				If you intend on using the same regular expression pattern
   37.97 + *						multiple times, consider using CompileRegex and MatchRegex 
   37.98 + *						instead of making this function reparse the expression each time.
   37.99 + *
  37.100 + * @param str			The string to check.
  37.101 + * @param pattern		The regular expression pattern.
  37.102 + * @param flags			General flags for the regular expression.
  37.103 + * @param error			Error message, if applicable.
  37.104 + * @param maxLen		Maximum length of the error buffer.
  37.105 + * @return				Number of substrings found or -1 on failure.
  37.106 + */
  37.107 +stock SimpleRegexMatch(const String:str[], const String:pattern[], flags = 0, String:error[]="", maxLen = 0)
  37.108 +{
  37.109 +	new Handle:regex = CompileRegex(pattern, flags, error, maxLen);
  37.110 +	
  37.111 +	if (regex == INVALID_HANDLE)
  37.112 +	{
  37.113 +		return -1;	
  37.114 +	}
  37.115 +	
  37.116 +	new substrings = MatchRegex(regex, str);
  37.117 +	
  37.118 +	CloseHandle(regex);
  37.119 +	
  37.120 +	return substrings;	
  37.121 +}
  37.122 +
  37.123 +/**
  37.124 + * @endsection
  37.125 + */
  37.126 +
  37.127 +/**
  37.128 + * Do not edit below this line!
  37.129 + */
  37.130 +public Extension:__ext_regex = 
  37.131 +{
  37.132 +	name = "Regex Extension",
  37.133 +	file = "regex.ext",
  37.134 +#if defined AUTOLOAD_EXTENSIONS
  37.135 +	autoload = 1,
  37.136 +#else
  37.137 +	autoload = 0,
  37.138 +#endif
  37.139 +#if defined REQUIRE_EXTENSIONS
  37.140 +	required = 1,
  37.141 +#else
  37.142 +	required = 0,
  37.143 +#endif
  37.144 +};
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/plugins/mapmanager.sp	Wed Mar 26 03:52:37 2008 +0000
    38.3 @@ -0,0 +1,362 @@
    38.4 +/**
    38.5 + * vim: set ts=4 :
    38.6 + * =============================================================================
    38.7 + * SourceMod Map Management Plugin
    38.8 + * Provides all map related functionality, including map changing, map voting,
    38.9 + * and nextmap.
   38.10 + *
   38.11 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
   38.12 + * =============================================================================
   38.13 + *
   38.14 + * This program is free software; you can redistribute it and/or modify it under
   38.15 + * the terms of the GNU General Public License, version 3.0, as published by the
   38.16 + * Free Software Foundation.
   38.17 + * 
   38.18 + * This program is distributed in the hope that it will be useful, but WITHOUT
   38.19 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   38.20 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   38.21 + * details.
   38.22 + *
   38.23 + * You should have received a copy of the GNU General Public License along with
   38.24 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   38.25 + *
   38.26 + * As a special exception, AlliedModders LLC gives you permission to link the
   38.27 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   38.28 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   38.29 + * by the Valve Corporation.  You must obey the GNU General Public License in
   38.30 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   38.31 + * this exception to all derivative works.  AlliedModders LLC defines further
   38.32 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   38.33 + * or <http://www.sourcemod.net/license.php>.
   38.34 + *
   38.35 + * Version: $Id$
   38.36 + */
   38.37 +
   38.38 +#pragma semicolon 1
   38.39 +#include <sourcemod>
   38.40 +
   38.41 +public Plugin:myinfo =
   38.42 +{
   38.43 +	name = "Map Manager",
   38.44 +	author = "AlliedModders LLC",
   38.45 +	description = "Map Management",
   38.46 +	version = SOURCEMOD_VERSION,
   38.47 +	url = "http://www.sourcemod.net/"
   38.48 +};
   38.49 +
   38.50 +#include "mapmanagement/globals.sp"
   38.51 +#include "mapmanagement/commands.sp"
   38.52 +#include "mapmanagement/events.sp"
   38.53 +#include "mapmanagement/functions.sp"
   38.54 +#include "mapmanagement/menus.sp"
   38.55 +#include "mapmanagement/timers.sp"
   38.56 +#include "mapmanagement/votes.sp"
   38.57 +
   38.58 +public OnPluginStart()
   38.59 +{	
   38.60 +	LoadTranslations("mapmanager.phrases");
   38.61 +
   38.62 +	// Prepare nextmap functionality.	
   38.63 +	g_VGUIMenu = GetUserMessageId("VGUIMenu");
   38.64 +	if (g_VGUIMenu == INVALID_MESSAGE_ID)
   38.65 +	{
   38.66 +		LogError("FATAL: Cannot find VGUIMenu user message id. MapManager crippled.");
   38.67 +		g_NextMapEnabled = false;
   38.68 +	}
   38.69 +	HookUserMessage(g_VGUIMenu, UserMsg_VGUIMenu);
   38.70 +
   38.71 +	// Create all of the arrays, sized for a 64 character string.
   38.72 +	new arraySize = ByteCountToCells(64);
   38.73 +	g_MapCycle = CreateArray(arraySize);
   38.74 +	g_MapList = CreateArray(arraySize);
   38.75 +	g_MapHistory = CreateArray(arraySize);
   38.76 +	g_NextVoteMaps = CreateArray(arraySize);
   38.77 +	g_SelectedMaps = CreateArray(arraySize);
   38.78 +	g_NominatedMaps = CreateArray(arraySize);
   38.79 +	
   38.80 +	g_TeamScores = CreateArray(2);
   38.81 +
   38.82 +	// Hook say
   38.83 +	RegConsoleCmd("say", Command_Say);
   38.84 +	RegConsoleCmd("say_team", Command_Say);	
   38.85 +
   38.86 +	// Register all commands.
   38.87 +	RegAdminCmd("sm_map", Command_Map, ADMFLAG_CHANGEMAP, "sm_map <map> [r/e]");
   38.88 +	RegAdminCmd("sm_setnextmap", Command_SetNextmap, ADMFLAG_CHANGEMAP, "sm_setnextmap <map>");
   38.89 +	RegAdminCmd("sm_votemap", Command_Votemap, ADMFLAG_VOTE|ADMFLAG_CHANGEMAP, "sm_votemap <mapname> [mapname2] ... [mapname5] ");
   38.90 +	RegAdminCmd("sm_maplist", Command_List, ADMFLAG_GENERIC, "sm_maplist");
   38.91 +	RegAdminCmd("sm_nominate", Command_Addmap, ADMFLAG_CHANGEMAP, "sm_nominate <mapname> - Nominates a map for RockTheVote and MapChooser. Overrides existing nominations.");
   38.92 +	RegAdminCmd("sm_mapvote", Command_Mapvote, ADMFLAG_CHANGEMAP, "sm_mapvote - Forces the MapChooser vote to occur.");
   38.93 +	
   38.94 +	if (GetCommandFlags("nextmap") == INVALID_FCVAR_FLAGS)
   38.95 +	{
   38.96 +		RegServerCmd("nextmap", Command_Nextmap);
   38.97 +	}	
   38.98 +	
   38.99 +	// Register all convars
  38.100 +	g_Cvar_Nextmap = CreateConVar("sm_nextmap", "", "Sets the Next Map", FCVAR_NOTIFY);
  38.101 +	
  38.102 +	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);	
  38.103 +	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);
  38.104 +	
  38.105 +	g_Cvar_MapChooser = CreateConVar("sm_mm_mapchooser", "0", "Enables MapChooser (End of Map voting)", 0, true, 0.0, true, 1.0);
  38.106 +	g_Cvar_RockTheVote = CreateConVar("sm_mm_rockthevote", "0", "Enables RockTheVote (Player initiated map votes)", 0, true, 0.0, true, 1.0);
  38.107 +	g_Cvar_Randomize = CreateConVar("sm_mm_randomize", "0", "Enabled Randomizer (Randomly picks the next map)", 0, true, 0.0, true, 1.0);
  38.108 +	g_Cvar_Nominate = CreateConVar("sm_mm_nominate", "1", "Enables nomination system.", 0, true, 0.0, true, 1.0);
  38.109 +	
  38.110 +	g_Cvar_VoteMap = CreateConVar("sm_mm_votemap", "0.60", "Percentage required for successful sm_votemap.", 0, true, 0.05, true, 1.0);
  38.111 +	g_Cvar_RTVLimit = CreateConVar("sm_mm_rtvlimit", "0.60", "Required percentage of players needed to rockthevote", 0, true, 0.05, true, 1.0);
  38.112 +	g_Cvar_MinPlayers = CreateConVar("sm_mm_minplayers", "0", "Number of players required before RTV will be enabled.", 0, true, 0.0, true, float(MAXPLAYERS));
  38.113 +	
  38.114 +	g_Cvar_StartTime = CreateConVar("sm_mapvote_start", "3.0", "Specifies when to start the vote based on time remaining.", _, true, 1.0);
  38.115 +	g_Cvar_StartRounds = CreateConVar("sm_mapvote_startround", "2.0", "Specifies when to start the vote based on rounds remaining.", _, true, 1.0);
  38.116 +	g_Cvar_StartFrags = CreateConVar("sm_mapvote_startfrags", "5.0", "Specifies when to start the vote base on frags remaining.", _, true, 1.0);
  38.117 +	g_Cvar_ExtendTimeMax = CreateConVar("sm_extendmap_maxtime", "90", "Specifies the maximum amount of time a map can be extended", _, true, 0.0);
  38.118 +	g_Cvar_ExtendTimeStep = CreateConVar("sm_extendmap_timestep", "15", "Specifies how much many more minutes each extension makes", _, true, 5.0);
  38.119 +	g_Cvar_ExtendRoundMax = CreateConVar("sm_extendmap_maxrounds", "30", "Specfies the maximum amount of rounds a map can be extended", _, true, 0.0);
  38.120 +	g_Cvar_ExtendRoundStep = CreateConVar("sm_extendmap_roundstep", "5", "Specifies how many more rounds each extension makes", _, true, 5.0);
  38.121 +	g_Cvar_ExtendFragMax = CreateConVar("sm_extendmap_maxfrags", "150", "Specfies the maximum frags allowed that a map can be extended.", _, true, 0.0);
  38.122 +	g_Cvar_ExtendFragStep = CreateConVar("sm_extendmap_fragstep", "10", "Specifies how many more frags are allowed when map is extended.", _, true, 5.0);	
  38.123 +	g_Cvar_Mapfile = CreateConVar("sm_mapvote_file", "configs/maps.ini", "Map file to use. (Def sourcemod/configs/maps.ini)");
  38.124 +	g_Cvar_ExcludeMaps = CreateConVar("sm_mapvote_exclude", "5", "Specifies how many past maps to exclude from the vote.", _, true, 0.0);
  38.125 +	g_Cvar_IncludeMaps = CreateConVar("sm_mapvote_include", "5", "Specifies how many maps to include in the vote.", _, true, 2.0, true, 6.0);
  38.126 +	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);
  38.127 +	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);
  38.128 +	
  38.129 +	// Find game convars
  38.130 +	g_Cvar_Chattime = FindConVar("mp_chattime");
  38.131 +	g_Cvar_Winlimit = FindConVar("mp_winlimit");
  38.132 +	g_Cvar_Maxrounds = FindConVar("mp_maxrounds");
  38.133 +	g_Cvar_Fraglimit = FindConVar("mp_fraglimit");	
  38.134 +
  38.135 +	if (GetCommandFlags("nextmap") == INVALID_FCVAR_FLAGS)
  38.136 +	{
  38.137 +		RegServerCmd("nextmap", Command_Nextmap);
  38.138 +	}
  38.139 +	
  38.140 +	// Hook events
  38.141 +	HookEvent("round_end", Event_RoundEnd);	// We always require round_end
  38.142 +	if (g_Cvar_Fraglimit != INVALID_HANDLE)
  38.143 +	{
  38.144 +		HookEvent("player_death", Event_PlayerDeath);		
  38.145 +	}	
  38.146 +	
  38.147 +	// Set to the current map so OnMapStart() will know what to do
  38.148 +	decl String:currentMap[64];
  38.149 +	GetCurrentMap(currentMap, 64);
  38.150 +	SetNextmap(currentMap);	
  38.151 +
  38.152 +	// Create necessary menus for TopMenu
  38.153 +	g_Menu_Map = CreateMenu(MenuHandler_Map);
  38.154 +	SetMenuTitle(g_Menu_Map, "Please select a map");
  38.155 +	SetMenuExitBackButton(g_Menu_Map, true);
  38.156 +	
  38.157 +	g_Menu_Votemap = CreateMenu(MenuHandler_VoteMap, MenuAction_DrawItem);
  38.158 +	SetMenuTitle(g_Menu_Votemap, "Please select a map");
  38.159 +	SetMenuExitBackButton(g_Menu_Votemap, true);	
  38.160 +	
  38.161 +	// Bind TopMenu commands to adminmenu_maplist.ini, in cases it doesn't exist in maplists.cfg
  38.162 +	decl String:mapListPath[PLATFORM_MAX_PATH];
  38.163 +	BuildPath(Path_SM, mapListPath, sizeof(mapListPath), "configs/adminmenu_maplist.ini");
  38.164 +	SetMapListCompatBind("sm_map menu", mapListPath);
  38.165 +	SetMapListCompatBind("sm_votemap menu", mapListPath);
  38.166 +
  38.167 +	// Account for late loading
  38.168 +	new Handle:topmenu;
  38.169 +	if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
  38.170 +	{
  38.171 +		OnAdminMenuReady(topmenu);
  38.172 +	}	
  38.173 +	
  38.174 +	AutoExecConfig(true, "mapmanager");
  38.175 +}
  38.176 +
  38.177 +public OnAdminMenuReady(Handle:topmenu)
  38.178 +{
  38.179 +	/* Block us from being called twice */
  38.180 +	if (topmenu == hTopMenu)
  38.181 +	{
  38.182 +		return;
  38.183 +	}
  38.184 +	
  38.185 +	/* Save the Handle */
  38.186 +	hTopMenu = topmenu;
  38.187 +	
  38.188 +	new TopMenuObject:server_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_SERVERCOMMANDS);
  38.189 +
  38.190 +	if (server_commands != INVALID_TOPMENUOBJECT)
  38.191 +	{
  38.192 +		AddToTopMenu(hTopMenu,
  38.193 +			"sm_map",
  38.194 +			TopMenuObject_Item,
  38.195 +			AdminMenu_Map,
  38.196 +			server_commands,
  38.197 +			"sm_map",
  38.198 +			ADMFLAG_CHANGEMAP);
  38.199 +	}
  38.200 +
  38.201 +	new TopMenuObject:voting_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_VOTINGCOMMANDS);
  38.202 +
  38.203 +	if (voting_commands != INVALID_TOPMENUOBJECT)
  38.204 +	{
  38.205 +		AddToTopMenu(hTopMenu,
  38.206 +			"sm_votemap",
  38.207 +			TopMenuObject_Item,
  38.208 +			AdminMenu_VoteMap,
  38.209 +			voting_commands,
  38.210 +			"sm_votemap",
  38.211 +			ADMFLAG_VOTE|ADMFLAG_CHANGEMAP);
  38.212 +	}
  38.213 +}
  38.214 +
  38.215 +public OnLibraryRemoved(const String:name[])
  38.216 +{
  38.217 +	if (strcmp(name, "adminmenu") == 0)
  38.218 +	{
  38.219 +		hTopMenu = INVALID_HANDLE;
  38.220 +	}
  38.221 +}
  38.222 +
  38.223 +public OnConfigsExecuted()
  38.224 +{
  38.225 +	// Add map logic here
  38.226 +	
  38.227 +	// Get the current and last maps.
  38.228 +	decl String:lastMap[64], String:currentMap[64];
  38.229 +	GetConVarString(g_Cvar_Nextmap, lastMap, 64);
  38.230 +	GetCurrentMap(currentMap, 64);
  38.231 +	
  38.232 +	// 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
  38.233 +	// some other plugin/command), we don't want to scramble the map cycle. Or for example, admin switches to a custom map
  38.234 +	// not in mapcyclefile. So we keep it set to the last expected nextmap. - ferret
  38.235 +	if (strcmp(lastMap, currentMap) == 0)
  38.236 +	{
  38.237 +		FindAndSetNextMap();
  38.238 +	}
  38.239 +	
  38.240 +	// Build map menus for sm_map, sm_votemap, and RTV.
  38.241 +	BuildMapMenu(g_Menu_Map, list);
  38.242 +	BuildMapMenu(g_Menu_VoteMap, list);
  38.243 +	
  38.244 +	// If the Randomize option is on, randomize!
  38.245 +	if (GetConVarBool(g_Cvar_Randomize))
  38.246 +	{
  38.247 +		CreateTimer(5.0, Timer_RandomizeNextmap);
  38.248 +	}
  38.249 +	
  38.250 +	// If MapChooser is active, start it up!
  38.251 +	if (GetConVarBool(g_Cvar_MapChooser))
  38.252 +	{
  38.253 +		SetupTimeleftTimer();
  38.254 +		SetConVarString(g_Cvar_Nextmap, "Pending Vote");
  38.255 +	}
  38.256 +	
  38.257 +	// If RockTheVote is active, start it up!
  38.258 +	if (GetConVarBool(g_Cvar_RockTheVote))
  38.259 +	{
  38.260 +		BuildMapMenu(g_Menu_RTV, list);
  38.261 +		CreateTimer(30.0, Timer_DelayRTV);
  38.262 +	}	
  38.263 +}
  38.264 +
  38.265 +// Reinitialize all our various globals
  38.266 +public OnMapStart()
  38.267 +{
  38.268 +	if (g_Nominate != INVALID_HANDLE)
  38.269 +	{
  38.270 +		ClearArray(g_Nominate);
  38.271 +	}
  38.272 +	
  38.273 +	if (g_TeamScores != INVALID_HANDLE)
  38.274 +	{
  38.275 +		ClearArray(g_TeamScores);
  38.276 +	}
  38.277 +
  38.278 +	g_TotalRounds = 0;	
  38.279 +	
  38.280 +	g_RTV_Voters = 0;
  38.281 +	g_RTV_Votes = 0;
  38.282 +	g_RTV_VotesNeeded = 0;
  38.283 +	g_RTV_Started = false;
  38.284 +	g_RTV_Ended = false;
  38.285 +}
  38.286 +
  38.287 +// Reset globals as necessary and kill timers
  38.288 +public OnMapEnd()
  38.289 +{
  38.290 +	g_IntermissionCalled = false;
  38.291 +	g_HasVoteStarted = false;
  38.292 +		
  38.293 +	g_RTV_Allowed = false;	
  38.294 +	
  38.295 +	if (g_VoteTimer != INVALID_HANDLE)
  38.296 +	{
  38.297 +		KillTimer(g_VoteTimer);
  38.298 +		g_VoteTimer = INVALID_HANDLE;
  38.299 +	}
  38.300 +	
  38.301 +	if (g_RetryTimer != INVALID_HANDLE)
  38.302 +	{
  38.303 +		KillTimer(g_RetryTimer);
  38.304 +		g_RetryTimer = INVALID_HANDLE;
  38.305 +	}
  38.306 +}
  38.307 +
  38.308 +public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
  38.309 +{
  38.310 +	if (IsFakeClient(client))
  38.311 +	{
  38.312 +		return true;
  38.313 +	}
  38.314 +	
  38.315 +	// If RTV is active, deal with vote counting.
  38.316 +	if (GetConVarBool(g_Cvar_RockTheVote))
  38.317 +	{
  38.318 +		g_RTV_Voted[client] = false;
  38.319 +		g_RTV_Voters++;
  38.320 +		g_RTV_VotesNeeded = RoundToFloor(float(g_Voters) * GetConVarFloat(g_Cvar_Needed));
  38.321 +	}
  38.322 +
  38.323 +	// If Nominate is active, let the new client nominate
  38.324 +	if (GetConVarBool(g_Cvar_Nominate))
  38.325 +	{
  38.326 +		g_Nominated[client] = false;
  38.327 +	}
  38.328 +	
  38.329 +	return true;
  38.330 +}
  38.331 +
  38.332 +public OnClientDisconnect(client)
  38.333 +{
  38.334 +	if (IsFakeClient(client))
  38.335 +	{
  38.336 +		return;
  38.337 +	}
  38.338 +	
  38.339 +	// If RTV is active, deal with vote counting.
  38.340 +	if (GetConVarBool(g_Cvar_RockTheVote))
  38.341 +	{
  38.342 +		if(g_RTV_Voted[client])
  38.343 +		{
  38.344 +			g_RTV_Votes--;
  38.345 +		}
  38.346 +
  38.347 +		g_RTV_Voters--;
  38.348 +		g_RTV_VotesNeeded = RoundToFloor(float(g_RTV_Voters) * GetConVarFloat(g_Cvar_RTVLimit));
  38.349 +		
  38.350 +		// If this client caused us to fall below the RTV threshold and its allowed be started, start it.	
  38.351 +		if (g_RTV_Votes && g_RTV_Voters && g_RTV_Votes >= g_RTV_VotesNeeded && g_RTV_Allowed && !g_RTV_Started) 
  38.352 +		{
  38.353 +			g_RTV_Started = true;
  38.354 +			CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
  38.355 +		}	
  38.356 +	}
  38.357 +}
  38.358 +
  38.359 +public OnMapTimeLeftChanged()
  38.360 +{
  38.361 +	if (GetConVarBool(g_Cvar_MapChooser))
  38.362 +	{
  38.363 +		SetupTimeleftTimer();
  38.364 +	}
  38.365 +}
  38.366 \ No newline at end of file
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/plugins/mapmanager/commands.sp	Wed Mar 26 03:52:37 2008 +0000
    39.3 @@ -0,0 +1,398 @@
    39.4 +/**
    39.5 + * vim: set ts=4 :
    39.6 + * =============================================================================
    39.7 + * SourceMod Map Manager Plugin
    39.8 + * Contains callbacks for commands
    39.9 + *
   39.10 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
   39.11 + * =============================================================================
   39.12 + *
   39.13 + * This program is free software; you can redistribute it and/or modify it under
   39.14 + * the terms of the GNU General Public License, version 3.0, as published by the
   39.15 + * Free Software Foundation.
   39.16 + * 
   39.17 + * This program is distributed in the hope that it will be useful, but WITHOUT
   39.18 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   39.19 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   39.20 + * details.
   39.21 + *
   39.22 + * You should have received a copy of the GNU General Public License along with
   39.23 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   39.24 + *
   39.25 + * As a special exception, AlliedModders LLC gives you permission to link the
   39.26 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   39.27 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   39.28 + * by the Valve Corporation.  You must obey the GNU General Public License in
   39.29 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   39.30 + * this exception to all derivative works.  AlliedModders LLC defines further
   39.31 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   39.32 + * or <http://www.sourcemod.net/license.php>.
   39.33 + *
   39.34 + * Version: $Id$
   39.35 + */
   39.36 + 
   39.37 + public Action:Command_Say(client, args)
   39.38 + {
   39.39 +	decl String:text[192];
   39.40 +	if (GetCmdArgString(text, sizeof(text)) < 1)
   39.41 +	{
   39.42 +		return Plugin_Continue;
   39.43 +	}
   39.44 +	
   39.45 +	new startidx;
   39.46 +	if (text[strlen(text)-1] == '"')
   39.47 +	{
   39.48 +		text[strlen(text)-1] = '\0';
   39.49 +		startidx = 1;
   39.50 +	}
   39.51 +	
   39.52 +	decl String:message[8];
   39.53 +	BreakString(text[startidx], message, sizeof(message));
   39.54 +	
   39.55 +	if (strcmp(message, "nextmap", false) == 0)
   39.56 +	{
   39.57 +		decl String:map[32];
   39.58 +		GetConVarString(g_Cvar_Nextmap, map, sizeof(map));
   39.59 +		
   39.60 +		PrintToChat(client, "%t", "Next Map", map);
   39.61 +	}
   39.62 +	else
   39.63 +	{
   39.64 +		if (GetConVarBool(g_Cvar_RockTheVote) && (strcmp(text[startidx], "rtv", false) == 0 || strcmp(text[startidx], "rockthevote", false) == 0))
   39.65 +		{
   39.66 +			if (g_MapChanged)
   39.67 +			{
   39.68 +				ReplyToCommand(client, "[SM] %t", "Map change in progress");
   39.69 +				return Plugin_Continue;
   39.70 +			}			
   39.71 +			
   39.72 +			if (!g_RTV_Allowed)
   39.73 +			{
   39.74 +				PrintToChat(client, "[SM] %t", "RTV Not Allowed");
   39.75 +				return Plugin_Continue;
   39.76 +			}
   39.77 +			
   39.78 +			if (g_RTV_Ended)
   39.79 +			{
   39.80 +				PrintToChat(client, "[SM] %t", "RTV Ended");
   39.81 +				return Plugin_Continue;
   39.82 +			}
   39.83 +			
   39.84 +			if (g_RTV_Started)
   39.85 +			{
   39.86 +				PrintToChat(client, "[SM] %t", "RTV Started");
   39.87 +				return Plugin_Continue;
   39.88 +			}
   39.89 +			
   39.90 +			if (GetClientCount(true) < GetConVarInt(g_Cvar_MinPlayers) && g_RTV_Votes == 0) // Should we keep checking g_Votes here?
   39.91 +			{
   39.92 +				PrintToChat(client, "[SM] %t", "Minimal Players Not Met");
   39.93 +				return Plugin_Continue;			
   39.94 +			}
   39.95 +			
   39.96 +			if (g_RTV_Voted[client])
   39.97 +			{
   39.98 +				PrintToChat(client, "[SM] %t", "Already Voted");
   39.99 +				return Plugin_Continue;
  39.100 +			}	
  39.101 +			
  39.102 +			new String:name[64];
  39.103 +			GetClientName(client, name, sizeof(name));
  39.104 +			
  39.105 +			g_RTV_Votes++;
  39.106 +			g_RTV_Voted[client] = true;
  39.107 +			
  39.108 +			PrintToChatAll("[SM] %t", "RTV Requested", name, g_RTV_Votes, g_RTV_VotesNeeded);
  39.109 +			
  39.110 +			if (g_RTV_Votes >= g_RTV_VotesNeeded)
  39.111 +			{
  39.112 +				g_RTV_Started = true;
  39.113 +				CreateTimer(2.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
  39.114 +			}
  39.115 +		}
  39.116 +		else if (GetConVarBool(g_Cvar_Nominate) && strcmp(text[startidx], "nominate", false) == 0)
  39.117 +		{
  39.118 +			if (g_MapChanged)
  39.119 +			{
  39.120 +				ReplyToCommand(client, "[SM] %t", "Map change in progress");
  39.121 +				return Plugin_Continue;
  39.122 +			}
  39.123 +			
  39.124 +			if (g_RTV_Started || g_HasVoteStarted)
  39.125 +			{
  39.126 +				ReplyToCommand(client, "[SM] %t", "Map vote in progress");
  39.127 +				return Plugin_Continue;				
  39.128 +			}
  39.129 +			
  39.130 +			if (g_Nominated[client])
  39.131 +			{
  39.132 +				PrintToChat(client, "[SM] %t", "Already Nominated");
  39.133 +				return Plugin_Continue;
  39.134 +			}
  39.135 +			
  39.136 +			if (GetArraySize(g_Nominate) >= GetConVarInt(g_Cvar_Maps))
  39.137 +			{
  39.138 +				PrintToChat(client, "[SM] %t", "Max Nominations");
  39.139 +				return Plugin_Continue;			
  39.140 +			}
  39.141 +			
  39.142 +			DisplayMenu(g_Menu_Nominate, client, MENU_TIME_FOREVER);		
  39.143 +		}		
  39.144 +	}
  39.145 +	
  39.146 +	return Plugin_Continue;	
  39.147 +}
  39.148 +
  39.149 +public Action:Command_Mapvote(client, args)
  39.150 +{
  39.151 +	InitiateVote();
  39.152 +
  39.153 +	return Plugin_Handled;	
  39.154 +}
  39.155 + 
  39.156 +public Action:Command_Nextmap(args)
  39.157 +{
  39.158 +	decl String:map[64];
  39.159 +	
  39.160 +	GetConVarString(g_Cvar_Nextmap, map, sizeof(map));
  39.161 +	
  39.162 +	ReplyToCommand(0, "%t", "Next Map", map);
  39.163 +	
  39.164 +	return Plugin_Handled;
  39.165 +} 
  39.166 + 
  39.167 +public Action:Command_List(client, args) 
  39.168 +{
  39.169 +	PrintToConsole(client, "Map Cycle:");
  39.170 +	
  39.171 +	decl String:currentMap[64];
  39.172 +	GetCurrentMap(currentMap, 64);	
  39.173 +	
  39.174 +	decl String:mapName[64];
  39.175 +	for (new i = 0; i < GetArraySize(g_MapCycle); i++)
  39.176 +	{
  39.177 +		GetArrayString(g_MapCycle, i, mapName, sizeof(mapName));
  39.178 +		if (strcmp(mapName, currentMap) == 0)
  39.179 +		{
  39.180 +			PrintToConsole(client, "%s <========= Current map", mapName);
  39.181 +		}
  39.182 +		else if (strcmp(mapName, g_NextMap) == 0)
  39.183 +		{
  39.184 +			PrintToConsole(client, "%s <========= Next map", mapName);
  39.185 +		}
  39.186 +		else
  39.187 +		{
  39.188 +			PrintToConsole(client, "%s", mapName);
  39.189 +		}
  39.190 +	}
  39.191 + 
  39.192 +	return Plugin_Handled;
  39.193 +} 
  39.194 +
  39.195 +public Action:Command_SetNextmap(client, args)
  39.196 +{
  39.197 +	if (args < 1)
  39.198 +	{
  39.199 +		ReplyToCommand(client, "[SM] Usage: sm_setnextmap <map>");
  39.200 +		return Plugin_Handled;
  39.201 +	}
  39.202 +	
  39.203 +	if (g_MapChanged)
  39.204 +	{
  39.205 +		ReplyToCommand(client, "[SM] %t", "Map change in progress");
  39.206 +		return Plugin_Handled;
  39.207 +	}	
  39.208 +
  39.209 +	decl String:map[64];
  39.210 +	GetCmdArg(1, map, sizeof(map));
  39.211 +
  39.212 +	if (!IsMapValid(map))
  39.213 +	{
  39.214 +		ReplyToCommand(client, "[SM] %t", "Map was not found", map);
  39.215 +		return Plugin_Handled;
  39.216 +	}
  39.217 +
  39.218 +	ShowActivity(client, "%t", "Cvar changed", "sm_nextmap", map);
  39.219 +	LogMessage("\"%L\" changed sm_nextmap to \"%s\"", client, map);
  39.220 +
  39.221 +	SetNextMap(map);
  39.222 +
  39.223 +	return Plugin_Handled;
  39.224 +}
  39.225 + 
  39.226 + public Action:Command_Map(client, args)
  39.227 + {
  39.228 +	if (args < 1)
  39.229 +	{
  39.230 +		ReplyToCommand(client, "[SM] Usage: sm_map <map> [r/e]");
  39.231 +		return Plugin_Handled;
  39.232 +	}
  39.233 +	
  39.234 +	if (g_MapChanged)
  39.235 +	{
  39.236 +		ReplyToCommand(client, "[SM] %t", "Map change in progress");
  39.237 +		return Plugin_Handled;
  39.238 +	}
  39.239 + 
  39.240 +	decl String:map[64];
  39.241 +	GetCmdArg(1, map, sizeof(map));
  39.242 + 
  39.243 +	if (!IsMapValid(map))
  39.244 +	{
  39.245 +		ReplyToCommand(client, "[SM] %t", "Map was not found", map);
  39.246 +		return Plugin_Handled;
  39.247 +	}
  39.248 +	
  39.249 +	decl String:when[2];
  39.250 +	if (args > 1)
  39.251 +	{
  39.252 +		GetCmdArg(2, when, sizeof(when));
  39.253 +		
  39.254 +		when[0] = CharToLower(when[0]);
  39.255 +		if (when[0] != 'r' && when[0] != 'e')
  39.256 +		{
  39.257 +			when[0] = 'i';
  39.258 +		}	
  39.259 +	}
  39.260 +	
  39.261 +	SetMapChange(client, map, when);
  39.262 + 
  39.263 +	return Plugin_Handled;
  39.264 +}
  39.265 +
  39.266 +public Action:Command_Votemap(client, args)
  39.267 +{
  39.268 +	if (args < 1)
  39.269 +	{
  39.270 +		ReplyToCommand(client, "[SM] Usage: sm_votemap [r/e] <mapname> [mapname2] ... [mapname5]");
  39.271 +		return Plugin_Handled;	
  39.272 +	}
  39.273 +	
  39.274 +	if (g_MapChanged)
  39.275 +	{
  39.276 +		ReplyToCommand(client, "[SM] %t", "Map change in progress");
  39.277 +		return Plugin_Handled;
  39.278 +	}	
  39.279 +	
  39.280 +	if (IsVoteInProgress())
  39.281 +	{
  39.282 +		ReplyToCommand(client, "[SM] %t", "Vote in Progress");
  39.283 +		return Plugin_Handled;
  39.284 +	}
  39.285 +		
  39.286 +	if (!TestVoteDelay(client))
  39.287 +	{
  39.288 +		return Plugin_Handled;
  39.289 +	}
  39.290 +	
  39.291 +	decl String:text[256];
  39.292 +	GetCmdArgString(text, sizeof(text));
  39.293 +
  39.294 +	decl String:maps[5][64];
  39.295 +	new mapCount;	
  39.296 +	new len, pos;
  39.297 +
  39.298 +	// Find out if the user specified "when"
  39.299 +	decl String:when[64];
  39.300 +	pos = BreakString(text[len], when, sizeof(when));
  39.301 +	if (!IsMapValid(when))
  39.302 +	{
  39.303 +		when[0] = CharToLower(when[0]);
  39.304 +		if (when[0] != 'r' && when[0] != 'e')
  39.305 +		{
  39.306 +			ReplyToCommand(client, "[SM] %t", "Map was not found", maps[mapCount]);
  39.307 +			return Plugin_Handled;
  39.308 +		}
  39.309 +	}
  39.310 +	else
  39.311 +	{
  39.312 +		strcpy(maps[mapCount], sizeof(maps[]), when);
  39.313 +		mapCount++;
  39.314 +		when[0] = 'i';
  39.315 +	}
  39.316 +	
  39.317 +	len += pos;
  39.318 +	
  39.319 +	while (pos != -1 && mapCount < 5)
  39.320 +	{	
  39.321 +		pos = BreakString(text[len], maps[mapCount], sizeof(maps[]));
  39.322 +		
  39.323 +		if (!IsMapValid(maps[mapCount]))
  39.324 +		{
  39.325 +			ReplyToCommand(client, "[SM] %t", "Map was not found", maps[mapCount]);
  39.326 +			return Plugin_Handled;
  39.327 +		}		
  39.328 +
  39.329 +		mapCount++;
  39.330 +		
  39.331 +		len += pos;
  39.332 +	}
  39.333 +
  39.334 +	g_VoteMapInUse = client;
  39.335 +	g_Client_Data[client][0] = when[0];
  39.336 +
  39.337 +	DisplayVoteMapMenu(client, mapCount, maps);
  39.338 +	
  39.339 +	return Plugin_Handled;	
  39.340 +}
  39.341 +
  39.342 +public Action:Command_Nominate(client, args)
  39.343 +{
  39.344 +	if (args < 1)
  39.345 +	{
  39.346 +		ReplyToCommand(client, "[SM] Usage: sm_nominate <mapname>");
  39.347 +		return Plugin_Handled;
  39.348 +	}
  39.349 +	
  39.350 +	if (!GetConVarBool(g_Cvar_Nominate))
  39.351 +	{
  39.352 +		ReplyToCommand(client, "[SM] Nominations are currently disabled.");
  39.353 +		return Plugin_Handled;
  39.354 +	}
  39.355 +	
  39.356 +	decl String:mapname[64];
  39.357 +	GetCmdArg(1, mapname, sizeof(mapname));
  39.358 +
  39.359 +	if (FindStringInArray(g_MapList, mapname) == -1)
  39.360 +	{
  39.361 +		ReplyToCommand(client, "%t", "Map was not found", mapname);
  39.362 +		return Plugin_Handled;
  39.363 +	}
  39.364 +	
  39.365 +	if (GetArraySize(g_Nominated) > 0)
  39.366 +	{
  39.367 +		if (FindStringInArray(g_Nominated, mapname) != -1)
  39.368 +		{
  39.369 +			ReplyToCommand(client, "%t", "Map Already In Vote", mapname);
  39.370 +			return Plugin_Handled;				
  39.371 +		}
  39.372 +		
  39.373 +		ShiftArrayUp(g_Nominated, 0);
  39.374 +		SetArrayString(g_Nominated, 0, mapname);
  39.375 +		
  39.376 +		while (GetArraySize(g_Nominated) > GetConVarInt(g_Cvar_Maps))
  39.377 +		{
  39.378 +			RemoveFromArray(g_Nominated, GetConVarInt(g_Cvar_Maps));
  39.379 +		}
  39.380 +	}
  39.381 +	else
  39.382 +	{
  39.383 +		PushArrayString(g_Nominated, mapname);
  39.384 +	}
  39.385 +		
  39.386 +	decl String:item[64];
  39.387 +	for (new i = 0; i < GetMenuItemCount(g_Menu_Nominate); i++)
  39.388 +	{
  39.389 +		GetMenuItem(g_Menu_Nominate, i, item, sizeof(item));
  39.390 +		if (strcmp(item, mapname) == 0)
  39.391 +		{
  39.392 +			RemoveMenuItem(g_Menu_Nominate, i);
  39.393 +			break;
  39.394 +		}			
  39.395 +	}	
  39.396 +	
  39.397 +	ReplyToCommand(client, "%t", "Map Inserted", mapname);
  39.398 +	LogAction(client, -1, "\"%L\" inserted map \"%s\".", client, mapname);
  39.399 +
  39.400 +	return Plugin_Handled;		
  39.401 +}
  39.402 \ No newline at end of file
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/plugins/mapmanager/events.sp	Wed Mar 26 03:52:37 2008 +0000
    40.3 @@ -0,0 +1,166 @@
    40.4 +/**
    40.5 + * vim: set ts=4 :
    40.6 + * =============================================================================
    40.7 + * SourceMod Map Manager Plugin
    40.8 + * Contains event callbacks
    40.9 + *
   40.10 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
   40.11 + * =============================================================================
   40.12 + *
   40.13 + * This program is free software; you can redistribute it and/or modify it under
   40.14 + * the terms of the GNU General Public License, version 3.0, as published by the
   40.15 + * Free Software Foundation.
   40.16 + * 
   40.17 + * This program is distributed in the hope that it will be useful, but WITHOUT
   40.18 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   40.19 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   40.20 + * details.
   40.21 + *
   40.22 + * You should have received a copy of the GNU General Public License along with
   40.23 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   40.24 + *
   40.25 + * As a special exception, AlliedModders LLC gives you permission to link the
   40.26 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   40.27 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   40.28 + * by the Valve Corporation.  You must obey the GNU General Public License in
   40.29 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   40.30 + * this exception to all derivative works.  AlliedModders LLC defines further
   40.31 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   40.32 + * or <http://www.sourcemod.net/license.php>.
   40.33 + *
   40.34 + * Version: $Id$
   40.35 + */
   40.36 +
   40.37 +public Action:UserMsg_VGUIMenu(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
   40.38 +{
   40.39 +	if (g_IntermissionCalled)
   40.40 +	{
   40.41 +		return Plugin_Handled;
   40.42 +	}
   40.43 +	
   40.44 +	decl String:type[15];
   40.45 +
   40.46 +	/* If we don't get a valid string, bail out. */
   40.47 +	if (BfReadString(bf, type, sizeof(type)) < 0)
   40.48 +	{
   40.49 +		return Plugin_Handled;
   40.50 +	}
   40.51 + 
   40.52 +	if (BfReadByte(bf) == 1 && BfReadByte(bf) == 0 && (strcmp(type, "scores", false) == 0))
   40.53 +	{
   40.54 +		g_IntermissionCalled = true;
   40.55 +		
   40.56 +		decl String:map[32];
   40.57 +		new Float:fChatTime = GetConVarFloat(g_Cvar_Chattime);
   40.58 +		
   40.59 +		if (fChatTime < 2.0)
   40.60 +		{
   40.61 +			SetConVarFloat(g_Cvar_Chattime, 2.0);
   40.62 +		}
   40.63 +		
   40.64 +		LogMessage("[MapManager] Changing map to '%s' due to map ending.", g_NextMap);
   40.65 +		
   40.66 +		g_MapChanged = true;
   40.67 +		CreateTimer(fChatTime - 1.0, Timer_ChangeMap);		
   40.68 +	}
   40.69 +	
   40.70 +	return Plugin_Handled;
   40.71 +}
   40.72 +
   40.73 +public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
   40.74 +{
   40.75 +	if (g_MapChanged)
   40.76 +	{
   40.77 +		return;
   40.78 +	}
   40.79 +	
   40.80 +	if (g_MapChangeSet && g_MapChangeWhen == 'r')
   40.81 +	{
   40.82 +		LogMessage("[MapManager] Changing map to '%s' due to round ending.", g_NextMap);
   40.83 +		
   40.84 +		g_MapChanged = true;
   40.85 +		CreateTimer(1.0, Timer_ChangeMap);
   40.86 +		
   40.87 +		return;
   40.88 +	}
   40.89 +	
   40.90 +	if (g_HasVoteStarted)
   40.91 +	{
   40.92 +		return;
   40.93 +	}
   40.94 +
   40.95 +	new winner = GetEventInt(event, "winner");
   40.96 +	
   40.97 +	if (winner == 0 || winner == 1)
   40.98 +	{
   40.99 +		return;
  40.100 +	}
  40.101 +
  40.102 +	g_TotalRounds++;
  40.103 +	
  40.104 +	new team[2], teamPos = -1;
  40.105 +	for (new i; i < GetArraySize(g_TeamScores); i++)
  40.106 +	{
  40.107 +		GetArrayArray(g_TeamScores, i, team);
  40.108 +		if (team[0] == winner)
  40.109 +		{
  40.110 +			teamPos = i;
  40.111 +			break;
  40.112 +		}		
  40.113 +	}
  40.114 +	
  40.115 +	if (teamPos == -1)
  40.116 +	{
  40.117 +		team[0] = winner;
  40.118 +		team[1] = 1;
  40.119 +		PushArrayArray(g_TeamScores, team);
  40.120 +	}
  40.121 +	else
  40.122 +	{
  40.123 +		team[1]++;
  40.124 +		SetArrayArray(g_TeamScores, teamPos, team);
  40.125 +	}	
  40.126 +	
  40.127 +	if (g_Cvar_Winlimit != INVALID_HANDLE)
  40.128 +	{
  40.129 +		new winlimit = GetConVarInt(g_Cvar_Winlimit);
  40.130 +		if (winlimit)
  40.131 +		{
  40.132 +			if (team[1] >= (winlimit - GetConVarInt(g_Cvar_StartRounds)))
  40.133 +			{
  40.134 +				InitiateVote();
  40.135 +			}
  40.136 +		}
  40.137 +	}
  40.138 +	
  40.139 +	if (g_Cvar_Maxrounds != INVALID_HANDLE)
  40.140 +	{
  40.141 +		new maxrounds = GetConVarInt(g_Cvar_Maxrounds);
  40.142 +		if (maxrounds)
  40.143 +		{
  40.144 +			if (g_TotalRounds >= (maxrounds - GetConVarInt(g_Cvar_StartRounds)))
  40.145 +			{
  40.146 +				InitiateVote();
  40.147 +			}			
  40.148 +		}
  40.149 +	}
  40.150 +}
  40.151 +
  40.152 +public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
  40.153 +{
  40.154 +	if (g_MapChanged || g_HasVoteStarted || g_Cvar_Fraglimit == INVALID_HANDLE)
  40.155 +	{
  40.156 +		return;
  40.157 +	}
  40.158 +	
  40.159 +	if (!GetConVarInt(g_Cvar_Fraglimit))
  40.160 +	{
  40.161 +		return;
  40.162 +	}
  40.163 +
  40.164 +	new fragger = GetClientOfUserId(GetEventInt(event, "attacker"));
  40.165 +	if (fragger && GetClientFrags(fragger) >= (GetConVarInt(g_Cvar_Fraglimit) - GetConVarInt(g_Cvar_StartFrags)))
  40.166 +	{
  40.167 +		InitiateVote();
  40.168 +	}
  40.169 +}
  40.170 \ No newline at end of file
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/plugins/mapmanager/functions.sp	Wed Mar 26 03:52:37 2008 +0000
    41.3 @@ -0,0 +1,335 @@
    41.4 +/**
    41.5 + * vim: set ts=4 :
    41.6 + * =============================================================================
    41.7 + * SourceMod Map Management Plugin
    41.8 + * Contains misc functions.
    41.9 + *
   41.10 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
   41.11 + * =============================================================================
   41.12 + *
   41.13 + * This program is free software; you can redistribute it and/or modify it under
   41.14 + * the terms of the GNU General Public License, version 3.0, as published by the
   41.15 + * Free Software Foundation.
   41.16 + * 
   41.17 + * This program is distributed in the hope that it will be useful, but WITHOUT
   41.18 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   41.19 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   41.20 + * details.
   41.21 + *
   41.22 + * You should have received a copy of the GNU General Public License along with
   41.23 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   41.24 + *
   41.25 + * As a special exception, AlliedModders LLC gives you permission to link the
   41.26 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   41.27 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   41.28 + * by the Valve Corporation.  You must obey the GNU General Public License in
   41.29 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   41.30 + * this exception to all derivative works.  AlliedModders LLC defines further
   41.31 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   41.32 + * or <http://www.sourcemod.net/license.php>.
   41.33 + *
   41.34 + * Version: $Id$
   41.35 + */
   41.36 +
   41.37 +SetNextMap(String:map[])
   41.38 +{
   41.39 +	strcopy(g_NextMap, sizeof(g_NextMap), map);
   41.40 +	SetConVarString(g_Cvar_Nextmap, map);
   41.41 +}
   41.42 +
   41.43 +SetMapChange(client, map, when, Float:time = 3.0)
   41.44 +{
   41.45 +	g_MapChangeSet = true;
   41.46 +	g_MapChangeWhen = when[0];
   41.47 +	SetNextMap(map);
   41.48 + 
   41.49 +	if (when[0] == 'r')
   41.50 +	{
   41.51 + 		ShowActivity2(client, "[SM] ", "%t", "Changing map end of round", map);
   41.52 + 		LogAction(client, -1, "\"%L\" set end of round map change to \"%s\"", client, map);
   41.53 +	}
   41.54 +	else if (when[0] == 'e')
   41.55 +	{
   41.56 +		ShowActivity2(client, "[SM] ", "%t", "Set nextmap", map);
   41.57 +		LogAction(client, -1, "\"%L\" set the next map to \"%s\"", client, map);
   41.58 +	}
   41.59 +	else
   41.60 +	{
   41.61 +		ShowActivity2(client, "[SM] ", "%t", "Change map", map);
   41.62 +		LogAction(client, -1, "\"%L\" changed map to \"%s\"", client, map);
   41.63 +		
   41.64 +		g_MapChanged = true;
   41.65 +	 	CreateTimer(3.0, Timer_ChangeMap);
   41.66 +	}
   41.67 +}
   41.68 +
   41.69 +FindAndSetNextMap()
   41.70 +{
   41.71 +	if (ReadMapList(g_MapList, 
   41.72 +			g_MapListSerial, 
   41.73 +			"mapcyclefile", 
   41.74 +			MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_NO_DEFAULT)
   41.75 +		== INVALID_HANDLE)
   41.76 +	{
   41.77 +		if (g_MapListSerial == -1)
   41.78 +		{
   41.79 +			LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
   41.80 +			SetFailState("Mapcycle Not Found");
   41.81 +		}
   41.82 +	}
   41.83 +	
   41.84 +	new mapCount = GetArraySize(g_MapList);
   41.85 +	decl String:mapName[32];
   41.86 +	
   41.87 +	if (g_MapPos == -1)
   41.88 +	{
   41.89 +		decl String:current[64];
   41.90 +		GetCurrentMap(current, 64);
   41.91 +
   41.92 +		for (new i = 0; i < mapCount; i++)
   41.93 +		{
   41.94 +			GetArrayString(g_MapList, i, mapName, sizeof(mapName));
   41.95 +			if (strcmp(current, mapName, false) == 0)
   41.96 +			{
   41.97 +				g_MapPos = i;
   41.98 +				break;
   41.99 +			}
  41.100 +		}
  41.101 +		
  41.102 +		if (g_MapPos == -1)
  41.103 +			g_MapPos = 0;
  41.104 +	}
  41.105 +	
  41.106 +	g_MapPos++;
  41.107 +	if (g_MapPos >= mapCount)
  41.108 +		g_MapPos = 0;	
  41.109 + 
  41.110 + 	GetArrayString(g_MapList, g_MapPos, mapName, sizeof(mapName));
  41.111 +	SetConVarString(g_Cvar_Nextmap, mapName);
  41.112 +}
  41.113 +
  41.114 +Float:GetVotePercent(votes, totalVotes)
  41.115 +{
  41.116 +	return FloatDiv(float(votes),float(totalVotes));
  41.117 +}
  41.118 +
  41.119 +bool:TestVoteDelay(client)
  41.120 +{
  41.121 + 	new delay = CheckVoteDelay();
  41.122 + 	
  41.123 + 	if (delay > 0)
  41.124 + 	{
  41.125 + 		if (delay > 60)
  41.126 + 		{
  41.127 + 			ReplyToCommand(client, "[SM] %t", "Vote Delay Minutes", delay % 60);
  41.128 + 		}
  41.129 + 		else
  41.130 + 		{
  41.131 + 			ReplyToCommand(client, "[SM] %t", "Vote Delay Seconds", delay);
  41.132 + 		}
  41.133 + 		
  41.134 + 		return false;
  41.135 + 	}
  41.136 + 	
  41.137 +	return true;
  41.138 +}
  41.139 +
  41.140 +BuildMapMenu()
  41.141 +{
  41.142 +	if (g_MapMenu != INVALID_HANDLE)
  41.143 +	{
  41.144 +		CloseHandle(g_MapMenu);
  41.145 +		g_MapMenu = INVALID_HANDLE;
  41.146 +	}
  41.147 +	
  41.148 +	g_MapMenu = CreateMenu(Handler_MapSelectMenu);
  41.149 +	SetMenuTitle(g_MapMenu, "%t", "Nominate Title");
  41.150 +
  41.151 +	decl String:map[64];		
  41.152 +	for (new i = 0; i < GetArraySize(g_MapList); i++)
  41.153 +	{
  41.154 +		GetArrayString(g_MapList, i, map, sizeof(map));
  41.155 +		AddMenuItem(g_MapMenu, map, map);
  41.156 +	}
  41.157 +	
  41.158 +	SetMenuExitButton(g_MapMenu, false);
  41.159 +}
  41.160 +
  41.161 +SetupTimeleftTimer()
  41.162 +{
  41.163 +	new time;
  41.164 +	if (GetMapTimeLeft(time) && time > 0)
  41.165 +	{
  41.166 +		new startTime = GetConVarInt(g_Cvar_StartTime) * 60;
  41.167 +		if (time - startTime < 0)
  41.168 +		{
  41.169 +			InitiateVote();		
  41.170 +		}
  41.171 +		else
  41.172 +		{
  41.173 +			if (g_VoteTimer != INVALID_HANDLE)
  41.174 +			{
  41.175 +				KillTimer(g_VoteTimer);
  41.176 +				g_VoteTimer = INVALID_HANDLE;
  41.177 +			}	
  41.178 +			
  41.179 +			g_VoteTimer = CreateTimer(float(time - startTime), Timer_StartMapVote);
  41.180 +		}		
  41.181 +	}
  41.182 +}
  41.183 +
  41.184 +InitiateVote()
  41.185 +{
  41.186 +	if (g_HasVoteStarted || g_RetryTimer != INVALID_HANDLE)
  41.187 +	{
  41.188 +		return;
  41.189 +	}
  41.190 +	
  41.191 +	if (IsVoteInProgress())
  41.192 +	{
  41.193 +		// Can't start a vote, try again in 5 seconds.
  41.194 +		g_RetryTimer = CreateTimer(5.0, Timer_StartMapVote);
  41.195 +		return;
  41.196 +	}		
  41.197 +	
  41.198 +	g_HasVoteStarted = true;
  41.199 +	g_VoteMenu = CreateMenu(Handler_MapVoteMenu, MenuAction:MENU_ACTIONS_ALL);
  41.200 +	SetMenuTitle(g_VoteMenu, "Vote Nextmap");
  41.201 +
  41.202 +	decl String:map[32];
  41.203 +	for (new i = 0; i < GetArraySize(g_NextMapList); i++)
  41.204 +	{
  41.205 +		GetArrayString(g_NextMapList, i, map, sizeof(map));
  41.206 +		AddMenuItem(g_VoteMenu, map, map);
  41.207 +	}
  41.208 +
  41.209 +	if (GetConVarBool(g_Cvar_Extend))
  41.210 +	{
  41.211 +		new bool:allowExtend, time;
  41.212 +		if (GetMapTimeLimit(time) && time > 0 && time < GetConVarInt(g_Cvar_ExtendTimeMax))
  41.213 +		{
  41.214 +			allowExtend = true;
  41.215 +		}
  41.216 +
  41.217 +		if (g_Cvar_Winlimit != INVALID_HANDLE && GetConVarInt(g_Cvar_Winlimit) < GetConVarInt(g_Cvar_ExtendRoundMax))
  41.218 +		{
  41.219 +			allowExtend = true;
  41.220 +		}	
  41.221 +	
  41.222 +		if (g_Cvar_Maxrounds != INVALID_HANDLE && GetConVarInt(g_Cvar_Maxrounds) < GetConVarInt(g_Cvar_ExtendRoundMax))
  41.223 +		{
  41.224 +			allowExtend = true;
  41.225 +		}
  41.226 +	
  41.227 +		if (g_Cvar_Fraglimit != INVALID_HANDLE && GetConVarInt(g_Cvar_Fraglimit) < GetConVarInt(g_Cvar_ExtendFragMax))
  41.228 +		{
  41.229 +			allowExtend = true;
  41.230 +		}
  41.231 +
  41.232 +		if (allowExtend)
  41.233 +		{
  41.234 +			AddMenuItem(g_VoteMenu, VOTE_EXTEND, "Extend Map");
  41.235 +		}
  41.236 +	}
  41.237 +
  41.238 +	SetMenuExitButton(g_VoteMenu, false);
  41.239 +	VoteMenuToAll(g_VoteMenu, 20);
  41.240 +
  41.241 +	LogMessage("Voting for next map has started.");
  41.242 +	PrintToChatAll("[SM] %t", "Nextmap Voting Started");
  41.243 +}
  41.244 +
  41.245 +SetNextMap(const String:map[])
  41.246 +{
  41.247 +	SetConVarString(g_Cvar_Nextmap, map);
  41.248 +	PushArrayString(g_OldMapList, map);
  41.249 +				
  41.250 +	if (GetArraySize(g_OldMapList) > GetConVarInt(g_Cvar_ExcludeMaps))
  41.251 +	{
  41.252 +		RemoveFromArray(g_OldMapList, 0);
  41.253 +	}
  41.254 +		
  41.255 +	PrintToChatAll("[SM] %t", "Nextmap Voting Finished", map);
  41.256 +	LogMessage("Voting for next map has finished. Nextmap: %s.", map);	
  41.257 +}
  41.258 +
  41.259 +CreateNextVote()
  41.260 +{
  41.261 +	if(g_NextMapList != INVALID_HANDLE)
  41.262 +	{
  41.263 +		ClearArray(g_NextMapList);
  41.264 +	}
  41.265 +	
  41.266 +	decl String:map[32];
  41.267 +	new index, Handle:tempMaps  = CloneArray(g_MapList);
  41.268 +	
  41.269 +	GetCurrentMap(map, sizeof(map));
  41.270 +	index = FindStringInArray(tempMaps, map);
  41.271 +	if (index != -1)
  41.272 +	{
  41.273 +		RemoveFromArray(tempMaps, index);
  41.274 +	}	
  41.275 +	
  41.276 +	if (GetConVarInt(g_Cvar_ExcludeMaps) && GetArraySize(tempMaps) > GetConVarInt(g_Cvar_ExcludeMaps))
  41.277 +	{
  41.278 +		for (new i = 0; i < GetArraySize(g_OldMapList); i++)
  41.279 +		{
  41.280 +			GetArrayString(g_OldMapList, i, map, sizeof(map));
  41.281 +			index = FindStringInArray(tempMaps, map);
  41.282 +			if (index != -1)
  41.283 +			{
  41.284 +				RemoveFromArray(tempMaps, index);
  41.285 +			}
  41.286 +		}	
  41.287 +	}
  41.288 +
  41.289 +	new limit = (GetConVarInt(g_Cvar_IncludeMaps) < GetArraySize(tempMaps) ? GetConVarInt(g_Cvar_IncludeMaps) : GetArraySize(tempMaps));
  41.290 +	for (new i = 0; i < limit; i++)
  41.291 +	{
  41.292 +		new b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
  41.293 +		GetArrayString(tempMaps, b, map, sizeof(map));		
  41.294 +		PushArrayString(g_NextMapList, map);
  41.295 +		RemoveFromArray(tempMaps, b);
  41.296 +	}
  41.297 +	
  41.298 +	CloseHandle(tempMaps);
  41.299 +}
  41.300 +
  41.301 +/*
  41.302 +
  41.303 +new Handle:g_map_array = INVALID_HANDLE;
  41.304 +new g_map_serial = -1;
  41.305 +
  41.306 +LoadMapList(Handle:menu)
  41.307 +{
  41.308 +	new Handle:map_array;
  41.309 +	
  41.310 +	if ((map_array = ReadMapList(g_map_array,
  41.311 +			g_map_serial,
  41.312 +			"sm_map menu",
  41.313 +			MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_NO_DEFAULT|MAPLIST_FLAG_MAPSFOLDER))
  41.314 +		!= INVALID_HANDLE)
  41.315 +	{
  41.316 +		g_map_array = map_array;
  41.317 +	}
  41.318 +	
  41.319 +	if (g_map_array == INVALID_HANDLE)
  41.320 +	{
  41.321 +		return 0;
  41.322 +	}
  41.323 +	
  41.324 +	RemoveAllMenuItems(menu);
  41.325 +	
  41.326 +	decl String:map_name[64];
  41.327 +	new map_count = GetArraySize(g_map_array);
  41.328 +	
  41.329 +	for (new i = 0; i < map_count; i++)
  41.330 +	{
  41.331 +		GetArrayString(g_map_array, i, map_name, sizeof(map_name));
  41.332 +		AddMenuItem(menu, map_name, map_name);
  41.333 +	}
  41.334 +	
  41.335 +	return map_count;
  41.336 +}
  41.337 +
  41.338 +*/
  41.339 \ No newline at end of file
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/plugins/mapmanager/functions_menu.sp	Wed Mar 26 03:52:37 2008 +0000
    42.3 @@ -0,0 +1,115 @@
    42.4 +/**
    42.5 + * vim: set ts=4 :
    42.6 + * =============================================================================
    42.7 + * SourceMod Map Management Plugin
    42.8 + * Contains misc functions.
    42.9 + *
   42.10 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
   42.11 + * =============================================================================
   42.12 + *
   42.13 + * This program is free software; you can redistribute it and/or modify it under
   42.14 + * the terms of the GNU General Public License, version 3.0, as published by the
   42.15 + * Free Software Foundation.
   42.16 + * 
   42.17 + * This program is distributed in the hope that it will be useful, but WITHOUT
   42.18 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   42.19 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   42.20 + * details.
   42.21 + *
   42.22 + * You should have received a copy of the GNU General Public License along with
   42.23 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   42.24 + *
   42.25 + * As a special exception, AlliedModders LLC gives you permission to link the
   42.26 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   42.27 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   42.28 + * by the Valve Corporation.  You must obey the GNU General Public License in
   42.29 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   42.30 + * this exception to all derivative works.  AlliedModders LLC defines further
   42.31 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   42.32 + * or <http://www.sourcemod.net/license.php>.
   42.33 + *
   42.34 + * Version: $Id$
   42.35 + */
   42.36 +
   42.37 +DisplayWhenMenu(client, bool:vote = false)
   42.38 +{
   42.39 +	new Handle:
   42.40 +	
   42.41 +	if (!vote)
   42.42 +	{
   42.43 +		menu = CreateMenu(MenuHandler_ChangeMap);
   42.44 +	}
   42.45 +	else
   42.46 +	{
   42.47 +		menu = CreateMenu(MenuHandler_VoteWhen);
   42.48 +	}
   42.49 +	
   42.50 +	decl String:title[100];
   42.51 +	Format(title, sizeof(title), "%T:", "Map Change When", client);
   42.52 +	SetMenuTitle(menu, title);
   42.53 +	SetMenuExitBackButton(menu, true);
   42.54 +	
   42.55 +	AddMenuItem(menu, "i", "Immediately");
   42.56 +	AddMenuItem(menu, "r", "Round End");
   42.57 +	AddMenuItem(menu, "e", "Map End");
   42.58 +	
   42.59 +	DisplayMenu(menu, client, MENU_TIME_FOREVER);	
   42.60 +}
   42.61 +
   42.62 +DisplayConfirmVoteMenu(client)
   42.63 +{
   42.64 +	new Handle:menu = CreateMenu(MenuHandler_Confirm);
   42.65 +	
   42.66 +	decl String:title[100];
   42.67 +	Format(title, sizeof(title), "%T:", "Confirm Vote", client);
   42.68 +	SetMenuTitle(menu, title);
   42.69 +	SetMenuExitBackButton(menu, true);
   42.70 +	
   42.71 +	AddMenuItem(menu, "Confirm", "Start the Vote");
   42.72 +	
   42.73 +	DisplayMenu(menu, client, MENU_TIME_FOREVER);	
   42.74 +}
   42.75 +
   42.76 +DisplayAcceptVoteMenu(String:map[])
   42.77 +{
   42.78 +	new Handle:menu = CreateMenu(MenuHandler_Accept);
   42.79 +	
   42.80 +	decl String:title[100];
   42.81 +	Format(title, sizeof(title), "%T:", "Accept Vote", client);
   42.82 +	SetMenuTitle(menu, title);
   42.83 +	SetMenuExitBackButton(menu, true);
   42.84 +	
   42.85 +	AddMenuItem(menu, map, "Accept Vote");
   42.86 +	
   42.87 +	DisplayMenu(menu, g_VoteMapInUse, MENU_TIME_FOREVER);	
   42.88 +}
   42.89 +
   42.90 +DisplayVoteMapMenu(client, mapCount, String:maps[5][])
   42.91 +{
   42.92 +	LogAction(client, -1, "\"%L\" initiated a map vote.", client);
   42.93 +	ShowActivity2(client, "[SM] ", "%t", "Initiated Vote Map");
   42.94 +	
   42.95 +	new Handle:menu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
   42.96 +	
   42.97 +	if (mapCount == 1)
   42.98 +	{
   42.99 +		//strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), maps[0]);
  42.100 +			
  42.101 +		SetMenuTitle(menu, "Change Map To");
  42.102 +		AddMenuItem(menu, maps[0], "Yes");
  42.103 +		AddMenuItem(menu, VOTE_NO, "No");
  42.104 +	}
  42.105 +	else
  42.106 +	{
  42.107 +		//g_voteInfo[VOTE_NAME][0] = '\0';
  42.108 +		
  42.109 +		SetMenuTitle(menu, "Map Vote");
  42.110 +		for (new i = 0; i < mapCount; i++)
  42.111 +		{
  42.112 +			AddMenuItem(menu, maps[i], maps[i]);
  42.113 +		}	
  42.114 +	}
  42.115 +	
  42.116 +	SetMenuExitButton(menu, false);
  42.117 +	VoteMenuToAll(menu, 20);		
  42.118 +}
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/plugins/mapmanager/globals.sp	Wed Mar 26 03:52:37 2008 +0000
    43.3 @@ -0,0 +1,104 @@
    43.4 +/**
    43.5 + * vim: set ts=4 :
    43.6 + * =============================================================================
    43.7 + * SourceMod Map Manager Plugin
    43.8 + * Contains globals and defines
    43.9 + *
   43.10 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
   43.11 + * =============================================================================
   43.12 + *
   43.13 + * This program is free software; you can redistribute it and/or modify it under
   43.14 + * the terms of the GNU General Public License, version 3.0, as published by the
   43.15 + * Free Software Foundation.
   43.16 + * 
   43.17 + * This program is distributed in the hope that it will be useful, but WITHOUT
   43.18 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   43.19 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   43.20 + * details.
   43.21 + *
   43.22 + * You should have received a copy of the GNU General Public License along with
   43.23 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   43.24 + *
   43.25 + * As a special exception, AlliedModders LLC gives you permission to link the
   43.26 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   43.27 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   43.28 + * by the Valve Corporation.  You must obey the GNU General Public License in
   43.29 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   43.30 + * this exception to all derivative works.  AlliedModders LLC defines further
   43.31 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   43.32 + * or <http://www.sourcemod.net/license.php>.
   43.33 + *
   43.34 + * Version: $Id$
   43.35 + */
   43.36 +
   43.37 +#define VOTE_EXTEND "##extend##"
   43.38 +#define VOTE_YES "###yes###"
   43.39 +#define VOTE_NO "###no###"
   43.40 +
   43.41 +new Handle:hTopMenu = INVALID_HANDLE;			// TopMenu
   43.42 +
   43.43 +new Handle:g_MapCycle = INVALID_HANDLE;			// mapcyclefile maps
   43.44 +new Handle:g_MapList = INVALID_HANDLE;			// maplist.txt maps
   43.45 +new Handle:g_MapHistory = INVALID_HANDLE;		// History of maps played
   43.46 +new Handle:g_NextVoteMaps = INVALID_HANDLE;		// Array of maps for next RTV or MC vote
   43.47 +new Handle:g_NominatedMaps = INVALID_HANDLE;	// Array of maps that have been nominated
   43.48 +
   43.49 +new Handle:g_Menu_Map = INVALID_HANDLE;			// Menu of maps used by sm_map in admin menu
   43.50 +new Handle:g_Menu_Votemap = INVALID_HANDLE;		// Menu of maps used by sm_votemap in admin menu
   43.51 +new Handle:g_Menu_Nominate = INVALID_HANDLE;		// Menu of maps used by Nomination system
   43.52 +
   43.53 +new Handle:g_SelectedMaps;						// List of maps chosen so far by a user in sm_votemap admin menu
   43.54 +new g_VoteMapInUse;								// Client index of admin using sm_votemap
   43.55 +new String:g_Client_Data[MAXCLIENTS+1][64]; 	// Used to hold bits of client data during sm_votemap
   43.56 +
   43.57 +new bool:g_MapChangeSet;						// True if a command or vote has set the map
   43.58 +new bool:g_MapChanged;							// True if a map change has been issued
   43.59 +new g_MapChangeWhen;							// Either 'i' for immediate, 'r' for round end, or 'e' for end of map.
   43.60 +
   43.61 +new UserMsg:g_VGUIMenu;							// VGUI usermsg id for nextmap
   43.62 +new bool:g_NextMapEnabled = true				// If set to false, all features requiring nextmap are disabled.
   43.63 +new bool:g_IntermissionCalled;					// Has the end of map intermission begun?
   43.64 +new String:g_NextMap[64];						// All important! This is the next map!
   43.65 +new g_MapPos = -1;								// Position in mapcycle
   43.66 +
   43.67 +new bool:g_RTV_Voted[MAXPLAYERS+1] = {false, ...};	// Whether or not a player has voted for RTV
   43.68 +new bool:g_RTV_Allowed = false;					// True if RTV is available to players. Used to delay rtv votes.
   43.69 +new bool:g_RTV_Started = false;					// Indicates that the actual map vote has started
   43.70 +new bool:g_RTV_Ended = false;					// Indicates that the actual map vote has concluded
   43.71 +new g_RTV_Voters = 0;							// Total voters connected. Doesn't include fake clients.
   43.72 +new g_RTV_Votes = 0;							// Total number of "say rtv" votes
   43.73 +new g_RTV_VotesNeeded = 0;						// Necessary votes before map vote begins. (voters * percent_needed)
   43.74 +
   43.75 +new bool:g_Nominated[MAXPLAYERS+1] = {false, ...};	// Whether or not a player has nominated a map
   43.76 +
   43.77 +new Handle:g_TeamScores = INVALID_HANDLE;		// Array of team scores
   43.78 +new g_TotalRounds;								// Total rounds played this map
   43.79 +new bool:g_HasVoteStarted;						// Whether or not MapChooser has begun
   43.80 +
   43.81 +// ConVar handles
   43.82 +new Handle:g_Cvar_NextMap = INVALID_HANDLE;
   43.83 +new Handle:g_Cvar_VoteMap = INVALID_HANDLE;
   43.84 +new Handle:g_Cvar_Excludes = INVALID_HANDLE;
   43.85 +new Handle:g_Cvar_StartTime = INVALID_HANDLE;
   43.86 +new Handle:g_Cvar_StartRounds = INVALID_HANDLE;
   43.87 +new Handle:g_Cvar_StartFrags = INVALID_HANDLE;
   43.88 +new Handle:g_Cvar_ExtendTimeMax = INVALID_HANDLE;
   43.89 +new Handle:g_Cvar_ExtendTimeStep = INVALID_HANDLE;
   43.90 +new Handle:g_Cvar_ExtendRoundMax = INVALID_HANDLE;
   43.91 +new Handle:g_Cvar_ExtendRoundStep = INVALID_HANDLE;
   43.92 +new Handle:g_Cvar_ExtendFragMax = INVALID_HANDLE;
   43.93 +new Handle:g_Cvar_ExtendFragStep = INVALID_HANDLE;
   43.94 +new Handle:g_Cvar_Mapfile = INVALID_HANDLE;
   43.95 +new Handle:g_Cvar_ExcludeMaps = INVALID_HANDLE;
   43.96 +new Handle:g_Cvar_IncludeMaps = INVALID_HANDLE;
   43.97 +new Handle:g_Cvar_NoVoteMode = INVALID_HANDLE;
   43.98 +new Handle:g_Cvar_Extend = INVALID_HANDLE;
   43.99 +
  43.100 +new Handle:g_VoteTimer = INVALID_HANDLE;
  43.101 +new Handle:g_RetryTimer = INVALID_HANDLE;
  43.102 +
  43.103 +// VALVe ConVars
  43.104 +new Handle:g_Cvar_Chattime = INVALID_HANDLE;
  43.105 +new Handle:g_Cvar_Winlimit = INVALID_HANDLE;
  43.106 +new Handle:g_Cvar_Maxrounds = INVALID_HANDLE;
  43.107 +new Handle:g_Cvar_Fraglimit = INVALID_HANDLE;
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/plugins/mapmanager/menus.sp	Wed Mar 26 03:52:37 2008 +0000
    44.3 @@ -0,0 +1,263 @@
    44.4 +/**
    44.5 + * vim: set ts=4 :
    44.6 + * =============================================================================
    44.7 + * SourceMod Map Manager Plugin
    44.8 + * Contains menu callbacks
    44.9 + *
   44.10 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
   44.11 + * =============================================================================
   44.12 + *
   44.13 + * This program is free software; you can redistribute it and/or modify it under
   44.14 + * the terms of the GNU General Public License, version 3.0, as published by the
   44.15 + * Free Software Foundation.
   44.16 + * 
   44.17 + * This program is distributed in the hope that it will be useful, but WITHOUT
   44.18 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   44.19 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   44.20 + * details.
   44.21 + *
   44.22 + * You should have received a copy of the GNU General Public License along with
   44.23 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   44.24 + *
   44.25 + * As a special exception, AlliedModders LLC gives you permission to link the
   44.26 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   44.27 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   44.28 + * by the Valve Corporation.  You must obey the GNU General Public License in
   44.29 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   44.30 + * this exception to all derivative works.  AlliedModders LLC defines further
   44.31 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   44.32 + * or <http://www.sourcemod.net/license.php>.
   44.33 + *
   44.34 + * Version: $Id$
   44.35 + */
   44.36 +
   44.37 +// Following callbacks are for sm_map
   44.38 +public AdminMenu_Map(Handle:topmenu, 
   44.39 +							  TopMenuAction:action,
   44.40 +							  TopMenuObject:object_id,
   44.41 +							  param,
   44.42 +							  String:buffer[],
   44.43 +							  maxlength)
   44.44 +{
   44.45 +	if (action == TopMenuAction_DisplayOption)
   44.46 +	{
   44.47 +		Format(buffer, maxlength, "%T", "Choose Map", param);
   44.48 +	}
   44.49 +	else if (action == TopMenuAction_SelectOption)
   44.50 +	{
   44.51 +		DisplayMenu(g_Menu_Map, param, MENU_TIME_FOREVER);
   44.52 +	}
   44.53 +}
   44.54 +
   44.55 +public MenuHandler_Map(Handle:menu, MenuAction:action, param1, param2)
   44.56 +{
   44.57 +	if (action == MenuAction_Cancel)
   44.58 +	{
   44.59 +		if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
   44.60 +		{
   44.61 +			DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
   44.62 +		}
   44.63 +	}
   44.64 +	else if (action == MenuAction_Select)
   44.65 +	{
   44.66 +		GetMenuItem(menu, param2, g_Client_Data[param1], sizeof(g_Client_Data[]));
   44.67 +		DisplayWhenMenu(param1);
   44.68 +	}
   44.69 +}
   44.70 +
   44.71 +public MenuHandler_ChangeMap(Handle:menu, MenuAction:action, param1, param2)
   44.72 +{
   44.73 +	if (action == MenuAction_Cancel)
   44.74 +	{
   44.75 +		if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
   44.76 +		{
   44.77 +			DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
   44.78 +		}
   44.79 +	}
   44.80 +	else if (action == MenuAction_Select)
   44.81 +	{
   44.82 +		decl String:when[2];
   44.83 +		GetMenuItem(menu, param2, when, sizeof(when));
   44.84 +		SetMapChange(client, g_Client_Data[param1], when[0])
   44.85 +	}
   44.86 +}
   44.87 +
   44.88 +// Following callbacks are for sm_votemap
   44.89 +public AdminMenu_VoteMap(Handle:topmenu, 
   44.90 +							  TopMenuAction:action,
   44.91 +							  TopMenuObject:object_id,
   44.92 +							  param,
   44.93 +							  String:buffer[],
   44.94 +							  maxlength)
   44.95 +{
   44.96 +	if (action == TopMenuAction_DisplayOption)
   44.97 +	{
   44.98 +		Format(buffer, maxlength, "%T", "Map vote", param);
   44.99 +	}
  44.100 +	else if (action == TopMenuAction_SelectOption)
  44.101 +	{
  44.102 +		g_VoteMapInUse = param;
  44.103 +		ClearArray(g_SelectedMaps);
  44.104 +		DisplayMenu(g_Menu_Votemap, param, MENU_TIME_FOREVER);
  44.105 +	}
  44.106 +	else if (action == TopMenuAction_DrawOption)
  44.107 +	{	
  44.108 +		/* disable this option if a vote is already running, theres no maps listed or someone else has already accessed this menu */
  44.109 +		buffer[0] = (!IsNewVoteAllowed() || g_VoteMapInUse) ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
  44.110 +	}
  44.111 +}
  44.112 +
  44.113 +public MenuHandler_VoteMap(Handle:menu, MenuAction:action, param1, param2)
  44.114 +{
  44.115 +	if (action == MenuAction_Cancel)
  44.116 +	{		
  44.117 +		if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
  44.118 +		{
  44.119 +			DisplayWhenMenu(param1, true);
  44.120 +		}
  44.121 +		else // no action was selected.
  44.122 +		{
  44.123 +			/* Re-enable the menu option */
  44.124 +			g_VoteMapInUse = 0;
  44.125 +		}
  44.126 +	}
  44.127 +	else if (action == MenuAction_DrawItem)
  44.128 +	{
  44.129 +		decl String:info[32];
  44.130 +		
  44.131 +		GetMenuItem(menu, param2, info, sizeof(info));
  44.132 +		
  44.133 +		if (FindStringInArray(g_SelectedMaps, info) != -1)
  44.134 +		{
  44.135 +			return ITEMDRAW_IGNORE;
  44.136 +		}
  44.137 +		else
  44.138 +		{
  44.139 +			return ITEMDRAW_DEFAULT;
  44.140 +		}
  44.141 +	}
  44.142 +	else if (action == MenuAction_Select)
  44.143 +	{
  44.144 +		decl String:info[32];
  44.145 +		
  44.146 +		GetMenuItem(menu, param2, info, sizeof(info));
  44.147 +		
  44.148 +		PushArrayString(g_SelectedMaps, info);
  44.149 +		
  44.150 +		/* Redisplay the list */
  44.151 +		if (GetArraySize(g_SelectedMaps) < 5)
  44.152 +		{
  44.153 +			DisplayMenu(g_MapList, param1, MENU_TIME_FOREVER);
  44.154 +		}
  44.155 +		else
  44.156 +		{
  44.157 +			DisplayWhenMenu(param1, true);
  44.158 +		}
  44.159 +	}
  44.160 +	
  44.161 +	return 0;
  44.162 +}
  44.163 +
  44.164 +public MenuHandler_VoteWhen(Handle:menu, MenuAction:action, param1, param2)
  44.165 +{
  44.166 +	if (action == MenuAction_End)
  44.167 +	{
  44.168 +		CloseHandle(menu);
  44.169 +	}
  44.170 +	else if (action == MenuAction_Cancel)
  44.171 +	{
  44.172 +		if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
  44.173 +		{
  44.174 +			g_Menu_Info[param1][0] = 'i';
  44.175 +			DisplayConfirmVoteMenu(param1);
  44.176 +		}
  44.177 +		else
  44.178 +		{
  44.179 +			g_VoteMapInUse = 0;
  44.180 +		}
  44.181 +	}
  44.182 +	else if (action == MenuAction_Select)
  44.183 +	{
  44.184 +		GetMenuItem(menu, param2, g_Menu_Info[param1], sizeof(g_Menu_Info[]));
  44.185 +		
  44.186 +		DisplayConfirmVoteMenu(param1);
  44.187 +	}
  44.188 +}
  44.189 +
  44.190 +public MenuHandler_Confirm(Handle:menu, MenuAction:action, param1, param2)
  44.191 +{
  44.192 +	if (action == MenuAction_End)
  44.193 +	{
  44.194 +		CloseHandle(menu);
  44.195 +	}
  44.196 +	else if (action == MenuAction_Cancel)
  44.197 +	{
  44.198 +		g_VoteMapInUse = 0;
  44.199 +		
  44.200 +		if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
  44.201 +		{
  44.202 +			DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
  44.203 +		}
  44.204 +	}
  44.205 +	else if (action == MenuAction_Select)
  44.206 +	{
  44.207 +		decl String:maps[5][64];
  44.208 +		new selectedmaps = GetArraySize(g_SelectedMaps);
  44.209 +		
  44.210 +		for (new i = 0; i < selectedmaps; i++)
  44.211 +		{
  44.212 +			GetArrayString(g_SelectedMaps, i, maps[i], sizeof(maps[]));
  44.213 +		}
  44.214 +		
  44.215 +		DisplayVoteMapMenu(param1, selectedmaps, maps);
  44.216 +	}
  44.217 +}
  44.218 +
  44.219 +public MenuHandler_Accept(Handle:menu, MenuAction:action, param1, param2)
  44.220 +{
  44.221 +	if (action == MenuAction_End)
  44.222 +	{
  44.223 +		CloseHandle(menu);
  44.224 +		g_VoteMapInUse = 0;
  44.225 +	}
  44.226 +	else if (action == MenuAction_Select)
  44.227 +	{
  44.228 +		decl String:map[64]
  44.229 +		GetMenuItem(menu, 1, map, sizeof(map));
  44.230 +		
  44.231 +		SetMapChange(param1, map, g_Client_Data[param1][0])
  44.232 +	}
  44.233 +}
  44.234 +
  44.235 +public Handler_MapSelectMenu(Handle:menu, MenuAction:action, param1, param2)
  44.236 +{
  44.237 +	switch (action)
  44.238 +	{
  44.239 +		case MenuAction_Select:
  44.240 +		{
  44.241 +			if (GetArraySize(g_RTVMapList) >= GetConVarInt(g_Cvar_Maps)) 
  44.242 +			{
  44.243 +				PrintToChat(param1, "[SM] %t", "Max Nominations");
  44.244 +				return;	
  44.245 +			}
  44.246 +			
  44.247 +			decl String:map[64], String:name[64];
  44.248 +			GetMenuItem(menu, param2, map, sizeof(map));
  44.249 +			
  44.250 +			if (FindStringInArray(g_RTVMapList, map) != -1)
  44.251 +			{
  44.252 +				PrintToChat(param1, "[SM] %t", "Map Already Nominated");
  44.253 +				return;
  44.254 +			}
  44.255 +			
  44.256 +			GetClientName(param1, name, 64);
  44.257 +
  44.258 +			PushArrayString(g_RTVMapList, map);
  44.259 +			RemoveMenuItem(menu, param2);
  44.260 +			
  44.261 +			g_Nominated[param1] = true;
  44.262 +			
  44.263 +			PrintToChatAll("[SM] %t", "Map Nominated", name, map);
  44.264 +		}
  44.265 +	}
  44.266 +}
  44.267 \ No newline at end of file
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/plugins/mapmanager/timers.sp	Wed Mar 26 03:52:37 2008 +0000
    45.3 @@ -0,0 +1,166 @@
    45.4 +/**
    45.5 + * vim: set ts=4 :
    45.6 + * =============================================================================
    45.7 + * SourceMod Map Manager Plugin
    45.8 + * Contains timer callbacks
    45.9 + *
   45.10 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
   45.11 + * =============================================================================
   45.12 + *
   45.13 + * This program is free software; you can redistribute it and/or modify it under
   45.14 + * the terms of the GNU General Public License, version 3.0, as published by the
   45.15 + * Free Software Foundation.
   45.16 + * 
   45.17 + * This program is distributed in the hope that it will be useful, but WITHOUT
   45.18 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   45.19 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   45.20 + * details.
   45.21 + *
   45.22 + * You should have received a copy of the GNU General Public License along with
   45.23 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   45.24 + *
   45.25 + * As a special exception, AlliedModders LLC gives you permission to link the
   45.26 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   45.27 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   45.28 + * by the Valve Corporation.  You must obey the GNU General Public License in
   45.29 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   45.30 + * this exception to all derivative works.  AlliedModders LLC defines further
   45.31 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   45.32 + * or <http://www.sourcemod.net/license.php>.
   45.33 + *
   45.34 + * Version: $Id$
   45.35 + */
   45.36 +
   45.37 +public Action:Timer_ChangeMap(Handle:timer)
   45.38 +{
   45.39 +	ServerCommand("changelevel \"%s\"", g_NextMap);
   45.40 +	PushArrayString(g_MapHistory, g_NextMap);
   45.41 +
   45.42 +	return Plugin_Stop;
   45.43 +}
   45.44 +
   45.45 +public Action:Timer_RandomizeNextmap(Handle:timer)
   45.46 +{
   45.47 +	decl String:map[64];
   45.48 +	
   45.49 +	new exclusion = GetConVarInt(g_Cvar_ExcludeMaps);
   45.50 +	if (exclusion > GetArraySize(g_MapCycle))
   45.51 +	{
   45.52 +		exclusion = GetArraySize(g_MapCycle) - 1;
   45.53 +	}
   45.54 +
   45.55 +	new b = GetRandomInt(0, GetArraySize(g_MapCycle) - 1);
   45.56 +	GetArrayString(g_MapCycle, b, map, sizeof(map));
   45.57 +
   45.58 +	while (FindStringInArray(g_MapHistory, map) != -1)
   45.59 +	{
   45.60 +		b = GetRandomInt(0, GetArraySize(g_MapCycle) - 1);
   45.61 +		GetArrayString(g_MapCycle, b, map, sizeof(map));
   45.62 +	}
   45.63 +	
   45.64 +	SetNextmap(map);
   45.65 +
   45.66 +	LogMessage("[MapManager] Randomizer has chosen '%s' as the next map.", map);	
   45.67 +
   45.68 +	return Plugin_Stop;
   45.69 +}
   45.70 +
   45.71 +public Action:Timer_DelayRTV(Handle:timer)
   45.72 +{
   45.73 +	g_RTVAllowed = true;
   45.74 +	g_RTVStarted = false;
   45.75 +	g_RTVEnded = false;	
   45.76 +}
   45.77 +
   45.78 +public Action:Timer_StartRTV(Handle:timer)
   45.79 +{
   45.80 +	if (timer == g_RetryTimer)
   45.81 +	{
   45.82 +		g_RetryTimer = INVALID_HANDLE;
   45.83 +	}
   45.84 +	
   45.85 +	if (g_RetryTimer != INVALID_HANDLE)
   45.86 +	{
   45.87 +		return;
   45.88 +	}
   45.89 +
   45.90 +	if (IsVoteInProgress())
   45.91 +	{
   45.92 +		// Can't start a vote, try again in 5 seconds.
   45.93 +		g_RetryTimer = CreateTimer(5.0, Timer_StartRTV, TIMER_FLAG_NO_MAPCHANGE);
   45.94 +		return;
   45.95 +	}			
   45.96 +	
   45.97 +	PrintToChatAll("[SM] %t", "RTV Vote Ready");
   45.98 +		
   45.99 +	new Handle:MapVoteMenu = CreateMenu(Handler_MapMapVoteMenu, MenuAction:MENU_ACTIONS_ALL);
  45.100 +	SetMenuTitle(MapVoteMenu, "Rock The Vote");
  45.101 +	
  45.102 +	new Handle:tempMaps  = CloneArray(g_MapList);
  45.103 +	decl String:map[32];
  45.104 +
  45.105 +	GetCurrentMap(map, sizeof(map));
  45.106 +	new index = FindStringInArray(tempMaps, map);
  45.107 +	if (index != -1)
  45.108 +	{
  45.109 +		RemoveFromArray(tempMaps, index);
  45.110 +	}	
  45.111 +	
  45.112 +	// We assume that g_RTVMapList is within the correct limits, based on the logic for nominations
  45.113 +	for (new i = 0; i < GetArraySize(g_RTVMapList); i++)
  45.114 +	{
  45.115 +		GetArrayString(g_RTVMapList, i, map, sizeof(map));
  45.116 +		AddMenuItem(MapVoteMenu, map, map);
  45.117 +		
  45.118 +		index = FindStringInArray(tempMaps, map);
  45.119 +		if (index != -1)
  45.120 +		{
  45.121 +			RemoveFromArray(tempMaps, index);
  45.122 +		}
  45.123 +	}
  45.124 +	
  45.125 +	new limit = GetConVarInt(g_Cvar_Maps) - GetArraySize(g_RTVMapList);
  45.126 +	if (limit > GetArraySize(tempMaps))
  45.127 +	{
  45.128 +		limit = GetArraySize(tempMaps);
  45.129 +	}
  45.130 +
  45.131 +	for (new i = 0; i < limit; i++)
  45.132 +	{
  45.133 +		new b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
  45.134 +		GetArrayString(tempMaps, b, map, sizeof(map));		
  45.135 +		PushArrayString(g_RTVMapList, map);
  45.136 +		AddMenuItem(MapVoteMenu, map, map);			
  45.137 +		RemoveFromArray(tempMaps, b);
  45.138 +	}	
  45.139 +	
  45.140 +	CloseHandle(tempMaps);
  45.141 +	
  45.142 +	AddMenuItem(MapVoteMenu, "Don't Change", "Don't Change");
  45.143 +		
  45.144 +	SetMenuExitButton(MapVoteMenu, false);
  45.145 +	VoteMenuToAll(MapVoteMenu, 20);
  45.146 +		
  45.147 +	LogMessage("[SM] Rockthevote was successfully started.");
  45.148 +}
  45.149 +
  45.150 +public Action:Timer_StartMapVote(Handle:timer)
  45.151 +{
  45.152 +	if (!GetArraySize(g_MapList))
  45.153 +	{
  45.154 +		return Plugin_Stop;
  45.155 +	}		
  45.156 +	
  45.157 +	if (timer == g_RetryTimer)
  45.158 +	{
  45.159 +		g_RetryTimer = INVALID_HANDLE;
  45.160 +	}
  45.161 +	else
  45.162 +	{
  45.163 +		g_VoteTimer = INVALID_HANDLE;
  45.164 +	}
  45.165 +
  45.166 +	InitiateVote();
  45.167 +
  45.168 +	return Plugin_Stop;
  45.169 +}
  45.170 \ No newline at end of file
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/plugins/mapmanager/votes.sp	Wed Mar 26 03:52:37 2008 +0000
    46.3 @@ -0,0 +1,318 @@
    46.4 +/**
    46.5 + * vim: set ts=4 :
    46.6 + * =============================================================================
    46.7 + * SourceMod Map Manager Plugin
    46.8 + * Contains vote callbacks
    46.9 + *
   46.10 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
   46.11 + * =============================================================================
   46.12 + *
   46.13 + * This program is free software; you can redistribute it and/or modify it under
   46.14 + * the terms of the GNU General Public License, version 3.0, as published by the
   46.15 + * Free Software Foundation.
   46.16 + * 
   46.17 + * This program is distributed in the hope that it will be useful, but WITHOUT
   46.18 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   46.19 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
   46.20 + * details.
   46.21 + *
   46.22 + * You should have received a copy of the GNU General Public License along with
   46.23 + * this program.  If not, see <http://www.gnu.org/licenses/>.
   46.24 + *
   46.25 + * As a special exception, AlliedModders LLC gives you permission to link the
   46.26 + * code of this program (as well as its derivative works) to "Half-Life 2," the
   46.27 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
   46.28 + * by the Valve Corporation.  You must obey the GNU General Public License in
   46.29 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
   46.30 + * this exception to all derivative works.  AlliedModders LLC defines further
   46.31 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
   46.32 + * or <http://www.sourcemod.net/license.php>.
   46.33 + *
   46.34 + * Version: $Id$
   46.35 + */
   46.36 +
   46.37 +// sm_votemap
   46.38 +public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2)
   46.39 +{
   46.40 +	if (action == MenuAction_End)
   46.41 +	{
   46.42 +		CloseHandle(menu);
   46.43 +	}
   46.44 +	else if (action == MenuAction_Display)
   46.45 +	{
   46.46 +	 	decl String:title[64];
   46.47 +		GetMenuTitle(menu, title, sizeof(title));
   46.48 +			
   46.49 +		decl String:map[64];
   46.50 +		GetMenuItem(menu, 1, map, sizeof(map));
   46.51 +		
   46.52 + 		decl String:buffer[255];
   46.53 +		Format(buffer, sizeof(buffer), "%T", title, param1, map);
   46.54 +
   46.55 +		new Handle:panel = Handle:param2;
   46.56 +		SetPanelTitle(panel, buffer);
   46.57 +	}
   46.58 +	else if (action == MenuAction_DisplayItem)
   46.59 +	{
   46.60 +		decl String:display[64];
   46.61 +		GetMenuItem(menu, param2, "", 0, _, display, sizeof(display));
   46.62 +	 
   46.63 +	 	if (strcmp(display, "No") == 0 || strcmp(display, "Yes") == 0)
   46.64 +	 	{
   46.65 +			decl String:buffer[255];
   46.66 +			Format(buffer, sizeof(buffer), "%T", display, param1);
   46.67 +
   46.68 +			return RedrawMenuItem(buffer);
   46.69 +		}
   46.70 +	}
   46.71 +	else if (action == MenuAction_VoteCancel && param1 == VoteCancel_NoVotes)
   46.72 +	{
   46.73 +		PrintToChatAll("[SM] %t", "No Votes Cast");
   46.74 +	}	
   46.75 +	else if (action == MenuAction_VoteEnd)
   46.76 +	{
   46.77 +		decl String:item[64], String:display[64];
   46.78 +		new Float:percent, Float:limit, votes, totalVotes;
   46.79 +
   46.80 +		GetMenuVoteInfo(param2, votes, totalVotes);
   46.81 +		GetMenuItem(menu, param1, item, sizeof(item), _, display, sizeof(display));
   46.82 +		
   46.83 +		if (strcmp(item, VOTE_NO) == 0 && param1 == 1)
   46.84 +		{
   46.85 +			votes = totalVotes - votes; // Reverse the votes to be in relation to the Yes option.
   46.86 +		}
   46.87 +		
   46.88 +		percent = GetVotePercent(votes, totalVotes);
   46.89 +		
   46.90 +		limit = GetConVarFloat(g_Cvar_VoteMap);
   46.91 +		
   46.92 +		// A multi-argument vote is "always successful", but have to check if its a Yes/No vote.
   46.93 +		if ((strcmp(item, VOTE_YES) == 0 && FloatCompare(percent,limit) < 0 && param1 == 0) || (strcmp(item, VOTE_NO) == 0 && param1 == 1))
   46.94 +		{
   46.95 +			LogAction(-1, -1, "Vote failed.");
   46.96 +			PrintToChatAll("[SM] %t", "Votemap Failed", RoundToNearest(100.0*limit), RoundToNearest(100.0*percent), totalVotes);
   46.97 +		}
   46.98 +		else
   46.99 +		{
  46.100 +			PrintToChatAll("[SM] %t", "Votemap Successful", RoundToNearest(100.0*percent), totalVotes);
  46.101 +
  46.102 +			if (g_VoteMapInUse && IsClientInGame(g_VoteMapInUse))
  46.103 +			{
  46.104 +				DisplayAcceptVoteMenu(item);
  46.105 +			}
  46.106 +			else
  46.107 +			{
  46.108 +				LogAction(-1, -1, "Changing map to %s due to vote.", item);
  46.109 +				PrintToChatAll("[SM] %t", "Changing map", item);
  46.110 +				SetMapChange(0, item, g_Client_Data[g_VoteMapInUse][0])
  46.111 +			}	
  46.112 +		}
  46.113 +	}
  46.114 +	
  46.115 +	return 0;
  46.116 +}
  46.117 +
  46.118 +public Handler_MapMapVoteMenu(Handle:menu, MenuAction:action, param1, param2)
  46.119 +{
  46.120 +	switch (action)
  46.121 +	{
  46.122 +		case MenuAction_End:
  46.123 +		{
  46.124 +			CloseHandle(menu);
  46.125 +		}
  46.126 +		
  46.127 +		case MenuAction_Display:
  46.128 +		{
  46.129 +	 		decl String:oldTitle[255], String:buffer[255];
  46.130 +			GetMenuTitle(menu, oldTitle, sizeof(oldTitle));
  46.131 +			Format(buffer, sizeof(buffer), "%T", oldTitle, param1);
  46.132 +
  46.133 +			new Handle:panel = Handle:param2;
  46.134 +			SetPanelTitle(panel, buffer);
  46.135 +		}
  46.136 +		
  46.137 +		case MenuAction_DisplayItem:
  46.138 +		{
  46.139 +			if (GetMenuItemCount(menu) - 1 == param2)
  46.140 +			{
  46.141 +				decl String:buffer[255];
  46.142 +				Format(buffer, sizeof(buffer), "%T", "Don't Change", param1);
  46.143 +				return RedrawMenuItem(buffer);
  46.144 +			}
  46.145 +		}		
  46.146 +
  46.147 +		// Why am I commented out? Because BAIL hasn't decided yet if
  46.148 +		// vote notification will be built into the Vote API.
  46.149 +		/*case MenuAction_Select:
  46.150 +		{
  46.151 +			decl String:Name[32], String:Map[32];
  46.152 +			GetClientName(param1, Name, sizeof(Name));
  46.153 +			GetMenuItem(menu, param2, Map, sizeof(Map));
  46.154 +
  46.155 +			PrintToChatAll("[SM] %s has voted for map '%s'", Name, Map);
  46.156 +		}*/
  46.157 +		
  46.158 +		case MenuAction_VoteCancel:
  46.159 +		{
  46.160 +			if (param1 == VoteCancel_NoVotes)
  46.161 +			{
  46.162 +				PrintToChatAll("[SM] %t", "No Votes");
  46.163 +				g_RTVEnded = true;
  46.164 +			}
  46.165 +		}
  46.166 +
  46.167 +		case MenuAction_VoteEnd:
  46.168 +		{
  46.169 +			new String:map[64];
  46.170 +			
  46.171 +			GetMenuItem(menu, param1, map, sizeof(map));
  46.172 +			
  46.173 +			if (GetMenuItemCount(menu) - 1 == param1) // This should always match the "Keep Current" option
  46.174 +			{
  46.175 +				PrintToChatAll("[SM] %t", "Current Map Stays");
  46.176 +				LogMessage("[SM] Rockthevote has ended, current map kept.");
  46.177 +			}
  46.178 +			else
  46.179 +			{
  46.180 +				PrintToChatAll("[SM] %t", "Changing Maps", map);
  46.181 +				LogMessage("[SM] Rockthevote has ended, changing to map %s.", map);
  46.182 +				new Handle:dp;
  46.183 +				CreateDataTimer(5.0, Timer_ChangeMap, dp);
  46.184 +				WritePackString(dp, map);
  46.185 +			}
  46.186 +			
  46.187 +			g_RTVEnded = true;
  46.188 +		}
  46.189 +	}
  46.190 +	
  46.191 +	return 0;
  46.192 +}
  46.193 +
  46.194 +public Handler_MapVoteMenu(Handle:menu, MenuAction:action, param1, param2)
  46.195 +{
  46.196 +	switch (action)
  46.197 +	{
  46.198 +		case MenuAction_End:
  46.199 +		{
  46.200 +			g_VoteMenu = INVALID_HANDLE;
  46.201 +			CloseHandle(menu);
  46.202 +		}
  46.203 +		
  46.204 +		case MenuAction_Display:
  46.205 +		{
  46.206 +	 		decl String:buffer[255];
  46.207 +			Format(buffer, sizeof(buffer), "%T", "Vote Nextmap", param1);
  46.208 +
  46.209 +			new Handle:panel = Handle:param2;
  46.210 +			SetPanelTitle(panel, buffer);
  46.211 +		}		
  46.212 +		
  46.213 +		case MenuAction_DisplayItem:
  46.214 +		{
  46.215 +			if (GetMenuItemCount(menu) - 1 == param2)
  46.216 +			{
  46.217 +				decl String:map[64], String:buffer[255];
  46.218 +				GetMenuItem(menu, param2, map, sizeof(map));
  46.219 +				if (strcmp(map, VOTE_EXTEND, false) == 0)
  46.220 +				{
  46.221 +					Format(buffer, sizeof(buffer), "%T", "Extend Map", param1);
  46.222 +					return RedrawMenuItem(buffer);
  46.223 +				}
  46.224 +			}
  46.225 +		}		
  46.226 +
  46.227 +		// Why am I commented out? Because BAIL hasn't decided yet if
  46.228 +		// vote notification will be built into the Vote API.
  46.229 +		/*case MenuAction_Select:
  46.230 +		{
  46.231 +			decl String:Name[32], String:Map[32];
  46.232 +			GetClientName(param1, Name, sizeof(Name));
  46.233 +			GetMenuItem(menu, param2, Map, sizeof(Map));
  46.234 +
  46.235 +			PrintToChatAll("[SM] %s has voted for map '%s'", Name, Map);
  46.236 +		}*/
  46.237 +		
  46.238 +		case MenuAction_VoteCancel:
  46.239 +		{
  46.240 +			// If we receive 0 votes, pick at random.
  46.241 +			if (param1 == VoteCancel_NoVotes && GetConVarBool(g_Cvar_NoVoteMode))
  46.242 +			{
  46.243 +				new count = GetMenuItemCount(menu);
  46.244 +				new item = GetRandomInt(0, count - 1);
  46.245 +				decl String:map[32];
  46.246 +				GetMenuItem(menu, item, map, sizeof(map));
  46.247 +				
  46.248 +				while (strcmp(map, VOTE_EXTEND, false) == 0)
  46.249 +				{
  46.250 +					item = GetRandomInt(0, count - 1);
  46.251 +					GetMenuItem(menu, item, map, sizeof(map));
  46.252 +				}
  46.253 +				
  46.254 +				SetNextMap(map);			
  46.255 +			}
  46.256 +			else
  46.257 +			{
  46.258 +				// We were actually cancelled. What should we do?
  46.259 +			}
  46.260 +		}
  46.261 +
  46.262 +		case MenuAction_VoteEnd:
  46.263 +		{
  46.264 +			decl String:map[32];
  46.265 +			GetMenuItem(menu, param1, map, sizeof(map));
  46.266 +
  46.267 +			if (strcmp(map, VOTE_EXTEND, false) == 0)
  46.268 +			{
  46.269 +				new time;
  46.270 +				if (GetMapTimeLimit(time))
  46.271 +				{
  46.272 +					if (time > 0 && time < GetConVarInt(g_Cvar_ExtendTimeMax))
  46.273 +					{
  46.274 +						ExtendMapTimeLimit(GetConVarInt(g_Cvar_ExtendTimeStep)*60);						
  46.275 +					}
  46.276 +				}
  46.277 +				
  46.278 +				if (g_Cvar_Winlimit != INVALID_HANDLE)
  46.279 +				{
  46.280 +					new winlimit = GetConVarInt(g_Cvar_Winlimit);
  46.281 +					if (winlimit && winlimit < GetConVarInt(g_Cvar_ExtendRoundMax))
  46.282 +					{
  46.283 +						SetConVarInt(g_Cvar_Winlimit, winlimit + GetConVarInt(g_Cvar_ExtendRoundStep));
  46.284 +					}					
  46.285 +				}
  46.286 +				
  46.287 +				if (g_Cvar_Maxrounds != INVALID_HANDLE)
  46.288 +				{
  46.289 +					new maxrounds = GetConVarInt(g_Cvar_Maxrounds);
  46.290 +					if (maxrounds && maxrounds < GetConVarInt(g_Cvar_ExtendRoundMax))
  46.291 +					{
  46.292 +						SetConVarInt(g_Cvar_Maxrounds, maxrounds + GetConVarInt(g_Cvar_ExtendRoundStep));
  46.293 +					}
  46.294 +				}
  46.295 +				
  46.296 +				if (g_Cvar_Fraglimit != INVALID_HANDLE)
  46.297 +				{
  46.298 +					new fraglimit = GetConVarInt(g_Cvar_Fraglimit);
  46.299 +					if (fraglimit && fraglimit < GetConVarInt(g_Cvar_ExtendFragMax))
  46.300 +					{
  46.301 +						SetConVarInt(g_Cvar_Fraglimit, fraglimit + GetConVarInt(g_Cvar_ExtendFragStep));						
  46.302 +					}
  46.303 +				}
  46.304 +
  46.305 +				PrintToChatAll("[SM] %t", "Current Map Extended");
  46.306 +				LogMessage("Voting for next map has finished. The current map has been extended.");
  46.307 +				
  46.308 +				// We extended, so we'll have to vote again.
  46.309 +				g_HasVoteStarted = false;
  46.310 +				CreateNextVote();
  46.311 +				SetupTimeleftTimer();
  46.312 +			}
  46.313 +			else
  46.314 +			{
  46.315 +				SetNextMap(map);
  46.316 +			}
  46.317 +		}
  46.318 +	}
  46.319 +	
  46.320 +	return 0;
  46.321 +}
  46.322 \ No newline at end of file
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/plugins/testsuite/goto_test.sp	Wed Mar 26 03:52:37 2008 +0000
    47.3 @@ -0,0 +1,28 @@
    47.4 +#include <sourcemod>
    47.5 +
    47.6 +public OnPluginStart()
    47.7 +{
    47.8 +	RegServerCmd("test_goto", Test_Goto);
    47.9 +}
   47.10 +
   47.11 +public Action:Test_Goto(args)
   47.12 +{
   47.13 +	new bool:hello = false;
   47.14 +	new String:crab[] = "space crab";
   47.15 +
   47.16 +sample_label:
   47.17 +
   47.18 +	new String:yam[] = "yams";
   47.19 +
   47.20 +	PrintToServer("%s %s", crab, yam);
   47.21 +
   47.22 +	if (!hello)
   47.23 +	{
   47.24 +		new bool:what = true;
   47.25 +		hello = what
   47.26 +		goto sample_label;
   47.27 +	}
   47.28 +
   47.29 +	return Plugin_Handled;
   47.30 +}
   47.31 +
    48.1 --- a/sourcepawn/compiler/sc4.c	Fri Mar 21 04:26:53 2008 +0000
    48.2 +++ b/sourcepawn/compiler/sc4.c	Wed Mar 26 03:52:37 2008 +0000
    48.3 @@ -854,19 +854,10 @@
    48.4  /* set the stack to a hard offset from the frame */
    48.5  SC_FUNC void setstk(cell value)
    48.6  {
    48.7 -  stgwrite("\tlctrl 5\n");      /* get FRM in PRI */
    48.8 +  stgwrite("\tstackadjust ");
    48.9    assert(value<=0);             /* STK should always become <= FRM */
   48.10 -  if (value<0) {
   48.11 -    stgwrite("\tadd.c ");
   48.12 -    outval(value, TRUE);        /* add (negative) offset */
   48.13 -    code_idx+=opcodes(1)+opargs(1);
   48.14 -    // ??? write zeros in the space between STK and the value in PRI (the new stk)
   48.15 -    //     get value of STK in ALT
   48.16 -    //     zero PRI
   48.17 -    //     need new FILL opcode that takes a variable size
   48.18 -  } /* if */
   48.19 -  stgwrite("\tsctrl 4\n");      /* store in STK */
   48.20 -  code_idx+=opcodes(2)+opargs(2);
   48.21 +  outval(value, TRUE);        /* add (negative) offset */
   48.22 +  code_idx+=opcodes(1)+opargs(1);
   48.23  }
   48.24  
   48.25  SC_FUNC void modheap(int delta)
    49.1 --- a/sourcepawn/compiler/sc6.c	Fri Mar 21 04:26:53 2008 +0000
    49.2 +++ b/sourcepawn/compiler/sc6.c	Wed Mar 26 03:52:37 2008 +0000
    49.3 @@ -596,6 +596,7 @@
    49.4    { 21, "sref.s.pri", sIN_CSEG, parm1 },
    49.5    { 67, "sshr",       sIN_CSEG, parm0 },
    49.6    { 44, "stack",      sIN_CSEG, parm1 },
    49.7 +  {165, "stackadjust",sIN_CSEG, parm1 },
    49.8    {  0, "stksize",    0,        noop },
    49.9    { 16, "stor.alt",   sIN_CSEG, parm1 },
   49.10    { 23, "stor.i",     sIN_CSEG, parm0 },
    50.1 --- a/sourcepawn/jit/x86/jit_x86.cpp	Fri Mar 21 04:26:53 2008 +0000
    50.2 +++ b/sourcepawn/jit/x86/jit_x86.cpp	Wed Mar 26 03:52:37 2008 +0000
    50.3 @@ -1209,6 +1209,28 @@
    50.4  	}
    50.5  }
    50.6  
    50.7 +inline void WriteOp_StackAdjust(JitWriter *jit)
    50.8 +{
    50.9 +	cell_t val = jit->read_cell();
   50.10 +
   50.11 +	assert(val <= 0);
   50.12 +
   50.13 +	//lea edi, [ebx-val]
   50.14 +	
   50.15 +	if (val < SCHAR_MAX && val > SCHAR_MIN)
   50.16 +	{
   50.17 +		IA32_Lea_DispRegImm8(jit, AMX_REG_STK, AMX_REG_FRM, val);
   50.18 +	}
   50.19 +	else
   50.20 +	{
   50.21 +		IA32_Lea_DispRegImm32(jit, AMX_REG_STK, AMX_REG_FRM, val);
   50.22 +	}
   50.23 +
   50.24 +	/* We assume the compiler has generated good code -- 
   50.25 +	 * That is, we do not bother validating this amount!
   50.26 +	 */
   50.27 +}
   50.28 +
   50.29  inline void WriteOp_Heap(JitWriter *jit)
   50.30  {
   50.31  	//mov edx, [esi+hea]
    51.1 --- a/sourcepawn/jit/x86/opcode_helpers.h	Fri Mar 21 04:26:53 2008 +0000
    51.2 +++ b/sourcepawn/jit/x86/opcode_helpers.h	Wed Mar 26 03:52:37 2008 +0000
    51.3 @@ -124,8 +124,8 @@
    51.4  	OP_LOAD_ALT,			//~!VERIFIED (load.pri)
    51.5  	OP_LOAD_S_PRI,			//VERIFIED
    51.6  	OP_LOAD_S_ALT,			//VERIFIED
    51.7 -	OP_LREF_PRI,			// !GEN :TODO: we will need this for dynarrays
    51.8 -	OP_LREF_ALT,			// !GEN :TODO: we will need this for dynarrays
    51.9 +	OP_LREF_PRI,			//VERIFIED
   51.10 +	OP_LREF_ALT,			//~VERIFIED
   51.11  	OP_LREF_S_PRI,			//VERIFIED
   51.12  	OP_LREF_S_ALT,			//~VERIFIED (lref.s.pri)
   51.13  	OP_LOAD_I,				//VERIFIED
   51.14 @@ -138,8 +138,8 @@
   51.15  	OP_STOR_ALT,			//~VERIFIED (stor.pri)
   51.16  	OP_STOR_S_PRI,			//VERIFIED
   51.17  	OP_STOR_S_ALT,			//~VERIFIED (stor.s.pri)
   51.18 -	OP_SREF_PRI,			// !GEN :TODO: we will need this for dynarrays
   51.19 -	OP_SREF_ALT,			// !GEN :TODO: we will need this for dynarrays
   51.20 +	OP_SREF_PRI,			//VERIFIED
   51.21 +	OP_SREF_ALT,			//~VERIFIED
   51.22  	OP_SREF_S_PRI,			//VERIFIED
   51.23  	OP_SREF_S_ALT,			//~VERIFIED (stor.s.alt)
   51.24  	OP_STOR_I,				//VERIFIED
   51.25 @@ -286,6 +286,7 @@
   51.26  	OP_GENARRAY,			//VERIFIED
   51.27  	OP_GENARRAY_Z,			//-VERIFIED (not tested for 1D arrays)
   51.28  	OP_STRADJUST_PRI,		//VERIFIED
   51.29 +	OP_STACKADJUST,			//:TODO: VERIFY
   51.30  	OP_FABS,				//VERIFIED
   51.31  	OP_FLOAT,				//VERIFIED
   51.32  	OP_FLOATADD,			//VERIFIED
   51.33 @@ -301,22 +302,4 @@
   51.34  	OP_NUM_OPCODES
   51.35  } OPCODE;
   51.36  
   51.37 -/*
   51.38 -* :TODO: List of ASM Opts
   51.39 -*	from jit_x86.cpp 
   51.40 -*       DONE: Rest of opcodes including the SYSREQ.N inlined version (rev2)
   51.41 -*			  Including genarray and the 2 tracker ones
   51.42 -*       DONE: ALL ungen opcodes (rev1)
   51.43 -*	from opcode_helpers.cpp
   51.44 -*       DONE: SYSREQ.N .C (rev2)
   51.45 -*			  MACRO OPCODES (rev2)
   51.46 -*             ERROR CHECKS\{VERIFY ADDR} (rev2)
   51.47 -*			  ARRAY STUFF
   51.48 -*		TODO: BrkDebug
   51.49 -*			  EXEC FUNCTION
   51.50 -*			  VERIFY ADDR
   51.51 -*
   51.52 -*	Oh and ALIGN to 16BYTES all stuff that is called via CALL and frequently used jump labels like what's done with PROC.
   51.53 -*/
   51.54 -
   51.55  #endif //_INCLUDE_SOURCEPAWN_JIT_X86_OPCODE_INFO_H_
    52.1 --- a/sourcepawn/jit/x86/opcode_switch.inc	Fri Mar 21 04:26:53 2008 +0000
    52.2 +++ b/sourcepawn/jit/x86/opcode_switch.inc	Wed Mar 26 03:52:37 2008 +0000
    52.3 @@ -748,6 +748,11 @@
    52.4  				WriteOp_FloatCompare(jit);
    52.5  				break;
    52.6  			}
    52.7 +		case OP_STACKADJUST:
    52.8 +			{
    52.9 +				WriteOp_StackAdjust(jit);
   52.10 +				break;
   52.11 +			}
   52.12  #if defined USE_UNGEN_OPCODES
   52.13  		#include "ungen_opcode_switch.inc"
   52.14  #endif