diff --git a/dlls/hamsandwich/CString.h b/dlls/hamsandwich/CString.h deleted file mode 100644 index 3bdc3605..00000000 --- a/dlls/hamsandwich/CString.h +++ /dev/null @@ -1,413 +0,0 @@ -/* AMX Mod X -* -* by the AMX Mod X Development Team -* originally developed by OLO -* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -*/ - -#ifndef _INCLUDE_CSTRING_H -#define _INCLUDE_CSTRING_H - -#include -#include - -//by David "BAILOPAN" Anderson -class String -{ -public: - String() - { - v = NULL; - a_size = 0; - //assign(""); - } - - ~String() - { - if (v) - delete [] v; - } - - String(const char *src) - { - v = NULL; - a_size = 0; - assign(src); - } - - const char * _fread(FILE *fp) - { - Grow(512, false); - char *ret = fgets(v, 511, fp); - return ret; - } - - String(const String &src) - { - v = NULL; - a_size = 0; - assign(src.c_str()); - } - - const char *c_str() { return v?v:""; } - - const char *c_str() const { return v?v:""; } - - void append(const char *t) - { - Grow(size() + strlen(t) + 1); - strcat(v, t); - } - - void append(const char c) - { - size_t len = size(); - Grow(len + 2); - v[len] = c; - v[len + 1] = '\0'; - } - - void append(String &d) - { - append(d.c_str()); - } - - void assign(const String &src) - { - assign(src.c_str()); - } - - void assign(const char *d) - { - if (!d) - { - clear(); - } else { - size_t len = strlen(d); - Grow(len + 1, false); - memcpy(v, d, len); - v[len] = '\0'; - } - } - - void clear() - { - if (v) - v[0] = '\0'; - } - - int compare (const char *d) const - { - if (!v) - return strcmp("", d); - else - return strcmp(v, d); - } - - //Added this for amxx inclusion - bool empty() const - { - if (!v) - return true; - - if (v[0] == '\0') - return true; - - return false; - } - - size_t size() const - { - if (v) - return strlen(v); - else - return 0; - } - - int find(const char c, int index = 0) - { - int len = static_cast(size()); - if (len < 1) - return npos; - if (index >= len || index < 0) - return npos; - int i = 0; - for (i=index; i=0; i--) - { - if (!is_space(v[i]) - || (is_space(v[i]) && i==0)) - { - erase(i+1, j); - break; - } - j++; - } - } - - if (len == 1) - { - if (is_space(v[0])) - { - clear(); - return; - } - } - } - - void erase(unsigned int start, int num = npos) - { - if (!v) - return; - unsigned int i = 0; - size_t len = size(); - //check for bounds - if (num == npos || start+num > len-start) - num = len - start; - //do the erasing - bool copyflag = false; - for (i=0; i=start && i= len || !v) - return ns; - - if (num == npos) - { - num = len - index; - } else if (index+num >= len) { - num = len - index; - } - - unsigned int i = 0; - unsigned int nslen = num + 2; - - ns.Grow(nslen); - - for (i=index; i= 65 && v[i] <= 90) - v[i] &= ~(1<<5); - } - } - - String & operator = (const String &src) - { - assign(src); - return *this; - } - - String & operator = (const char *src) - { - assign(src); - return *this; - - } - - char operator [] (unsigned int index) - { - if (index > size() || !v) - { - return -1; - } else { - return v[index]; - } - } - - int at(int a) - { - if (a < 0 || a >= (int)size() || !v) - return -1; - - return v[a]; - } - - bool at(int at, char c) - { - if (at < 0 || at >= (int)size() || !v) - return false; - - v[at] = c; - - return true; - } - -private: - void Grow(unsigned int d, bool copy=true) - { - if (d <= a_size) - return; - char *n = new char[d + 1]; - if (copy && v) - strcpy(n, v); - if (v) - delete [] v; - else - strcpy(n, ""); - v = n; - a_size = d + 1; - } - - char *v; - unsigned int a_size; -public: - static const int npos = -1; -}; - -#endif //_INCLUDE_CSTRING_H diff --git a/dlls/hamsandwich/CVector.h b/dlls/hamsandwich/CVector.h deleted file mode 100644 index d0fef2be..00000000 --- a/dlls/hamsandwich/CVector.h +++ /dev/null @@ -1,491 +0,0 @@ -/* AMX Mod X -* -* by the AMX Mod X Development Team -* originally developed by OLO -* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -*/ - -#ifndef __CVECTOR_H__ -#define __CVECTOR_H__ - -#include - -// Vector -template class CVector -{ - bool Grow() - { - // automatic grow - size_t newSize = m_Size * 2; - if (newSize == 0) - newSize = 8; // a good init value - T *newData = new T[newSize]; - if (!newData) - return false; - if (m_Data) - { - for (size_t i=0; i= m_Size) - return Grow(); - else - return true; - } - - bool ChangeSize(size_t size) - { - // change size - if (size == m_Size) - return true; - - if (!size) - { - if (m_Data) - { - delete [] m_Data; - m_Data = NULL; - m_Size = 0; - } - return true; - } - - T *newData = new T[size]; - if (!newData) - return false; - if (m_Data) - { - size_t end = (m_CurrentUsedSize < size) ? (m_CurrentUsedSize) : size; - for (size_t i=0; i m_Size) - m_CurrentUsedSize = m_Size; - - return true; - } - - void FreeMemIfPossible() - { - if (!m_Data) - return; - - if (!m_CurrentUsedSize) - { - ChangeSize(0); - return; - } - - size_t newSize = m_Size; - while (m_CurrentUsedSize <= newSize / 2) - newSize /= 2; - - if (newSize != m_Size) - ChangeSize(newSize); - } -protected: - T *m_Data; - size_t m_Size; - size_t m_CurrentUsedSize; -public: - class iterator - { - protected: - T *m_Ptr; - public: - // constructors / destructors - iterator() - { - m_Ptr = NULL; - } - - iterator(T * ptr) - { - m_Ptr = ptr; - } - - // member functions - T * base() - { - return m_Ptr; - } - - const T * base() const - { - return m_Ptr; - } - - // operators - T & operator*() - { - return *m_Ptr; - } - - T * operator->() - { - return m_Ptr; - } - - iterator & operator++() // preincrement - { - ++m_Ptr; - return (*this); - } - - iterator operator++(int) // postincrement - { - iterator tmp = *this; - ++m_Ptr; - return tmp; - } - - iterator & operator--() // predecrement - { - --m_Ptr; - return (*this); - } - - iterator operator--(int) // postdecrememnt - { - iterator tmp = *this; - --m_Ptr; - return tmp; - } - - bool operator==(T * right) const - { - return (m_Ptr == right); - } - - bool operator==(const iterator & right) const - { - return (m_Ptr == right.m_Ptr); - } - - bool operator!=(T * right) const - { - return (m_Ptr != right); - } - - bool operator!=(const iterator & right) const - { - return (m_Ptr != right.m_Ptr); - } - - iterator & operator+=(size_t offset) - { - m_Ptr += offset; - return (*this); - } - - iterator & operator-=(size_t offset) - { - m_Ptr -= offset; - return (*this); - } - - iterator operator+(size_t offset) const - { - iterator tmp(*this); - tmp.m_Ptr += offset; - return tmp; - } - - iterator operator-(size_t offset) const - { - iterator tmp(*this); - tmp.m_Ptr -= offset; - return tmp; - } - - T & operator[](size_t offset) - { - return (*(*this + offset)); - } - - const T & operator[](size_t offset) const - { - return (*(*this + offset)); - } - - bool operator<(const iterator & right) const - { - return m_Ptr < right.m_Ptr; - } - - bool operator>(const iterator & right) const - { - return m_Ptr > right.m_Ptr; - } - - bool operator<=(const iterator & right) const - { - return m_Ptr <= right.m_Ptr; - } - - bool operator>=(const iterator & right) const - { - return m_Ptr >= right.m_Ptr; - } - - size_t operator-(const iterator & right) const - { - return m_Ptr - right.m_Ptr; - } - }; - - // constructors / destructors - CVector() - { - m_Size = 0; - m_CurrentUsedSize = 0; - m_Data = NULL; - } - - CVector(const CVector & other) - { - // copy data - m_Data = new T [other.m_CurrentUsedSize]; - m_Size = other.m_CurrentUsedSize; - m_CurrentUsedSize = other.m_CurrentUsedSize; - for (size_t i=0; i() - { - clear(); - } - - // interface - size_t size() const - { - return m_CurrentUsedSize; - } - - size_t capacity() const - { - return m_Size; - } - - iterator begin() const - { - return iterator(m_Data); - } - - iterator end() const - { - return iterator(m_Data + m_CurrentUsedSize); - } - - iterator iterAt(size_t pos) - { - if (pos > m_CurrentUsedSize) - assert(0); - return iterator(m_Data + pos); - } - - bool reserve(size_t newSize) - { - if (newSize > m_Size) - return ChangeSize(newSize); - return true; - } - - bool push_back(const T & elem) - { - ++m_CurrentUsedSize; - if (!GrowIfNeeded()) - { - --m_CurrentUsedSize; - return false; - } - - m_Data[m_CurrentUsedSize - 1] = elem; - return true; - } - - void pop_back() - { - --m_CurrentUsedSize; - if (m_CurrentUsedSize < 0) - m_CurrentUsedSize = 0; - - FreeMemIfPossible(); - } - - bool resize(size_t newSize) - { - if (!ChangeSize(newSize)) - return false; - m_CurrentUsedSize = newSize; - return true; - } - - bool empty() const - { - return (m_CurrentUsedSize == 0); - } - - T & at(size_t pos) - { - if (pos > m_CurrentUsedSize) - { - assert(0); - } - return m_Data[pos]; - } - - const T & at(size_t pos) const - { - if (pos > m_CurrentUsedSize) - { - assert(0); - } - return m_Data[pos]; - } - - T & operator[](size_t pos) - { - return at(pos); - } - - const T & operator[](size_t pos) const - { - return at(pos); - } - - T & front() - { - if (m_CurrentUsedSize < 1) - { - assert(0); - } - return m_Data[0]; - } - - const T & front() const - { - if (m_CurrentUsedSize < 1) - { - assert(0); - } - return m_Data[0]; - } - - T & back() - { - if (m_CurrentUsedSize < 1) - { - assert(0); - } - return m_Data[m_CurrentUsedSize - 1]; - } - - const T & back() const - { - if (m_CurrentUsedSize < 1) - { - assert(0); - } - return m_Data[m_CurrentUsedSize - 1]; - } - - iterator insert(iterator where, const T & value) - { - // validate iter - if (where < m_Data || where > (m_Data + m_CurrentUsedSize)) - return iterator(0); - - size_t ofs = where - begin(); - - ++m_CurrentUsedSize; - if (!GrowIfNeeded()) - { - --m_CurrentUsedSize; - return false; - } - - where = begin() + ofs; - - // Move subsequent entries - for (T *ptr = m_Data + m_CurrentUsedSize - 2; ptr >= where.base(); --ptr) - *(ptr + 1) = *ptr; - - *where.base() = value; - - return where; - } - - iterator erase(iterator where) - { - // validate iter - if (where < m_Data || where >= (m_Data + m_CurrentUsedSize)) - return iterator(0); - - size_t ofs = where - begin(); - - if (m_CurrentUsedSize > 1) - { - // move - T *theend = m_Data + m_CurrentUsedSize; - for (T *ptr = where.base() + 1; ptr < theend; ++ptr) - *(ptr - 1) = *ptr; - } - - --m_CurrentUsedSize; - - FreeMemIfPossible(); - - return begin() + ofs; - } - - void clear() - { - m_Size = 0; - m_CurrentUsedSize = 0; - if (m_Data) - { - delete [] m_Data; - m_Data = NULL; - } - } -}; - -#endif // __CVECTOR_H__ - diff --git a/dlls/hamsandwich/FileParser.cpp b/dlls/hamsandwich/FileParser.cpp deleted file mode 100644 index d4a0489c..00000000 --- a/dlls/hamsandwich/FileParser.cpp +++ /dev/null @@ -1,161 +0,0 @@ -#include -#include -#include -#include - -#include "sdk/amxxmodule.h" - -#include "FileParser.h" - -#define FP_MAX_LENGTH 2048 - - -/** - * Given a string, this will remove whitespace at the beginning and end, and remove comments. - * - * @param data The string to format. It changes this data directly. - * @return Returns a pointer to the end of the newly formated string. - */ -static char *FP_FormatLine(char *data) -{ - char *End; /**< Pointer to the end of the string. */ - char *Start; /**< Pointer to the start of the string. */ - char *Temp; /**< Temporary pointer for parsing. */ - - Start=data; - - // Strip beginning whitespace - while (*Start==' ' || *Start=='\t') Start++; - - // if the beginning non-whitespace character is a ';', then it's a comment - // ignore the rest of the file - if (*Start==';') - { - // just set data[0] to \0 and return out of here. - *data='\0'; - return data; - } - - // now strip comments from the end of a line - Temp=Start; - - End=Start+(strlen(Start)-1); - - - while (Temp<=End) - { - if (*Temp==';') - { - *Temp='\0'; - break; - } - ++Temp; - } - - - - // now go to the end of the line, and remove whitespace - - while ( (*End=='\n' || - *End=='\r' || - *End==' ' || - *End=='\t') && - End>=Start) - { - End--; - } - ++End; - *End='\0'; - - // if Start==data, we're done - if (Start==data) - { - return End; - } - - // otherwise, copy from Start to data - - while ((*data++=*Start++)!='\0')/*do nothing*/; - - return End; -}; - -static const char* get_localinfo( const char* name , const char* def = 0 ) -{ - const char* b = LOCALINFO( (char*)name ); - if (((b==0)||(*b==0)) && def ) - SET_LOCALINFO((char*)name,(char*)(b = def) ); - return b; -} -/** - * Reads the config file and parses keys. - * - * @param Category The category (prefix) to look for. Eg.: "cs_linux_", "dod_windows_" - * @param Feedback The function to call when a match is made. - * @noreturn - */ -void FP_SetupOffsets(const char *Category, FP_ptrFeedback Feedback) -{ - char FileName[512]; - - size_t CatLen=strlen(Category); - - MF_BuildPathnameR(FileName,sizeof(FileName)-1,"%s",get_localinfo("amxx_configsdir","addons/amxmodx/configs")); - - strncat(FileName,"/hamdata.ini",sizeof(FileName)-1); - - FILE *fp=fopen(FileName,"r"); - - if (!fp) - { - MF_Log("Unable to open \"%s\" for reading",FileName); - return; - } - - char Data[FP_MAX_LENGTH + 1]; - - - while (!feof(fp)) - { - - Data[0]='\0'; - - fgets(Data,FP_MAX_LENGTH,fp); - - FP_FormatLine(Data); - - if (strncmp(Data,Category,CatLen)==0) - { - // Find the first space, set it to NULL - char *Param=&Data[0]; - - while (*Param!=' ' && *Param!='\t' && *Param!='\0') - { - ++Param; - } - if (*Param=='\0') - { - // special instance; if this is NULL get out of here - continue; - } - - // NULL this space, and then find the first non whitespace character and - // use that as the parameter field in the callback - *Param++='\0'; - while (*Param==' ' || *Param=='\t') - { - ++Param; - } - - if (*Param=='\0') - { - // special instance; if this is NULL get out of here - continue; - } - Feedback(&Data[0],Param); - } - } - - - fclose(fp); -} diff --git a/dlls/hamsandwich/FileParser.h b/dlls/hamsandwich/FileParser.h deleted file mode 100644 index 8cae8d79..00000000 --- a/dlls/hamsandwich/FileParser.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef FILEPARSER_H -#define FILEPARSER_H - -typedef bool (*FP_ptrFeedback)(const char *key, const char *value); - -#endif // FILEPARSER_H diff --git a/dlls/hamsandwich/Makefile b/dlls/hamsandwich/Makefile deleted file mode 100644 index b933dbe6..00000000 --- a/dlls/hamsandwich/Makefile +++ /dev/null @@ -1,116 +0,0 @@ -#(C)2004-2005 AMX Mod X Development Team -# Makefile written by David "BAILOPAN" Anderson - -HLSDK = ../../../hlsdk -MM_ROOT = ../../metamod/metamod - -### EDIT BELOW FOR OTHER PROJECTS ### - - -CRAZY_OPT_FLAGS = -DCRAZY_OPTS -O3 -funroll-loops -ffast-math -s -pipe -fomit-frame-pointer -fno-strict-aliasing -DNDEBUG -fmerge-all-constants -fmodulo-sched -fgcse-sm -fgcse-las -fgcse-after-reload -floop-optimize2 -funsafe-loop-optimizations -ftree-loop-linear -ftree-loop-im -ftree-loop-ivcanon -fivopts -ftree-vectorize -fvariable-expansion-in-unroller -funsafe-math-optimizations -ffinite-math-only -fpeel-loops -funswitch-loops -fvisibility=hidden -fvisibility-inlines-hidden -fPIC -Wall -Wno-unknown-pragmas -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H -static-libgcc -fno-rtti -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion -Wsign-compare -Wmissing-noreturn -Winline -Wlong-long -Wunsafe-loop-optimizations -Wctor-dtor-privacy -Wno-non-virtual-dtor -Wreorder -Woverloaded-virtual -Wsign-promo -Wsynth -shared - -CRAZY_LINK_FLAGS = -fwhole-program -#-fwhole-program -combine - -SANE_OPT_FLAGS = -O3 -funroll-loops -s -pipe -fomit-frame-pointer -fno-strict-aliasing -DNDEBUG - -OPT_FLAGS = - -DEBUG_FLAGS = -g -ggdb3 -CPP = gcc-4.1 -#CPP = gcc-2.95 -NAME = hamsandwich - -BIN_SUFFIX = amxx_i386.so - -OBJECTS = sdk/amxxmodule.cpp FileParser.cpp amxxapi.cpp hooks.cpp \ -tableentries/VTableManager.cpp tableentries/TakeDamage.cpp tableentries/Use.cpp \ -tableentries/Blocked.cpp tableentries/Killed.cpp tableentries/Respawn.cpp \ -tableentries/Restart.cpp tableentries/AddPoints.cpp tableentries/AddPointsToTeam.cpp \ -tableentries/AddPlayerItem.cpp tableentries/RemovePlayerItem.cpp tableentries/IsPlayer.cpp \ -tableentries/BloodColor.cpp tableentries/ObjectCaps.cpp tableentries/Classify.cpp \ -tableentries/IsInWorld.cpp tableentries/IsNetClient.cpp tableentries/IsSneaking.cpp \ -tableentries/IsMoving.cpp tableentries/IsBSPModel.cpp tableentries/IsAlive.cpp \ -tableentries/GetToggleState.cpp tableentries/Think.cpp tableentries/Touch.cpp - - -#natives.cpp vtable.cpp - -#tableentries/VTableUse.cpp tableentries/VTableTakedamage.cpp - - -#natives/cs.cpp natives/dod.cpp natives/tfc.cpp \ -#natives/ns.cpp natives/ts.cpp natives/sven.cpp \ -#FileParser.cpp - -LINK = - -INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/game_shared \ - -I$(MM_ROOT) -I$(HLSDK)/common -I$(HLSDK)/pm_shared -I./tableentries - -GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1) - -ifeq "$(DEBUG)" "true" - BIN_DIR = Debug - CFLAGS = $(DEBUG_FLAGS) -else - ifeq "$(CRAZY)" "true" - BIN_DIR = Optimized - OPT_FLAGS = $(CRAZY_OPT_FLAGS) - LINK = $(CRAZY_LINK_FLAGS) - else - BIN_DIR = Release - OPT_FLAGS = $(SANE_OPT_FLAGS) - endif - ifeq "$(GCC_VERSION)" "4" - OPT_FLAGS += -fvisibility=hidden -fvisibility-inlines-hidden - endif - CFLAGS = $(OPT_FLAGS) -endif - -CFLAGS += -fPIC -Wall -Wno-non-virtual-dtor -fno-exceptions -DHAVE_STDINT_H -fno-rtti - -BINARY = $(NAME)_$(BIN_SUFFIX) -CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32 -OPT_FLAGS += -march=i586 - -OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) - -$(BIN_DIR)/%.o: %.cpp - $(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $< - -all: - mkdir -p $(BIN_DIR) - mkdir -p $(BIN_DIR)/sdk - mkdir -p $(BIN_DIR)/natives - mkdir -p $(BIN_DIR)/tableentries - $(MAKE) hamsandwich - -hamsandwich: $(OBJ_LINUX) - $(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) - -debug: - $(MAKE) all DEBUG=true - -default: all - -crazy: - $(MAKE) all CRAZY=true - -clean: - rm -rf Release/*.o - rm -rf Release/sdk/*.o - rm -rf Release/natives/*.o - rm -rf Release/tableentries/*.o - rm -rf Release/$(NAME)_$(BIN_SUFFIX) - rm -rf Debug/*.o - rm -rf Debug/sdk/*.o - rm -rf Debug/natives/*.o - rm -rf Debug/tableentries/*.o - rm -rf Debug/$(NAME)_$(BIN_SUFFIX) - rm -rf Optimized/*.o - rm -rf Optimized/sdk/*.o - rm -rf Optimized/natives/*.o - rm -rf Optimized/tableentries/*.o - rm -rf Optimized/$(NAME)_$(BIN_SUFFIX) - diff --git a/dlls/hamsandwich/NEW_Util.h b/dlls/hamsandwich/NEW_Util.h deleted file mode 100644 index e76fbf23..00000000 --- a/dlls/hamsandwich/NEW_Util.h +++ /dev/null @@ -1,90 +0,0 @@ -/* Ham Sandwich - * - * by sawce - * - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - */ - -/* Inlined replacements for INDEXENT/ENTINDEX - * It only really removes the overhead of the push/jump - * but since INDEXENT/ENTINDEX are used a lot with amxx - * it might be beneficial to include. - * NOTE: Bad stuff will happen if you call these before - * NEW_Initialize() - * NOTE: No bounds checking is done because natives - * should use their own bounds checking! - */ - -#ifndef NEW_UTIL_H -#define NEW_UTIL_H - - -extern edict_t *NEW_FirstEdict; -extern bool NEW_Initialized; - -/** - * This is called on the first Spawn() ever hooked. This would be worldspawn (index 0) - */ -inline void NEW_Initialize(edict_t *Entity) -{ - // This is not worldspawn? - // compensate - NEW_FirstEdict=Entity; - NEW_Initialized=true; -} - - -/** - * Converts an integer index into an edict pointer - */ -inline edict_t *INDEXENT_NEW(const int Index) -{ - return (edict_t *)(NEW_FirstEdict + Index); -}; - -/** - * Converts an edict pointer into an integer index - */ -inline int ENTINDEX_NEW(const edict_t *Ent) -{ - return (int)(Ent - NEW_FirstEdict); -}; - -// Inlined replacement of MF_GetAmxAddr - - -inline REAL amx_ctof2(cell x) -{ - return *(REAL*)&x; -} -inline cell amx_ftoc2(REAL x) -{ - return *(cell*)&x; -} - - -#endif // NEW_UTIL_H - diff --git a/dlls/hamsandwich/Trampolines.h b/dlls/hamsandwich/Trampolines.h deleted file mode 100644 index 1fbc5ffd..00000000 --- a/dlls/hamsandwich/Trampolines.h +++ /dev/null @@ -1,632 +0,0 @@ -/* Trampolines - * - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - */ - - -#ifndef TRAMPOLINES_H -#define TRAMPOLINES_H - -#ifndef NDEBUG -#define TPRINT(msg) printf msg -#else -#define TPRINT(msg) /* nothing */ -#endif - -#if defined _WIN32 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif // WIN32_LEAN_AND_MEAN -#if _MSC_VER >= 1400 -#ifdef offsetof -#undef offsetof -#endif // offsetof -#endif // _MSC_VER >= 1400 -#include -#elif defined __linux__ -#include -#endif -#include // size_t -#include // memcpy - - -namespace Trampolines -{ - - /** - * List of x86 bytecodes for creating - * basic trampolines at runtime. - * - - * These are defined here so that, should - * the need ever arise, this can be ported - * to other architectures fairly painlessly - */ - namespace Bytecode - { - /** - * Prologue for a void function - * Clobbers EBX and EAX - */ - const unsigned char codeVoidPrologue[] = { - 0x55, // push ebp - 0x89, 0xE5, // mov ebp, esp - 0x50, // push eax - }; - - /** - * Prologue for a function that returns - * Clobbers EBX, EAX too but not after call - */ - const unsigned char codeReturnPrologue[] = { - 0x55, // push ebp - 0x89, 0xE5, // mov ebp, esp - }; - const unsigned char codeThisReturnPrologue[] = { - 0x55, // push ebp - 0x89, 0xE5, // mov ebp, esp - }; - - - /** - * Takes a paramter from the trampoline's stack - * and pushes it onto the target's stack. - */ - const unsigned char codePushParam[] = { - 0xFF, 0x75, 0xFF // pushl [ebp+0xFF] - }; - - /** - * Offset of codePushParam to modify at runtime - * that contains the stack offset - */ - const unsigned int codePushParamReplace = 2; - - - /** - * Takes the "this" pointer from the trampoline and - * pushes it onto the target's stack. - */ - const unsigned char codePushThis[] = { - #if defined _WIN32 - 0x51 // push ecx - #elif defined __linux__ - 0xFF, 0x75, 0x04 // pushl [ebp+0x08h] - #endif - }; - -#if defined __linux__ - const int codePushThisReplace = 2; -#endif - - /** - * Pushes a raw number onto the target's stack - */ - const unsigned char codePushID[] = { - 0x68, 0xDE, 0xFA, 0xAD, 0xDE // push DEADFADEh - }; - - /** - * Offset of codePushID to modify at runtime - * to contain the number to push - */ - const unsigned int codePushIDReplace = 1; - - /** - * Call our procedure - */ - const unsigned char codeCall[] = { - 0xB8, 0xDE, 0xFA, 0xAD, 0xDE,// mov eax, DEADFADEh - 0xFF, 0xD0 // call eax - }; - - /** - * Offset of codeCall to modify at runtime - * to contain the pointer to the function - */ - const unsigned int codeCallReplace = 1; - - /** - * Adds to ESP, freeing up stack space - */ - const unsigned char codeFreeStack[] = { - 0x81, 0xC4, 0xFF, 0xFF, 0xFF, 0xFF// add esp REPLACEME - }; - - /** - * Offset of codeFreeStack to modify at runtime - * to contain how much data to free - */ - const unsigned int codeFreeStackReplace = 2; - - /** - * Epilogue of a simple return function - */ - const unsigned char codeReturnEpilogue[] = { - 0x5D, // pop ebp - 0xC3 // ret - }; - const unsigned char codeReturnEpilogueN[] = { - 0x5D, // pop ebp - 0xC2, 0xCD, 0xAB // retn 0xABCD - }; - const int codeReturnEpilogueNReplace = 2; - - - /** - * Epilogue of a void return function - */ - const unsigned char codeVoidEpilogue[] = { - 0x58, // pop eax - 0x5D, // pop ebp - 0xC3 // ret - }; - - const unsigned char codeVoidEpilogueN[] = { - 0x58, // pop eax - 0x5D, // pop ebp - 0xC2, 0xCD, 0xAB // retn 0xABCD - }; - const int codeVoidEpilogueNReplace = 3; - - - - const unsigned char codeBreakpoint[] = { - 0xCC // int 3 - }; - - } - - /** - * Our actual maker of the trampolines!!@$ - * I've no idea why I made this a class and not a namespace - * Oh well! - */ - - class TrampolineMaker - { - private: - unsigned char *m_buffer; // the actual buffer containing the code - int m_size; // size of the buffer - int m_mystack; // stack for the trampoline itself - int m_calledstack; // stack for the target function - int m_paramstart; - int m_thiscall; - - /** - * Adds data to the buffer - * data must be pre-formatted before hand! - */ - void Append(const unsigned char *src, size_t size) - { - int orig=m_size; - m_size+=size; - - if (m_buffer==NULL) - { - m_buffer=(unsigned char *)malloc(m_size); - } - else - { - m_buffer=(unsigned char *)realloc(m_buffer,m_size); - } - - unsigned char *dat=m_buffer+orig; // point dat to the end of the prewritten - - while (origReturnPrologue(); - m_thiscall=1; - }; - - /** - * Adds the void prologue pushes registers, prepares the stack - */ - void VoidPrologue() - { - Append(&::Trampolines::Bytecode::codeVoidPrologue[0],sizeof(::Trampolines::Bytecode::codeVoidPrologue)); - m_paramstart=0; - m_thiscall=0; - }; - - /** - * Flags this trampoline as a thiscall trampoline, and prepares the void prologue. - */ - void ThisVoidPrologue() - { - this->VoidPrologue(); - m_thiscall=1; - }; - /** - * Epilogue for a returning function pops registers but does not free any more of the stack! - */ - void ReturnEpilogue() - { - Append(&::Trampolines::Bytecode::codeReturnEpilogue[0],sizeof(::Trampolines::Bytecode::codeReturnEpilogue)); - }; - - /** - * Epilogue that also frees it's estimated stack usage. Useful for stdcall/thiscall/fastcall. - */ - void ReturnEpilogueAndFree() - { - printf("Freeing %d bytes\n",m_mystack); - this->ReturnEpilogue(m_mystack); - }; - - /** - * Return epilogue. Pops registers, and frees given amount of data from the stack. - * - * @param howmuch How many bytes to free from the stack. - */ - void ReturnEpilogue(int howmuch) - { - - unsigned char code[sizeof(::Trampolines::Bytecode::codeReturnEpilogueN)]; - - memcpy(&code[0],&::Trampolines::Bytecode::codeReturnEpilogueN[0],sizeof(::Trampolines::Bytecode::codeReturnEpilogueN)); - - - unsigned char *c=&code[0]; - - union - { - int i; - unsigned char b[4]; - } bi; - - bi.i=howmuch; - - c+=::Trampolines::Bytecode::codeReturnEpilogueNReplace; - *c++=bi.b[0]; - *c++=bi.b[1]; - - Append(&code[0],sizeof(::Trampolines::Bytecode::codeReturnEpilogueN)); - //Append(&::Trampolines::Bytecode::codeReturnEpilogueN[0],sizeof(::Trampolines::Bytecode::codeReturnEpilogueN)); - }; - - /** - * Void epilogue, pops registers and frees the estimated stack usage of the trampoline. - */ - void VoidEpilogueAndFree() - { - printf("Freeing %d bytes\n",m_mystack); - this->VoidEpilogue(m_mystack); - }; - /** - * Void epilogue, pops registers, nothing else done with stack. - */ - void VoidEpilogue() - { - Append(&::Trampolines::Bytecode::codeVoidEpilogue[0],sizeof(::Trampolines::Bytecode::codeVoidEpilogue)); - }; - /** - * Void epilogue, pops registers, frees given amount of data off of the stack. - * - * @param howmuch How many bytes to free from the stack. - */ - void VoidEpilogue(int howmuch) - { - - unsigned char code[sizeof(::Trampolines::Bytecode::codeVoidEpilogueN)]; - - memcpy(&code[0],&::Trampolines::Bytecode::codeVoidEpilogueN[0],sizeof(::Trampolines::Bytecode::codeVoidEpilogueN)); - - - unsigned char *c=&code[0]; - - union - { - int i; - unsigned char b[4]; - } bi; - - bi.i=howmuch; - - c+=::Trampolines::Bytecode::codeVoidEpilogueNReplace; - *c++=bi.b[0]; - *c++=bi.b[1]; - - Append(&code[0],sizeof(::Trampolines::Bytecode::codeVoidEpilogueN)); - Append(&::Trampolines::Bytecode::codeVoidEpilogueN[0],sizeof(::Trampolines::Bytecode::codeVoidEpilogueN)); - }; - - /** - * Pushes the "this" pointer onto the callee stack. Pushes ECX for MSVC, and param0 on GCC. - */ - void PushThis() - { - - if (!m_thiscall) - { - return; - } - - unsigned char code[sizeof(::Trampolines::Bytecode::codePushThis)]; - - memcpy(&code[0],&::Trampolines::Bytecode::codePushThis[0],sizeof(::Trampolines::Bytecode::codePushThis)); - - -#if defined __linux__ - unsigned char *c=&code[0]; - - union - { - int i; - unsigned char b[4]; - } bi; - - bi.i=m_paramstart+8; - - c+=::Trampolines::Bytecode::codePushThisReplace; - *c++=bi.b[0]; -#endif - - Append(&code[0],sizeof(::Trampolines::Bytecode::codePushThis)); - -#if defined __linux__ - TPRINT(("mystack=%d+4\n",m_mystack)); - m_mystack+=4; -#endif - TPRINT(("calledstack=%d+4\n",m_calledstack)); - m_calledstack+=4; - }; - - /** - * Frees what is estimated as the stack usage of the trampoline. - */ - void FreeMyStack(void) - { - - TPRINT(("freeing mystack=%d+4\n",m_mystack)); - this->FreeStack(m_mystack); - }; - - /** - * Frees the estimated stack usage of the callee. - */ - void FreeTargetStack(void) - { - TPRINT(("freeing calledstack=%d+4\n",m_calledstack)); - this->FreeStack(m_calledstack); - }; - - - /** - * Frees the estimated stack usage of the callee and the trampoline. - */ - void FreeBothStacks(void) - { - TPRINT(("freeing mystack=%d+4\n",m_mystack)); - TPRINT(("freeing calledstack=%d+4\n",m_calledstack)); - this->FreeStack(m_calledstack + m_mystack); - }; - - /** - * Frees a given amount of bytes from the stack. - * - * @param howmuch How many bytes to free. - */ - void FreeStack(int howmuch) - { - unsigned char code[sizeof(::Trampolines::Bytecode::codeFreeStack)]; - - memcpy(&code[0],&::Trampolines::Bytecode::codeFreeStack[0],sizeof(::Trampolines::Bytecode::codeFreeStack)); - - unsigned char *c=&code[0]; - - union - { - int i; - unsigned char b[4]; - } bi; - - bi.i=howmuch; - - c+=::Trampolines::Bytecode::codeFreeStackReplace; - *c++=bi.b[0]; - *c++=bi.b[1]; - *c++=bi.b[2]; - *c++=bi.b[3]; - - Append(&code[0],sizeof(::Trampolines::Bytecode::codeFreeStack)); - - }; - - /** - * Pushes a raw number onto the callee stack. - * - * @param Number The number to push onto the callee stack. - */ - void PushNum(int Number) - { - unsigned char code[sizeof(::Trampolines::Bytecode::codePushID)]; - - memcpy(&code[0],&::Trampolines::Bytecode::codePushID[0],sizeof(::Trampolines::Bytecode::codePushID)); - - unsigned char *c=&code[0]; - - union - { - int i; - unsigned char b[4]; - } bi; - - bi.i=Number; - - c+=::Trampolines::Bytecode::codePushIDReplace; - *c++=bi.b[0]; - *c++=bi.b[1]; - *c++=bi.b[2]; - *c++=bi.b[3]; - - Append(&code[0],sizeof(::Trampolines::Bytecode::codePushID)); - - TPRINT(("calledstack=%d+4\n",m_calledstack)); - m_calledstack+=4; // increase auto detected stack size - - }; - - - /** - * Takes a parameter passed on the trampoline's stack and inserts it into the callee's stack. - * - * @param which The parameter number to push. 1-based. "thiscall" trampolines automatically compensate for the off-number on GCC. - */ - void PushParam(int which) - { -#if defined __linux__ - if (m_thiscall) - { - which++; - } -#endif - which=which*4; - which+=m_paramstart+4; - - unsigned char value=which; - - unsigned char code[sizeof(::Trampolines::Bytecode::codePushParam)]; - - memcpy(&code[0],&::Trampolines::Bytecode::codePushParam[0],sizeof(::Trampolines::Bytecode::codePushParam)); - - unsigned char *c=&code[0]; - - - c+=::Trampolines::Bytecode::codePushParamReplace; - - *c=value; - - Append(&code[0],sizeof(::Trampolines::Bytecode::codePushParam)); - - TPRINT(("calledstack=%d+4\n",m_calledstack)); - m_calledstack+=4; // increase auto detected stack size - TPRINT(("mystack=%d+4\n",m_mystack)); - m_mystack+=4; - - }; - - /** - * Insert a function to call into the trampoline. - * - * @param ptr The function to call, cast to void*. - */ - void Call(void *ptr) - { - unsigned char code[sizeof(::Trampolines::Bytecode::codeCall)]; - - memcpy(&code[0],&::Trampolines::Bytecode::codeCall[0],sizeof(::Trampolines::Bytecode::codeCall)); - - unsigned char *c=&code[0]; - - union - { - void *p; - unsigned char b[4]; - } bp; - - bp.p=ptr; - - c+=::Trampolines::Bytecode::codeCallReplace; - - *c++=bp.b[0]; - *c++=bp.b[1]; - *c++=bp.b[2]; - *c++=bp.b[3]; - Append(&code[0],sizeof(::Trampolines::Bytecode::codeCall)); - - - }; - - /** - * Finalizes the trampoline. Do not try to modify it after this. - * - * @param size A pointer to retrieve the size of the trampoline. Ignored if set to NULL. - * @return The trampoline pointer, cast to void*. - */ - void *Finish(int *size) - { - void *ret=(void *)m_buffer; - - if (size) - { - *size=m_size; - } -#if defined _WIN32 - DWORD OldFlags; - VirtualProtect(ret,m_size,PAGE_EXECUTE_READWRITE,&OldFlags); -#elif defined __linux__ - mprotect(ret,m_size,PROT_READ|PROT_WRITE|PROT_EXEC); -#endif - - - m_size=0; - m_buffer=NULL; // so we don't accidentally rewrite! - m_mystack=0; - m_calledstack=0; - - return ret; - }; - }; -}; - - -#endif // TRAMPOLINEMANAGER_H diff --git a/dlls/hamsandwich/amxxapi.cpp b/dlls/hamsandwich/amxxapi.cpp deleted file mode 100644 index e0e1bf40..00000000 --- a/dlls/hamsandwich/amxxapi.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* AMX Mod X -* -* by the AMX Mod X Development Team -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -* Description: AMX Mod X Module Interface hooks -*/ - -#include -#include - -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "CVector.h" -#include "CString.h" - -#include "FileParser.h" - -#include "NEW_Util.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -CVector SuffixNames; /**< List of names being searched for in the config file. */ -CVector SuffixFunctions; /**< Callback functions for when we find a hunted keyvalue. */ -CVector ConfigDoneCallbacks; /**< Callbacks when our config file is done being parsed. */ - -edict_t *NEW_FirstEdict=NULL; /**< Used for the NEW_Utils INDEXENT/ENTINDEX replacements. */ -bool NEW_Initialized=false; /**< Whether NEW_Utils has been initialized yet. */ - -void FP_SetupOffsets(const char *name, FP_ptrFeedback feedback); - - -unsigned int HAM_pev=0; /**< Offset of pev from the this pointer. */ -unsigned int HAM_pevset=0; /**< Whether or not the pev offset has been set. */ -unsigned int HAM_classbase=0; /**< Offset of the vtable from the this pointer. */ -unsigned int HAM_classbaseset=0; /**< Whether or not the classbase offset has been set. */ - -char ModKey[256]; /**< Temporary buffer for holding the _ prefix. */ - -/** - * Adds a callback to the config parser for this config suffix. - * - * @param suffix The suffix to add, eg "takedamage" would be called for "cs_linux_takedamage" - * @param callback The function to call when this key is found. - * @noreturn - */ -void RegisterKeySuffix(const char *suffix, void (*callback)(const char *,const char *)) -{ - String *Suffix=new String(suffix); - - - SuffixNames.push_back(Suffix); - - SuffixFunctions.push_back(callback); -}; - -/** - * Adds this entry to the configdone callback. - * - * @param callback Function to call when the config file is done being parsed. - * @noreturn - */ -void RegisterConfigCallback(void (*callback)(void)) -{ - ConfigDoneCallbacks.push_back(callback); -}; -/** - * Starts each vtable entry. This needs to be edited for every additional hook. - * - * @noreturn - */ -void HAM_CallInitialization(void) -{ -#define VTINIT(TableName) VTable##TableName::Initialize(&HAM_pev,&HAM_pevset,&HAM_classbase,&HAM_classbaseset) - - VTINIT(TakeDamage); - VTINIT(Use); - VTINIT(Killed); - VTINIT(Blocked); - VTINIT(Respawn); - VTINIT(Restart); - VTINIT(AddPoints); - VTINIT(AddPointsToTeam); - VTINIT(AddPlayerItem); - VTINIT(RemovePlayerItem); - VTINIT(BloodColor); - VTINIT(Classify); - VTINIT(GetToggleState); - VTINIT(IsAlive); - VTINIT(IsBSPModel); - VTINIT(IsInWorld); - VTINIT(IsMoving); - VTINIT(IsNetClient); - VTINIT(IsPlayer); - VTINIT(IsSneaking); - VTINIT(ObjectCaps); - VTINIT(Think); - VTINIT(Touch); - - -#undef VTINIT -} - -/** - * Tells all the table entries that the config file is done being parsed. Register their natives now. - * - * @noreturn - */ -void HAM_CallConfigDone(void) -{ - int i=0; /**< Iterator. */ - int end=ConfigDoneCallbacks.size(); /**< How many to parse. */ - - while (i__ prefix is found. - * - * @param key The full key (eg: cs_windows_takedamage) - * @param data The corresponding data. - * @return true when key is used, false otherwise - */ -bool HAM_GetKey(const char *key, const char *data) -{ - char TempKey[512]; /**< Temporary buffer. */ - int i=0; /**< Iterator. */ - int end=SuffixNames.size(); /**< How many suffixes to check. */ - bool found=false; /**< Whether this key has been used or not. */ - - while (ic_str()); - if (strcmp(TempKey,key)==0) - { - SuffixFunctions[i](SuffixNames[i]->c_str(),data); - found=true; - } - ++i; - } - return found; -} -/** - * Simple function to set the "pev" field that is used by all forwards. - * - * @param key The key suffix being forwarded. - * @param data The data corresponding to the key. - * @noreturn - */ -void HAM_SetPev(const char *key, const char *data) -{ - HAM_pev=HAM_StrToNum(data); - HAM_pevset=1; -} -/** - * Simple function to set the "classbase" field that is used by all natives when built with GCC. - * - * @param key The key suffix being forwarded. - * @param data The data corresponding to the key. - * @noreturn - */ -#if defined __linux__ -void HAM_SetClassBase(const char *key, const char *data) -{ - HAM_classbase=HAM_StrToNum(data); - HAM_classbaseset=1; -} -#endif - -void OnAmxxAttach() -{ - HAM_CallInitialization(); -#ifdef __linux__ - snprintf(ModKey,sizeof(ModKey)-1,"%s_linux",MF_GetModname()); -#else - snprintf(ModKey,sizeof(ModKey)-1,"%s_windows",MF_GetModname()); -#endif - - RegisterKeySuffix("pev",HAM_SetPev); - - // this is only needed for Linux -#if defined __linux__ - RegisterKeySuffix("classbase",HAM_SetClassBase); -#else // Emulate it being set on Windows, since it's not needed - HAM_classbase=0; - HAM_classbaseset=1; -#endif - - RegisterRegisterNatives(); - - FP_SetupOffsets(ModKey,HAM_GetKey); - - HAM_CallConfigDone(); - - /* TODO: Cbase natives - if (HAM_Set & HAM_GOT_PEV) - { - HAM_RegisterCbaseFast(); - } - HAM_RegisterCbaseSafe(); - - VTH_Natives(); - */ -} - -void OnPluginsLoaded() -{ - NEW_Initialize(INDEXENT(0)); - -}; -void OnPluginsUnloaded() -{ - VTMan.Cleanup(); -}; diff --git a/dlls/hamsandwich/config/hamdata.ini b/dlls/hamsandwich/config/hamdata.ini deleted file mode 100644 index 21fcb84d..00000000 --- a/dlls/hamsandwich/config/hamdata.ini +++ /dev/null @@ -1,120 +0,0 @@ -; Ham Sandwich module config file -; - -; Do not modify this file unless you know exactly what you're doing! -; - -; entry syntax is as follows: -; [modname]_[os]_key -; Example: the "use" key on TS running Linux would be "ts_linux_use" -; "modname" is the game directory, NOT the game description! -; eg: "ts", not "The Specialists" -; - -; Keys support either hexadecimal (MUST prefix with 0x) or base 10 -; - -; Key types: -; * takedamage: this is the vtable index of the takedamage routine -; * use: this is the vtable index of the use routine -; * pev: this is the offset in bytes of the location of pev in the cbaseentity -; * classbase: this is the size in bytes of the cbaseentity base class LINUX ONLY -; NOTE: If the mod is compiled with GCC 3.3+ (NS is the only one -; I know of), then the classbase will always be 0x0 -; - -; NOTE: If a mod is missing keys for a certain native, that particular native -; will not be loaded! Example: Say CS is missing the "takedamage" index -; but has the use and pev indexes. The hs_use and hs_pdata_cbase natives -; will be registered, but the hs_takedamage native will not be registered. - -; Data dated: 2007-02-23 -; Version tested: 1.6 Steam (legitimate) -cstrike_windows_takedamage 12 -cstrike_windows_killed 14 ;estimated -cstrike_windows_addpoints 23 ;estimated -cstrike_windows_addpointstoteam 24 ;estimated -cstrike_windows_use 46 -cstrike_windows_blocked 47 ;estimated -cstrike_windows_respawn 48 ;estimated -cstrike_windows_pev 4 -cstrike_linux_restart 4 ;estimated -cstrike_linux_takedamage 14 -cstrike_windows_addpoints 25 ;estimated -cstrike_windows_addpointstoteam 26 ;estimated -cstrike_linux_killed 16 ;estimated -cstrike_linux_use 48 -cstrike_linux_blocked 49 ;estimated -cstrike_linux_respawn 50 ;estimated -cstrike_linux_pev 0 -cstrike_linux_classbase 0x94 - -; Data dated: 2007-02-23 -; Version tested: 1.6 Steam (legitimate) -czero_windows_takedamage 12 -czero_windows_use 46 -czero_windows_pev 4 -czero_linux_takedamage 14 -czero_linux_use 48 -czero_linux_pev 0 -czero_linux_classbase 0x94 - -; Data dated: 2007-02-23 -; Version tested: 3.1 -ns_windows_takedamage 10 -ns_windows_use 49 -ns_windows_pev 4 -ns_linux_takedamage 11 -ns_linux_use 50 -ns_linux_pev 4 -ns_linux_classbase 0x0 - -; Data dated: 2007-02-23 -; Version tested: 3.2 beta 2 -nsp_windows_takedamage 10 -nsp_windows_use 49 -nsp_windows_pev 4 -nsp_linux_takedamage 11 -nsp_linux_use 50 -nsp_linux_pev 4 -nsp_linux_classbase 0x0 - -; Data dated: 2007-02-23 -; Version tested: 1.3 (?) Steam (legitimate) -dod_windows_takedamage 18 -dod_windows_use 51 -dod_windows_pev 4 -dod_linux_takedamage 20 -dod_linux_use 51 -dod linux_pev 0 -dod_linux_classbase 0x154 - -; Data dated: 2007-02-23 -; Version tested: 2.1 -ts_windows_takedamage 12 -ts_windows_use 44 -ts_windows_pev 4 -ts_linux_takedamage 14 -ts_linux_use 46 -ts_linux_pev 0 -ts_linux_classbase 0x470 - -; Data dated: 2007-02-23 -; Version tested: 1.5 Steam (legitimate) -tfc_windows_takedamage 14 -tfc_windows_use 48 -tfc_windows_pev 4 -tfc_linux_takedamage 16 -tfc_linux_use 50 -tfc_linux_pev 0 -tfc_linux_classbase 0x60 - -; Data dated: 2007-02-23 -; Version tested: 3.0 -; Sven-Coop does not have a Linux build -svencoop_windows_takedamage 11 -svencoop_windows_use 46 -svencoop_windows_pev 4 - -; Data dated: 2007-02-26 -; Version tested: 2.18.07 -; Earth's Special Forces (I can't find the non beta version, but it should still work!) -; ESF does not have a Linux binary! -esf_openbeta_windows_takedamage 12 -esf_openbeta_windows_use 46 -esf_openbeta_windows_pev 4 \ No newline at end of file diff --git a/dlls/hamsandwich/hamsandwich.h b/dlls/hamsandwich/hamsandwich.h deleted file mode 100644 index bc8a8acd..00000000 --- a/dlls/hamsandwich/hamsandwich.h +++ /dev/null @@ -1,162 +0,0 @@ -/* Ham Sandwich - * - * by sawce - * - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - */ - -#ifndef HAMSANDWICH_H -#define HAMSANDWICH_H - -#include "NEW_Util.h" - -extern unsigned int HAM_pev; -extern unsigned int HAM_classbase; - -enum HAMHooks -{ - HAM_TakeDamage, - HAM_Use, - HAM_AddPoints, - HAM_AddPointsToTeam, - HAM_Blocked, - HAM_Killed, - HAM_Respawn, - HAM_Restart, - HAM_TakeHealth, - HAM_AddPlayerItem, - HAM_RemovePlayerItem, - HAM_BloodColor, - HAM_Classify, - HAM_GetToggleState, - HAM_IsAlive, - HAM_IsBSPModel, - HAM_IsInWorld, - HAM_IsMoving, - HAM_IsNetClient, - HAM_IsPlayer, - HAM_IsSneaking, - HAM_ObjectCaps, - HAM_Think, - HAM_Touch, - - - HAM_END_DONT_USE_ME -}; - -inline edict_t *PrivateToEdict(const void *pdata) -{ - - if (!pdata) - { - return NULL; - } - - char *ptr=(char*)pdata + HAM_pev; - entvars_t *pev=(entvars_t *)ptr; - - if (!pev) - { - return NULL; - } - return pev->pContainingEntity; -}; - -inline int PrivateToIndex(const void *pdata) -{ - - if (pdata==NULL) - { - return -1; - } - char *ptr=(char*)pdata; - - ptr+=HAM_pev; - - entvars_t *pev=*(entvars_t **)ptr; - - - if (pev==NULL) - { - return -1; - } - - if (pev->pContainingEntity==NULL) - { - return -1; - } - - return ENTINDEX_NEW(pev->pContainingEntity); -}; - -inline int EntvarToIndex(entvars_t *pev) -{ - if (pev==NULL) - { - return -1; - } - - if (pev->pContainingEntity==NULL) - { - return -1; - } - - return ENTINDEX_NEW(pev->pContainingEntity); -}; - -inline edict_t *EntvarToEdict(entvars_t *pev) -{ - if (pev==NULL) - { - return NULL; - } - - return pev->pContainingEntity; -}; -inline void **EdictToVTable(edict_t *ent) -{ - char *btbl=(char *)ent->pvPrivateData; - btbl+=HAM_classbase; - return *((void ***)btbl); -}; - - - - -void RegisterKeySuffix(const char *suffix, void (*callback)(const char *,const char *)); -void RegisterConfigCallback(void (*callback)(void)); -void HAM_CallConfigDone(void); -void HAM_CallInitialization(void); -int HAM_StrToNum(const char *input); -bool HAM_GetKey(const char *key, const char *data); -void HAM_SetPev(const char *key, const char *data); -#ifdef __linux__ -void HAM_SetClassBase(const char *key, const char *data); -#endif - - - -#endif //HAMSANDWICH_H diff --git a/dlls/hamsandwich/include/hamsandwich.inc b/dlls/hamsandwich/include/hamsandwich.inc deleted file mode 100644 index 5938afbf..00000000 --- a/dlls/hamsandwich/include/hamsandwich.inc +++ /dev/null @@ -1,137 +0,0 @@ -#if defined _hamsandwich_included - #endinput -#endif -#define _hamsandwich_included - -#if AMXX_VERSION_NUM >= 175 - #pragma reqlib hamsandwich - #if !defined AMXMODX_NOAUTOLOAD - #pragma loadlib hamsandwich - #endif -#else - #pragma library hamsandwich -#endif - -#if !defined _amxmodx_included - #include -#endif - -native ham_addplayeritem(idPlayer,idItem); -native ham_eaddplayeritem(idPlayer,idItem); - -native ham_addpoints(idEntity,points,bool:allownegative); -native ham_eaddpoints(idEntity,points,bool:allownegative); - -native ham_addpointstoteam(idEntity,points,bool:allownegative); -native ham_eaddpointstoteam(idEntity,points,bool:allownegative); - -native ham_blocked(idEntity,idOther); -native ham_eblocked(idEntity,idOther); - -native ham_bloodcolor(idEntity); -native ham_ebloodcolor(idEntity); - -native ham_classify(idEntity); -native ham_eclassify(idEntity); - -native ham_gettogglestate(idEntity); -native ham_egettogglestate(idEntity); - -native ham_isalive(idEntity); -native ham_eisalive(idEntity); - -native ham_isbspmodel(idEntity); -native ham_eisbspmodel(idEntity); - -native ham_isinworld(idEntity); -native ham_eisinworld(idEntity); - -native ham_isnetclient(idEntity); -native ham_eisnetclient(idEntity); - -native ham_isplayer(idEntity); -native ham_eisplayer(idEntity); - -native ham_issneaking(idEntity); -native ham_eissneaking(idEntity); - -native ham_killed(idEntity,idAttacker,iGib); -native ham_ekilled(idEntity,idAttacker,iGib); - -native ham_objectcaps(idEntity); -native ham_eobjectcaps(idEntity); - -native ham_removeplayeritem(idEntity,idItem); -native ham_eremoveplayeritem(idEntity,idItem); - -native ham_respawn(idEntity); -native ham_erespawn(idEntity); - -native ham_restart(idEntity); -native ham_erestart(idEntity); - -native ham_takedamage(idEntity,idInflictor,idAttacker,Float:damage,dmgtype); -native ham_etakedamage(idEntity,idInflictor,idAttacker,Float:damage,dmgtype); - -native ham_takehealth(idEntity,Float:health,dmgtype); -native ham_etakehealth(idEntity,Float:health,dmgtype); - -native ham_think(idEntity); -native ham_ethink(idEntity); - -native ham_touch(idEntity,idOther); -native ham_etouch(idEntity,idOther); - -native ham_use(idEntity,idActivator,idCaller,use_type,Float:value); -native ham_euse(idEntity,idActivator,idCaller,use_type,Float:value); - - - -enum -{ - HAM_UNSET = 0, - HAM_IGNORED, - HAM_HANDLED, - HAM_OVERRIDE, - HAM_SUPERCEDE -}; - - - -enum HAMHooks -{ - HAM_TakeDamage, - HAM_Use, - HAM_AddPoints, - HAM_AddPointsToTeam, - HAM_Blocked, - HAM_Killed, - HAM_Respawn, - HAM_Restart, - HAM_TakeHealth, - HAM_AddPlayerItem, - HAM_RemovePlayerItem, - HAM_BloodColor, - HAM_Classify, - HAM_GetToggleState, - HAM_IsAlive, - HAM_IsBSPModel, - HAM_IsInWorld, - HAM_IsMoving, - HAM_IsNetClient, - HAM_IsPlayer, - HAM_IsSneaking, - HAM_ObjectCaps, - HAM_Think, - HAM_Touch, - - - HAM_END_DONT_USE_ME -}; - -native ham_register(HAMHooks:hook, const classname[], const function[], post=0); - -public __fatal_ham_error(const reason[]) -{ - set_fail_state(reason); -} \ No newline at end of file diff --git a/dlls/hamsandwich/msvc8/hs.sln b/dlls/hamsandwich/msvc8/hs.sln deleted file mode 100644 index 21904bc2..00000000 --- a/dlls/hamsandwich/msvc8/hs.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ham sandwich", "hs.vcproj", "{5B5DEFD0-28ED-4D0E-A1B0-50F9304A65DF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5B5DEFD0-28ED-4D0E-A1B0-50F9304A65DF}.Debug|Win32.ActiveCfg = Debug|Win32 - {5B5DEFD0-28ED-4D0E-A1B0-50F9304A65DF}.Debug|Win32.Build.0 = Debug|Win32 - {5B5DEFD0-28ED-4D0E-A1B0-50F9304A65DF}.Release|Win32.ActiveCfg = Release|Win32 - {5B5DEFD0-28ED-4D0E-A1B0-50F9304A65DF}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/dlls/hamsandwich/msvc8/hs.vcproj b/dlls/hamsandwich/msvc8/hs.vcproj deleted file mode 100644 index 1e91df1b..00000000 --- a/dlls/hamsandwich/msvc8/hs.vcproj +++ /dev/null @@ -1,364 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dlls/hamsandwich/natives.cpp b/dlls/hamsandwich/natives.cpp deleted file mode 100644 index 18f19e6d..00000000 --- a/dlls/hamsandwich/natives.cpp +++ /dev/null @@ -1,185 +0,0 @@ - -/* Ham Sandwich - * - * by sawce - * - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - */ - -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" -#include "NEW_Util.h" - -#include "vfunc_msvc.h" -#include "vfunc_gcc295.h" - -static cell AMX_NATIVE_CALL hs_takedamage(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - HAM_Takedamage, /*vtable entry*/ - HAM_Classbase, /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5]); /*dmgtype*/ -}; -static cell AMX_NATIVE_CALL hs_use(AMX *amx, cell *params) -{ - VoidVCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - HAM_Use, /*vtable entry*/ - HAM_Classbase, /*size of class*/ - INDEXENT_NEW(params[2])->pvPrivateData, /*activator*/ - INDEXENT_NEW(params[3])->pvPrivateData, /*caller*/ - params[4], /*use type*/ - amx_ctof2(params[5])); /*value*/ - - return 1; -} - -/** - * Very fast, but potentially unsafe (if you use the wrong index/offset) - * method of converting a CBaseEntity pointer into a usable entity index - */ -static cell AMX_NATIVE_CALL hs_pdata_cbase(AMX *amx, cell *params) -{ - // Get the offset of the private data - int Offset=params[2]; - - // If this is a linux server increase the offset -#ifdef __linux__ - Offset+=params[3]; -#endif - - // Get the CBase pointer - int *ent=*((int **)INDEXENT_NEW(params[1])->pvPrivateData + Offset); - - // Null pointer; get out - if (ent==NULL) - { - return 0; - } - - // Now move up HAM_Pev bytes - char *bent=*(char**)&ent; - - bent+=HAM_Pev; - - entvars_t *pev=*(entvars_t **)&bent; - - // Null pointer, get out - if (pev==NULL) - { - return 0; - } - - return ENTINDEX_NEW(pev->pContainingEntity); - - -} -/** - * Slow, but very safe replacement for hs_pdata_cbase - * - - * This will scan through all entities to check their private - * data against the requested offset's data. - * It will never reference the requested PData, so unless - * the plugin author is way off with the offset it should - * never crash. - * - - * This should only be used for offset searching; NEVER - * in a release quality script. - */ -static cell AMX_NATIVE_CALL hs_pdata_cbase_safe(AMX *amx, cell *params) -{ - // Get the offset of the private data - int Offset=params[2]; - - // If this is a linux server increase the offset -#ifdef __linux__ - Offset+=params[3]; -#endif - - // Get the CBase pointer - int *data=*((int **)INDEXENT_NEW(params[1])->pvPrivateData + Offset); - - // Get the first entity - edict_t *Entity=INDEXENT_NEW(0); - - // Get the last entity - edict_t *Last=INDEXENT_NEW(gpGlobals->maxEntities); - - // Scan through all of the entities (excluding 0, because no other module allows for worldspawn) - while (Entity++pvPrivateData)==data) - { - return ENTINDEX_NEW(Entity); - } - } - - // Not found - return 0; -} - -static AMX_NATIVE_INFO reg_takedamage[] = { - { "hs_takedamage", hs_takedamage }, - { NULL, NULL } -}; -static AMX_NATIVE_INFO reg_use[] = { - { "hs_use", hs_use }, - - { NULL, NULL } -}; -static AMX_NATIVE_INFO reg_cbase_fast[] = { - { "hs_pdata_cbase", hs_pdata_cbase }, - - { NULL, NULL } -}; -static AMX_NATIVE_INFO reg_cbase_safe[] = { - { "hs_pdata_cbase_safe", hs_pdata_cbase_safe }, - - { NULL, NULL } -}; -void HAM_RegisterTakeDamage() -{ - MF_AddNatives(reg_takedamage); -} -void HAM_RegisterUse() -{ - MF_AddNatives(reg_use); -} -void HAM_RegisterCbaseFast() -{ - MF_AddNatives(reg_cbase_fast); -} -void HAM_RegisterCbaseSafe() -{ - MF_AddNatives(reg_cbase_safe); -} - diff --git a/dlls/hamsandwich/sdk/amxxmodule.cpp b/dlls/hamsandwich/sdk/amxxmodule.cpp deleted file mode 100644 index 146eddca..00000000 --- a/dlls/hamsandwich/sdk/amxxmodule.cpp +++ /dev/null @@ -1,3131 +0,0 @@ -/* AMX Mod X -* -* by the AMX Mod X Development Team -* originally developed by OLO -* -* Parts Copyright (C) 2001-2003 Will Day -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -* Description: AMX Mod X Module Interface Functions -*/ - -#include -#include -#include -#include -#include -#include "amxxmodule.h" - -/************* METAMOD SUPPORT *************/ -#ifdef USE_METAMOD - -enginefuncs_t g_engfuncs; -globalvars_t *gpGlobals; - -DLL_FUNCTIONS *g_pFunctionTable; -DLL_FUNCTIONS *g_pFunctionTable_Post; -enginefuncs_t *g_pengfuncsTable; -enginefuncs_t *g_pengfuncsTable_Post; -NEW_DLL_FUNCTIONS *g_pNewFunctionsTable; -NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post; - -// GetEntityAPI2 functions -static DLL_FUNCTIONS g_EntityAPI_Table = -{ -#ifdef FN_GameDLLInit - FN_GameDLLInit, -#else - NULL, -#endif -#ifdef FN_DispatchSpawn - FN_DispatchSpawn, -#else - NULL, -#endif -#ifdef FN_DispatchThink - FN_DispatchThink, -#else - NULL, -#endif -#ifdef FN_DispatchUse - FN_DispatchUse, -#else - NULL, -#endif -#ifdef FN_DispatchTouch - FN_DispatchTouch, -#else - NULL, -#endif -#ifdef FN_DispatchBlocked - FN_DispatchBlocked, -#else - NULL, -#endif -#ifdef FN_DispatchKeyValue - FN_DispatchKeyValue, -#else - NULL, -#endif -#ifdef FN_DispatchSave - FN_DispatchSave, -#else - NULL, -#endif -#ifdef FN_DispatchRestore - FN_DispatchRestore, -#else - NULL, -#endif -#ifdef FN_DispatchObjectCollsionBox - FN_DispatchObjectCollsionBox, -#else - NULL, -#endif -#ifdef FN_SaveWriteFields - FN_SaveWriteFields, -#else - NULL, -#endif -#ifdef FN_SaveReadFields - FN_SaveReadFields, -#else - NULL, -#endif -#ifdef FN_SaveGlobalState - FN_SaveGlobalState, -#else - NULL, -#endif -#ifdef FN_RestoreGlobalState - FN_RestoreGlobalState, -#else - NULL, -#endif -#ifdef FN_ResetGlobalState - FN_ResetGlobalState, -#else - NULL, -#endif -#ifdef FN_ClientConnect - FN_ClientConnect, -#else - NULL, -#endif -#ifdef FN_ClientDisconnect - FN_ClientDisconnect, -#else - NULL, -#endif -#ifdef FN_ClientKill - FN_ClientKill, -#else - NULL, -#endif -#ifdef FN_ClientPutInServer - FN_ClientPutInServer, -#else - NULL, -#endif -#ifdef FN_ClientCommand - FN_ClientCommand, -#else - NULL, -#endif -#ifdef FN_ClientUserInfoChanged - FN_ClientUserInfoChanged, -#else - NULL, -#endif -#ifdef FN_ServerActivate - FN_ServerActivate, -#else - NULL, -#endif -#ifdef FN_ServerDeactivate - FN_ServerDeactivate, -#else - NULL, -#endif -#ifdef FN_PlayerPreThink - FN_PlayerPreThink, -#else - NULL, -#endif -#ifdef FN_PlayerPostThink - FN_PlayerPostThink, -#else - NULL, -#endif -#ifdef FN_StartFrame - FN_StartFrame, -#else - NULL, -#endif -#ifdef FN_ParmsNewLevel - FN_ParmsNewLevel, -#else - NULL, -#endif -#ifdef FN_ParmsChangeLevel - FN_ParmsChangeLevel, -#else - NULL, -#endif -#ifdef FN_GetGameDescription - FN_GetGameDescription, -#else - NULL, -#endif -#ifdef FN_PlayerCustomization - FN_PlayerCustomization, -#else - NULL, -#endif -#ifdef FN_SpectatorConnect - FN_SpectatorConnect, -#else - NULL, -#endif -#ifdef FN_SpectatorDisconnect - FN_SpectatorDisconnect, -#else - NULL, -#endif -#ifdef FN_SpectatorThink - FN_SpectatorThink, -#else - NULL, -#endif -#ifdef FN_Sys_Error - FN_Sys_Error, -#else - NULL, -#endif -#ifdef FN_PM_Move - FN_PM_Move, -#else - NULL, -#endif -#ifdef FN_PM_Init - FN_PM_Init, -#else - NULL, -#endif -#ifdef FN_PM_FindTextureType - FN_PM_FindTextureType, -#else - NULL, -#endif -#ifdef FN_SetupVisibility - FN_SetupVisibility, -#else - NULL, -#endif -#ifdef FN_UpdateClientData - FN_UpdateClientData, -#else - NULL, -#endif -#ifdef FN_AddToFullPack - FN_AddToFullPack, -#else - NULL, -#endif -#ifdef FN_CreateBaseline - FN_CreateBaseline, -#else - NULL, -#endif -#ifdef FN_RegisterEncoders - FN_RegisterEncoders, -#else - NULL, -#endif -#ifdef FN_GetWeaponData - FN_GetWeaponData, -#else - NULL, -#endif -#ifdef FN_CmdStart - FN_CmdStart, -#else - NULL, -#endif -#ifdef FN_CmdEnd - FN_CmdEnd, -#else - NULL, -#endif -#ifdef FN_ConnectionlessPacket - FN_ConnectionlessPacket, -#else - NULL, -#endif -#ifdef FN_GetHullBounds - FN_GetHullBounds, -#else - NULL, -#endif -#ifdef FN_CreateInstancedBaselines - FN_CreateInstancedBaselines, -#else - NULL, -#endif -#ifdef FN_InconsistentFile - FN_InconsistentFile, -#else - NULL, -#endif -#ifdef FN_AllowLagCompensation - FN_AllowLagCompensation -#else - NULL -#endif -}; // g_EntityAPI2_Table - -// GetEntityAPI2_Post functions -static DLL_FUNCTIONS g_EntityAPI_Post_Table = -{ -#ifdef FN_GameDLLInit_Post - FN_GameDLLInit_Post, -#else - NULL, -#endif -#ifdef FN_DispatchSpawn_Post - FN_DispatchSpawn_Post, -#else - NULL, -#endif -#ifdef FN_DispatchThink_Post - FN_DispatchThink_Post, -#else - NULL, -#endif -#ifdef FN_DispatchUse_Post - FN_DispatchUse_Post, -#else - NULL, -#endif -#ifdef FN_DispatchTouch_Post - FN_DispatchTouch_Post, -#else - NULL, -#endif -#ifdef FN_DispatchBlocked_Post - FN_DispatchBlocked_Post, -#else - NULL, -#endif -#ifdef FN_DispatchKeyValue_Post - FN_DispatchKeyValue_Post, -#else - NULL, -#endif -#ifdef FN_DispatchSave_Post - FN_DispatchSave_Post, -#else - NULL, -#endif -#ifdef FN_DispatchRestore_Post - FN_DispatchRestore_Post, -#else - NULL, -#endif -#ifdef FN_DispatchObjectCollsionBox_Post - FN_DispatchObjectCollsionBox_Post, -#else - NULL, -#endif -#ifdef FN_SaveWriteFields_Post - FN_SaveWriteFields_Post, -#else - NULL, -#endif -#ifdef FN_SaveReadFields_Post - FN_SaveReadFields_Post, -#else - NULL, -#endif -#ifdef FN_SaveGlobalState_Post - FN_SaveGlobalState_Post, -#else - NULL, -#endif -#ifdef FN_RestoreGlobalState_Post - FN_RestoreGlobalState_Post, -#else - NULL, -#endif -#ifdef FN_ResetGlobalState_Post - FN_ResetGlobalState_Post, -#else - NULL, -#endif -#ifdef FN_ClientConnect_Post - FN_ClientConnect_Post, -#else - NULL, -#endif -#ifdef FN_ClientDisconnect_Post - FN_ClientDisconnect_Post, -#else - NULL, -#endif -#ifdef FN_ClientKill_Post - FN_ClientKill_Post, -#else - NULL, -#endif -#ifdef FN_ClientPutInServer_Post - FN_ClientPutInServer_Post, -#else - NULL, -#endif -#ifdef FN_ClientCommand_Post - FN_ClientCommand_Post, -#else - NULL, -#endif -#ifdef FN_ClientUserInfoChanged_Post - FN_ClientUserInfoChanged_Post, -#else - NULL, -#endif -#ifdef FN_ServerActivate_Post - FN_ServerActivate_Post, -#else - NULL, -#endif -#ifdef FN_ServerDeactivate_Post - FN_ServerDeactivate_Post, -#else - NULL, -#endif -#ifdef FN_PlayerPreThink_Post - FN_PlayerPreThink_Post, -#else - NULL, -#endif -#ifdef FN_PlayerPostThink_Post - FN_PlayerPostThink_Post, -#else - NULL, -#endif -#ifdef FN_StartFrame_Post - FN_StartFrame_Post, -#else - NULL, -#endif -#ifdef FN_ParmsNewLevel_Post - FN_ParmsNewLevel_Post, -#else - NULL, -#endif -#ifdef FN_ParmsChangeLevel_Post - FN_ParmsChangeLevel_Post, -#else - NULL, -#endif -#ifdef FN_GetGameDescription_Post - FN_GetGameDescription_Post, -#else - NULL, -#endif -#ifdef FN_PlayerCustomization_Post - FN_PlayerCustomization_Post, -#else - NULL, -#endif -#ifdef FN_SpectatorConnect_Post - FN_SpectatorConnect_Post, -#else - NULL, -#endif -#ifdef FN_SpectatorDisconnect_Post - FN_SpectatorDisconnect_Post, -#else - NULL, -#endif -#ifdef FN_SpectatorThink_Post - FN_SpectatorThink_Post, -#else - NULL, -#endif -#ifdef FN_Sys_Error_Post - FN_Sys_Error_Post, -#else - NULL, -#endif -#ifdef FN_PM_Move_Post - FN_PM_Move_Post, -#else - NULL, -#endif -#ifdef FN_PM_Init_Post - FN_PM_Init_Post, -#else - NULL, -#endif -#ifdef FN_PM_FindTextureType_Post - FN_PM_FindTextureType_Post, -#else - NULL, -#endif -#ifdef FN_SetupVisibility_Post - FN_SetupVisibility_Post, -#else - NULL, -#endif -#ifdef FN_UpdateClientData_Post - FN_UpdateClientData_Post, -#else - NULL, -#endif -#ifdef FN_AddToFullPack_Post - FN_AddToFullPack_Post, -#else - NULL, -#endif -#ifdef FN_CreateBaseline_Post - FN_CreateBaseline_Post, -#else - NULL, -#endif -#ifdef FN_RegisterEncoders_Post - FN_RegisterEncoders_Post, -#else - NULL, -#endif -#ifdef FN_GetWeaponData_Post - FN_GetWeaponData_Post, -#else - NULL, -#endif -#ifdef FN_CmdStart_Post - FN_CmdStart_Post, -#else - NULL, -#endif -#ifdef FN_CmdEnd_Post - FN_CmdEnd_Post, -#else - NULL, -#endif -#ifdef FN_ConnectionlessPacket_Post - FN_ConnectionlessPacket_Post, -#else - NULL, -#endif -#ifdef FN_GetHullBounds_Post - FN_GetHullBounds_Post, -#else - NULL, -#endif -#ifdef FN_CreateInstancedBaselines_Post - FN_CreateInstancedBaselines_Post, -#else - NULL, -#endif -#ifdef FN_InconsistentFile_Post - FN_InconsistentFile_Post, -#else - NULL, -#endif -#ifdef FN_AllowLagCompensation - FN_AllowLagCompensation, -#else - NULL, -#endif -}; // g_EntityAPI2_Table - -static enginefuncs_t g_EngineFuncs_Table = -{ -#ifdef FN_PrecacheModel - FN_PrecacheModel, -#else - NULL, -#endif -#ifdef FN_PrecacheSound - FN_PrecacheSound, -#else - NULL, -#endif -#ifdef FN_SetModel - FN_SetModel, -#else - NULL, -#endif -#ifdef FN_ModelIndex - FN_ModelIndex, -#else - NULL, -#endif -#ifdef FN_ModelFrames - FN_ModelFrames, -#else - NULL, -#endif -#ifdef FN_SetSize - FN_SetSize, -#else - NULL, -#endif -#ifdef FN_ChangeLevel - FN_ChangeLevel, -#else - NULL, -#endif -#ifdef FN_GetSpawnParms - FN_GetSpawnParms, -#else - NULL, -#endif -#ifdef FN_SaveSpawnParms - FN_SaveSpawnParms, -#else - NULL, -#endif -#ifdef FN_VecToYaw - FN_VecToYaw, -#else - NULL, -#endif -#ifdef FN_VecToAngles - FN_VecToAngles, -#else - NULL, -#endif -#ifdef FN_MoveToOrigin - FN_MoveToOrigin, -#else - NULL, -#endif -#ifdef FN_ChangeYaw - FN_ChangeYaw, -#else - NULL, -#endif -#ifdef FN_ChangePitch - FN_ChangePitch, -#else - NULL, -#endif -#ifdef FN_FindEntityByString - FN_FindEntityByString, -#else - NULL, -#endif -#ifdef FN_GetEntityIllum - FN_GetEntityIllum, -#else - NULL, -#endif -#ifdef FN_FindEntityInSphere - FN_FindEntityInSphere, -#else - NULL, -#endif -#ifdef FN_FindClientInPVS - FN_FindClientInPVS, -#else - NULL, -#endif -#ifdef FN_EntitiesInPVS - FN_EntitiesInPVS, -#else - NULL, -#endif -#ifdef FN_MakeVectors - FN_MakeVectors, -#else - NULL, -#endif -#ifdef FN_AngleVectors - FN_AngleVectors, -#else - NULL, -#endif -#ifdef FN_CreateEntity - FN_CreateEntity, -#else - NULL, -#endif -#ifdef FN_RemoveEntity - FN_RemoveEntity, -#else - NULL, -#endif -#ifdef FN_CreateNamedEntity - FN_CreateNamedEntity, -#else - NULL, -#endif -#ifdef FN_MakeStatic - FN_MakeStatic, -#else - NULL, -#endif -#ifdef FN_EntIsOnFloor - FN_EntIsOnFloor, -#else - NULL, -#endif -#ifdef FN_DropToFloor - FN_DropToFloor, -#else - NULL, -#endif -#ifdef FN_WalkMove - FN_WalkMove, -#else - NULL, -#endif -#ifdef FN_SetOrigin - FN_SetOrigin, -#else - NULL, -#endif -#ifdef FN_EmitSound - FN_EmitSound, -#else - NULL, -#endif -#ifdef FN_EmitAmbientSound - FN_EmitAmbientSound, -#else - NULL, -#endif -#ifdef FN_TraceLine - FN_TraceLine, -#else - NULL, -#endif -#ifdef FN_TraceToss - FN_TraceToss, -#else - NULL, -#endif -#ifdef FN_TraceMonsterHull - FN_TraceMonsterHull, -#else - NULL, -#endif -#ifdef FN_TraceHull - FN_TraceHull, -#else - NULL, -#endif -#ifdef FN_TraceModel - FN_TraceModel, -#else - NULL, -#endif -#ifdef FN_TraceTexture - FN_TraceTexture, -#else - NULL, -#endif -#ifdef FN_TraceSphere - FN_TraceSphere, -#else - NULL, -#endif -#ifdef FN_GetAimVector - FN_GetAimVector, -#else - NULL, -#endif -#ifdef FN_ServerCommand - FN_ServerCommand, -#else - NULL, -#endif -#ifdef FN_ServerExecute - FN_ServerExecute, -#else - NULL, -#endif -#ifdef FN_engClientCommand - FN_engClientCommand, -#else - NULL, -#endif -#ifdef FN_ParticleEffect - FN_ParticleEffect, -#else - NULL, -#endif -#ifdef FN_LightStyle - FN_LightStyle, -#else - NULL, -#endif -#ifdef FN_DecalIndex - FN_DecalIndex, -#else - NULL, -#endif -#ifdef FN_PointContents - FN_PointContents, -#else - NULL, -#endif -#ifdef FN_MessageBegin - FN_MessageBegin, -#else - NULL, -#endif -#ifdef FN_MessageEnd - FN_MessageEnd, -#else - NULL, -#endif -#ifdef FN_WriteByte - FN_WriteByte, -#else - NULL, -#endif -#ifdef FN_WriteChar - FN_WriteChar, -#else - NULL, -#endif -#ifdef FN_WriteShort - FN_WriteShort, -#else - NULL, -#endif -#ifdef FN_WriteLong - FN_WriteLong, -#else - NULL, -#endif -#ifdef FN_WriteAngle - FN_WriteAngle, -#else - NULL, -#endif -#ifdef FN_WriteCoord - FN_WriteCoord, -#else - NULL, -#endif -#ifdef FN_WriteString - FN_WriteString, -#else - NULL, -#endif -#ifdef FN_WriteEntity - FN_WriteEntity, -#else - NULL, -#endif -#ifdef FN_CVarRegister - FN_CVarRegister, -#else - NULL, -#endif -#ifdef FN_CVarGetFloat - FN_CVarGetFloat, -#else - NULL, -#endif -#ifdef FN_CVarGetString - FN_CVarGetString, -#else - NULL, -#endif -#ifdef FN_CVarSetFloat - FN_CVarSetFloat, -#else - NULL, -#endif -#ifdef FN_CVarSetString - FN_CVarSetString, -#else - NULL, -#endif -#ifdef FN_AlertMessage - FN_AlertMessage, -#else - NULL, -#endif -#ifdef FN_EngineFprintf - FN_EngineFprintf, -#else - NULL, -#endif -#ifdef FN_PvAllocEntPrivateData - FN_PvAllocEntPrivateData, -#else - NULL, -#endif -#ifdef FN_PvEntPrivateData - FN_PvEntPrivateData, -#else - NULL, -#endif -#ifdef FN_FreeEntPrivateData - FN_FreeEntPrivateData, -#else - NULL, -#endif -#ifdef FN_SzFromIndex - FN_SzFromIndex, -#else - NULL, -#endif -#ifdef FN_AllocString - FN_AllocString, -#else - NULL, -#endif -#ifdef FN_GetVarsOfEnt - FN_GetVarsOfEnt, -#else - NULL, -#endif -#ifdef FN_PEntityOfEntOffset - FN_PEntityOfEntOffset, -#else - NULL, -#endif -#ifdef FN_EntOffsetOfPEntity - FN_EntOffsetOfPEntity, -#else - NULL, -#endif -#ifdef FN_IndexOfEdict - FN_IndexOfEdict, -#else - NULL, -#endif -#ifdef FN_PEntityOfEntIndex - FN_PEntityOfEntIndex, -#else - NULL, -#endif -#ifdef FN_FindEntityByVars - FN_FindEntityByVars, -#else - NULL, -#endif -#ifdef FN_GetModelPtr - FN_GetModelPtr, -#else - NULL, -#endif -#ifdef FN_RegUserMsg - FN_RegUserMsg, -#else - NULL, -#endif -#ifdef FN_AnimationAutomove - FN_AnimationAutomove, -#else - NULL, -#endif -#ifdef FN_GetBonePosition - FN_GetBonePosition, -#else - NULL, -#endif -#ifdef FN_FunctionFromName - FN_FunctionFromName, -#else - NULL, -#endif -#ifdef FN_NameForFunction - FN_NameForFunction, -#else - NULL, -#endif -#ifdef FN_ClientPrintf - FN_ClientPrintf, -#else - NULL, -#endif -#ifdef FN_ServerPrint - FN_ServerPrint, -#else - NULL, -#endif -#ifdef FN_Cmd_Args - FN_Cmd_Args, -#else - NULL, -#endif -#ifdef FN_Cmd_Argv - FN_Cmd_Argv, -#else - NULL, -#endif -#ifdef FN_Cmd_Argc - FN_Cmd_Argc, -#else - NULL, -#endif -#ifdef FN_GetAttachment - FN_GetAttachment, -#else - NULL, -#endif -#ifdef FN_CRC32_Init - FN_CRC32_Init, -#else - NULL, -#endif -#ifdef FN_CRC32_ProcessBuffer - FN_CRC32_ProcessBuffer, -#else - NULL, -#endif -#ifdef FN_CRC32_ProcessByte - FN_CRC32_ProcessByte, -#else - NULL, -#endif -#ifdef FN_CRC32_Final - FN_CRC32_Final, -#else - NULL, -#endif -#ifdef FN_RandomLong - FN_RandomLong, -#else - NULL, -#endif -#ifdef FN_RandomFloat - FN_RandomFloat, -#else - NULL, -#endif -#ifdef FN_SetView - FN_SetView, -#else - NULL, -#endif -#ifdef FN_Time - FN_Time, -#else - NULL, -#endif -#ifdef FN_CrosshairAngle - FN_CrosshairAngle, -#else - NULL, -#endif -#ifdef FN_LoadFileForMe - FN_LoadFileForMe, -#else - NULL, -#endif -#ifdef FN_FreeFile - FN_FreeFile, -#else - NULL, -#endif -#ifdef FN_EndSection - FN_EndSection, -#else - NULL, -#endif -#ifdef FN_CompareFileTime - FN_CompareFileTime, -#else - NULL, -#endif -#ifdef FN_GetGameDir - FN_GetGameDir, -#else - NULL, -#endif -#ifdef FN_Cvar_RegisterVariable - FN_Cvar_RegisterVariable, -#else - NULL, -#endif -#ifdef FN_FadeClientVolume - FN_FadeClientVolume, -#else - NULL, -#endif -#ifdef FN_SetClientMaxspeed - FN_SetClientMaxspeed, -#else - NULL, -#endif -#ifdef FN_CreateFakeClient - FN_CreateFakeClient, -#else - NULL, -#endif -#ifdef FN_RunPlayerMove - FN_RunPlayerMove, -#else - NULL, -#endif -#ifdef FN_NumberOfEntities - FN_NumberOfEntities, -#else - NULL, -#endif -#ifdef FN_GetInfoKeyBuffer - FN_GetInfoKeyBuffer, -#else - NULL, -#endif -#ifdef FN_InfoKeyValue - FN_InfoKeyValue, -#else - NULL, -#endif -#ifdef FN_SetKeyValue - FN_SetKeyValue, -#else - NULL, -#endif -#ifdef FN_SetClientKeyValue - FN_SetClientKeyValue, -#else - NULL, -#endif -#ifdef FN_IsMapValid - FN_IsMapValid, -#else - NULL, -#endif -#ifdef FN_StaticDecal - FN_StaticDecal, -#else - NULL, -#endif -#ifdef FN_PrecacheGeneric - FN_PrecacheGeneric, -#else - NULL, -#endif -#ifdef FN_GetPlayerUserId - FN_GetPlayerUserId, -#else - NULL, -#endif -#ifdef FN_BuildSoundMsg - FN_BuildSoundMsg, -#else - NULL, -#endif -#ifdef FN_IsDedicatedServer - FN_IsDedicatedServer, -#else - NULL, -#endif -#ifdef FN_CVarGetPointer - FN_CVarGetPointer, -#else - NULL, -#endif -#ifdef FN_GetPlayerWONId - FN_GetPlayerWONId, -#else - NULL, -#endif -#ifdef FN_Info_RemoveKey - FN_Info_RemoveKey, -#else - NULL, -#endif -#ifdef FN_GetPhysicsKeyValue - FN_GetPhysicsKeyValue, -#else - NULL, -#endif -#ifdef FN_SetPhysicsKeyValue - FN_SetPhysicsKeyValue, -#else - NULL, -#endif -#ifdef FN_GetPhysicsInfoString - FN_GetPhysicsInfoString, -#else - NULL, -#endif -#ifdef FN_PrecacheEvent - FN_PrecacheEvent, -#else - NULL, -#endif -#ifdef FN_PlaybackEvent - FN_PlaybackEvent, -#else - NULL, -#endif -#ifdef FN_SetFatPVS - FN_SetFatPVS, -#else - NULL, -#endif -#ifdef FN_SetFatPAS - FN_SetFatPAS, -#else - NULL, -#endif -#ifdef FN_CheckVisibility - FN_CheckVisibility, -#else - NULL, -#endif -#ifdef FN_DeltaSetField - FN_DeltaSetField, -#else - NULL, -#endif -#ifdef FN_DeltaUnsetField - FN_DeltaUnsetField, -#else - NULL, -#endif -#ifdef FN_DeltaAddEncoder - FN_DeltaAddEncoder, -#else - NULL, -#endif -#ifdef FN_GetCurrentPlayer - FN_GetCurrentPlayer, -#else - NULL, -#endif -#ifdef FN_CanSkipPlayer - FN_CanSkipPlayer, -#else - NULL, -#endif -#ifdef FN_DeltaFindField - FN_DeltaFindField, -#else - NULL, -#endif -#ifdef FN_DeltaSetFieldByIndex - FN_DeltaSetFieldByIndex, -#else - NULL, -#endif -#ifdef FN_DeltaUnsetFieldByIndex - FN_DeltaUnsetFieldByIndex, -#else - NULL, -#endif -#ifdef FN_SetGroupMask - FN_SetGroupMask, -#else - NULL, -#endif -#ifdef FN_engCreateInstancedBaseline - FN_engCreateInstancedBaseline, -#else - NULL, -#endif -#ifdef FN_Cvar_DirectSet - FN_Cvar_DirectSet, -#else - NULL, -#endif -#ifdef FN_ForceUnmodified - FN_ForceUnmodified, -#else - NULL, -#endif -#ifdef FN_GetPlayerStats - FN_GetPlayerStats, -#else - NULL, -#endif -#ifdef FN_AddServerCommand - FN_AddServerCommand, -#else - NULL, -#endif -#ifdef FN_Voice_GetClientListening - FN_Voice_GetClientListening, -#else - NULL, -#endif -#ifdef FN_Voice_SetClientListening - FN_Voice_SetClientListening, -#else - NULL, -#endif -#ifdef FN_GetPlayerAuthId - FN_GetPlayerAuthId -#else - NULL -#endif -}; // g_EngineFuncs_Table - - -static enginefuncs_t g_EngineFuncs_Post_Table = -{ -#ifdef FN_PrecacheModel_Post - FN_PrecacheModel_Post, -#else - NULL, -#endif -#ifdef FN_PrecacheSound_Post - FN_PrecacheSound_Post, -#else - NULL, -#endif -#ifdef FN_SetModel_Post - FN_SetModel_Post, -#else - NULL, -#endif -#ifdef FN_ModelIndex_Post - FN_ModelIndex_Post, -#else - NULL, -#endif -#ifdef FN_ModelFrames_Post - FN_ModelFrames_Post, -#else - NULL, -#endif -#ifdef FN_SetSize_Post - FN_SetSize_Post, -#else - NULL, -#endif -#ifdef FN_ChangeLevel_Post - FN_ChangeLevel_Post, -#else - NULL, -#endif -#ifdef FN_GetSpawnParms_Post - FN_GetSpawnParms_Post, -#else - NULL, -#endif -#ifdef FN_SaveSpawnParms_Post - FN_SaveSpawnParms_Post, -#else - NULL, -#endif -#ifdef FN_VecToYaw_Post - FN_VecToYaw_Post, -#else - NULL, -#endif -#ifdef FN_VecToAngles_Post - FN_VecToAngles_Post, -#else - NULL, -#endif -#ifdef FN_MoveToOrigin_Post - FN_MoveToOrigin_Post, -#else - NULL, -#endif -#ifdef FN_ChangeYaw_Post - FN_ChangeYaw_Post, -#else - NULL, -#endif -#ifdef FN_ChangePitch_Post - FN_ChangePitch_Post, -#else - NULL, -#endif -#ifdef FN_FindEntityByString_Post - FN_FindEntityByString_Post, -#else - NULL, -#endif -#ifdef FN_GetEntityIllum_Post - FN_GetEntityIllum_Post, -#else - NULL, -#endif -#ifdef FN_FindEntityInSphere_Post - FN_FindEntityInSphere_Post, -#else - NULL, -#endif -#ifdef FN_FindClientInPVS_Post - FN_FindClientInPVS_Post, -#else - NULL, -#endif -#ifdef FN_EntitiesInPVS_Post - FN_EntitiesInPVS_Post, -#else - NULL, -#endif -#ifdef FN_MakeVectors_Post - FN_MakeVectors_Post, -#else - NULL, -#endif -#ifdef FN_AngleVectors_Post - FN_AngleVectors_Post, -#else - NULL, -#endif -#ifdef FN_CreateEntity_Post - FN_CreateEntity_Post, -#else - NULL, -#endif -#ifdef FN_RemoveEntity_Post - FN_RemoveEntity_Post, -#else - NULL, -#endif -#ifdef FN_CreateNamedEntity_Post - FN_CreateNamedEntity_Post, -#else - NULL, -#endif -#ifdef FN_MakeStatic_Post - FN_MakeStatic_Post, -#else - NULL, -#endif -#ifdef FN_EntIsOnFloor_Post - FN_EntIsOnFloor_Post, -#else - NULL, -#endif -#ifdef FN_DropToFloor_Post - FN_DropToFloor_Post, -#else - NULL, -#endif -#ifdef FN_WalkMove_Post - FN_WalkMove_Post, -#else - NULL, -#endif -#ifdef FN_SetOrigin_Post - FN_SetOrigin_Post, -#else - NULL, -#endif -#ifdef FN_EmitSound_Post - FN_EmitSound_Post, -#else - NULL, -#endif -#ifdef FN_EmitAmbientSound_Post - FN_EmitAmbientSound_Post, -#else - NULL, -#endif -#ifdef FN_TraceLine_Post - FN_TraceLine_Post, -#else - NULL, -#endif -#ifdef FN_TraceToss_Post - FN_TraceToss_Post, -#else - NULL, -#endif -#ifdef FN_TraceMonsterHull_Post - FN_TraceMonsterHull_Post, -#else - NULL, -#endif -#ifdef FN_TraceHull_Post - FN_TraceHull_Post, -#else - NULL, -#endif -#ifdef FN_TraceModel_Post - FN_TraceModel_Post, -#else - NULL, -#endif -#ifdef FN_TraceTexture_Post - FN_TraceTexture_Post, -#else - NULL, -#endif -#ifdef FN_TraceSphere_Post - FN_TraceSphere_Post, -#else - NULL, -#endif -#ifdef FN_GetAimVector_Post - FN_GetAimVector_Post, -#else - NULL, -#endif -#ifdef FN_ServerCommand_Post - FN_ServerCommand_Post, -#else - NULL, -#endif -#ifdef FN_ServerExecute_Post - FN_ServerExecute_Post, -#else - NULL, -#endif -#ifdef FN_engClientCommand_Post - FN_engClientCommand_Post, -#else - NULL, -#endif -#ifdef FN_ParticleEffect_Post - FN_ParticleEffect_Post, -#else - NULL, -#endif -#ifdef FN_LightStyle_Post - FN_LightStyle_Post, -#else - NULL, -#endif -#ifdef FN_DecalIndex_Post - FN_DecalIndex_Post, -#else - NULL, -#endif -#ifdef FN_PointContents_Post - FN_PointContents_Post, -#else - NULL, -#endif -#ifdef FN_MessageBegin_Post - FN_MessageBegin_Post, -#else - NULL, -#endif -#ifdef FN_MessageEnd_Post - FN_MessageEnd_Post, -#else - NULL, -#endif -#ifdef FN_WriteByte_Post - FN_WriteByte_Post, -#else - NULL, -#endif -#ifdef FN_WriteChar_Post - FN_WriteChar_Post, -#else - NULL, -#endif -#ifdef FN_WriteShort_Post - FN_WriteShort_Post, -#else - NULL, -#endif -#ifdef FN_WriteLong_Post - FN_WriteLong_Post, -#else - NULL, -#endif -#ifdef FN_WriteAngle_Post - FN_WriteAngle_Post, -#else - NULL, -#endif -#ifdef FN_WriteCoord_Post - FN_WriteCoord_Post, -#else - NULL, -#endif -#ifdef FN_WriteString_Post - FN_WriteString_Post, -#else - NULL, -#endif -#ifdef FN_WriteEntity_Post - FN_WriteEntity_Post, -#else - NULL, -#endif -#ifdef FN_CVarRegister_Post - FN_CVarRegister_Post, -#else - NULL, -#endif -#ifdef FN_CVarGetFloat_Post - FN_CVarGetFloat_Post, -#else - NULL, -#endif -#ifdef FN_CVarGetString_Post - FN_CVarGetString_Post, -#else - NULL, -#endif -#ifdef FN_CVarSetFloat_Post - FN_CVarSetFloat_Post, -#else - NULL, -#endif -#ifdef FN_CVarSetString_Post - FN_CVarSetString_Post, -#else - NULL, -#endif -#ifdef FN_AlertMessage_Post - FN_AlertMessage_Post, -#else - NULL, -#endif -#ifdef FN_EngineFprintf_Post - FN_EngineFprintf_Post, -#else - NULL, -#endif -#ifdef FN_PvAllocEntPrivateData_Post - FN_PvAllocEntPrivateData_Post, -#else - NULL, -#endif -#ifdef FN_PvEntPrivateData_Post - FN_PvEntPrivateData_Post, -#else - NULL, -#endif -#ifdef FN_FreeEntPrivateData_Post - FN_FreeEntPrivateData_Post, -#else - NULL, -#endif -#ifdef FN_SzFromIndex_Post - FN_SzFromIndex_Post, -#else - NULL, -#endif -#ifdef FN_AllocString_Post - FN_AllocString_Post, -#else - NULL, -#endif -#ifdef FN_GetVarsOfEnt_Post - FN_GetVarsOfEnt_Post, -#else - NULL, -#endif -#ifdef FN_PEntityOfEntOffset_Post - FN_PEntityOfEntOffset_Post, -#else - NULL, -#endif -#ifdef FN_EntOffsetOfPEntity_Post - FN_EntOffsetOfPEntity_Post, -#else - NULL, -#endif -#ifdef FN_IndexOfEdict_Post - FN_IndexOfEdict_Post, -#else - NULL, -#endif -#ifdef FN_PEntityOfEntIndex_Post - FN_PEntityOfEntIndex_Post, -#else - NULL, -#endif -#ifdef FN_FindEntityByVars_Post - FN_FindEntityByVars_Post, -#else - NULL, -#endif -#ifdef FN_GetModelPtr_Post - FN_GetModelPtr_Post, -#else - NULL, -#endif -#ifdef FN_RegUserMsg_Post - FN_RegUserMsg_Post, -#else - NULL, -#endif -#ifdef FN_AnimationAutomove_Post - FN_AnimationAutomove_Post, -#else - NULL, -#endif -#ifdef FN_GetBonePosition_Post - FN_GetBonePosition_Post, -#else - NULL, -#endif -#ifdef FN_FunctionFromName_Post - FN_FunctionFromName_Post, -#else - NULL, -#endif -#ifdef FN_NameForFunction_Post - FN_NameForFunction_Post, -#else - NULL, -#endif -#ifdef FN_ClientPrintf_Post - FN_ClientPrintf_Post, -#else - NULL, -#endif -#ifdef FN_ServerPrint_Post - FN_ServerPrint_Post, -#else - NULL, -#endif -#ifdef FN_Cmd_Args_Post - FN_Cmd_Args_Post, -#else - NULL, -#endif -#ifdef FN_Cmd_Argv_Post - FN_Cmd_Argv_Post, -#else - NULL, -#endif -#ifdef FN_Cmd_Argc_Post - FN_Cmd_Argc_Post, -#else - NULL, -#endif -#ifdef FN_GetAttachment_Post - FN_GetAttachment_Post, -#else - NULL, -#endif -#ifdef FN_CRC32_Init_Post - FN_CRC32_Init_Post, -#else - NULL, -#endif -#ifdef FN_CRC32_ProcessBuffer_Post - FN_CRC32_ProcessBuffer_Post, -#else - NULL, -#endif -#ifdef FN_CRC32_ProcessByte_Post - FN_CRC32_ProcessByte_Post, -#else - NULL, -#endif -#ifdef FN_CRC32_Final_Post - FN_CRC32_Final_Post, -#else - NULL, -#endif -#ifdef FN_RandomLong_Post - FN_RandomLong_Post, -#else - NULL, -#endif -#ifdef FN_RandomFloat_Post - FN_RandomFloat_Post, -#else - NULL, -#endif -#ifdef FN_SetView_Post - FN_SetView_Post, -#else - NULL, -#endif -#ifdef FN_Time_Post - FN_Time_Post, -#else - NULL, -#endif -#ifdef FN_CrosshairAngle_Post - FN_CrosshairAngle_Post, -#else - NULL, -#endif -#ifdef FN_LoadFileForMe_Post - FN_LoadFileForMe_Post, -#else - NULL, -#endif -#ifdef FN_FreeFile_Post - FN_FreeFile_Post, -#else - NULL, -#endif -#ifdef FN_EndSection_Post - FN_EndSection_Post, -#else - NULL, -#endif -#ifdef FN_CompareFileTime_Post - FN_CompareFileTime_Post, -#else - NULL, -#endif -#ifdef FN_GetGameDir_Post - FN_GetGameDir_Post, -#else - NULL, -#endif -#ifdef FN_Cvar_RegisterVariable_Post - FN_Cvar_RegisterVariable_Post, -#else - NULL, -#endif -#ifdef FN_FadeClientVolume_Post - FN_FadeClientVolume_Post, -#else - NULL, -#endif -#ifdef FN_SetClientMaxspeed_Post - FN_SetClientMaxspeed_Post, -#else - NULL, -#endif -#ifdef FN_CreateFakeClient_Post - FN_CreateFakeClient_Post, -#else - NULL, -#endif -#ifdef FN_RunPlayerMove_Post - FN_RunPlayerMove_Post, -#else - NULL, -#endif -#ifdef FN_NumberOfEntities_Post - FN_NumberOfEntities_Post, -#else - NULL, -#endif -#ifdef FN_GetInfoKeyBuffer_Post - FN_GetInfoKeyBuffer_Post, -#else - NULL, -#endif -#ifdef FN_InfoKeyValue_Post - FN_InfoKeyValue_Post, -#else - NULL, -#endif -#ifdef FN_SetKeyValue_Post - FN_SetKeyValue_Post, -#else - NULL, -#endif -#ifdef FN_SetClientKeyValue_Post - FN_SetClientKeyValue_Post, -#else - NULL, -#endif -#ifdef FN_IsMapValid_Post - FN_IsMapValid_Post, -#else - NULL, -#endif -#ifdef FN_StaticDecal_Post - FN_StaticDecal_Post, -#else - NULL, -#endif -#ifdef FN_PrecacheGeneric_Post - FN_PrecacheGeneric_Post, -#else - NULL, -#endif -#ifdef FN_GetPlayerUserId_Post - FN_GetPlayerUserId_Post, -#else - NULL, -#endif -#ifdef FN_BuildSoundMsg_Post - FN_BuildSoundMsg_Post, -#else - NULL, -#endif -#ifdef FN_IsDedicatedServer_Post - FN_IsDedicatedServer_Post, -#else - NULL, -#endif -#ifdef FN_CVarGetPointer_Post - FN_CVarGetPointer_Post, -#else - NULL, -#endif -#ifdef FN_GetPlayerWONId_Post - FN_GetPlayerWONId_Post, -#else - NULL, -#endif -#ifdef FN_Info_RemoveKey_Post - FN_Info_RemoveKey_Post, -#else - NULL, -#endif -#ifdef FN_GetPhysicsKeyValue_Post - FN_GetPhysicsKeyValue_Post, -#else - NULL, -#endif -#ifdef FN_SetPhysicsKeyValue_Post - FN_SetPhysicsKeyValue_Post, -#else - NULL, -#endif -#ifdef FN_GetPhysicsInfoString_Post - FN_GetPhysicsInfoString_Post, -#else - NULL, -#endif -#ifdef FN_PrecacheEvent_Post - FN_PrecacheEvent_Post, -#else - NULL, -#endif -#ifdef FN_PlaybackEvent_Post - FN_PlaybackEvent_Post, -#else - NULL, -#endif -#ifdef FN_SetFatPVS_Post - FN_SetFatPVS_Post, -#else - NULL, -#endif -#ifdef FN_SetFatPAS_Post - FN_SetFatPAS_Post, -#else - NULL, -#endif -#ifdef FN_CheckVisibility_Post - FN_CheckVisibility_Post, -#else - NULL, -#endif -#ifdef FN_DeltaSetField_Post - FN_DeltaSetField_Post, -#else - NULL, -#endif -#ifdef FN_DeltaUnsetField_Post - FN_DeltaUnsetField_Post, -#else - NULL, -#endif -#ifdef FN_DeltaAddEncoder_Post - FN_DeltaAddEncoder_Post, -#else - NULL, -#endif -#ifdef FN_GetCurrentPlayer_Post - FN_GetCurrentPlayer_Post, -#else - NULL, -#endif -#ifdef FN_CanSkipPlayer_Post - FN_CanSkipPlayer_Post, -#else - NULL, -#endif -#ifdef FN_DeltaFindField_Post - FN_DeltaFindField_Post, -#else - NULL, -#endif -#ifdef FN_DeltaSetFieldByIndex_Post - FN_DeltaSetFieldByIndex_Post, -#else - NULL, -#endif -#ifdef FN_DeltaUnsetFieldByIndex_Post - FN_DeltaUnsetFieldByIndex_Post, -#else - NULL, -#endif -#ifdef FN_SetGroupMask_Post - FN_SetGroupMask_Post, -#else - NULL, -#endif -#ifdef FN_engCreateInstancedBaseline_Post - FN_engCreateInstancedBaseline_Post, -#else - NULL, -#endif -#ifdef FN_Cvar_DirectSet_Post - FN_Cvar_DirectSet_Post, -#else - NULL, -#endif -#ifdef FN_ForceUnmodified_Post - FN_ForceUnmodified_Post, -#else - NULL, -#endif -#ifdef FN_GetPlayerStats_Post - FN_GetPlayerStats_Post, -#else - NULL, -#endif -#ifdef FN_AddServerCommand_Post - FN_AddServerCommand_Post, -#else - NULL, -#endif -#ifdef FN_Voice_GetClientListening_Post - FN_Voice_GetClientListening_Post, -#else - NULL, -#endif -#ifdef FN_Voice_SetClientListening_Post - FN_Voice_SetClientListening_Post, -#else - NULL, -#endif -#ifdef FN_GetPlayerAuthId_Post - FN_GetPlayerAuthId_Post -#else - NULL -#endif -}; // g_EngineFuncs_Post_Table - - -static NEW_DLL_FUNCTIONS g_NewFuncs_Table = -{ -#ifdef FN_OnFreeEntPrivateData - FN_OnFreeEntPrivateData, -#else - NULL, -#endif -#ifdef FN_GameShutdown - FN_GameShutdown, -#else - NULL, -#endif -#ifdef FN_ShouldCollide - ShouldCollide, -#else - NULL, -#endif -}; - - -static NEW_DLL_FUNCTIONS g_NewFuncs_Post_Table = -{ -#ifdef FN_OnFreeEntPrivateData_Post - FN_OnFreeEntPrivateData_Post, -#else - NULL, -#endif -#ifdef FN_GameShutdown_Post - FN_GameShutdown_Post, -#else - NULL, -#endif -#ifdef FN_ShouldCollide_Post - ShouldCollide_Post, -#else - NULL, -#endif -}; - -// Global variables from metamod. These variable names are referenced by -// various macros. -meta_globals_t *gpMetaGlobals; // metamod globals -gamedll_funcs_t *gpGamedllFuncs; // gameDLL function tables -mutil_funcs_t *gpMetaUtilFuncs; // metamod utility functions - - -plugin_info_t Plugin_info = { - META_INTERFACE_VERSION, - MODULE_NAME, - MODULE_VERSION, - MODULE_DATE, - MODULE_AUTHOR, - MODULE_URL, - MODULE_LOGTAG, - PT_ANYTIME, - PT_ANYTIME -}; - -/* -C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion) -{ - LOG_DEVELOPER(PLID, "called: GetEntityAPI; version=%d", interfaceVersion); - if(!pFunctionTable) { - LOG_ERROR(PLID, "GetEntityAPI called with null pFunctionTable"); - return(FALSE); - } - else if(interfaceVersion != INTERFACE_VERSION) { - LOG_ERROR(PLID, "GetEntityAPI version mismatch; requested=%d ours=%d", interfaceVersion, INTERFACE_VERSION); - return(FALSE); - } - memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof( DLL_FUNCTIONS ) ); - - return (TRUE); -} - -C_DLLEXPORT int GetEntityAPI_Post(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion) -{ - LOG_DEVELOPER(PLID, "called: GetEntityAPI_Post; version=%d", interfaceVersion); - if(!pFunctionTable) { - LOG_ERROR(PLID, "GetEntityAPI_Post called with null pFunctionTable"); - return(FALSE); - } - else if(interfaceVersion != INTERFACE_VERSION) { - LOG_ERROR(PLID, "GetEntityAPI_Post version mismatch; requested=%d ours=%d", interfaceVersion, INTERFACE_VERSION); - return(FALSE); - } - memcpy(pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) ); - - return(TRUE); -} -*/ - -C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion) -{ - LOG_DEVELOPER(PLID, "called: GetEntityAPI2; version=%d", *interfaceVersion); - if(!pFunctionTable) { - LOG_ERROR(PLID, "GetEntityAPI2 called with null pFunctionTable"); - return(FALSE); - } - else if(*interfaceVersion != INTERFACE_VERSION) { - LOG_ERROR(PLID, - "GetEntityAPI2 version mismatch; requested=%d ours=%d", - *interfaceVersion, INTERFACE_VERSION); - //! Tell engine what version we had, so it can figure out who is - //! out of date. - *interfaceVersion = INTERFACE_VERSION; - return(FALSE); - } - memcpy(pFunctionTable, &g_EntityAPI_Table, sizeof(DLL_FUNCTIONS)); - g_pFunctionTable=pFunctionTable; - return(TRUE); -} - -C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion) -{ - LOG_DEVELOPER(PLID, "called: GetEntityAPI2_Post; version=%d", *interfaceVersion); - if(!pFunctionTable) { - LOG_ERROR(PLID, "GetEntityAPI2_Post called with null pFunctionTable"); - return(FALSE); - } - else if(*interfaceVersion != INTERFACE_VERSION) { - LOG_ERROR(PLID, "GetEntityAPI2_Post version mismatch; requested=%d ours=%d", *interfaceVersion, INTERFACE_VERSION); - //! Tell engine what version we had, so it can figure out who is out of date. - *interfaceVersion = INTERFACE_VERSION; - return(FALSE); - } - memcpy( pFunctionTable, &g_EntityAPI_Post_Table, sizeof( DLL_FUNCTIONS ) ); - g_pFunctionTable_Post=pFunctionTable; - return(TRUE); -} - -C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion) -{ - LOG_DEVELOPER(PLID, "called: GetEngineFunctions; version=%d", - *interfaceVersion); - if(!pengfuncsFromEngine) { - LOG_ERROR(PLID, - "GetEngineFunctions called with null pengfuncsFromEngine"); - return(FALSE); - } - else if(*interfaceVersion != ENGINE_INTERFACE_VERSION) { - LOG_ERROR(PLID, - "GetEngineFunctions version mismatch; requested=%d ours=%d", - *interfaceVersion, ENGINE_INTERFACE_VERSION); - // Tell metamod what version we had, so it can figure out who is - // out of date. - *interfaceVersion = ENGINE_INTERFACE_VERSION; - return(FALSE); - } - memcpy(pengfuncsFromEngine, &g_EngineFuncs_Table, sizeof(enginefuncs_t)); - g_pengfuncsTable=pengfuncsFromEngine; - return TRUE; -} - -C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion) -{ - LOG_DEVELOPER(PLID, "called: GetEngineFunctions_Post; version=%d", *interfaceVersion); - if(!pengfuncsFromEngine) { - LOG_ERROR(PLID, "GetEngineFunctions_Post called with null pengfuncsFromEngine"); - return(FALSE); - } - else if(*interfaceVersion != ENGINE_INTERFACE_VERSION) { - LOG_ERROR(PLID, "GetEngineFunctions_Post version mismatch; requested=%d ours=%d", *interfaceVersion, ENGINE_INTERFACE_VERSION); - // Tell metamod what version we had, so it can figure out who is out of date. - *interfaceVersion = ENGINE_INTERFACE_VERSION; - return(FALSE); - } - memcpy(pengfuncsFromEngine, &g_EngineFuncs_Post_Table, sizeof(enginefuncs_t)); - g_pengfuncsTable_Post=pengfuncsFromEngine; - return TRUE; - -} - -C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, - int *interfaceVersion) -{ - LOG_DEVELOPER(PLID, "called: GetNewDLLFunctions; version=%d", - *interfaceVersion); - if(!pNewFunctionTable) { - LOG_ERROR(PLID, - "GetNewDLLFunctions called with null pNewFunctionTable"); - return(FALSE); - } - else if(*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION) { - LOG_ERROR(PLID, - "GetNewDLLFunctions version mismatch; requested=%d ours=%d", - *interfaceVersion, NEW_DLL_FUNCTIONS_VERSION); - //! Tell engine what version we had, so it can figure out who is - //! out of date. - *interfaceVersion = NEW_DLL_FUNCTIONS_VERSION; - return(FALSE); - } - memcpy(pNewFunctionTable, &g_NewFuncs_Table, sizeof(NEW_DLL_FUNCTIONS)); - g_pNewFunctionsTable=pNewFunctionTable; - return TRUE; -} - -C_DLLEXPORT int GetNewDLLFunctions_Post( NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion ) -{ - LOG_DEVELOPER(PLID, "called: GetNewDLLFunctions_Post; version=%d", *interfaceVersion); - if(!pNewFunctionTable) { - LOG_ERROR(PLID, "GetNewDLLFunctions_Post called with null pNewFunctionTable"); - return(FALSE); - } - else if(*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION) { - LOG_ERROR(PLID, "GetNewDLLFunctions_Post version mismatch; requested=%d ours=%d", *interfaceVersion, NEW_DLL_FUNCTIONS_VERSION); - //! Tell engine what version we had, so it can figure out who is out of date. - *interfaceVersion = NEW_DLL_FUNCTIONS_VERSION; - return(FALSE); - } - memcpy(pNewFunctionTable, &g_NewFuncs_Post_Table, sizeof(NEW_DLL_FUNCTIONS)); - g_pNewFunctionsTable_Post=pNewFunctionTable; - return TRUE; -} - - -static META_FUNCTIONS g_MetaFunctions_Table = -{ - NULL, - NULL, - GetEntityAPI2, - GetEntityAPI2_Post, - GetNewDLLFunctions, - GetNewDLLFunctions_Post, - GetEngineFunctions, - GetEngineFunctions_Post -}; - -C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs) -{ - if ((int) CVAR_GET_FLOAT("developer") != 0) - UTIL_LogPrintf("[%s] dev: called: Meta_Query; version=%s, ours=%s\n", - Plugin_info.logtag, ifvers, Plugin_info.ifvers); - - // Check for valid pMetaUtilFuncs before we continue. - if(!pMetaUtilFuncs) { - UTIL_LogPrintf("[%s] ERROR: Meta_Query called with null pMetaUtilFuncs\n", Plugin_info.logtag); - return(FALSE); - } - - gpMetaUtilFuncs = pMetaUtilFuncs; - - *pPlugInfo = &Plugin_info; - - // Check for interface version compatibility. - if(!FStrEq(ifvers, Plugin_info.ifvers)) { - int mmajor=0, mminor=0, pmajor=0, pminor=0; - LOG_MESSAGE(PLID, "WARNING: meta-interface version mismatch; requested=%s ours=%s", - Plugin_info.logtag, ifvers); - // If plugin has later interface version, it's incompatible (update - // metamod). - sscanf(ifvers, "%d:%d", &mmajor, &mminor); - sscanf(META_INTERFACE_VERSION, "%d:%d", &pmajor, &pminor); - if(pmajor > mmajor || (pmajor==mmajor && pminor > mminor)) { - LOG_ERROR(PLID, "metamod version is too old for this module; update metamod"); - return(FALSE); - } - // If plugin has older major interface version, it's incompatible - // (update plugin). - else if(pmajor < mmajor) { - LOG_ERROR(PLID, "metamod version is incompatible with this module; please find a newer version of this module"); - return(FALSE); - } - // Minor interface is older, but this is guaranteed to be backwards - // compatible, so we warn, but we still accept it. - else if(pmajor==mmajor && pminor < mminor) - LOG_MESSAGE(PLID, "WARNING: metamod version is newer than expected; consider finding a newer version of this module"); - else - LOG_ERROR(PLID, "unexpected version comparison; metavers=%s, mmajor=%d, mminor=%d; plugvers=%s, pmajor=%d, pminor=%d", ifvers, mmajor, mminor, META_INTERFACE_VERSION, pmajor, pminor); - } - -#ifdef FN_META_QUERY - FN_META_QUERY(); -#endif // FN_META_QUERY - - return 1; -} - - -C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs) -{ - if(now > Plugin_info.loadable) { - LOG_ERROR(PLID, "Can't load module right now"); - return(FALSE); - } - if(!pMGlobals) { - LOG_ERROR(PLID, "Meta_Attach called with null pMGlobals"); - return(FALSE); - } - gpMetaGlobals=pMGlobals; - if(!pFunctionTable) { - LOG_ERROR(PLID, "Meta_Attach called with null pFunctionTable"); - return(FALSE); - } - - memcpy(pFunctionTable, &g_MetaFunctions_Table, sizeof(META_FUNCTIONS)); - gpGamedllFuncs=pGamedllFuncs; - - // Let's go. - -#ifdef FN_META_ATTACH - FN_META_ATTACH(); -#endif // FN_META_ATTACH - - return TRUE; -} - -C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason) -{ - if(now > Plugin_info.unloadable && reason != PNL_CMD_FORCED) { - LOG_ERROR(PLID, "Can't unload plugin right now"); - return(FALSE); - } - -#ifdef FN_META_DETACH - FN_META_DETACH(); -#endif // FN_META_DETACH - return TRUE; -} - - - -#ifdef __linux__ -// linux prototype -C_DLLEXPORT void GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) { - -#else -#ifdef _MSC_VER -// MSVC: Simulate __stdcall calling convention -C_DLLEXPORT __declspec(naked) void GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) -{ - __asm // Prolog - { - // Save ebp - push ebp - // Set stack frame pointer - mov ebp, esp - // Allocate space for local variables - // The MSVC compiler gives us the needed size in __LOCAL_SIZE. - sub esp, __LOCAL_SIZE - // Push registers - push ebx - push esi - push edi - } -#else // _MSC_VER -#ifdef __GNUC__ -// GCC can also work with this -C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) -{ -#else // __GNUC__ -// compiler not known -#error There is no support (yet) for your compiler. Please use MSVC or GCC compilers or contact the AMX Mod X dev team. -#endif // __GNUC__ -#endif // _MSC_VER -#endif // __linux__ - - // ** Function core <-- - memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t)); - gpGlobals = pGlobals; - // NOTE! Have to call logging function _after_ copying into g_engfuncs, so - // that g_engfuncs.pfnAlertMessage() can be resolved properly, heh. :) - // UTIL_LogPrintf("[%s] dev: called: GiveFnptrsToDll\n", Plugin_info.logtag); - // --> ** Function core - -#ifdef _MSC_VER - // Epilog - if (sizeof(int*) == 8) - { // 64 bit - __asm - { - // Pop registers - pop edi - pop esi - pop ebx - // Restore stack frame pointer - mov esp, ebp - // Restore ebp - pop ebp - // 2 * sizeof(int*) = 16 on 64 bit - ret 16 - } - } - else - { // 32 bit - __asm - { - // Pop registers - pop edi - pop esi - pop ebx - // Restore stack frame pointer - mov esp, ebp - // Restore ebp - pop ebp - // 2 * sizeof(int*) = 8 on 32 bit - ret 8 - } - } -#endif // #ifdef _MSC_VER -} - -#endif // #ifdef USE_METAMOD - -/************* AMXX Stuff *************/ - -// *** Globals *** -// Module info -static amxx_module_info_s g_ModuleInfo = -{ - MODULE_NAME, - MODULE_AUTHOR, - MODULE_VERSION, -#ifdef MODULE_RELOAD_ON_MAPCHANGE - 1, -#else // MODULE_RELOAD_ON_MAPCHANGE - 0, -#endif // MODULE_RELOAD_ON_MAPCHANGE - MODULE_LOGTAG, - MODULE_LIBRARY, - MODULE_LIBCLASS -}; - -// Storage for the requested functions -PFN_ADD_NATIVES g_fn_AddNatives; -PFN_ADD_NEW_NATIVES g_fn_AddNewNatives; -PFN_BUILD_PATHNAME g_fn_BuildPathname; -PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR; -PFN_GET_AMXADDR g_fn_GetAmxAddr; -PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; -PFN_GET_MODNAME g_fn_GetModname; -PFN_GET_AMXSCRIPTNAME g_fn_GetAmxScriptName; -PFN_GET_AMXSCRIPT g_fn_GetAmxScript; -PFN_FIND_AMXSCRIPT_BYAMX g_fn_FindAmxScriptByAmx; -PFN_FIND_AMXSCRIPT_BYNAME g_fn_FindAmxScriptByName; -PFN_SET_AMXSTRING g_fn_SetAmxString; -PFN_GET_AMXSTRING g_fn_GetAmxString; -PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen; -PFN_FORMAT_AMXSTRING g_fn_FormatAmxString; -PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory; -PFN_LOG g_fn_Log; -PFN_LOG_ERROR g_fn_LogErrorFunc; -PFN_RAISE_AMXERROR g_fn_RaiseAmxError; -PFN_REGISTER_FORWARD g_fn_RegisterForward; -PFN_EXECUTE_FORWARD g_fn_ExecuteForward; -PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray; -PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray; -PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA; -PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA; -PFN_IS_PLAYER_VALID g_fn_IsPlayerValid; -PFN_GET_PLAYER_NAME g_fn_GetPlayerName; -PFN_GET_PLAYER_IP g_fn_GetPlayerIP; -PFN_IS_PLAYER_INGAME g_fn_IsPlayerIngame; -PFN_IS_PLAYER_BOT g_fn_IsPlayerBot; -PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized; -PFN_GET_PLAYER_TIME g_fn_GetPlayerTime; -PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime; -PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon; -PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; -PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID; -PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths; -PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu; -PFN_GET_PLAYER_KEYS g_fn_GetPlayerKeys; -PFN_IS_PLAYER_ALIVE g_fn_IsPlayerAlive; -PFN_GET_PLAYER_FRAGS g_fn_GetPlayerFrags; -PFN_IS_PLAYER_CONNECTING g_fn_IsPlayerConnecting; -PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV; -PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor; -PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth; -#ifdef MEMORY_TEST -PFN_ALLOCATOR g_fn_Allocator; -PFN_REALLOCATOR g_fn_Reallocator; -PFN_DEALLOCATOR g_fn_Deallocator; -#endif -PFN_AMX_EXEC g_fn_AmxExec; -PFN_AMX_EXECV g_fn_AmxExecv; -PFN_AMX_ALLOT g_fn_AmxAllot; -PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic; -PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript; -PFN_UNLOAD_AMXSCRIPT g_fn_UnloadAmxScript; -PFN_REAL_TO_CELL g_fn_RealToCell; -PFN_CELL_TO_REAL g_fn_CellToReal; -PFN_REGISTER_SPFORWARD g_fn_RegisterSPForward; -PFN_REGISTER_SPFORWARD_BYNAME g_fn_RegisterSPForwardByName; -PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward; -PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File; -PFN_AMX_FINDNATIVE g_fn_AmxFindNative; -PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; -PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; -PFN_FORMAT g_fn_Format; -PFN_REGISTERFUNCTION g_fn_RegisterFunction; -PFN_REQ_FNPTR g_fn_RequestFunction; -PFN_AMX_PUSH g_fn_AmxPush; -PFN_SET_TEAM_INFO g_fn_SetTeamInfo; -PFN_PLAYER_PROP_ADDR g_fn_PlayerPropAddr; -PFN_REG_AUTH_FUNC g_fn_RegAuthFunc; -PFN_UNREG_AUTH_FUNC g_fn_UnregAuthFunc; -PFN_FINDLIBRARY g_fn_FindLibrary; -PFN_ADDLIBRARIES g_fn_AddLibraries; -PFN_REMOVELIBRARIES g_fn_RemoveLibraries; -PFN_OVERRIDENATIVES g_fn_OverrideNatives; -PFN_GETLOCALINFO g_fn_GetLocalInfo; -PFN_AMX_REREGISTER g_fn_AmxReRegister; -PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx; -PFN_MESSAGE_BLOCK g_fn_MessageBlock; - -// *** Exports *** -C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) -{ - // check parameters - if (!interfaceVersion || !moduleInfo) - return AMXX_PARAM; - - // check interface version - if (*interfaceVersion != AMXX_INTERFACE_VERSION) - { - // Tell amxx core our interface version - *interfaceVersion = AMXX_INTERFACE_VERSION; - return AMXX_IFVERS; - } - - // copy module info - memcpy(moduleInfo, &g_ModuleInfo, sizeof(amxx_module_info_s)); - -#ifdef FN_AMXX_QUERY - FN_AMXX_QUERY(); -#endif // FN_AMXX_QUERY - // Everything ok :) - return AMXX_OK; -} - -// request function -#define REQFUNC(name, fptr, type) if ((fptr = (type)reqFnptrFunc(name)) == 0) return AMXX_FUNC_NOT_PRESENT -// request optional function -#define REQFUNC_OPT(name, fptr, type) fptr = (type)reqFnptrFunc(name) - -C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc) -{ - // Check pointer - if (!reqFnptrFunc) - return AMXX_PARAM; - - g_fn_RequestFunction = reqFnptrFunc; - - // Req all known functions - // Misc - REQFUNC("BuildPathname", g_fn_BuildPathname, PFN_BUILD_PATHNAME); - REQFUNC("BuildPathnameR", g_fn_BuildPathnameR, PFN_BUILD_PATHNAME_R); - REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); - REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); - REQFUNC("Log", g_fn_Log, PFN_LOG); - REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR); - REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); - REQFUNC("Format", g_fn_Format, PFN_FORMAT); - REQFUNC("RegisterFunction", g_fn_RegisterFunction, PFN_REGISTERFUNCTION); - REQFUNC("RegisterFunctionEx", g_fn_RegisterFunctionEx, PFN_REGISTERFUNCTIONEX); - - // Amx scripts - REQFUNC("GetAmxScript", g_fn_GetAmxScript, PFN_GET_AMXSCRIPT); - REQFUNC("FindAmxScriptByAmx", g_fn_FindAmxScriptByAmx, PFN_FIND_AMXSCRIPT_BYAMX); - REQFUNC("FindAmxScriptByName", g_fn_FindAmxScriptByName, PFN_FIND_AMXSCRIPT_BYNAME); - REQFUNC("LoadAmxScript", g_fn_LoadAmxScript, PFN_LOAD_AMXSCRIPT); - REQFUNC("UnloadAmxScript", g_fn_UnloadAmxScript, PFN_UNLOAD_AMXSCRIPT); - REQFUNC("GetAmxScriptName", g_fn_GetAmxScriptName, PFN_GET_AMXSCRIPTNAME); - - // String / mem in amx scripts support - REQFUNC("SetAmxString", g_fn_SetAmxString, PFN_SET_AMXSTRING); - REQFUNC("GetAmxString", g_fn_GetAmxString, PFN_GET_AMXSTRING); - REQFUNC("GetAmxStringLen", g_fn_GetAmxStringLen, PFN_GET_AMXSTRINGLEN); - REQFUNC("FormatAmxString", g_fn_FormatAmxString, PFN_FORMAT_AMXSTRING); - REQFUNC("CopyAmxMemory", g_fn_CopyAmxMemory, PFN_COPY_AMXMEMORY); - REQFUNC("GetAmxAddr", g_fn_GetAmxAddr, PFN_GET_AMXADDR); - - REQFUNC("amx_Exec", g_fn_AmxExec, PFN_AMX_EXEC); - REQFUNC("amx_Execv", g_fn_AmxExecv, PFN_AMX_EXECV); - REQFUNC("amx_FindPublic", g_fn_AmxFindPublic, PFN_AMX_FINDPUBLIC); - REQFUNC("amx_Allot", g_fn_AmxAllot, PFN_AMX_ALLOT); - REQFUNC("amx_FindNative", g_fn_AmxFindNative, PFN_AMX_FINDNATIVE); - - // Natives / Forwards - REQFUNC("AddNatives", g_fn_AddNatives, PFN_ADD_NATIVES); - REQFUNC("AddNewNatives", g_fn_AddNewNatives, PFN_ADD_NEW_NATIVES); - REQFUNC("RaiseAmxError", g_fn_RaiseAmxError, PFN_RAISE_AMXERROR); - REQFUNC("RegisterForward", g_fn_RegisterForward, PFN_REGISTER_FORWARD); - REQFUNC("RegisterSPForward", g_fn_RegisterSPForward, PFN_REGISTER_SPFORWARD); - REQFUNC("RegisterSPForwardByName", g_fn_RegisterSPForwardByName, PFN_REGISTER_SPFORWARD_BYNAME); - REQFUNC("UnregisterSPForward", g_fn_UnregisterSPForward, PFN_UNREGISTER_SPFORWARD); - REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD); - REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY); - REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY); - REQFUNC("PrepareCellArrayA", g_fn_PrepareCellArrayA, PFN_PREPARE_CELLARRAY_A); - REQFUNC("PrepareCharArrayA", g_fn_PrepareCharArrayA, PFN_PREPARE_CHARARRAY_A); - // Player - REQFUNC("IsPlayerValid", g_fn_IsPlayerValid, PFN_IS_PLAYER_VALID); - REQFUNC("GetPlayerName", g_fn_GetPlayerName, PFN_GET_PLAYER_NAME); - REQFUNC("GetPlayerIP", g_fn_GetPlayerIP, PFN_GET_PLAYER_IP); - REQFUNC("IsPlayerInGame", g_fn_IsPlayerIngame, PFN_IS_PLAYER_INGAME); - REQFUNC("IsPlayerBot", g_fn_IsPlayerBot, PFN_IS_PLAYER_BOT); - REQFUNC("IsPlayerAuthorized", g_fn_IsPlayerAuthorized, PFN_IS_PLAYER_AUTHORIZED); - REQFUNC("GetPlayerTime", g_fn_GetPlayerTime, PFN_GET_PLAYER_TIME); - REQFUNC("GetPlayerPlayTime", g_fn_GetPlayerPlayTime, PFN_GET_PLAYER_PLAYTIME); - REQFUNC("GetPlayerCurweapon", g_fn_GetPlayerCurweapon, PFN_GET_PLAYER_CURWEAPON); - REQFUNC("GetPlayerTeamID", g_fn_GetPlayerTeamID, PFN_GET_PLAYER_TEAMID); - REQFUNC("GetPlayerTeam",g_fn_GetPlayerTeam, PFN_GET_PLAYER_TEAM); - REQFUNC("GetPlayerDeaths", g_fn_GetPlayerDeaths, PFN_GET_PLAYER_DEATHS); - REQFUNC("GetPlayerMenu", g_fn_GetPlayerMenu, PFN_GET_PLAYER_MENU); - REQFUNC("GetPlayerKeys", g_fn_GetPlayerKeys, PFN_GET_PLAYER_KEYS); - REQFUNC("IsPlayerAlive", g_fn_IsPlayerAlive, PFN_IS_PLAYER_ALIVE); - REQFUNC("GetPlayerFrags", g_fn_GetPlayerFrags, PFN_GET_PLAYER_FRAGS); - REQFUNC("IsPlayerConnecting", g_fn_IsPlayerConnecting, PFN_IS_PLAYER_CONNECTING); - REQFUNC("IsPlayerHLTV", g_fn_IsPlayerHLTV, PFN_IS_PLAYER_HLTV); - REQFUNC("GetPlayerArmor", g_fn_GetPlayerArmor, PFN_GET_PLAYER_ARMOR); - REQFUNC("GetPlayerHealth", g_fn_GetPlayerHealth, PFN_GET_PLAYER_HEALTH); - REQFUNC("GetPlayerFlags", g_fn_GetPlayerFlags, PFN_GETPLAYERFLAGS); - REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT); - REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH); - REQFUNC("SetPlayerTeamInfo", g_fn_SetTeamInfo, PFN_SET_TEAM_INFO); - REQFUNC("PlayerPropAddr", g_fn_PlayerPropAddr, PFN_PLAYER_PROP_ADDR); - REQFUNC("RegAuthFunc", g_fn_RegAuthFunc, PFN_REG_AUTH_FUNC); - REQFUNC("UnregAuthFunc", g_fn_UnregAuthFunc, PFN_UNREG_AUTH_FUNC); - - //Added in 1.75 - REQFUNC("FindLibrary", g_fn_FindLibrary, PFN_FINDLIBRARY); - REQFUNC("AddLibraries", g_fn_AddLibraries, PFN_ADDLIBRARIES); - REQFUNC("RemoveLibraries", g_fn_RemoveLibraries, PFN_REMOVELIBRARIES); - REQFUNC("OverrideNatives", g_fn_OverrideNatives, PFN_OVERRIDENATIVES); - REQFUNC("GetLocalInfo", g_fn_GetLocalInfo, PFN_GETLOCALINFO); - REQFUNC("AmxReregister", g_fn_AmxReRegister, PFN_AMX_REREGISTER); - - REQFUNC("MessageBlock", g_fn_MessageBlock, PFN_MESSAGE_BLOCK); - -#ifdef MEMORY_TEST - // Memory - REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR); - REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR); - REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR); -#endif - - REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL); - REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL); - -#ifdef FN_AMXX_ATTACH - FN_AMXX_ATTACH(); -#endif // FN_AMXX_ATACH - - return AMXX_OK; -} - -C_DLLEXPORT int AMXX_Detach() -{ -#ifdef FN_AMXX_DETACH - FN_AMXX_DETACH(); -#endif // FN_AMXX_DETACH - - return AMXX_OK; -} - -C_DLLEXPORT int AMXX_PluginsLoaded() -{ -#ifdef FN_AMXX_PLUGINSLOADED - FN_AMXX_PLUGINSLOADED(); -#endif // FN_AMXX_PLUGINSLOADED - return AMXX_OK; -} - -C_DLLEXPORT void AMXX_PluginsUnloaded() -{ -#ifdef FN_AMXX_PLUGINSUNLOADED - FN_AMXX_PLUGINSUNLOADED(); -#endif // FN_AMXX_PLUGINSUNLOADED -} - -C_DLLEXPORT void AMXX_PluginsUnloading() -{ -#ifdef FN_AMXX_PLUGINSUNLOADING - FN_AMXX_PLUGINSUNLOADING(); -#endif // FN_AMXX_PLUGINSUNLOADING -} - -// Advanced MF functions -void MF_Log(const char *fmt, ...) -{ - char msg[3072]; - va_list arglst; - va_start(arglst, fmt); - vsnprintf(msg, sizeof(msg) - 1, fmt, arglst); - va_end(arglst); - - g_fn_Log("[%s] %s", MODULE_LOGTAG, msg); -} - -void MF_LogError(AMX *amx, int err, const char *fmt, ...) -{ - char msg[3072]; - va_list arglst; - va_start(arglst, fmt); - vsnprintf(msg, sizeof(msg) - 1, fmt, arglst); - va_end(arglst); - - g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_LOGTAG, msg); -} - - -#ifdef _DEBUG -// validate macros -// Makes sure compiler reports errors when macros are invalid -void ValidateMacros_DontCallThis_Smiley() -{ - MF_BuildPathname("str", "str", 0); - MF_BuildPathnameR(NULL, 0, "%d", 0); - MF_FormatAmxString(NULL, 0, 0, NULL); - MF_GetAmxAddr(NULL, 0); - MF_PrintSrvConsole("str", "str", 0); - MF_GetModname(); - MF_GetScriptName(0); - MF_GetScriptAmx(0); - MF_FindScriptByAmx(NULL); - MF_FindScriptByName("str"); - MF_SetAmxString(NULL, 0, "str", 0); - MF_GetAmxString(NULL, 0, 0, 0); - MF_GetAmxStringLen(NULL); - MF_CopyAmxMemory(NULL, NULL, 0); - MF_Log("str", "str", 0); - MF_LogError(NULL, 0, NULL); - MF_RaiseAmxError(NULL, 0); - MF_RegisterForward("str", (ForwardExecType)0, 0, 0, 0); - MF_ExecuteForward(0, 0, 0); - MF_PrepareCellArray(NULL, 0); - MF_PrepareCharArray(NULL, 0); - MF_PrepareCellArrayA(NULL, 0, true); - MF_PrepareCharArrayA(NULL, 0, true); - MF_IsPlayerValid(0); - MF_GetPlayerName(0); - MF_GetPlayerIP(0); - MF_IsPlayerIngame(0); - MF_IsPlayerBot(0); - MF_IsPlayerAuthorized(0); - MF_GetPlayerTime(0); - MF_GetPlayerPlayTime(0); - MF_GetPlayerCurweapon(0); - MF_GetPlayerTeamID(0); - MF_GetPlayerTeam(0); - MF_GetPlayerDeaths(0); - MF_GetPlayerMenu(0); - MF_GetPlayerKeys(0); - MF_IsPlayerAlive(0); - MF_GetPlayerFrags(0); - MF_IsPlayerConnecting(0); - MF_IsPlayerHLTV(0); - MF_GetPlayerArmor(0); - MF_GetPlayerHealth(0); - MF_AmxExec(0, 0, 0); - MF_AmxExecv(0, 0, 0, 0, 0); - MF_AmxFindPublic(0, 0, 0); - MF_AmxAllot(0, 0, 0, 0); - MF_LoadAmxScript(0, 0, 0, 0, 0); - MF_UnloadAmxScript(0, 0); - MF_RegisterSPForward(0, 0, 0, 0, 0, 0); - MF_RegisterSPForwardByName(0, 0, 0, 0, 0, 0); - MF_UnregisterSPForward(0); - MF_GetPlayerFrags(0); - MF_GetPlayerEdict(0); - MF_Format("", 4, "str"); - MF_RegisterFunction(NULL, ""); - MF_RegisterFunctionEx(NULL, ""); - MF_SetPlayerTeamInfo(0, 0, ""); - MF_PlayerPropAddr(0, 0); - MF_RegAuthFunc(NULL); - MF_UnregAuthFunc(NULL); - MF_FindLibrary(NULL, LibType_Class); - MF_AddLibraries(NULL, LibType_Class, NULL); - MF_RemoveLibraries(NULL); - MF_OverrideNatives(NULL, NULL); - MF_MessageBlock(0, 0, NULL); -} -#endif - -#ifdef MEMORY_TEST - -/************* MEMORY *************/ -// undef all defined macros -#undef new -#undef delete -#undef malloc -#undef calloc -#undef realloc -#undef free - -const unsigned int m_alloc_unknown = 0; -const unsigned int m_alloc_new = 1; -const unsigned int m_alloc_new_array = 2; -const unsigned int m_alloc_malloc = 3; -const unsigned int m_alloc_calloc = 4; -const unsigned int m_alloc_realloc = 5; -const unsigned int m_alloc_delete = 6; -const unsigned int m_alloc_delete_array = 7; -const unsigned int m_alloc_free = 8; - -const char *g_Mem_CurrentFilename = "??"; -int g_Mem_CurrentLine = 0; -const char *g_Mem_CurrentFunc = "??"; - -const char *Mem_MakeSourceFile(const char *sourceFile) -{ - static char buffer[512]; - static size_t pos = 0; - if (!pos) - { - // init - buffer[0] = '['; - strcpy(buffer + 1, MODULE_NAME); - pos = strlen(MODULE_NAME) + 1; - buffer[pos++] = ']'; - } - - // convert from absolute path to [modulename]filename - const char *ptr = strrchr(sourceFile, '\\'); - if (ptr) - ptr++; - else - { - ptr = strrchr(sourceFile, '/'); - if (ptr) - ptr++; - else - ptr = sourceFile; - } - strcpy(buffer + pos, ptr); - return buffer; -} - -void Mem_SetOwner(const char *filename, int line, const char *function) -{ - g_Mem_CurrentFilename = filename; - g_Mem_CurrentLine = line; - g_Mem_CurrentFunc = function; -} - -void Mem_ResetGlobals() -{ - Mem_SetOwner("??", 0, "??"); -} - -// raw (re/de)allocators -void * Mem_Allocator(const char *sourceFile, const unsigned int sourceLine, const char *sourceFunc, - const unsigned int allocationType, const size_t reportedSize) -{ - if (g_fn_Allocator) - return g_fn_Allocator(Mem_MakeSourceFile(sourceFile), sourceLine, sourceFunc, allocationType, reportedSize); - else - return malloc(reportedSize); -} - -void * Mem_Reallocator(const char *sourceFile, const unsigned int sourceLine, const char *sourceFunc, - const unsigned int reallocationType, const size_t reportedSize, void *reportedAddress) -{ - if (g_fn_Reallocator) - return g_fn_Reallocator(Mem_MakeSourceFile(sourceFile), sourceLine, sourceFunc, reallocationType, reportedSize, reportedAddress); - else - return realloc(reportedAddress, reportedSize); -} - -void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, const char *sourceFunc, - const unsigned int deallocationType, void *reportedAddress) -{ - // If you you get user breakpoint here, something failed :) - // - invalid pointer - // - alloc type mismatch ( for example - // char *a = new char[5]; delete char; - // ) - // - The allocation unit is damaged (for example - // char *a = new char[5]; a[6] = 8; - // ) - // - break on dealloc flag set (somehow) - - if (g_fn_Deallocator) - g_fn_Deallocator(Mem_MakeSourceFile(sourceFile), sourceLine, sourceFunc, deallocationType, reportedAddress); - else - free(reportedAddress); -} - -// new and delete operators -void *operator new(size_t reportedSize) -{ - if (reportedSize == 0) - reportedSize = 1; - void *ptr = Mem_Allocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_new, reportedSize); - // :TODO: Handler support ? - if (ptr) - return ptr; - - // allocation failed - return NULL; -} - -void *operator new[](size_t reportedSize) -{ - if (reportedSize == 0) - reportedSize = 1; - void *ptr = Mem_Allocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_new_array, reportedSize); - // :TODO: Handler support ? - if (ptr) - return ptr; - - // allocation failed - return NULL; -} - -// Microsoft memory tracking operators -void *operator new(size_t reportedSize, const char *sourceFile, int sourceLine) -{ - if (reportedSize == 0) - reportedSize = 1; - void *ptr = Mem_Allocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_new, reportedSize); - // :TODO: Handler support ? - if (ptr) - return ptr; - - // allocation failed - return NULL; -} -void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine) -{ - if (reportedSize == 0) - reportedSize = 1; - void *ptr = Mem_Allocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_new_array, reportedSize); - // :TODO: Handler support ? - if (ptr) - return ptr; - - // allocation failed - return NULL; -} - -void operator delete(void *reportedAddress) -{ - if (!reportedAddress) - return; - - Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete, reportedAddress); -} - -void operator delete[](void *reportedAddress) -{ - if (!reportedAddress) - return; - - Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress); -} - -#else - -#if !defined NO_ALLOC_OVERRIDES && !defined MEMORY_TEST && !defined WIN32 -void * operator new(size_t size) { - return(calloc(1, size)); -} - -void * operator new[](size_t size) { - return(calloc(1, size)); -} - -void operator delete(void * ptr) { - if(ptr) - free(ptr); -} - -void operator delete[](void * ptr) { - if(ptr) - free(ptr); -} -#endif - -#endif //MEMORY_TEST - -/************* stuff from dlls/util.cpp *************/ -// must come here because cbase.h declares it's own operator new - -#ifdef USE_METAMOD - -// Selected portions of dlls/util.cpp from SDK 2.1. -// Functions copied from there as needed... -// And modified to avoid buffer overflows (argh). - -/*** -* -* Copyright (c) 1999, 2000 Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -/* - -===== util.cpp ======================================================== - - Utility code. Really not optional after all. - -*/ - -#include -#include "sdk_util.h" -#include - -#include // for strncpy(), etc - -#include "osdep.h" // win32 vsnprintf, etc - -char* UTIL_VarArgs( char *format, ... ) -{ - va_list argptr; - static char string[1024]; - - va_start (argptr, format); - vsnprintf (string, sizeof(string), format, argptr); - va_end (argptr); - - return string; -} - - -//========================================================= -// UTIL_LogPrintf - Prints a logged message to console. -// Preceded by LOG: ( timestamp ) < message > -//========================================================= -void UTIL_LogPrintf( char *fmt, ... ) -{ - va_list argptr; - static char string[1024]; - - va_start ( argptr, fmt ); - vsnprintf ( string, sizeof(string), fmt, argptr ); - va_end ( argptr ); - - // Print to server console - ALERT( at_logged, "%s", string ); -} - - -void UTIL_HudMessage(CBaseEntity *pEntity, const hudtextparms_t &textparms, - const char *pMessage) -{ - if ( !pEntity ) - return; - - MESSAGE_BEGIN( MSG_ONE, SVC_TEMPENTITY, NULL, ENT(pEntity->pev) ); - WRITE_BYTE( TE_TEXTMESSAGE ); - WRITE_BYTE( textparms.channel & 0xFF ); - - WRITE_SHORT( FixedSigned16( textparms.x, 1<<13 ) ); - WRITE_SHORT( FixedSigned16( textparms.y, 1<<13 ) ); - WRITE_BYTE( textparms.effect ); - - WRITE_BYTE( textparms.r1 ); - WRITE_BYTE( textparms.g1 ); - WRITE_BYTE( textparms.b1 ); - WRITE_BYTE( textparms.a1 ); - - WRITE_BYTE( textparms.r2 ); - WRITE_BYTE( textparms.g2 ); - WRITE_BYTE( textparms.b2 ); - WRITE_BYTE( textparms.a2 ); - - WRITE_SHORT( FixedUnsigned16( textparms.fadeinTime, 1<<8 ) ); - WRITE_SHORT( FixedUnsigned16( textparms.fadeoutTime, 1<<8 ) ); - WRITE_SHORT( FixedUnsigned16( textparms.holdTime, 1<<8 ) ); - - if ( textparms.effect == 2 ) - WRITE_SHORT( FixedUnsigned16( textparms.fxTime, 1<<8 ) ); - - if ( strlen( pMessage ) < 512 ) - { - WRITE_STRING( pMessage ); - } - else - { - char tmp[512]; - strncpy( tmp, pMessage, 511 ); - tmp[511] = 0; - WRITE_STRING( tmp ); - } - MESSAGE_END(); -} - -short FixedSigned16( float value, float scale ) -{ - int output; - - output = (int) (value * scale); - - if ( output > 32767 ) - output = 32767; - - if ( output < -32768 ) - output = -32768; - - return (short)output; -} - -unsigned short FixedUnsigned16( float value, float scale ) -{ - int output; - - output = (int) (value * scale); - if ( output < 0 ) - output = 0; - if ( output > 0xFFFF ) - output = 0xFFFF; - - return (unsigned short)output; -} -#endif // USE_METAMOD diff --git a/dlls/hamsandwich/sdk/amxxmodule.h b/dlls/hamsandwich/sdk/amxxmodule.h deleted file mode 100644 index b7256802..00000000 --- a/dlls/hamsandwich/sdk/amxxmodule.h +++ /dev/null @@ -1,2468 +0,0 @@ -/* - * AMX Mod X Module Interface Functions - * This file may be freely used -*/ - -// prevent double include -#ifndef __AMXXMODULE_H__ -#define __AMXXMODULE_H__ - -// config -#include "moduleconfig.h" - -// metamod include files -#ifdef USE_METAMOD -#include -#include -#include "osdep.h" -#endif // #ifdef USE_METAMOD - -// DLL Export -#undef DLLEXPORT -#ifndef __linux__ -#define DLLEXPORT __declspec(dllexport) -#else -#define DLLEXPORT __attribute__((visibility("default"))) -#define LINUX -#endif - -#undef C_DLLEXPORT -#define C_DLLEXPORT extern "C" DLLEXPORT - -// ***** AMXX stuff ***** - -// module interface version was 1 -// 2 - added logtag to struct (amxx1.1-rc1) -// 3 - added new tagAMX structure (amxx1.5) -// 4 - added new 'library' setting for direct loading -#define AMXX_INTERFACE_VERSION 4 - -// amxx module info -struct amxx_module_info_s -{ - const char *name; - const char *author; - const char *version; - int reload; // reload on mapchange when nonzero - const char *logtag; // added in version 2 - const char *library; // added in version 4 - const char *libclass; // added in version 4 -}; - -// return values from functions called by amxx -#define AMXX_OK 0 /* no error */ -#define AMXX_IFVERS 1 /* interface version */ -#define AMXX_PARAM 2 /* Invalid parameter */ -#define AMXX_FUNC_NOT_PRESENT 3 /* Function not present */ - -// *** Small stuff *** -// The next section is copied from the amx.h file -// Copyright (c) ITB CompuPhase, 1997-2005 - -#if defined HAVE_STDINT_H - #include -#else - #if defined __LCC__ || defined __DMC__ || defined LINUX - #if defined HAVE_INTTYPES_H - #include - #else - #include - #endif - #elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L - /* The ISO C99 defines the int16_t and int_32t types. If the compiler got - * here, these types are probably undefined. - */ - #if defined __MACH__ - #include - typedef unsigned short int uint16_t; - typedef unsigned long int uint32_t; - #elif defined __FreeBSD__ - #include - #else - typedef short int int16_t; - typedef unsigned short int uint16_t; - #if defined SN_TARGET_PS2 - typedef int int32_t; - typedef unsigned int uint32_t; - #else - typedef long int int32_t; - typedef unsigned long int uint32_t; - #endif - #if defined __WIN32__ || defined _WIN32 || defined WIN32 - typedef __int64 int64_t; - typedef unsigned __int64 uint64_t; - #define HAVE_I64 - #elif defined __GNUC__ - typedef long long int64_t; - typedef unsigned long long uint64_t; - #define HAVE_I64 - #endif - #endif - #endif - #define HAVE_STDINT_H -#endif -#if defined _LP64 || defined WIN64 || defined _WIN64 - #if !defined __64BIT__ - #define __64BIT__ - #endif -#endif - -/* calling convention for native functions */ -#if !defined AMX_NATIVE_CALL - #define AMX_NATIVE_CALL -#endif -/* calling convention for all interface functions and callback functions */ -#if !defined AMXAPI - #if defined STDECL - #define AMXAPI __stdcall - #elif defined CDECL - #define AMXAPI __cdecl - #else - #define AMXAPI - #endif -#endif -#if !defined AMXEXPORT - #define AMXEXPORT -#endif - -#if !defined PAWN_CELL_SIZE - #define PAWN_CELL_SIZE 32 /* by default, use 32-bit cells */ -#endif -#if PAWN_CELL_SIZE==16 - typedef uint16_t ucell; - typedef int16_t cell; -#elif PAWN_CELL_SIZE==32 - typedef uint32_t ucell; - typedef int32_t cell; -#define REAL float -#elif PAWN_CELL_SIZE==64 - typedef uint64_t ucell; - typedef int64_t cell; -#define REAL double -#else - #error Unsupported cell size (PAWN_CELL_SIZE) -#endif - -#define UNPACKEDMAX ((1 << (sizeof(cell)-1)*8) - 1) -#define UNLIMITED (~1u >> 1) - -struct tagAMX; -typedef cell (AMX_NATIVE_CALL *AMX_NATIVE)(struct tagAMX *amx, cell *params); -typedef int (AMXAPI *AMX_CALLBACK)(struct tagAMX *amx, cell index, - cell *result, cell *params); -typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx); -#if !defined _FAR - #define _FAR -#endif - -#if defined _MSC_VER - #pragma warning(disable:4103) /* disable warning message 4103 that complains - * about pragma pack in a header file */ - #pragma warning(disable:4100) /* "'%$S' : unreferenced formal parameter" */ - - #if _MSC_VER >= 1400 - #if !defined NO_MSVC8_AUTO_COMPAT - - /* Disable deprecation warnings concerning unsafe CRT functions */ - #if !defined _CRT_SECURE_NO_DEPRECATE - #define _CRT_SECURE_NO_DEPRECATE - #endif - - /* Replace the POSIX function with ISO C++ conformant ones as they are now deprecated */ - #define access _access - #define cabs _cabs - #define cgets _cgets - #define chdir _chdir - #define chmod _chmod - #define chsize _chsize - #define close _close - #define cprintf _cprintf - #define cputs _cputts - #define creat _creat - #define cscanf _cscanf - #define cwait _cwait - #define dup _dup - #define dup2 _dup2 - #define ecvt _ecvt - #define eof _eof - #define execl _execl - #define execle _execle - #define execlp _execlp - #define execlpe _execlpe - #define execv _execv - #define execve _execv - #define execvp _execvp - #define execvpe _execvpe - #define fcloseall _fcloseall - #define fcvt _fcvt - #define fdopen _fdopen - #define fgetchar _fgetchar - #define filelength _filelength - #define fileno _fileno - #define flushall _flushall - #define fputchar _fputchar - #define gcvt _gcvt - #define getch _getch - #define getche _getche - #define getcwd _getcwd - #define getpid _getpid - #define getw _getw - #define hypot _hypot - #define inp _inp - #define inpw _inpw - #define isascii __isascii - #define isatty _isatty - #define iscsym __iscsym - #define iscsymf __iscsymf - #define itoa _itoa - #define j0 _j0 - #define j1 _j1 - #define jn _jn - #define kbhit _kbhit - #define lfind _lfind - #define locking _locking - #define lsearch _lsearch - #define lseek _lseek - #define ltoa _ltoa - #define memccpy _memccpy - #define memicmp _memicmp - #define mkdir _mkdir - #define mktemp _mktemp - #define open _open - #define outp _outp - #define outpw _outpw - #define putch _putch - #define putenv _putenv - #define putw _putw - #define read _read - #define rmdir _rmdir - #define rmtmp _rmtmp - #define setmode _setmode - #define sopen _sopen - #define spawnl _spawnl - #define spawnle _spawnle - #define spawnlp _spawnlp - #define spawnlpe _spawnlpe - #define spawnv _spawnv - #define spawnve _spawnve - #define spawnvp _spawnvp - #define spawnvpe _spawnvpe - #define strcmpi _strcmpi - #define strdup _strdup - #define stricmp _stricmp - #define strlwr _strlwr - #define strnicmp _strnicmp - #define strnset _strnset - #define strrev _strrev - #define strset _strset - #define strupr _strupr - #define swab _swab - #define tell _tell - #define tempnam _tempnam - #define toascii __toascii - #define tzset _tzset - #define ultoa _ultoa - #define umask _umask - #define ungetch _ungetch - #define unlink _unlink - #define wcsdup _wcsdup - #define wcsicmp _wcsicmp - #define wcsicoll _wcsicoll - #define wcslwr _wcslwr - #define wcsnicmp _wcsnicmp - #define wcsnset _wcsnset - #define wcsrev _wcsrev - #define wcsset _wcsset - #define wcsupr _wcsupr - #define write _write - #define y0 _y0 - #define y1 _y1 - #define yn _yn - - /* Disable deprecation warnings because MSVC8 seemingly thinks the ISO C++ conformant - * functions above are deprecated. */ - #pragma warning (disable:4996) - - #endif - #else - #define vsnprintf _vsnprintf - #endif -#endif - - -/* Some compilers do not support the #pragma align, which should be fine. Some - * compilers give a warning on unknown #pragmas, which is not so fine... - */ -#if (defined SN_TARGET_PS2 || defined __GNUC__) && !defined AMX_NO_ALIGN - #define AMX_NO_ALIGN -#endif - -#if defined __GNUC__ - #define PACKED __attribute__((packed)) -#else - #define PACKED -#endif - -#if !defined AMX_NO_ALIGN - #if defined LINUX || defined __FreeBSD__ - #pragma pack(1) /* structures must be packed (byte-aligned) */ - #elif defined MACOS && defined __MWERKS__ - #pragma options align=mac68k - #else - #pragma pack(push) - #pragma pack(1) /* structures must be packed (byte-aligned) */ - #if defined __TURBOC__ - #pragma option -a- /* "pack" pragma for older Borland compilers */ - #endif - #endif -#endif - -typedef struct { - const char _FAR *name PACKED; - AMX_NATIVE func PACKED; -} AMX_NATIVE_INFO; - -#define AMX_USERNUM 4 - -/* The AMX structure is the internal structure for many functions. Not all - * fields are valid at all times; many fields are cached in local variables. - */ -typedef struct tagAMX { - unsigned char _FAR *base PACKED; /* points to the AMX header plus the code, optionally also the data */ - unsigned char _FAR *data PACKED; /* points to separate data+stack+heap, may be NULL */ - AMX_CALLBACK callback PACKED; - AMX_DEBUG debug PACKED; /* debug callback */ - /* for external functions a few registers must be accessible from the outside */ - cell cip PACKED; /* instruction pointer: relative to base + amxhdr->cod */ - cell frm PACKED; /* stack frame base: relative to base + amxhdr->dat */ - cell hea PACKED; /* top of the heap: relative to base + amxhdr->dat */ - cell hlw PACKED; /* bottom of the heap: relative to base + amxhdr->dat */ - cell stk PACKED; /* stack pointer: relative to base + amxhdr->dat */ - cell stp PACKED; /* top of the stack: relative to base + amxhdr->dat */ - int flags PACKED; /* current status, see amx_Flags() */ - /* user data */ - long usertags[AMX_USERNUM] PACKED; - //okay userdata[3] in AMX Mod X is for the CPlugin * pointer - //we're also gonna set userdata[2] to a special debug structure - void _FAR *userdata[AMX_USERNUM] PACKED; - /* native functions can raise an error */ - int error PACKED; - /* passing parameters requires a "count" field */ - int paramcount; - /* the sleep opcode needs to store the full AMX status */ - cell pri PACKED; - cell alt PACKED; - cell reset_stk PACKED; - cell reset_hea PACKED; - cell sysreq_d PACKED; /* relocated address/value for the SYSREQ.D opcode */ - /* support variables for the JIT */ - int reloc_size PACKED; /* required temporary buffer for relocations */ - long code_size PACKED; /* estimated memory footprint of the native code */ -} PACKED AMX; - -enum { - AMX_ERR_NONE, - /* reserve the first 15 error codes for exit codes of the abstract machine */ - AMX_ERR_EXIT, /* forced exit */ - AMX_ERR_ASSERT, /* assertion failed */ - AMX_ERR_STACKERR, /* stack/heap collision */ - AMX_ERR_BOUNDS, /* index out of bounds */ - AMX_ERR_MEMACCESS, /* invalid memory access */ - AMX_ERR_INVINSTR, /* invalid instruction */ - AMX_ERR_STACKLOW, /* stack underflow */ - AMX_ERR_HEAPLOW, /* heap underflow */ - AMX_ERR_CALLBACK, /* no callback, or invalid callback */ - AMX_ERR_NATIVE, /* native function failed */ - AMX_ERR_DIVIDE, /* divide by zero */ - AMX_ERR_SLEEP, /* go into sleepmode - code can be restarted */ - AMX_ERR_INVSTATE, /* invalid state for this access */ - - AMX_ERR_MEMORY = 16, /* out of memory */ - AMX_ERR_FORMAT, /* invalid file format */ - AMX_ERR_VERSION, /* file is for a newer version of the AMX */ - AMX_ERR_NOTFOUND, /* function not found */ - AMX_ERR_INDEX, /* invalid index parameter (bad entry point) */ - AMX_ERR_DEBUG, /* debugger cannot run */ - AMX_ERR_INIT, /* AMX not initialized (or doubly initialized) */ - AMX_ERR_USERDATA, /* unable to set user data field (table full) */ - AMX_ERR_INIT_JIT, /* cannot initialize the JIT */ - AMX_ERR_PARAMS, /* parameter error */ - AMX_ERR_DOMAIN, /* domain error, expression result does not fit in range */ -}; - -#if !defined AMX_NO_ALIGN - #if defined __linux__ - #pragma pack() /* reset default packing */ - #else - #pragma pack(pop) /* reset previous packing */ - #endif -#endif - - -// ***** declare functions ***** - -#ifdef USE_METAMOD -void UTIL_LogPrintf( char *fmt, ... ); -void UTIL_HudMessage(CBaseEntity *pEntity, const hudtextparms_t &textparms, const char *pMessage); -short FixedSigned16( float value, float scale ); -unsigned short FixedUnsigned16( float value, float scale ); - -#ifdef FN_META_QUERY -void FN_META_QUERY(void); -#endif // FN_META_QUERY - -#ifdef FN_META_ATTACH -void FN_META_ATTACH(void); -#endif // FN_META_ATTACH - -#ifdef FN_META_DETACH -void FN_META_DETACH(void); -#endif // FN_META_DETACH - - - - - -#ifdef FN_GameDLLInit -void FN_GameDLLInit(void); -#endif // FN_GameDLLInit - -#ifdef FN_DispatchSpawn -int FN_DispatchSpawn(edict_t *pent); -#endif // FN_DispatchSpawn - -#ifdef FN_DispatchThink -void FN_DispatchThink(edict_t *pent); -#endif // FN_DispatchThink - -#ifdef FN_DispatchUse -void FN_DispatchUse(edict_t *pentUser, edict_t *pentOther); -#endif // FN_DispatchUse - -#ifdef FN_DispatchTouch -void FN_DispatchTouch(edict_t *pentTouched, edict_t *pentOther); -#endif // FN_DispatchTouch - -#ifdef FN_DispatchBlocked -void FN_DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther); -#endif // FN_DispatchBlocked - -#ifdef FN_DispatchKeyValue -void FN_DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd); -#endif // FN_DispatchKeyValue - -#ifdef FN_DispatchSave -void FN_DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData); -#endif // FN_DispatchSave - -#ifdef FN_DispatchRestore -int FN_DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity); -#endif // FN_DispatchRestore - -#ifdef FN_DispatchObjectCollsionBox -void FN_DispatchObjectCollsionBox(edict_t *pent); -#endif // FN_DispatchObjectCollsionBox - -#ifdef FN_SaveWriteFields -void FN_SaveWriteFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount); -#endif // FN_SaveWriteFields - -#ifdef FN_SaveReadFields -void FN_SaveReadFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount); -#endif // FN_SaveReadFields - -#ifdef FN_SaveGlobalState -void FN_SaveGlobalState(SAVERESTOREDATA *pSaveData); -#endif // FN_SaveGlobalState - -#ifdef FN_RestoreGlobalState -void FN_RestoreGlobalState(SAVERESTOREDATA *pSaveData); -#endif // FN_RestoreGlobalState - -#ifdef FN_ResetGlobalState -void FN_ResetGlobalState(void); -#endif // FN_ResetGlobalState - -#ifdef FN_ClientConnect -BOOL FN_ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ]); -#endif // FN_ClientConnect - -#ifdef FN_ClientDisconnect -void FN_ClientDisconnect(edict_t *pEntity); -#endif // FN_ClientDisconnect - -#ifdef FN_ClientKill -void FN_ClientKill(edict_t *pEntity); -#endif // FN_ClientKill - -#ifdef FN_ClientPutInServer -void FN_ClientPutInServer(edict_t *pEntity); -#endif // FN_ClientPutInServer - -#ifdef FN_ClientCommand -void FN_ClientCommand(edict_t *pEntity); -#endif // FN_ClientCommand - -#ifdef FN_ClientUserInfoChanged -void FN_ClientUserInfoChanged(edict_t *pEntity, char *infobuffer); -#endif // FN_ClientUserInfoChanged - -#ifdef FN_ServerActivate -void FN_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax); -#endif // FN_ServerActivate - -#ifdef FN_ServerDeactivate -void FN_ServerDeactivate(void); -#endif // FN_ServerDeactivate - -#ifdef FN_PlayerPreThink -void FN_PlayerPreThink(edict_t *pEntity); -#endif // FN_PlayerPreThink - -#ifdef FN_PlayerPostThink -void FN_PlayerPostThink(edict_t *pEntity); -#endif // FN_PlayerPostThink - -#ifdef FN_StartFrame -void FN_StartFrame(void); -#endif // FN_StartFrame - -#ifdef FN_ParmsNewLevel -void FN_ParmsNewLevel(void); -#endif // FN_ParmsNewLevel - -#ifdef FN_ParmsChangeLevel -void FN_ParmsChangeLevel(void); -#endif // FN_ParmsChangeLevel - -#ifdef FN_GetGameDescription -const char *FN_GetGameDescription(void); -#endif // FN_GetGameDescription - -#ifdef FN_PlayerCustomization -void FN_PlayerCustomization(edict_t *pEntity, customization_t *pCust); -#endif // FN_PlayerCustomization - -#ifdef FN_SpectatorConnect -void FN_SpectatorConnect(edict_t *pEntity); -#endif // FN_SpectatorConnect - -#ifdef FN_SpectatorDisconnect -void FN_SpectatorDisconnect(edict_t *pEntity); -#endif // FN_SpectatorDisconnect - -#ifdef FN_SpectatorThink -void FN_SpectatorThink(edict_t *pEntity); -#endif // FN_SpectatorThink - -#ifdef FN_Sys_Error -void FN_Sys_Error(const char *error_string); -#endif // FN_Sys_Error - -#ifdef FN_PM_Move -void FN_PM_Move(struct playermove_s *ppmove, int server); -#endif // FN_PM_Move - -#ifdef FN_PM_Init -void FN_PM_Init(struct playermove_s *ppmove); -#endif // FN_PM_Init - -#ifdef FN_PM_FindTextureType -char FN_PM_FindTextureType(char *name); -#endif // FN_PM_FindTextureType - -#ifdef FN_SetupVisibility -void FN_SetupVisibility(edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas); -#endif // FN_SetupVisibility - -#ifdef FN_UpdateClientData -void FN_UpdateClientData(const struct edict_s *ent, int sendweapons, struct clientdata_s *cd); -#endif // FN_UpdateClientData - -#ifdef FN_AddToFullPack -int FN_AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet); -#endif // FN_AddToFullPack - -#ifdef FN_CreateBaseline -void FN_CreateBaseline(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs); -#endif // FN_CreateBaseline - -#ifdef FN_RegisterEncoders -void FN_RegisterEncoders(void); -#endif // FN_RegisterEncoders - -#ifdef FN_GetWeaponData -int FN_GetWeaponData(struct edict_s *player, struct weapon_data_s *info); -#endif // FN_GetWeaponData - -#ifdef FN_CmdStart -void FN_CmdStart(const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed); -#endif // FN_CmdStart - -#ifdef FN_CmdEnd -void FN_CmdEnd(const edict_t *player); -#endif // FN_CmdEnd - -#ifdef FN_ConnectionlessPacket -int FN_ConnectionlessPacket(const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size); -#endif // FN_ConnectionlessPacket - -#ifdef FN_GetHullBounds -int FN_GetHullBounds(int hullnumber, float *mins, float *maxs); -#endif // FN_GetHullBounds - -#ifdef FN_CreateInstancedBaselines -void FN_CreateInstancedBaselines(void); -#endif // FN_CreateInstancedBaselines - -#ifdef FN_InconsistentFile -int FN_InconsistentFile(const edict_t *player, const char *filename, char *disconnect_message); -#endif // FN_InconsistentFile - -#ifdef FN_AllowLagCompensation -int FN_AllowLagCompensation(void); -#endif // FN_AllowLagCompensation - - - - -#ifdef FN_GameDLLInit_Post -void FN_GameDLLInit_Post(void); -#endif // FN_GameDLLInit_Post - -#ifdef FN_DispatchSpawn_Post -int FN_DispatchSpawn_Post(edict_t *pent); -#endif // FN_DispatchSpawn_Post - -#ifdef FN_DispatchThink_Post -void FN_DispatchThink_Post(edict_t *pent); -#endif // FN_DispatchThink_Post - -#ifdef FN_DispatchUse_Post -void FN_DispatchUse_Post(edict_t *pentUser, edict_t *pentOther); -#endif // FN_DispatchUse_Post - -#ifdef FN_DispatchTouch_Post -void FN_DispatchTouch_Post(edict_t *pentTouched, edict_t *pentOther); -#endif // FN_DispatchTouch_Post - -#ifdef FN_DispatchBlocked_Post -void FN_DispatchBlocked_Post(edict_t *pentBlocked, edict_t *pentOther); -#endif // FN_DispatchBlocked_Post - -#ifdef FN_DispatchKeyValue_Post -void FN_DispatchKeyValue_Post(edict_t *pentKeyvalue, KeyValueData *pkvd); -#endif // FN_DispatchKeyValue_Post - -#ifdef FN_DispatchSave_Post -void FN_DispatchSave_Post(edict_t *pent, SAVERESTOREDATA *pSaveData); -#endif // FN_DispatchSave_Post - -#ifdef FN_DispatchRestore_Post -int FN_DispatchRestore_Post(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity); -#endif // FN_DispatchRestore_Post - -#ifdef FN_DispatchObjectCollsionBox_Post -void FN_DispatchObjectCollsionBox_Post(edict_t *pent); -#endif // FN_DispatchObjectCollsionBox_Post - -#ifdef FN_SaveWriteFields_Post -void FN_SaveWriteFields_Post(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount); -#endif // FN_SaveWriteFields_Post - -#ifdef FN_SaveReadFields_Post -void FN_SaveReadFields_Post(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount); -#endif // FN_SaveReadFields_Post - -#ifdef FN_SaveGlobalState_Post -void FN_SaveGlobalState_Post(SAVERESTOREDATA *pSaveData); -#endif // FN_SaveGlobalState_Post - -#ifdef FN_RestoreGlobalState_Post -void FN_RestoreGlobalState_Post(SAVERESTOREDATA *pSaveData); -#endif // FN_RestoreGlobalState_Post - -#ifdef FN_ResetGlobalState_Post -void FN_ResetGlobalState_Post(void); -#endif // FN_ResetGlobalState_Post - -#ifdef FN_ClientConnect_Post -BOOL FN_ClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ]); -#endif // FN_ClientConnect_Post - -#ifdef FN_ClientDisconnect_Post -void FN_ClientDisconnect_Post(edict_t *pEntity); -#endif // FN_ClientDisconnect_Post - -#ifdef FN_ClientKill_Post -void FN_ClientKill_Post(edict_t *pEntity); -#endif // FN_ClientKill_Post - -#ifdef FN_ClientPutInServer_Post -void FN_ClientPutInServer_Post(edict_t *pEntity); -#endif // FN_ClientPutInServer_Post - -#ifdef FN_ClientCommand_Post -void FN_ClientCommand_Post(edict_t *pEntity); -#endif // FN_ClientCommand_Post - -#ifdef FN_ClientUserInfoChanged_Post -void FN_ClientUserInfoChanged_Post(edict_t *pEntity, char *infobuffer); -#endif // FN_ClientUserInfoChanged_Post - -#ifdef FN_ServerActivate_Post -void FN_ServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax); -#endif // FN_ServerActivate_Post - -#ifdef FN_ServerDeactivate_Post -void FN_ServerDeactivate_Post(void); -#endif // FN_ServerDeactivate_Post - -#ifdef FN_PlayerPreThink_Post -void FN_PlayerPreThink_Post(edict_t *pEntity); -#endif // FN_PlayerPreThink_Post - -#ifdef FN_PlayerPostThink_Post -void FN_PlayerPostThink_Post(edict_t *pEntity); -#endif // FN_PlayerPostThink_Post - -#ifdef FN_StartFrame_Post -void FN_StartFrame_Post(void); -#endif // FN_StartFrame_Post - -#ifdef FN_ParmsNewLevel_Post -void FN_ParmsNewLevel_Post(void); -#endif // FN_ParmsNewLevel_Post - -#ifdef FN_ParmsChangeLevel_Post -void FN_ParmsChangeLevel_Post(void); -#endif // FN_ParmsChangeLevel_Post - -#ifdef FN_GetGameDescription_Post -const char *FN_GetGameDescription_Post(void); -#endif // FN_GetGameDescription_Post - -#ifdef FN_PlayerCustomization_Post -void FN_PlayerCustomization_Post(edict_t *pEntity, customization_t *pCust); -#endif // FN_PlayerCustomization_Post - -#ifdef FN_SpectatorConnect_Post -void FN_SpectatorConnect_Post(edict_t *pEntity); -#endif // FN_SpectatorConnect_Post - -#ifdef FN_SpectatorDisconnect_Post -void FN_SpectatorDisconnect_Post(edict_t *pEntity); -#endif // FN_SpectatorDisconnect_Post - -#ifdef FN_SpectatorThink_Post -void FN_SpectatorThink_Post(edict_t *pEntity); -#endif // FN_SpectatorThink_Post - -#ifdef FN_Sys_Error_Post -void FN_Sys_Error_Post(const char *error_string); -#endif // FN_Sys_Error_Post - -#ifdef FN_PM_Move_Post -void FN_PM_Move_Post(struct playermove_s *ppmove, int server); -#endif // FN_PM_Move_Post - -#ifdef FN_PM_Init_Post -void FN_PM_Init_Post(struct playermove_s *ppmove); -#endif // FN_PM_Init_Post - -#ifdef FN_PM_FindTextureType_Post -char FN_PM_FindTextureType_Post(char *name); -#endif // FN_PM_FindTextureType_Post - -#ifdef FN_SetupVisibility_Post -void FN_SetupVisibility_Post(edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas); -#endif // FN_SetupVisibility_Post - -#ifdef FN_UpdateClientData_Post -void FN_UpdateClientData_Post(const struct edict_s *ent, int sendweapons, struct clientdata_s *cd); -#endif // FN_UpdateClientData_Post - -#ifdef FN_AddToFullPack_Post -int FN_AddToFullPack_Post(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet); -#endif // FN_AddToFullPack_Post - -#ifdef FN_CreateBaseline_Post -void FN_CreateBaseline_Post(int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs); -#endif // FN_CreateBaseline_Post - -#ifdef FN_RegisterEncoders_Post -void FN_RegisterEncoders_Post(void); -#endif // FN_RegisterEncoders_Post - -#ifdef FN_GetWeaponData_Post -int FN_GetWeaponData_Post(struct edict_s *player, struct weapon_data_s *info); -#endif // FN_GetWeaponData_Post - -#ifdef FN_CmdStart_Post -void FN_CmdStart_Post(const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed); -#endif // FN_CmdStart_Post - -#ifdef FN_CmdEnd_Post -void FN_CmdEnd_Post(const edict_t *player); -#endif // FN_CmdEnd_Post - -#ifdef FN_ConnectionlessPacket_Post -int FN_ConnectionlessPacket_Post(const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size); -#endif // FN_ConnectionlessPacket_Post - -#ifdef FN_GetHullBounds_Post -int FN_GetHullBounds_Post(int hullnumber, float *mins, float *maxs); -#endif // FN_GetHullBounds_Post - -#ifdef FN_CreateInstancedBaselines_Post -void FN_CreateInstancedBaselines_Post(void); -#endif // FN_CreateInstancedBaselines_Post - -#ifdef FN_InconsistentFile_Post -int FN_InconsistentFile_Post(const edict_t *player, const char *filename, char *disconnect_message); -#endif // FN_InconsistentFile_Post - -#ifdef FN_AllowLagCompensation_Post -int FN_AllowLagCompensation_Post(void); -#endif // FN_AllowLagCompensation_Post - - - -#ifdef FN_PrecacheModel -int FN_PrecacheModel(char *s); -#endif // FN_PrecacheModel - -#ifdef FN_PrecacheSound -int FN_PrecacheSound(char *s); -#endif // FN_PrecacheSound - -#ifdef FN_SetModel -void FN_SetModel(edict_t *e, const char *m); -#endif // FN_SetModel - -#ifdef FN_ModelIndex -int FN_ModelIndex(const char *m); -#endif // FN_ModelIndex - -#ifdef FN_ModelFrames -int FN_ModelFrames(int modelIndex); -#endif // FN_ModelFrames - -#ifdef FN_SetSize -void FN_SetSize(edict_t *e, const float *rgflMin, const float *rgflMax); -#endif // FN_SetSize - -#ifdef FN_ChangeLevel -void FN_ChangeLevel(char *s1, char *s2); -#endif // FN_ChangeLevel - -#ifdef FN_GetSpawnParms -void FN_GetSpawnParms(edict_t *ent); -#endif // FN_GetSpawnParms - -#ifdef FN_SaveSpawnParms -void FN_SaveSpawnParms(edict_t *ent); -#endif // FN_SaveSpawnParms - -#ifdef FN_VecToYaw -float FN_VecToYaw(const float *rgflVector); -#endif // FN_VecToYaw - -#ifdef FN_VecToAngles -void FN_VecToAngles(const float *rgflVectorIn, float *rgflVectorOut); -#endif // FN_VecToAngles - -#ifdef FN_MoveToOrigin -void FN_MoveToOrigin(edict_t *ent, const float *pflGoal, float dist, int iMoveType); -#endif // FN_MoveToOrigin - -#ifdef FN_ChangeYaw -void FN_ChangeYaw(edict_t *ent); -#endif // FN_ChangeYaw - -#ifdef FN_ChangePitch -void FN_ChangePitch(edict_t *ent); -#endif // FN_ChangePitch - -#ifdef FN_FindEntityByString -edict_t *FN_FindEntityByString(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); -#endif // FN_FindEntityByString - -#ifdef FN_GetEntityIllum -int FN_GetEntityIllum(edict_t *pEnt); -#endif // FN_GetEntityIllum - -#ifdef FN_FindEntityInSphere -edict_t *FN_FindEntityInSphere(edict_t *pEdictStartSearchAfter, const float *org, float rad); -#endif // FN_FindEntityInSphere - -#ifdef FN_FindClientInPVS -edict_t *FN_FindClientInPVS(edict_t *pEdict); -#endif // FN_FindClientInPVS - -#ifdef FN_EntitiesInPVS -edict_t *FN_EntitiesInPVS(edict_t *pplayer); -#endif // FN_EntitiesInPVS - -#ifdef FN_MakeVectors -void FN_MakeVectors(const float *rgflVector); -#endif // FN_MakeVectors - -#ifdef FN_AngleVectors -void FN_AngleVectors(const float *rgflVector, float *forward, float *right, float *up); -#endif // FN_AngleVectors - -#ifdef FN_CreateEntity -edict_t *FN_CreateEntity(void); -#endif // FN_CreateEntity - -#ifdef FN_RemoveEntity -void FN_RemoveEntity(edict_t *e); -#endif // FN_RemoveEntity - -#ifdef FN_CreateNamedEntity -edict_t *FN_CreateNamedEntity(int className); -#endif // FN_CreateNamedEntity - -#ifdef FN_MakeStatic -void FN_MakeStatic(edict_t *ent); -#endif // FN_MakeStatic - -#ifdef FN_EntIsOnFloor -int FN_EntIsOnFloor(edict_t *ent); -#endif // FN_EntIsOnFloor - -#ifdef FN_DropToFloor -int FN_DropToFloor(edict_t *ent); -#endif // FN_DropToFloor - -#ifdef FN_WalkMove -int FN_WalkMove(edict_t *ent, float yaw, float dist, int iMode); -#endif // FN_WalkMove - -#ifdef FN_SetOrigin -void FN_SetOrigin(edict_t *e, const float *rgflOrigin); -#endif // FN_SetOrigin - -#ifdef FN_EmitSound -void FN_EmitSound(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); -#endif // FN_EmitSound - -#ifdef FN_EmitAmbientSound -void FN_EmitAmbientSound(edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); -#endif // FN_EmitAmbientSound - -#ifdef FN_TraceLine -void FN_TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); -#endif // FN_TraceLine - -#ifdef FN_TraceToss -void FN_TraceToss(edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr); -#endif // FN_TraceToss - -#ifdef FN_TraceMonsterHull -int FN_TraceMonsterHull(edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); -#endif // FN_TraceMonsterHull - -#ifdef FN_TraceHull -void FN_TraceHull(const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); -#endif // FN_TraceHull - -#ifdef FN_TraceModel -void FN_TraceModel(const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); -#endif // FN_TraceModel - -#ifdef FN_TraceTexture -const char *FN_TraceTexture(edict_t *pTextureEntity, const float *v1, const float *v2 ); -#endif // FN_TraceTexture - -#ifdef FN_TraceSphere -void FN_TraceSphere(const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); -#endif // FN_TraceSphere - -#ifdef FN_GetAimVector -void FN_GetAimVector(edict_t *ent, float speed, float *rgflReturn); -#endif // FN_GetAimVector - -#ifdef FN_ServerCommand -void FN_ServerCommand(char *str); -#endif // FN_ServerCommand - -#ifdef FN_ServerExecute -void FN_ServerExecute(void); -#endif // FN_ServerExecute - -#ifdef FN_engClientCommand -void FN_engClientCommand(edict_t *pEdict, char *szFmt, ...); -#endif // FN_engClientCommand - -#ifdef FN_ParticleEffect -void FN_ParticleEffect(const float *org, const float *dir, float color, float count); -#endif // FN_ParticleEffect - -#ifdef FN_LightStyle -void FN_LightStyle(int style, char *val); -#endif // FN_LightStyle - -#ifdef FN_DecalIndex -int FN_DecalIndex(const char *name); -#endif // FN_DecalIndex - -#ifdef FN_PointContents -int FN_PointContents(const float *rgflVector); -#endif // FN_PointContents - -#ifdef FN_MessageBegin -void FN_MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); -#endif // FN_MessageBegin - -#ifdef FN_MessageEnd -void FN_MessageEnd(void); -#endif // FN_MessageEnd - -#ifdef FN_WriteByte -void FN_WriteByte(int iValue); -#endif // FN_WriteByte - -#ifdef FN_WriteChar -void FN_WriteChar(int iValue); -#endif // FN_WriteChar - -#ifdef FN_WriteShort -void FN_WriteShort(int iValue); -#endif // FN_WriteShort - -#ifdef FN_WriteLong -void FN_WriteLong(int iValue); -#endif // FN_WriteLong - -#ifdef FN_WriteAngle -void FN_WriteAngle(float flValue); -#endif // FN_WriteAngle - -#ifdef FN_WriteCoord -void FN_WriteCoord(float flValue); -#endif // FN_WriteCoord - -#ifdef FN_WriteString -void FN_WriteString(const char *sz); -#endif // FN_WriteString - -#ifdef FN_WriteEntity -void FN_WriteEntity(int iValue); -#endif // FN_WriteEntity - -#ifdef FN_CVarRegister -void FN_CVarRegister(cvar_t *pCvar); -#endif // FN_CVarRegister - -#ifdef FN_CVarGetFloat -float FN_CVarGetFloat(const char *szVarName); -#endif // FN_CVarGetFloat - -#ifdef FN_CVarGetString -const char *FN_CVarGetString(const char *szVarName); -#endif // FN_CVarGetString - -#ifdef FN_CVarSetFloat -void FN_CVarSetFloat(const char *szVarName, float flValue); -#endif // FN_CVarSetFloat - -#ifdef FN_CVarSetString -void FN_CVarSetString(const char *szVarName, const char *szValue); -#endif // FN_CVarSetString - -#ifdef FN_AlertMessage -void FN_AlertMessage(ALERT_TYPE atype, char *szFmt, ...); -#endif // FN_AlertMessage - -#ifdef FN_EngineFprintf -void FN_EngineFprintf(void *pfile, char *szFmt, ...); -#endif // FN_EngineFprintf - -#ifdef FN_PvAllocEntPrivateData -void *FN_PvAllocEntPrivateData(edict_t *pEdict, int32 cb); -#endif // FN_PvAllocEntPrivateData - -#ifdef FN_PvEntPrivateData -void *FN_PvEntPrivateData(edict_t *pEdict); -#endif // FN_PvEntPrivateData - -#ifdef FN_FreeEntPrivateData -void FN_FreeEntPrivateData(edict_t *pEdict); -#endif // FN_FreeEntPrivateData - -#ifdef FN_SzFromIndex -const char *FN_SzFromIndex(int iString); -#endif // FN_SzFromIndex - -#ifdef FN_AllocString -int FN_AllocString(const char *szValue); -#endif // FN_AllocString - -#ifdef FN_GetVarsOfEnt -struct entvars_s *FN_GetVarsOfEnt(edict_t *pEdict); -#endif // FN_GetVarsOfEnt - -#ifdef FN_PEntityOfEntOffset -edict_t *FN_PEntityOfEntOffset(int iEntOffset); -#endif // FN_PEntityOfEntOffset - -#ifdef FN_EntOffsetOfPEntity -int FN_EntOffsetOfPEntity(const edict_t *pEdict); -#endif // FN_EntOffsetOfPEntity - -#ifdef FN_IndexOfEdict -int FN_IndexOfEdict(const edict_t *pEdict); -#endif // FN_IndexOfEdict - -#ifdef FN_PEntityOfEntIndex -edict_t *FN_PEntityOfEntIndex(int iEntIndex); -#endif // FN_PEntityOfEntIndex - -#ifdef FN_FindEntityByVars -edict_t *FN_FindEntityByVars(struct entvars_s *pvars); -#endif // FN_FindEntityByVars - -#ifdef FN_GetModelPtr -void *FN_GetModelPtr(edict_t *pEdict); -#endif // FN_GetModelPtr - -#ifdef FN_RegUserMsg -int FN_RegUserMsg(const char *pszName, int iSize); -#endif // FN_RegUserMsg - -#ifdef FN_AnimationAutomove -void FN_AnimationAutomove(const edict_t *pEdict, float flTime); -#endif // FN_AnimationAutomove - -#ifdef FN_GetBonePosition -void FN_GetBonePosition(const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles); -#endif // FN_GetBonePosition - -#ifdef FN_FunctionFromName -uint32 FN_FunctionFromName(const char *pName); -#endif // FN_FunctionFromName - -#ifdef FN_NameForFunction -const char *FN_NameForFunction(uint32); -#endif // FN_NameForFunction - -#ifdef FN_ClientPrintf -void FN_ClientPrintf(edict_t *pEdict, PRINT_TYPE ptype, const char *szMsg); -#endif // FN_ClientPrintf - -#ifdef FN_ServerPrint -void FN_ServerPrint(const char *szMsg); -#endif // FN_ServerPrint - -#ifdef FN_Cmd_Args -const char *FN_Cmd_Args(void); -#endif // FN_Cmd_Args - -#ifdef FN_Cmd_Argv -const char *FN_Cmd_Argv(int argc); -#endif // FN_Cmd_Argv - -#ifdef FN_Cmd_Argc -int FN_Cmd_Argc(void); -#endif // FN_Cmd_Argc - -#ifdef FN_GetAttachment -void FN_GetAttachment(const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); -#endif // FN_GetAttachment - -#ifdef FN_CRC32_Init -void FN_CRC32_Init(CRC32_t *pulCRC); -#endif // FN_CRC32_Init - -#ifdef FN_CRC32_ProcessBuffer -void FN_CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len); -#endif // FN_CRC32_ProcessBuffer - -#ifdef FN_CRC32_ProcessByte -void FN_CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch); -#endif // FN_CRC32_ProcessByte - -#ifdef FN_CRC32_Final -CRC32_t FN_CRC32_Final(CRC32_t pulCRC); -#endif // FN_CRC32_Final - -#ifdef FN_RandomLong -int32 FN_RandomLong(int32 lLow, int32 lHigh); -#endif // FN_RandomLong - -#ifdef FN_RandomFloat -float FN_RandomFloat(float flLow, float flHigh); -#endif // FN_RandomFloat - -#ifdef FN_SetView -void FN_SetView(const edict_t *pClient, const edict_t *pViewent); -#endif // FN_SetView - -#ifdef FN_Time -float FN_Time(void); -#endif // FN_Time - -#ifdef FN_CrosshairAngle -void FN_CrosshairAngle(const edict_t *pClient, float pitch, float yaw); -#endif // FN_CrosshairAngle - -#ifdef FN_LoadFileForMe -byte *FN_LoadFileForMe(char *filename, int *pLength); -#endif // FN_LoadFileForMe - -#ifdef FN_FreeFile -void FN_FreeFile(void *buffer); -#endif // FN_FreeFile - -#ifdef FN_EndSection -void FN_EndSection(const char *pszSectionName); -#endif // FN_EndSection - -#ifdef FN_CompareFileTime -int FN_CompareFileTime(char *filename1, char *filename2, int *iCompare); -#endif // FN_CompareFileTime - -#ifdef FN_GetGameDir -void FN_GetGameDir(char *szGetGameDir); -#endif // FN_GetGameDir - -#ifdef FN_Cvar_RegisterVariable -void FN_Cvar_RegisterVariable(cvar_t *variable); -#endif // FN_Cvar_RegisterVariable - -#ifdef FN_FadeClientVolume -void FN_FadeClientVolume(const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); -#endif // FN_FadeClientVolume - -#ifdef FN_SetClientMaxspeed -void FN_SetClientMaxspeed(const edict_t *pEdict, float fNewMaxspeed); -#endif // FN_SetClientMaxspeed - -#ifdef FN_CreateFakeClient -edict_t *FN_CreateFakeClient(const char *netname); -#endif // FN_CreateFakeClient - -#ifdef FN_RunPlayerMove -void FN_RunPlayerMove(edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec); -#endif // FN_RunPlayerMove - -#ifdef FN_NumberOfEntities -int FN_NumberOfEntities(void); -#endif // FN_NumberOfEntities - -#ifdef FN_GetInfoKeyBuffer -char *FN_GetInfoKeyBuffer(edict_t *e); -#endif // FN_GetInfoKeyBuffer - -#ifdef FN_InfoKeyValue -char *FN_InfoKeyValue(char *infobuffer, char *key); -#endif // FN_InfoKeyValue - -#ifdef FN_SetKeyValue -void FN_SetKeyValue(char *infobuffer, char *key, char *value); -#endif // FN_SetKeyValue - -#ifdef FN_SetClientKeyValue -void FN_SetClientKeyValue(int clientIndex, char *infobuffer, char *key, char *value); -#endif // FN_SetClientKeyValue - -#ifdef FN_IsMapValid -int FN_IsMapValid(char *filename); -#endif // FN_IsMapValid - -#ifdef FN_StaticDecal -void FN_StaticDecal(const float *origin, int decalIndex, int entityIndex, int modelIndex); -#endif // FN_StaticDecal - -#ifdef FN_PrecacheGeneric -int FN_PrecacheGeneric(char *s); -#endif // FN_PrecacheGeneric - -#ifdef FN_GetPlayerUserId -int FN_GetPlayerUserId(edict_t *e ); -#endif // FN_GetPlayerUserId - -#ifdef FN_BuildSoundMsg -void FN_BuildSoundMsg(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); -#endif // FN_BuildSoundMsg - -#ifdef FN_IsDedicatedServer -int FN_IsDedicatedServer(void); -#endif // FN_IsDedicatedServer - -#ifdef FN_CVarGetPointer -cvar_t *FN_CVarGetPointer(const char *szVarName); -#endif // FN_CVarGetPointer - -#ifdef FN_GetPlayerWONId -unsigned int FN_GetPlayerWONId(edict_t *e); -#endif // FN_GetPlayerWONId - -#ifdef FN_Info_RemoveKey -void FN_Info_RemoveKey( char *s, const char *key); -#endif // FN_Info_RemoveKey - -#ifdef FN_GetPhysicsKeyValue -const char *FN_GetPhysicsKeyValue(const edict_t *pClient, const char *key); -#endif // FN_GetPhysicsKeyValue - -#ifdef FN_SetPhysicsKeyValue -void FN_SetPhysicsKeyValue(const edict_t *pClient, const char *key, const char *value); -#endif // FN_SetPhysicsKeyValue - -#ifdef FN_GetPhysicsInfoString -const char *FN_GetPhysicsInfoString( const edict_t *pClient); -#endif // FN_GetPhysicsInfoString - -#ifdef FN_PrecacheEvent -unsigned short FN_PrecacheEvent(int type, const char *psz); -#endif // FN_PrecacheEvent - -#ifdef FN_PlaybackEvent -void FN_PlaybackEvent(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); -#endif // FN_PlaybackEvent - -#ifdef FN_SetFatPVS -unsigned char *FN_SetFatPVS(float *org); -#endif // FN_SetFatPVS - -#ifdef FN_SetFatPAS -unsigned char *FN_SetFatPAS(float *org); -#endif // FN_SetFatPAS - -#ifdef FN_CheckVisibility -int FN_CheckVisibility(const edict_t *entity, unsigned char *pset); -#endif // FN_CheckVisibility - -#ifdef FN_DeltaSetField -void FN_DeltaSetField(struct delta_s *pFields, const char *fieldname); -#endif // FN_DeltaSetField - -#ifdef FN_DeltaUnsetField -void FN_DeltaUnsetField(struct delta_s *pFields, const char *fieldname); -#endif // FN_DeltaUnsetField - -#ifdef FN_DeltaAddEncoder -void FN_DeltaAddEncoder(char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); -#endif // FN_DeltaAddEncoder - -#ifdef FN_GetCurrentPlayer -int FN_GetCurrentPlayer(void); -#endif // FN_GetCurrentPlayer - -#ifdef FN_CanSkipPlayer -int FN_CanSkipPlayer(const edict_t *player); -#endif // FN_CanSkipPlayer - -#ifdef FN_DeltaFindField -int FN_DeltaFindField(struct delta_s *pFields, const char *fieldname); -#endif // FN_DeltaFindField - -#ifdef FN_DeltaSetFieldByIndex -void FN_DeltaSetFieldByIndex(struct delta_s *pFields, int fieldNumber); -#endif // FN_DeltaSetFieldByIndex - -#ifdef FN_DeltaUnsetFieldByIndex -void FN_DeltaUnsetFieldByIndex(struct delta_s *pFields, int fieldNumber); -#endif // FN_DeltaUnsetFieldByIndex - -#ifdef FN_SetGroupMask -void FN_SetGroupMask(int mask, int op); -#endif // FN_SetGroupMask - -#ifdef FN_engCreateInstancedBaseline -int FN_engCreateInstancedBaseline(int classname, struct entity_state_s *baseline); -#endif // FN_engCreateInstancedBaseline - -#ifdef FN_Cvar_DirectSet -void FN_Cvar_DirectSet(struct cvar_s *var, char *value); -#endif // FN_Cvar_DirectSet - -#ifdef FN_ForceUnmodified -void FN_ForceUnmodified(FORCE_TYPE type, float *mins, float *maxs, const char *filename); -#endif // FN_ForceUnmodified - -#ifdef FN_GetPlayerStats -void FN_GetPlayerStats(const edict_t *pClient, int *ping, int *packet_loss); -#endif // FN_GetPlayerStats - -#ifdef FN_AddServerCommand -void FN_AddServerCommand(char *cmd_name, void (*function) (void)); -#endif // FN_AddServerCommand - -#ifdef FN_Voice_GetClientListening -qboolean FN_Voice_GetClientListening(int iReceiver, int iSender); -#endif // FN_Voice_GetClientListening - -#ifdef FN_Voice_SetClientListening -qboolean FN_Voice_SetClientListening(int iReceiver, int iSender, qboolean bListen); -#endif // FN_Voice_SetClientListening - -#ifdef FN_GetPlayerAuthId -const char *FN_GetPlayerAuthId(edict_t *e); -#endif // FN_GetPlayerAuthId - - - - - - -#ifdef FN_PrecacheModel_Post -int FN_PrecacheModel_Post(char *s); -#endif // FN_PrecacheModel_Post - -#ifdef FN_PrecacheSound_Post -int FN_PrecacheSound_Post(char *s); -#endif // FN_PrecacheSound_Post - -#ifdef FN_SetModel_Post -void FN_SetModel_Post(edict_t *e, const char *m); -#endif // FN_SetModel_Post - -#ifdef FN_ModelIndex_Post -int FN_ModelIndex_Post(const char *m); -#endif // FN_ModelIndex_Post - -#ifdef FN_ModelFrames_Post -int FN_ModelFrames_Post(int modelIndex); -#endif // FN_ModelFrames_Post - -#ifdef FN_SetSize_Post -void FN_SetSize_Post(edict_t *e, const float *rgflMin, const float *rgflMax); -#endif // FN_SetSize_Post - -#ifdef FN_ChangeLevel_Post -void FN_ChangeLevel_Post(char *s1, char *s2); -#endif // FN_ChangeLevel_Post - -#ifdef FN_GetSpawnParms_Post -void FN_GetSpawnParms_Post(edict_t *ent); -#endif // FN_GetSpawnParms_Post - -#ifdef FN_SaveSpawnParms_Post -void FN_SaveSpawnParms_Post(edict_t *ent); -#endif // FN_SaveSpawnParms_Post - -#ifdef FN_VecToYaw_Post -float FN_VecToYaw_Post(const float *rgflVector); -#endif // FN_VecToYaw_Post - -#ifdef FN_VecToAngles_Post -void FN_VecToAngles_Post(const float *rgflVectorIn, float *rgflVectorOut); -#endif // FN_VecToAngles_Post - -#ifdef FN_MoveToOrigin_Post -void FN_MoveToOrigin_Post(edict_t *ent, const float *pflGoal, float dist, int iMoveType); -#endif // FN_MoveToOrigin_Post - -#ifdef FN_ChangeYaw_Post -void FN_ChangeYaw_Post(edict_t *ent); -#endif // FN_ChangeYaw_Post - -#ifdef FN_ChangePitch_Post -void FN_ChangePitch_Post(edict_t *ent); -#endif // FN_ChangePitch_Post - -#ifdef FN_FindEntityByString_Post -edict_t *FN_FindEntityByString_Post(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); -#endif // FN_FindEntityByString_Post - -#ifdef FN_GetEntityIllum_Post -int FN_GetEntityIllum_Post(edict_t *pEnt); -#endif // FN_GetEntityIllum_Post - -#ifdef FN_FindEntityInSphere_Post -edict_t *FN_FindEntityInSphere_Post(edict_t *pEdictStartSearchAfter, const float *org, float rad); -#endif // FN_FindEntityInSphere_Post - -#ifdef FN_FindClientInPVS_Post -edict_t *FN_FindClientInPVS_Post(edict_t *pEdict); -#endif // FN_FindClientInPVS_Post - -#ifdef FN_EntitiesInPVS_Post -edict_t *FN_EntitiesInPVS_Post(edict_t *pplayer); -#endif // FN_EntitiesInPVS_Post - -#ifdef FN_MakeVectors_Post -void FN_MakeVectors_Post(const float *rgflVector); -#endif // FN_MakeVectors_Post - -#ifdef FN_AngleVectors_Post -void FN_AngleVectors_Post(const float *rgflVector, float *forward, float *right, float *up); -#endif // FN_AngleVectors_Post - -#ifdef FN_CreateEntity_Post -edict_t *FN_CreateEntity_Post(void); -#endif // FN_CreateEntity_Post - -#ifdef FN_RemoveEntity_Post -void FN_RemoveEntity_Post(edict_t *e); -#endif // FN_RemoveEntity_Post - -#ifdef FN_CreateNamedEntity_Post -edict_t *FN_CreateNamedEntity_Post(int className); -#endif // FN_CreateNamedEntity_Post - -#ifdef FN_MakeStatic_Post -void FN_MakeStatic_Post(edict_t *ent); -#endif // FN_MakeStatic_Post - -#ifdef FN_EntIsOnFloor_Post -int FN_EntIsOnFloor_Post(edict_t *ent); -#endif // FN_EntIsOnFloor_Post - -#ifdef FN_DropToFloor_Post -int FN_DropToFloor_Post(edict_t *ent); -#endif // FN_DropToFloor_Post - -#ifdef FN_WalkMove_Post -int FN_WalkMove_Post(edict_t *ent, float yaw, float dist, int iMode); -#endif // FN_WalkMove_Post - -#ifdef FN_SetOrigin_Post -void FN_SetOrigin_Post(edict_t *e, const float *rgflOrigin); -#endif // FN_SetOrigin_Post - -#ifdef FN_EmitSound_Post -void FN_EmitSound_Post(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); -#endif // FN_EmitSound_Post - -#ifdef FN_EmitAmbientSound_Post -void FN_EmitAmbientSound_Post(edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); -#endif // FN_EmitAmbientSound_Post - -#ifdef FN_TraceLine_Post -void FN_TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); -#endif // FN_TraceLine_Post - -#ifdef FN_TraceToss_Post -void FN_TraceToss_Post(edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr); -#endif // FN_TraceToss_Post - -#ifdef FN_TraceMonsterHull_Post -int FN_TraceMonsterHull_Post(edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); -#endif // FN_TraceMonsterHull_Post - -#ifdef FN_TraceHull_Post -void FN_TraceHull_Post(const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); -#endif // FN_TraceHull_Post - -#ifdef FN_TraceModel_Post -void FN_TraceModel_Post(const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); -#endif // FN_TraceModel_Post - -#ifdef FN_TraceTexture_Post -const char *FN_TraceTexture_Post(edict_t *pTextureEntity, const float *v1, const float *v2 ); -#endif // FN_TraceTexture_Post - -#ifdef FN_TraceSphere_Post -void FN_TraceSphere_Post(const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); -#endif // FN_TraceSphere_Post - -#ifdef FN_GetAimVector_Post -void FN_GetAimVector_Post(edict_t *ent, float speed, float *rgflReturn); -#endif // FN_GetAimVector_Post - -#ifdef FN_ServerCommand_Post -void FN_ServerCommand_Post(char *str); -#endif // FN_ServerCommand_Post - -#ifdef FN_ServerExecute_Post -void FN_ServerExecute_Post(void); -#endif // FN_ServerExecute_Post - -#ifdef FN_engClientCommand_Post -void FN_engClientCommand_Post(edict_t *pEdict, char *szFmt, ...); -#endif // FN_engClientCommand_Post - -#ifdef FN_ParticleEffect_Post -void FN_ParticleEffect_Post(const float *org, const float *dir, float color, float count); -#endif // FN_ParticleEffect_Post - -#ifdef FN_LightStyle_Post -void FN_LightStyle_Post(int style, char *val); -#endif // FN_LightStyle_Post - -#ifdef FN_DecalIndex_Post -int FN_DecalIndex_Post(const char *name); -#endif // FN_DecalIndex_Post - -#ifdef FN_PointContents_Post -int FN_PointContents_Post(const float *rgflVector); -#endif // FN_PointContents_Post - -#ifdef FN_MessageBegin_Post -void FN_MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); -#endif // FN_MessageBegin_Post - -#ifdef FN_MessageEnd_Post -void FN_MessageEnd_Post(void); -#endif // FN_MessageEnd_Post - -#ifdef FN_WriteByte_Post -void FN_WriteByte_Post(int iValue); -#endif // FN_WriteByte_Post - -#ifdef FN_WriteChar_Post -void FN_WriteChar_Post(int iValue); -#endif // FN_WriteChar_Post - -#ifdef FN_WriteShort_Post -void FN_WriteShort_Post(int iValue); -#endif // FN_WriteShort_Post - -#ifdef FN_WriteLong_Post -void FN_WriteLong_Post(int iValue); -#endif // FN_WriteLong_Post - -#ifdef FN_WriteAngle_Post -void FN_WriteAngle_Post(float flValue); -#endif // FN_WriteAngle_Post - -#ifdef FN_WriteCoord_Post -void FN_WriteCoord_Post(float flValue); -#endif // FN_WriteCoord_Post - -#ifdef FN_WriteString_Post -void FN_WriteString_Post(const char *sz); -#endif // FN_WriteString_Post - -#ifdef FN_WriteEntity_Post -void FN_WriteEntity_Post(int iValue); -#endif // FN_WriteEntity_Post - -#ifdef FN_CVarRegister_Post -void FN_CVarRegister_Post(cvar_t *pCvar); -#endif // FN_CVarRegister_Post - -#ifdef FN_CVarGetFloat_Post -float FN_CVarGetFloat_Post(const char *szVarName); -#endif // FN_CVarGetFloat_Post - -#ifdef FN_CVarGetString_Post -const char *FN_CVarGetString_Post(const char *szVarName); -#endif // FN_CVarGetString_Post - -#ifdef FN_CVarSetFloat_Post -void FN_CVarSetFloat_Post(const char *szVarName, float flValue); -#endif // FN_CVarSetFloat_Post - -#ifdef FN_CVarSetString_Post -void FN_CVarSetString_Post(const char *szVarName, const char *szValue); -#endif // FN_CVarSetString_Post - -#ifdef FN_AlertMessage_Post -void FN_AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...); -#endif // FN_AlertMessage_Post - -#ifdef FN_EngineFprintf_Post -void FN_EngineFprintf_Post(void *pfile, char *szFmt, ...); -#endif // FN_EngineFprintf_Post - -#ifdef FN_PvAllocEntPrivateData_Post -void *FN_PvAllocEntPrivateData_Post(edict_t *pEdict, int32 cb); -#endif // FN_PvAllocEntPrivateData_Post - -#ifdef FN_PvEntPrivateData_Post -void *FN_PvEntPrivateData_Post(edict_t *pEdict); -#endif // FN_PvEntPrivateData_Post - -#ifdef FN_FreeEntPrivateData_Post -void FN_FreeEntPrivateData_Post(edict_t *pEdict); -#endif // FN_FreeEntPrivateData_Post - -#ifdef FN_SzFromIndex_Post -const char *FN_SzFromIndex_Post(int iString); -#endif // FN_SzFromIndex_Post - -#ifdef FN_AllocString_Post -int FN_AllocString_Post(const char *szValue); -#endif // FN_AllocString_Post - -#ifdef FN_GetVarsOfEnt_Post -struct entvars_s *FN_GetVarsOfEnt_Post(edict_t *pEdict); -#endif // FN_GetVarsOfEnt_Post - -#ifdef FN_PEntityOfEntOffset_Post -edict_t *FN_PEntityOfEntOffset_Post(int iEntOffset); -#endif // FN_PEntityOfEntOffset_Post - -#ifdef FN_EntOffsetOfPEntity_Post -int FN_EntOffsetOfPEntity_Post(const edict_t *pEdict); -#endif // FN_EntOffsetOfPEntity_Post - -#ifdef FN_IndexOfEdict_Post -int FN_IndexOfEdict_Post(const edict_t *pEdict); -#endif // FN_IndexOfEdict_Post - -#ifdef FN_PEntityOfEntIndex_Post -edict_t *FN_PEntityOfEntIndex_Post(int iEntIndex); -#endif // FN_PEntityOfEntIndex_Post - -#ifdef FN_FindEntityByVars_Post -edict_t *FN_FindEntityByVars_Post(struct entvars_s *pvars); -#endif // FN_FindEntityByVars_Post - -#ifdef FN_GetModelPtr_Post -void *FN_GetModelPtr_Post(edict_t *pEdict); -#endif // FN_GetModelPtr_Post - -#ifdef FN_RegUserMsg_Post -int FN_RegUserMsg_Post(const char *pszName, int iSize); -#endif // FN_RegUserMsg_Post - -#ifdef FN_AnimationAutomove_Post -void FN_AnimationAutomove_Post(const edict_t *pEdict, float flTime); -#endif // FN_AnimationAutomove_Post - -#ifdef FN_GetBonePosition_Post -void FN_GetBonePosition_Post(const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles); -#endif // FN_GetBonePosition_Post - -#ifdef FN_FunctionFromName_Post -uint32 FN_FunctionFromName_Post(const char *pName); -#endif // FN_FunctionFromName_Post - -#ifdef FN_NameForFunction_Post -const char *FN_NameForFunction_Post(uint32); -#endif // FN_NameForFunction_Post - -#ifdef FN_ClientPrintf_Post -void FN_ClientPrintf_Post(edict_t *pEdict, PRINT_TYPE ptype, const char *szMsg); -#endif // FN_ClientPrintf_Post - -#ifdef FN_ServerPrint_Post -void FN_ServerPrint_Post(const char *szMsg); -#endif // FN_ServerPrint_Post - -#ifdef FN_Cmd_Args_Post -const char *FN_Cmd_Args_Post(void); -#endif // FN_Cmd_Args_Post - -#ifdef FN_Cmd_Argv_Post -const char *FN_Cmd_Argv_Post(int argc); -#endif // FN_Cmd_Argv_Post - -#ifdef FN_Cmd_Argc_Post -int FN_Cmd_Argc_Post(void); -#endif // FN_Cmd_Argc_Post - -#ifdef FN_GetAttachment_Post -void FN_GetAttachment_Post(const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); -#endif // FN_GetAttachment_Post - -#ifdef FN_CRC32_Init_Post -void FN_CRC32_Init_Post(CRC32_t *pulCRC); -#endif // FN_CRC32_Init_Post - -#ifdef FN_CRC32_ProcessBuffer_Post -void FN_CRC32_ProcessBuffer_Post(CRC32_t *pulCRC, void *p, int len); -#endif // FN_CRC32_ProcessBuffer_Post - -#ifdef FN_CRC32_ProcessByte_Post -void FN_CRC32_ProcessByte_Post(CRC32_t *pulCRC, unsigned char ch); -#endif // FN_CRC32_ProcessByte_Post - -#ifdef FN_CRC32_Final_Post -CRC32_t FN_CRC32_Final_Post(CRC32_t pulCRC); -#endif // FN_CRC32_Final_Post - -#ifdef FN_RandomLong_Post -int32 FN_RandomLong_Post(int32 lLow, int32 lHigh); -#endif // FN_RandomLong_Post - -#ifdef FN_RandomFloat_Post -float FN_RandomFloat_Post(float flLow, float flHigh); -#endif // FN_RandomFloat_Post - -#ifdef FN_SetView_Post -void FN_SetView_Post(const edict_t *pClient, const edict_t *pViewent); -#endif // FN_SetView_Post - -#ifdef FN_Time_Post -float FN_Time_Post(void); -#endif // FN_Time_Post - -#ifdef FN_CrosshairAngle_Post -void FN_CrosshairAngle_Post(const edict_t *pClient, float pitch, float yaw); -#endif // FN_CrosshairAngle_Post - -#ifdef FN_LoadFileForMe_Post -byte *FN_LoadFileForMe_Post(char *filename, int *pLength); -#endif // FN_LoadFileForMe_Post - -#ifdef FN_FreeFile_Post -void FN_FreeFile_Post(void *buffer); -#endif // FN_FreeFile_Post - -#ifdef FN_EndSection_Post -void FN_EndSection_Post(const char *pszSectionName); -#endif // FN_EndSection_Post - -#ifdef FN_CompareFileTime_Post -int FN_CompareFileTime_Post(char *filename1, char *filename2, int *iCompare); -#endif // FN_CompareFileTime_Post - -#ifdef FN_GetGameDir_Post -void FN_GetGameDir_Post(char *szGetGameDir); -#endif // FN_GetGameDir_Post - -#ifdef FN_Cvar_RegisterVariable_Post -void FN_Cvar_RegisterVariable_Post(cvar_t *variable); -#endif // FN_Cvar_RegisterVariable_Post - -#ifdef FN_FadeClientVolume_Post -void FN_FadeClientVolume_Post(const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); -#endif // FN_FadeClientVolume_Post - -#ifdef FN_SetClientMaxspeed_Post -void FN_SetClientMaxspeed_Post(const edict_t *pEdict, float fNewMaxspeed); -#endif // FN_SetClientMaxspeed_Post - -#ifdef FN_CreateFakeClient_Post -edict_t *FN_CreateFakeClient_Post(const char *netname); -#endif // FN_CreateFakeClient_Post - -#ifdef FN_RunPlayerMove_Post -void FN_RunPlayerMove_Post(edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec); -#endif // FN_RunPlayerMove_Post - -#ifdef FN_NumberOfEntities_Post -int FN_NumberOfEntities_Post(void); -#endif // FN_NumberOfEntities_Post - -#ifdef FN_GetInfoKeyBuffer_Post -char *FN_GetInfoKeyBuffer_Post(edict_t *e); -#endif // FN_GetInfoKeyBuffer_Post - -#ifdef FN_InfoKeyValue_Post -char *FN_InfoKeyValue_Post(char *infobuffer, char *key); -#endif // FN_InfoKeyValue_Post - -#ifdef FN_SetKeyValue_Post -void FN_SetKeyValue_Post(char *infobuffer, char *key, char *value); -#endif // FN_SetKeyValue_Post - -#ifdef FN_SetClientKeyValue_Post -void FN_SetClientKeyValue_Post(int clientIndex, char *infobuffer, char *key, char *value); -#endif // FN_SetClientKeyValue_Post - -#ifdef FN_IsMapValid_Post -int FN_IsMapValid_Post(char *filename); -#endif // FN_IsMapValid_Post - -#ifdef FN_StaticDecal_Post -void FN_StaticDecal_Post(const float *origin, int decalIndex, int entityIndex, int modelIndex); -#endif // FN_StaticDecal_Post - -#ifdef FN_PrecacheGeneric_Post -int FN_PrecacheGeneric_Post(char *s); -#endif // FN_PrecacheGeneric_Post - -#ifdef FN_GetPlayerUserId_Post -int FN_GetPlayerUserId_Post(edict_t *e ); -#endif // FN_GetPlayerUserId_Post - -#ifdef FN_BuildSoundMsg_Post -void FN_BuildSoundMsg_Post(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); -#endif // FN_BuildSoundMsg_Post - -#ifdef FN_IsDedicatedServer_Post -int FN_IsDedicatedServer_Post(void); -#endif // FN_IsDedicatedServer_Post - -#ifdef FN_CVarGetPointer_Post -cvar_t *FN_CVarGetPointer_Post(const char *szVarName); -#endif // FN_CVarGetPointer_Post - -#ifdef FN_GetPlayerWONId_Post -unsigned int FN_GetPlayerWONId_Post(edict_t *e); -#endif // FN_GetPlayerWONId_Post - -#ifdef FN_Info_RemoveKey_Post -void FN_Info_RemoveKey_Post( char *s, const char *key); -#endif // FN_Info_RemoveKey_Post - -#ifdef FN_GetPhysicsKeyValue_Post -const char *FN_GetPhysicsKeyValue_Post(const edict_t *pClient, const char *key); -#endif // FN_GetPhysicsKeyValue_Post - -#ifdef FN_SetPhysicsKeyValue_Post -void FN_SetPhysicsKeyValue_Post(const edict_t *pClient, const char *key, const char *value); -#endif // FN_SetPhysicsKeyValue_Post - -#ifdef FN_GetPhysicsInfoString_Post -const char *FN_GetPhysicsInfoString_Post( const edict_t *pClient); -#endif // FN_GetPhysicsInfoString_Post - -#ifdef FN_PrecacheEvent_Post -unsigned short FN_PrecacheEvent_Post(int type, const char *psz); -#endif // FN_PrecacheEvent_Post - -#ifdef FN_PlaybackEvent_Post -void FN_PlaybackEvent_Post(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); -#endif // FN_PlaybackEvent_Post - -#ifdef FN_SetFatPVS_Post -unsigned char *FN_SetFatPVS_Post(float *org); -#endif // FN_SetFatPVS_Post - -#ifdef FN_SetFatPAS_Post -unsigned char *FN_SetFatPAS_Post(float *org); -#endif // FN_SetFatPAS_Post - -#ifdef FN_CheckVisibility_Post -int FN_CheckVisibility_Post(const edict_t *entity, unsigned char *pset); -#endif // FN_CheckVisibility_Post - -#ifdef FN_DeltaSetField_Post -void FN_DeltaSetField_Post(struct delta_s *pFields, const char *fieldname); -#endif // FN_DeltaSetField_Post - -#ifdef FN_DeltaUnsetField_Post -void FN_DeltaUnsetField_Post(struct delta_s *pFields, const char *fieldname); -#endif // FN_DeltaUnsetField_Post - -#ifdef FN_DeltaAddEncoder_Post -void FN_DeltaAddEncoder_Post(char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); -#endif // FN_DeltaAddEncoder_Post - -#ifdef FN_GetCurrentPlayer_Post -int FN_GetCurrentPlayer_Post(void); -#endif // FN_GetCurrentPlayer_Post - -#ifdef FN_CanSkipPlayer_Post -int FN_CanSkipPlayer_Post(const edict_t *player); -#endif // FN_CanSkipPlayer_Post - -#ifdef FN_DeltaFindField_Post -int FN_DeltaFindField_Post(struct delta_s *pFields, const char *fieldname); -#endif // FN_DeltaFindField_Post - -#ifdef FN_DeltaSetFieldByIndex_Post -void FN_DeltaSetFieldByIndex_Post(struct delta_s *pFields, int fieldNumber); -#endif // FN_DeltaSetFieldByIndex_Post - -#ifdef FN_DeltaUnsetFieldByIndex_Post -void FN_DeltaUnsetFieldByIndex_Post(struct delta_s *pFields, int fieldNumber); -#endif // FN_DeltaUnsetFieldByIndex_Post - -#ifdef FN_SetGroupMask_Post -void FN_SetGroupMask_Post(int mask, int op); -#endif // FN_SetGroupMask_Post - -#ifdef FN_engCreateInstancedBaseline_Post -int FN_engCreateInstancedBaseline_Post(int classname, struct entity_state_s *baseline); -#endif // FN_engCreateInstancedBaseline_Post - -#ifdef FN_Cvar_DirectSet_Post -void FN_Cvar_DirectSet_Post(struct cvar_s *var, char *value); -#endif // FN_Cvar_DirectSet_Post - -#ifdef FN_ForceUnmodified_Post -void FN_ForceUnmodified_Post(FORCE_TYPE type, float *mins, float *maxs, const char *filename); -#endif // FN_ForceUnmodified_Post - -#ifdef FN_GetPlayerStats_Post -void FN_GetPlayerStats_Post(const edict_t *pClient, int *ping, int *packet_loss); -#endif // FN_GetPlayerStats_Post - -#ifdef FN_AddServerCommand_Post -void FN_AddServerCommand_Post(char *cmd_name, void (*function)(void)); -#endif // FN_AddServerCommand_Post - -#ifdef FN_Voice_GetClientListening_Post -qboolean FN_Voice_GetClientListening_Post(int iReceiver, int iSender); -#endif // FN_Voice_GetClientListening_Post - -#ifdef FN_Voice_SetClientListening_Post -qboolean FN_Voice_SetClientListening_Post(int iReceiver, int iSender, qboolean bListen); -#endif // FN_Voice_SetClientListening_Post - -#ifdef FN_GetPlayerAuthId_Post -const char *FN_GetPlayerAuthId_Post(edict_t *e); -#endif // FN_GetPlayerAuthId - - - - -#ifdef FN_OnFreeEntPrivateData -void FN_OnFreeEntPrivateData(edict_t *pEnt); -#endif // FN_OnFreeEntPrivateData - -#ifdef FN_GameShutdown -void FN_GameShutdown(void); -#endif // FN_GameShutdown - -#ifdef FN_ShouldCollide -int FN_ShouldCollide(edict_t *pentTouched, edict_t *pentOther); -#endif // FN_ShouldCollide - - - - - -#ifdef FN_OnFreeEntPrivateData_Post -void FN_OnFreeEntPrivateData_Post(edict_t *pEnt); -#endif // FN_OnFreeEntPrivateData_Post - -#ifdef FN_GameShutdown_Post -void FN_GameShutdown_Post(void); -#endif // FN_GameShutdown_Post - -#ifdef FN_ShouldCollide_Post -int FN_ShouldCollide_Post(edict_t *pentTouched, edict_t *pentOther); -#endif // FN_ShouldCollide_Post - -#endif // USE_METAMOD - - -#ifdef FN_AMXX_QUERY -void FN_AMXX_QUERY(void); -#endif // FN_AMXX_QUERY - -#ifdef FN_AMXX_ATTACH -void FN_AMXX_ATTACH(void); -#endif // FN_AMXX_ATTACH - -#ifdef FN_AMXX_DETACH -void FN_AMXX_DETACH(void); -#endif // FN_AMXX_DETACH - -#ifdef FN_AMXX_PLUGINSLOADED -void FN_AMXX_PLUGINSLOADED(void); -#endif // FN_AMXX_PLUGINSLOADED - -#ifdef FN_AMXX_PLUGINSUNLOADING -void FN_AMXX_PLUGINSUNLOADING(void); -#endif // FN_AMXX_PLUGINSUNLOADING - -#ifdef FN_AMXX_PLUGINSUNLOADED -void FN_AMXX_PLUGINSUNLOADED(void); -#endif // FN_AMXX_PLUGINSUNLOADED - -// *** Types *** -typedef void* (*PFN_REQ_FNPTR)(const char * /*name*/); - -// ***** Module funcs stuff ***** -enum ForwardExecType -{ - ET_IGNORE = 0, // Ignore return vaue - ET_STOP, // Stop on PLUGIN_HANDLED - ET_STOP2, // Stop on PLUGIN_HANDLED, continue on other values, return biggest return value - ET_CONTINUE, // Continue; return biggest return value -}; - -enum ForwardParam -{ - FP_DONE = -1, // specify this as the last argument - // only tells the function that there are no more arguments - FP_CELL, // normal cell - FP_FLOAT, // float; used as normal cell though - FP_STRING, // string - FP_STRINGEX, // string; will be updated to the last function's value - FP_ARRAY, // array; use the return value of prepareArray. -}; - -enum PlayerProp -{ - Player_Name, //String - Player_Ip, //String - Player_Team, //String - Player_Ingame, //bool - Player_Authorized, //bool - Player_Vgui, //bool - Player_Time, //float - Player_Playtime, //float - Player_MenuExpire, //float - Player_Weapons, //struct{int,int}[32] - Player_CurrentWeapon, //int - Player_TeamID, //int - Player_Deaths, //int - Player_Aiming, //int - Player_Menu, //int - Player_Keys, //int - Player_Flags, //int[32] - Player_Newmenu, //int - Player_NewmenuPage, //int -}; - -enum LibType -{ - LibType_Library, - LibType_Class -}; - -#define MSGBLOCK_SET 0 -#define MSGBLOCK_GET 1 -#define BLOCK_NOT 0 -#define BLOCK_ONCE 1 -#define BLOCK_SET 2 - -typedef void (*AUTHORIZEFUNC)(int player, const char *authstring); - -typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); -typedef int (*PFN_ADD_NEW_NATIVES) (const AMX_NATIVE_INFO * /*list*/); -typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); -typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...); -typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); -typedef void (*PFN_PRINT_SRVCONSOLE) (char * /*format*/, ...); -typedef const char * (*PFN_GET_MODNAME) (void); -typedef const char * (*PFN_GET_AMXSCRIPTNAME) (int /*id*/); -typedef AMX * (*PFN_GET_AMXSCRIPT) (int /*id*/); -typedef int (*PFN_FIND_AMXSCRIPT_BYAMX) (const AMX * /*amx*/); -typedef int (*PFN_FIND_AMXSCRIPT_BYNAME) (const char * /*name*/); -typedef int (*PFN_SET_AMXSTRING) (AMX * /*amx*/, cell /*amx_addr*/, const char * /* source */, int /* max */); -typedef char * (*PFN_GET_AMXSTRING) (AMX * /*amx*/, cell /*amx_addr*/, int /*bufferId*/, int * /*pLen*/); -typedef int (*PFN_GET_AMXSTRINGLEN) (const cell *ptr); -typedef char * (*PFN_FORMAT_AMXSTRING) (AMX * /*amx*/, cell * /*params*/, int /*startParam*/, int * /*pLen*/); -typedef void (*PFN_COPY_AMXMEMORY) (cell * /*dest*/, const cell * /*src*/, int /*len*/); -typedef void (*PFN_LOG) (const char * /*fmt*/, ...); -typedef void (*PFN_LOG_ERROR) (AMX * /*amx*/, int /*err*/, const char * /*fmt*/, ...); -typedef int (*PFN_RAISE_AMXERROR) (AMX * /*amx*/, int /*error*/); -typedef int (*PFN_REGISTER_FORWARD) (const char * /*funcname*/, ForwardExecType /*exectype*/, ... /*paramtypes terminated by PF_DONE*/); -typedef int (*PFN_EXECUTE_FORWARD) (int /*id*/, ... /*params*/); -typedef cell (*PFN_PREPARE_CELLARRAY) (cell * /*ptr*/, unsigned int /*size*/); -typedef cell (*PFN_PREPARE_CHARARRAY) (char * /*ptr*/, unsigned int /*size*/); -typedef cell (*PFN_PREPARE_CELLARRAY_A) (cell * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/); -typedef cell (*PFN_PREPARE_CHARARRAY_A) (char * /*ptr*/, unsigned int /*size*/, bool /*copyBack*/); -typedef int (*PFN_IS_PLAYER_VALID) (int /*id*/); -typedef const char * (*PFN_GET_PLAYER_NAME) (int /*id*/); -typedef const char * (*PFN_GET_PLAYER_IP) (int /*id*/); -typedef int (*PFN_IS_PLAYER_INGAME) (int /*id*/); -typedef int (*PFN_IS_PLAYER_BOT) (int /*id*/); -typedef int (*PFN_IS_PLAYER_AUTHORIZED) (int /*id*/); -typedef float (*PFN_GET_PLAYER_TIME) (int /*id*/); -typedef float (*PFN_GET_PLAYER_PLAYTIME) (int /*id*/); -typedef int (*PFN_GETPLAYERFLAGS) (int /* id*/); -typedef int (*PFN_GET_PLAYER_CURWEAPON) (int /*id*/); -typedef const char * (*PFN_GET_PLAYER_TEAM) (int /*id*/); -typedef int (*PFN_GET_PLAYER_TEAMID) (int /*id*/); -typedef int (*PFN_GET_PLAYER_DEATHS) (int /*id*/); -typedef int (*PFN_GET_PLAYER_MENU) (int /*id*/); -typedef int (*PFN_GET_PLAYER_KEYS) (int /*id*/); -typedef int (*PFN_IS_PLAYER_ALIVE) (int /*id*/); -typedef int (*PFN_GET_PLAYER_FRAGS) (int /*id*/); -typedef int (*PFN_IS_PLAYER_CONNECTING) (int /*id*/); -typedef int (*PFN_IS_PLAYER_HLTV) (int /*id*/); -typedef int (*PFN_GET_PLAYER_ARMOR) (int /*id*/); -typedef int (*PFN_GET_PLAYER_HEALTH) (int /*id*/); -#ifdef USE_METAMOD -typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/); -#else -typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/); -#endif -typedef void * (*PFN_PLAYER_PROP_ADDR) (int /*id*/, int /*prop*/); - -#ifdef MEMORY_TEST -typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/, - const unsigned int /*type*/, const size_t /*size*/); -typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/, - const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ ); -typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/, - const unsigned int /*type*/, const void* /*addr*/ ); -#endif -typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/); -typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/); -typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/); -typedef int (*PFN_AMX_FINDPUBLIC) (AMX* /*amx*/, char* /*func name*/, int* /*index*/); -typedef int (*PFN_AMX_FINDNATIVE) (AMX* /*amx*/, char* /*func name*/, int* /*index*/); -typedef int (*PFN_LOAD_AMXSCRIPT) (AMX* /*amx*/, void** /*code*/, const char* /*path*/, char[64] /*error info*/, int /* debug */); -typedef int (*PFN_UNLOAD_AMXSCRIPT) (AMX* /*amx*/,void** /*code*/); -typedef cell (*PFN_REAL_TO_CELL) (REAL /*x*/); -typedef REAL (*PFN_CELL_TO_REAL) (cell /*x*/); -typedef int (*PFN_REGISTER_SPFORWARD) (AMX * /*amx*/, int /*func*/, ... /*params*/); -typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*funcName*/, ... /*params*/); -typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/); -typedef void (*PFN_MERGEDEFINITION_FILE) (const char * /*filename*/); -typedef const char * (*PFN_FORMAT) (const char * /*fmt*/, ... /*params*/); -typedef void (*PFN_REGISTERFUNCTION) (void * /*pfn*/, const char * /*desc*/); -typedef int (*PFN_AMX_PUSH) (AMX * /*amx*/, cell /*value*/); -typedef int (*PFN_SET_TEAM_INFO) (int /*player */, int /*teamid */, const char * /*name */); -typedef void (*PFN_REG_AUTH_FUNC) (AUTHORIZEFUNC); -typedef void (*PFN_UNREG_AUTH_FUNC) (AUTHORIZEFUNC); -typedef int (*PFN_FINDLIBRARY) (const char * /*name*/, LibType /*type*/); -typedef size_t (*PFN_ADDLIBRARIES) (const char * /*name*/, LibType /*type*/, void * /*parent*/); -typedef size_t (*PFN_REMOVELIBRARIES) (void * /*parent*/); -typedef void (*PFN_OVERRIDENATIVES) (AMX_NATIVE_INFO * /*natives*/, const char * /*myname*/); -typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char * /*def*/); -typedef int (*PFN_AMX_REREGISTER) (AMX * /*amx*/, AMX_NATIVE_INFO * /*list*/, int /*list*/); -typedef void * (*PFN_REGISTERFUNCTIONEX) (void * /*pfn*/, const char * /*desc*/); -typedef void (*PFN_MESSAGE_BLOCK) (int /* mode */, int /* message */, int * /* opt */); - -extern PFN_ADD_NATIVES g_fn_AddNatives; -extern PFN_ADD_NEW_NATIVES g_fn_AddNewNatives; -extern PFN_BUILD_PATHNAME g_fn_BuildPathname; -extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR; -extern PFN_GET_AMXADDR g_fn_GetAmxAddr; -extern PFN_PRINT_SRVCONSOLE g_fn_PrintSrvConsole; -extern PFN_GET_MODNAME g_fn_GetModname; -extern PFN_GET_AMXSCRIPTNAME g_fn_GetAmxScriptName; -extern PFN_GET_AMXSCRIPT g_fn_GetAmxScript; -extern PFN_FIND_AMXSCRIPT_BYAMX g_fn_FindAmxScriptByAmx; -extern PFN_FIND_AMXSCRIPT_BYNAME g_fn_FindAmxScriptByName; -extern PFN_SET_AMXSTRING g_fn_SetAmxString; -extern PFN_GET_AMXSTRING g_fn_GetAmxString; -extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen; -extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString; -extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory; -extern PFN_LOG g_fn_Log; -extern PFN_LOG_ERROR g_fn_LogErrorFunc; -extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError; -extern PFN_REGISTER_FORWARD g_fn_RegisterForward; -extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward; -extern PFN_PREPARE_CELLARRAY g_fn_PrepareCellArray; -extern PFN_PREPARE_CHARARRAY g_fn_PrepareCharArray; -extern PFN_PREPARE_CELLARRAY_A g_fn_PrepareCellArrayA; -extern PFN_PREPARE_CHARARRAY_A g_fn_PrepareCharArrayA; -extern PFN_IS_PLAYER_VALID g_fn_IsPlayerValid; -extern PFN_GET_PLAYER_NAME g_fn_GetPlayerName; -extern PFN_GET_PLAYER_IP g_fn_GetPlayerIP; -extern PFN_IS_PLAYER_INGAME g_fn_IsPlayerIngame; -extern PFN_IS_PLAYER_BOT g_fn_IsPlayerBot; -extern PFN_IS_PLAYER_AUTHORIZED g_fn_IsPlayerAuthorized; -extern PFN_GET_PLAYER_TIME g_fn_GetPlayerTime; -extern PFN_GET_PLAYER_PLAYTIME g_fn_GetPlayerPlayTime; -extern PFN_GET_PLAYER_CURWEAPON g_fn_GetPlayerCurweapon; -extern PFN_GET_PLAYER_TEAMID g_fn_GetPlayerTeamID; -extern PFN_GET_PLAYER_DEATHS g_fn_GetPlayerDeaths; -extern PFN_GET_PLAYER_MENU g_fn_GetPlayerMenu; -extern PFN_GET_PLAYER_KEYS g_fn_GetPlayerKeys; -extern PFN_IS_PLAYER_ALIVE g_fn_IsPlayerAlive; -extern PFN_GET_PLAYER_FRAGS g_fn_GetPlayerFrags; -extern PFN_IS_PLAYER_CONNECTING g_fn_IsPlayerConnecting; -extern PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV; -extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor; -extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth; -extern PFN_AMX_EXEC g_fn_AmxExec; -extern PFN_AMX_ALLOT g_fn_AmxAllot; -extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic; -extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript; -extern PFN_UNLOAD_AMXSCRIPT g_fn_UnloadAmxScript; -extern PFN_REAL_TO_CELL g_fn_RealToCell; -extern PFN_CELL_TO_REAL g_fn_CellToReal; -extern PFN_REGISTER_SPFORWARD g_fn_RegisterSPForward; -extern PFN_REGISTER_SPFORWARD_BYNAME g_fn_RegisterSPForwardByName; -extern PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward; -extern PFN_MERGEDEFINITION_FILE g_fn_MergeDefinition_File; -extern PFN_AMX_FINDNATIVE g_fn_AmxFindNative; -extern PFN_GETPLAYERFLAGS g_fn_GetPlayerFlags; -extern PFN_GET_PLAYER_EDICT g_fn_GetPlayerEdict; -extern PFN_FORMAT g_fn_Format; -extern PFN_GET_PLAYER_TEAM g_fn_GetPlayerTeam; -extern PFN_REGISTERFUNCTION g_fn_RegisterFunction; -extern PFN_REQ_FNPTR g_fn_RequestFunction; -extern PFN_AMX_PUSH g_fn_AmxPush; -extern PFN_SET_TEAM_INFO g_fn_SetTeamInfo; -extern PFN_PLAYER_PROP_ADDR g_fn_PlayerPropAddr; -extern PFN_REG_AUTH_FUNC g_fn_RegAuthFunc; -extern PFN_UNREG_AUTH_FUNC g_fn_UnregAuthFunc; -extern PFN_FINDLIBRARY g_fn_FindLibrary; -extern PFN_ADDLIBRARIES g_fn_AddLibraries; -extern PFN_REMOVELIBRARIES g_fn_RemoveLibraries; -extern PFN_OVERRIDENATIVES g_fn_OverrideNatives; -extern PFN_GETLOCALINFO g_fn_GetLocalInfo; -extern PFN_AMX_REREGISTER g_fn_AmxReRegister; -extern PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx; -extern PFN_MESSAGE_BLOCK g_fn_MessageBlock; - -#ifdef MAY_NEVER_BE_DEFINED -// Function prototypes for intellisense and similar systems -// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED -int MF_AddNatives (const AMX_NATIVE_INFO *list) { } -int MF_AddNewNatives (const AMX_NATIVE_INFO *list) { } -char * MF_BuildPathname (const char * format, ...) { } -char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { } -cell * MF_GetAmxAddr (AMX * amx, cell offset) { } -void MF_PrintSrvConsole (char * format, ...) { } -const char * MF_GetModname (void) { } -const char * MF_GetScriptName (int id) { } -AMX * MF_GetScriptAmx (int id) { } -int MF_FindScriptByAmx (const AMX * amx) { } -int MF_FindScriptByAmx (const char * name) { } -int MF_SetAmxString (AMX * amx, cell amx_addr, const char * source , int max ) { } -char * MF_GetAmxString (AMX * amx, cell amx_addr, int bufferId, int * pLen) { } -int MF_GetAmxStringLen (const cell *ptr) { } -char * MF_FormatAmxString (AMX * amx, cell * params, int startParam, int * pLen) { } -void MF_CopyAmxMemory (cell * dest, const cell * src, int len) { } -void MF_Log (const char * fmt, ...) { } -void MF_LogError (AMX * amx, int err, const char *fmt, ...) { } -int MF_RaiseAmxError (AMX * amx, int error) { } -int MF_RegisterForward (const char * funcname, ForwardExecType exectype, ...) { } -int MF_ExecuteForward (int id, ...) { } -cell MF_PrepareCellArray (cell * ptr, unsigned int size) { } -cell MF_PrepareCharArray (char * ptr, unsigned int size) { } -cell MF_PrepareCellArrayA (cell * ptr, unsigned int size, bool copyBack) { } -cell MF_PrepareCharArrayA (char * ptr, unsigned int size, bool copyBack) { } -int MF_IsPlayerValid (int id) { } -const char * MF_GetPlayerName (int id) { } -const char * MF_GetPlayerIP (int id) { } -int MF_IsPlayerIngame (int id) { } -int MF_IsPlayerBot (int id) { } -int MF_IsPlayerAuthorized (int id) { } -float MF_GetPlayerTime (int id) { } -float MF_GetPlayerPlayTime (int id) { } -int MF_GetPlayerCurweapon (int id) { } -const char * MF_GetPlayerTeam (int id) { } -int MF_GetPlayerTeamID (int id) { } -int MF_GetPlayerDeaths (int id) { } -int MF_GetPlayerMenu (int id) { } -int MF_GetPlayerKeys (int id) { } -int MF_IsPlayerAlive (int id) { } -int MF_GetPlayerFrags (int id) { } -int MF_IsPlayerConnecting (int id) { } -int MF_IsPlayerHLTV (int id) { } -int MF_GetPlayerArmor (int id) { } -int MF_GetPlayerHealth (int id) { } -REAL amx_ctof (cell x) { } -cell amx_ftoc (float x) { } -int MF_RegisterSPForwardByName (AMX * amx, const char *str, ...) { } -int MF_RegisterSPForward (AMX * amx, int func, ...) { } -void MF_UnregisterSPForward (int id) { } -int MF_GetPlayerFlags (int id) { } -edict_t* MF_GetPlayerEdict (int id) { } -const char * MF_Format (const char *fmt, ...) { } -void MF_RegisterFunction (void *pfn, const char *description) { } -void * MF_RequestFunction (const char *description) { } -int MF_AmxPush (AMX *amx, cell *params) { } -int MF_AmxExec (AMX *amx, cell *retval, int idx) { } -int MF_SetPlayerTeamInfo (int id, int teamid, const char *teamname) { } -void * MF_PlayerPropAddr (int id, int prop) { } -void MF_RegAuthFunc (AUTHORIZEFUNC fn) { } -void MF_UnregAuthFunc (AUTHORIZEFUNC fn) { } -int MF_FindLibrary (const char *name, LibType type) { } -size_t MF_AddLibraries (const char *name, LibType type, void *parent) { } -size_t MF_RemoveLibraries (void *parent) { } -void MF_OverrideNatives (AMX_NATIVE_INFO *natives, const char *myname) { } -const char * MF_GetLocalInfo (const char *name, const char *def) { } -int MF_AmxReRegister (AMX *amx, AMX_NATIVE_INFO *list, int number) { return 0; } -void * MF_RegisterFunctionEx (void *pfn, const char *description) { } -void * MF_MessageBlock (int mode, int msg, int *opt) { } -#endif // MAY_NEVER_BE_DEFINED - -#define MF_AddNatives g_fn_AddNatives -#define MF_AddNewNatives g_fn_AddNewNatives -#define MF_BuildPathname g_fn_BuildPathname -#define MF_BuildPathnameR g_fn_BuildPathnameR -#define MF_FormatAmxString g_fn_FormatAmxString -#define MF_GetAmxAddr g_fn_GetAmxAddr -#define MF_PrintSrvConsole g_fn_PrintSrvConsole -#define MF_GetModname g_fn_GetModname -#define MF_GetScriptName g_fn_GetAmxScriptName -#define MF_GetScriptAmx g_fn_GetAmxScript -#define MF_FindScriptByAmx g_fn_FindAmxScriptByAmx -#define MF_FindScriptByName g_fn_FindAmxScriptByName -#define MF_SetAmxString g_fn_SetAmxString -#define MF_GetAmxString g_fn_GetAmxString -#define MF_GetAmxStringLen g_fn_GetAmxStringLen -#define MF_CopyAmxMemory g_fn_CopyAmxMemory -void MF_Log(const char *fmt, ...); -void MF_LogError(AMX *amx, int err, const char *fmt, ...); -#define MF_RaiseAmxError g_fn_RaiseAmxError -#define MF_RegisterForward g_fn_RegisterForward -#define MF_ExecuteForward g_fn_ExecuteForward -#define MF_PrepareCellArray g_fn_PrepareCellArray -#define MF_PrepareCharArray g_fn_PrepareCharArray -#define MF_PrepareCellArrayA g_fn_PrepareCellArrayA -#define MF_PrepareCharArrayA g_fn_PrepareCharArrayA -#define MF_IsPlayerValid g_fn_IsPlayerValid -#define MF_GetPlayerName g_fn_GetPlayerName -#define MF_GetPlayerIP g_fn_GetPlayerIP -#define MF_IsPlayerIngame g_fn_IsPlayerIngame -#define MF_IsPlayerBot g_fn_IsPlayerBot -#define MF_IsPlayerAuthorized g_fn_IsPlayerAuthorized -#define MF_GetPlayerTime g_fn_GetPlayerTime -#define MF_GetPlayerPlayTime g_fn_GetPlayerPlayTime -#define MF_GetPlayerCurweapon g_fn_GetPlayerCurweapon -#define MF_GetPlayerTeam g_fn_GetPlayerTeam -#define MF_GetPlayerTeamID g_fn_GetPlayerTeamID -#define MF_GetPlayerDeaths g_fn_GetPlayerDeaths -#define MF_GetPlayerMenu g_fn_GetPlayerMenu -#define MF_GetPlayerKeys g_fn_GetPlayerKeys -#define MF_IsPlayerAlive g_fn_IsPlayerAlive -#define MF_GetPlayerFrags g_fn_GetPlayerFrags -#define MF_IsPlayerConnecting g_fn_IsPlayerConnecting -#define MF_IsPlayerHLTV g_fn_IsPlayerHLTV -#define MF_GetPlayerArmor g_fn_GetPlayerArmor -#define MF_GetPlayerHealth g_fn_GetPlayerHealth -#define MF_AmxExec g_fn_AmxExec -#define MF_AmxExecv g_fn_AmxExecv -#define MF_AmxFindPublic g_fn_AmxFindPublic -#define MF_AmxAllot g_fn_AmxAllot -#define MF_AmxFindNative g_fn_AmxFindNative -#define MF_LoadAmxScript g_fn_LoadAmxScript -#define MF_UnloadAmxScript g_fn_UnloadAmxScript -#define MF_MergeDefinitionFile g_fn_MergeDefinition_File -#define amx_ctof g_fn_CellToReal -#define amx_ftoc g_fn_RealToCell -#define MF_RegisterSPForwardByName g_fn_RegisterSPForwardByName -#define MF_RegisterSPForward g_fn_RegisterSPForward -#define MF_UnregisterSPForward g_fn_UnregisterSPForward -#define MF_GetPlayerFlags g_fn_GetPlayerFlags -#define MF_GetPlayerEdict g_fn_GetPlayerEdict -#define MF_Format g_fn_Format -#define MF_RegisterFunction g_fn_RegisterFunction -#define MF_RequestFunction g_fn_RequestFunction -#define MF_AmxPush g_fn_AmxPush -#define MF_SetPlayerTeamInfo g_fn_SetTeamInfo -#define MF_PlayerPropAddr g_fn_PlayerPropAddr -#define MF_RegAuthFunc g_fn_RegAuthFunc -#define MF_UnregAuthFunc g_fn_UnregAuthFunc -#define MF_FindLibrary g_fn_FindLibrary -#define MF_AddLibraries g_fn_AddLibraries -#define MF_RemoveLibraries g_fn_RemoveLibraries -#define MF_OverrideNatives g_fn_OverrideNatives -#define MF_GetLocalInfo g_fn_GetLocalInfo -#define MF_AmxReRegister g_fn_AmxReRegister -#define MF_RegisterFunctionEx g_fn_RegisterFunctionEx -#define MF_MessageBlock g_fn_MessageBlock - -#ifdef MEMORY_TEST -/*** Memory ***/ -void *operator new(size_t reportedSize); -void *operator new[](size_t reportedSize); -void *operator new(size_t reportedSize, const char *sourceFile, int sourceLine); -void *operator new[](size_t reportedSize, const char *sourceFile, int sourceLine); -void operator delete(void *reportedAddress); -void operator delete[](void *reportedAddress); - -// Allocation types -extern const unsigned int m_alloc_unknown; -extern const unsigned int m_alloc_new; -extern const unsigned int m_alloc_new_array; -extern const unsigned int m_alloc_malloc; -extern const unsigned int m_alloc_calloc; -extern const unsigned int m_alloc_realloc; -extern const unsigned int m_alloc_delete; -extern const unsigned int m_alloc_delete_array; -extern const unsigned int m_alloc_free; - -// To be called before new / delete -void Mem_SetOwner(const char *filename, int line, const char *function); -// Actual allocator -void * Mem_Allocator(const char *sourceFile, const unsigned int sourceLine, const char *sourceFunc, - const unsigned int allocationType, const size_t reportedSize); -void * Mem_Reallocator(const char *sourceFile, const unsigned int sourceLine, const char *sourceFunc, - const unsigned int reallocationType, const size_t reportedSize, void *reportedAddress); -void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, const char *sourceFunc, - const unsigned int deallocationType, void *reportedAddress); - -// memory macros -#ifndef __FUNCTION__ -#define __FUNCTION__ "??" -#endif - -// call Mem_SetOwner, followed by the actual new operator -#define new (Mem_SetOwner(__FILE__,__LINE__,__FUNCTION__),false) ? NULL : new -// call Mem_SetOwner, followed by the actual delete operator -#define delete (Mem_SetOwner(__FILE__,__LINE__,__FUNCTION__),false) ? Mem_SetOwner("",0,"") : delete -#define malloc(sz) Mem_Allocator (__FILE__,__LINE__,__FUNCTION__,m_alloc_malloc,sz) -#define calloc(sz) Mem_Allocator (__FILE__,__LINE__,__FUNCTION__,m_alloc_calloc,sz) -#define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr) -#define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr) - -#endif //MEMORY_TEST - -#endif // #ifndef __AMXXMODULE_H__ diff --git a/dlls/hamsandwich/sdk/moduleconfig.h b/dlls/hamsandwich/sdk/moduleconfig.h deleted file mode 100644 index 13309082..00000000 --- a/dlls/hamsandwich/sdk/moduleconfig.h +++ /dev/null @@ -1,491 +0,0 @@ -// Configuration - -#ifndef __MODULECONFIG_H__ -#define __MODULECONFIG_H__ - -// Module info -#define MODULE_NAME "Ham Sandwich" -#define MODULE_VERSION "1.77" -#define MODULE_AUTHOR "AMX Mod X Dev Team" -#define MODULE_URL "http://www.amxmodx.org" -#define MODULE_LOGTAG "HAM" -#define MODULE_LIBRARY "hamsandwich" -#define MODULE_LIBCLASS "" -// If you want the module not to be reloaded on mapchange, remove / comment out the next line -// #define MODULE_RELOAD_ON_MAPCHANGE - -#ifdef __DATE__ -#define MODULE_DATE __DATE__ -#else // __DATE__ -#define MODULE_DATE "Unknown" -#endif // __DATE__ - -// metamod plugin? -#define USE_METAMOD - -// use memory manager/tester? -// note that if you use this, you cannot construct/allocate -// anything before the module attached (OnAmxxAttach). -// be careful of default constructors using new/malloc! -// #define MEMORY_TEST - -// Unless you use STL or exceptions, keep this commented. -// It allows you to compile without libstdc++.so as a dependency -// #define NO_ALLOC_OVERRIDES - -// Uncomment this if you are using MSVC8 or greater and want to fix some of the compatibility issues yourself -// #define NO_MSVC8_AUTO_COMPAT - -/** - * AMXX Init functions - * Also consider using FN_META_* - */ - -/** AMXX query */ -//#define FN_AMXX_QUERY OnAmxxQuery - -/** AMXX attach - * Do native functions init here (MF_AddNatives) - */ -#define FN_AMXX_ATTACH OnAmxxAttach - -/** AMXX Detach (unload) */ -//#define FN_AMXX_DETACH OnAmxxDetach - -/** All plugins loaded - * Do forward functions init here (MF_RegisterForward) - */ -#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded - -/** All plugins are about to be unloaded */ -//#define FN_AMXX_PLUGINSUNLOADING OnPluginsUnloading - -/** All plugins are now unloaded */ -#define FN_AMXX_PLUGINSUNLOADED OnPluginsUnloaded - -/**** METAMOD ****/ -// If your module doesn't use metamod, you may close the file now :) -#ifdef USE_METAMOD -// ---- -// Hook Functions -// Uncomment these to be called -// You can also change the function name - -// - Metamod init functions -// Also consider using FN_AMXX_* -// Meta query -//#define FN_META_QUERY OnMetaQuery -// Meta attach -//#define FN_META_ATTACH OnMetaAttach -// Meta detach -//#define FN_META_DETACH OnMetaDetach - -// (wd) are Will Day's notes -// - GetEntityAPI2 functions -// #define FN_GameDLLInit GameDLLInit /* pfnGameInit() */ -//#define FN_DispatchSpawn DispatchSpawn /* pfnSpawn() */ -// #define FN_DispatchThink DispatchThink /* pfnThink() */ -// #define FN_DispatchUse DispatchUse /* pfnUse() */ -// #define FN_DispatchTouch DispatchTouch /* pfnTouch() */ -// #define FN_DispatchBlocked DispatchBlocked /* pfnBlocked() */ -//#define FN_DispatchKeyValue DispatchKeyValue /* pfnKeyValue() */ -// #define FN_DispatchSave DispatchSave /* pfnSave() */ -// #define FN_DispatchRestore DispatchRestore /* pfnRestore() */ -// #define FN_DispatchObjectCollsionBox DispatchObjectCollsionBox /* pfnSetAbsBox() */ -// #define FN_SaveWriteFields SaveWriteFields /* pfnSaveWriteFields() */ -// #define FN_SaveReadFields SaveReadFields /* pfnSaveReadFields() */ -// #define FN_SaveGlobalState SaveGlobalState /* pfnSaveGlobalState() */ -// #define FN_RestoreGlobalState RestoreGlobalState /* pfnRestoreGlobalState() */ -// #define FN_ResetGlobalState ResetGlobalState /* pfnResetGlobalState() */ -//#define FN_ClientConnect ClientConnect /* pfnClientConnect() (wd) Client has connected */ -//#define FN_ClientDisconnect ClientDisconnect /* pfnClientDisconnect() (wd) Player has left the game */ -// #define FN_ClientKill ClientKill /* pfnClientKill() (wd) Player has typed "kill" */ -// #define FN_ClientPutInServer ClientPutInServer /* pfnClientPutInServer() (wd) Client is entering the game */ -// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */ -// #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */ -//#define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */ -//#define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */ -// #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */ -// #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */ -// #define FN_StartFrame StartFrame /* pfnStartFrame() */ -// #define FN_ParmsNewLevel ParmsNewLevel /* pfnParmsNewLevel() */ -// #define FN_ParmsChangeLevel ParmsChangeLevel /* pfnParmsChangeLevel() */ -// #define FN_GetGameDescription GetGameDescription /* pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2" "Half-Life" */ -// #define FN_PlayerCustomization PlayerCustomization /* pfnPlayerCustomization() Notifies .dll of new customization for player. */ -// #define FN_SpectatorConnect SpectatorConnect /* pfnSpectatorConnect() Called when spectator joins server */ -// #define FN_SpectatorDisconnect SpectatorDisconnect /* pfnSpectatorDisconnect() Called when spectator leaves the server */ -// #define FN_SpectatorThink SpectatorThink /* pfnSpectatorThink() Called when spectator sends a command packet (usercmd_t) */ -// #define FN_Sys_Error Sys_Error /* pfnSys_Error() Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. SDK2 */ -// #define FN_PM_Move PM_Move /* pfnPM_Move() (wd) SDK2 */ -// #define FN_PM_Init PM_Init /* pfnPM_Init() Server version of player movement initialization; (wd) SDK2 */ -// #define FN_PM_FindTextureType PM_FindTextureType /* pfnPM_FindTextureType() (wd) SDK2 */ -// #define FN_SetupVisibility SetupVisibility /* pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2 */ -// #define FN_UpdateClientData UpdateClientData /* pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2 */ -// #define FN_AddToFullPack AddToFullPack /* pfnAddToFullPack() (wd) SDK2 */ -// #define FN_CreateBaseline CreateBaseline /* pfnCreateBaseline() Tweak entity baseline for network encoding allows setup of player baselines too.; (wd) SDK2 */ -// #define FN_RegisterEncoders RegisterEncoders /* pfnRegisterEncoders() Callbacks for network encoding; (wd) SDK2 */ -// #define FN_GetWeaponData GetWeaponData /* pfnGetWeaponData() (wd) SDK2 */ -// #define FN_CmdStart CmdStart /* pfnCmdStart() (wd) SDK2 */ -// #define FN_CmdEnd CmdEnd /* pfnCmdEnd() (wd) SDK2 */ -// #define FN_ConnectionlessPacket ConnectionlessPacket /* pfnConnectionlessPacket() (wd) SDK2 */ -// #define FN_GetHullBounds GetHullBounds /* pfnGetHullBounds() (wd) SDK2 */ -// #define FN_CreateInstancedBaselines CreateInstancedBaselines /* pfnCreateInstancedBaselines() (wd) SDK2 */ -// #define FN_InconsistentFile InconsistentFile /* pfnInconsistentFile() (wd) SDK2 */ -// #define FN_AllowLagCompensation AllowLagCompensation /* pfnAllowLagCompensation() (wd) SDK2 */ - -// - GetEntityAPI2_Post functions -// #define FN_GameDLLInit_Post GameDLLInit_Post -// #define FN_DispatchSpawn_Post DispatchSpawn_Post -// #define FN_DispatchThink_Post DispatchThink_Post -// #define FN_DispatchUse_Post DispatchUse_Post -// #define FN_DispatchTouch_Post DispatchTouch_Post -// #define FN_DispatchBlocked_Post DispatchBlocked_Post -// #define FN_DispatchKeyValue_Post DispatchKeyValue_Post -// #define FN_DispatchSave_Post DispatchSave_Post -// #define FN_DispatchRestore_Post DispatchRestore_Post -// #define FN_DispatchObjectCollsionBox_Post DispatchObjectCollsionBox_Post -// #define FN_SaveWriteFields_Post SaveWriteFields_Post -// #define FN_SaveReadFields_Post SaveReadFields_Post -// #define FN_SaveGlobalState_Post SaveGlobalState_Post -// #define FN_RestoreGlobalState_Post RestoreGlobalState_Post -// #define FN_ResetGlobalState_Post ResetGlobalState_Post -// #define FN_ClientConnect_Post ClientConnect_Post -// #define FN_ClientDisconnect_Post ClientDisconnect_Post -// #define FN_ClientKill_Post ClientKill_Post -// #define FN_ClientPutInServer_Post ClientPutInServer_Post -// #define FN_ClientCommand_Post ClientCommand_Post -// #define FN_ClientUserInfoChanged_Post ClientUserInfoChanged_Post -//#define FN_ServerActivate_Post ServerActivate_Post -// #define FN_ServerDeactivate_Post ServerDeactivate_Post -// #define FN_PlayerPreThink_Post PlayerPreThink_Post -// #define FN_PlayerPostThink_Post PlayerPostThink_Post -// #define FN_StartFrame_Post StartFrame_Post -// #define FN_ParmsNewLevel_Post ParmsNewLevel_Post -// #define FN_ParmsChangeLevel_Post ParmsChangeLevel_Post -// #define FN_GetGameDescription_Post GetGameDescription_Post -// #define FN_PlayerCustomization_Post PlayerCustomization_Post -// #define FN_SpectatorConnect_Post SpectatorConnect_Post -// #define FN_SpectatorDisconnect_Post SpectatorDisconnect_Post -// #define FN_SpectatorThink_Post SpectatorThink_Post -// #define FN_Sys_Error_Post Sys_Error_Post -// #define FN_PM_Move_Post PM_Move_Post -// #define FN_PM_Init_Post PM_Init_Post -// #define FN_PM_FindTextureType_Post PM_FindTextureType_Post -// #define FN_SetupVisibility_Post SetupVisibility_Post -// #define FN_UpdateClientData_Post UpdateClientData_Post -// #define FN_AddToFullPack_Post AddToFullPack_Post -// #define FN_CreateBaseline_Post CreateBaseline_Post -// #define FN_RegisterEncoders_Post RegisterEncoders_Post -// #define FN_GetWeaponData_Post GetWeaponData_Post -// #define FN_CmdStart_Post CmdStart_Post -// #define FN_CmdEnd_Post CmdEnd_Post -// #define FN_ConnectionlessPacket_Post ConnectionlessPacket_Post -// #define FN_GetHullBounds_Post GetHullBounds_Post -// #define FN_CreateInstancedBaselines_Post CreateInstancedBaselines_Post -// #define FN_InconsistentFile_Post InconsistentFile_Post -// #define FN_AllowLagCompensation_Post AllowLagCompensation_Post - -// - GetEngineAPI functions -// #define FN_PrecacheModel PrecacheModel -// #define FN_PrecacheSound PrecacheSound -// #define FN_SetModel SetModel -// #define FN_ModelIndex ModelIndex -// #define FN_ModelFrames ModelFrames -// #define FN_SetSize SetSize -// #define FN_ChangeLevel ChangeLevel -// #define FN_GetSpawnParms GetSpawnParms -// #define FN_SaveSpawnParms SaveSpawnParms -// #define FN_VecToYaw VecToYaw -// #define FN_VecToAngles VecToAngles -// #define FN_MoveToOrigin MoveToOrigin -// #define FN_ChangeYaw ChangeYaw -// #define FN_ChangePitch ChangePitch -// #define FN_FindEntityByString FindEntityByString -// #define FN_GetEntityIllum GetEntityIllum -// #define FN_FindEntityInSphere FindEntityInSphere -// #define FN_FindClientInPVS FindClientInPVS -// #define FN_EntitiesInPVS EntitiesInPVS -// #define FN_MakeVectors MakeVectors -// #define FN_AngleVectors AngleVectors -// #define FN_CreateEntity CreateEntity -// #define FN_RemoveEntity RemoveEntity -// #define FN_CreateNamedEntity CreateNamedEntity -// #define FN_MakeStatic MakeStatic -// #define FN_EntIsOnFloor EntIsOnFloor -// #define FN_DropToFloor DropToFloor -// #define FN_WalkMove WalkMove -// #define FN_SetOrigin SetOrigin -// #define FN_EmitSound EmitSound -// #define FN_EmitAmbientSound EmitAmbientSound -// #define FN_TraceLine TraceLine -// #define FN_TraceToss TraceToss -// #define FN_TraceMonsterHull TraceMonsterHull -// #define FN_TraceHull TraceHull -// #define FN_TraceModel TraceModel -// #define FN_TraceTexture TraceTexture -// #define FN_TraceSphere TraceSphere -// #define FN_GetAimVector GetAimVector -// #define FN_ServerCommand ServerCommand -// #define FN_ServerExecute ServerExecute -// #define FN_engClientCommand engClientCommand -// #define FN_ParticleEffect ParticleEffect -// #define FN_LightStyle LightStyle -// #define FN_DecalIndex DecalIndex -// #define FN_PointContents PointContents -// #define FN_MessageBegin MessageBegin -// #define FN_MessageEnd MessageEnd -// #define FN_WriteByte WriteByte -// #define FN_WriteChar WriteChar -// #define FN_WriteShort WriteShort -// #define FN_WriteLong WriteLong -// #define FN_WriteAngle WriteAngle -// #define FN_WriteCoord WriteCoord -// #define FN_WriteString WriteString -// #define FN_WriteEntity WriteEntity -// #define FN_CVarRegister CVarRegister -// #define FN_CVarGetFloat CVarGetFloat -// #define FN_CVarGetString CVarGetString -// #define FN_CVarSetFloat CVarSetFloat -// #define FN_CVarSetString CVarSetString -// #define FN_AlertMessage AlertMessage -// #define FN_EngineFprintf EngineFprintf -// #define FN_PvAllocEntPrivateData PvAllocEntPrivateData -// #define FN_PvEntPrivateData PvEntPrivateData -// #define FN_FreeEntPrivateData FreeEntPrivateData -// #define FN_SzFromIndex SzFromIndex -// #define FN_AllocString AllocString -// #define FN_GetVarsOfEnt GetVarsOfEnt -// #define FN_PEntityOfEntOffset PEntityOfEntOffset -// #define FN_EntOffsetOfPEntity EntOffsetOfPEntity -// #define FN_IndexOfEdict IndexOfEdict -// #define FN_PEntityOfEntIndex PEntityOfEntIndex -// #define FN_FindEntityByVars FindEntityByVars -// #define FN_GetModelPtr GetModelPtr -// #define FN_RegUserMsg RegUserMsg -// #define FN_AnimationAutomove AnimationAutomove -// #define FN_GetBonePosition GetBonePosition -// #define FN_FunctionFromName FunctionFromName -// #define FN_NameForFunction NameForFunction -// #define FN_ClientPrintf ClientPrintf -// #define FN_ServerPrint ServerPrint -// #define FN_Cmd_Args Cmd_Args -// #define FN_Cmd_Argv Cmd_Argv -// #define FN_Cmd_Argc Cmd_Argc -// #define FN_GetAttachment GetAttachment -// #define FN_CRC32_Init CRC32_Init -// #define FN_CRC32_ProcessBuffer CRC32_ProcessBuffer -// #define FN_CRC32_ProcessByte CRC32_ProcessByte -// #define FN_CRC32_Final CRC32_Final -// #define FN_RandomLong RandomLong -// #define FN_RandomFloat RandomFloat -// #define FN_SetView SetView -// #define FN_Time Time -// #define FN_CrosshairAngle CrosshairAngle -// #define FN_LoadFileForMe LoadFileForMe -// #define FN_FreeFile FreeFile -// #define FN_EndSection EndSection -// #define FN_CompareFileTime CompareFileTime -// #define FN_GetGameDir GetGameDir -// #define FN_Cvar_RegisterVariable Cvar_RegisterVariable -// #define FN_FadeClientVolume FadeClientVolume -// #define FN_SetClientMaxspeed SetClientMaxspeed -// #define FN_CreateFakeClient CreateFakeClient -// #define FN_RunPlayerMove RunPlayerMove -// #define FN_NumberOfEntities NumberOfEntities -// #define FN_GetInfoKeyBuffer GetInfoKeyBuffer -// #define FN_InfoKeyValue InfoKeyValue -// #define FN_SetKeyValue SetKeyValue -// #define FN_SetClientKeyValue SetClientKeyValue -// #define FN_IsMapValid IsMapValid -// #define FN_StaticDecal StaticDecal -// #define FN_PrecacheGeneric PrecacheGeneric -// #define FN_GetPlayerUserId GetPlayerUserId -// #define FN_BuildSoundMsg BuildSoundMsg -// #define FN_IsDedicatedServer IsDedicatedServer -// #define FN_CVarGetPointer CVarGetPointer -// #define FN_GetPlayerWONId GetPlayerWONId -// #define FN_Info_RemoveKey Info_RemoveKey -// #define FN_GetPhysicsKeyValue GetPhysicsKeyValue -// #define FN_SetPhysicsKeyValue SetPhysicsKeyValue -// #define FN_GetPhysicsInfoString GetPhysicsInfoString -// #define FN_PrecacheEvent PrecacheEvent -// #define FN_PlaybackEvent PlaybackEvent -// #define FN_SetFatPVS SetFatPVS -// #define FN_SetFatPAS SetFatPAS -// #define FN_CheckVisibility CheckVisibility -// #define FN_DeltaSetField DeltaSetField -// #define FN_DeltaUnsetField DeltaUnsetField -// #define FN_DeltaAddEncoder DeltaAddEncoder -// #define FN_GetCurrentPlayer GetCurrentPlayer -// #define FN_CanSkipPlayer CanSkipPlayer -// #define FN_DeltaFindField DeltaFindField -// #define FN_DeltaSetFieldByIndex DeltaSetFieldByIndex -// #define FN_DeltaUnsetFieldByIndex DeltaUnsetFieldByIndex -// #define FN_SetGroupMask SetGroupMask -// #define FN_engCreateInstancedBaseline engCreateInstancedBaseline -// #define FN_Cvar_DirectSet Cvar_DirectSet -// #define FN_ForceUnmodified ForceUnmodified -// #define FN_GetPlayerStats GetPlayerStats -// #define FN_AddServerCommand AddServerCommand -// #define FN_Voice_GetClientListening Voice_GetClientListening -// #define FN_Voice_SetClientListening Voice_SetClientListening -// #define FN_GetPlayerAuthId GetPlayerAuthId - -// - GetEngineAPI_Post functions -// #define FN_PrecacheModel_Post PrecacheModel_Post -// #define FN_PrecacheSound_Post PrecacheSound_Post -// #define FN_SetModel_Post SetModel_Post -// #define FN_ModelIndex_Post ModelIndex_Post -// #define FN_ModelFrames_Post ModelFrames_Post -// #define FN_SetSize_Post SetSize_Post -// #define FN_ChangeLevel_Post ChangeLevel_Post -// #define FN_GetSpawnParms_Post GetSpawnParms_Post -// #define FN_SaveSpawnParms_Post SaveSpawnParms_Post -// #define FN_VecToYaw_Post VecToYaw_Post -// #define FN_VecToAngles_Post VecToAngles_Post -// #define FN_MoveToOrigin_Post MoveToOrigin_Post -// #define FN_ChangeYaw_Post ChangeYaw_Post -// #define FN_ChangePitch_Post ChangePitch_Post -// #define FN_FindEntityByString_Post FindEntityByString_Post -// #define FN_GetEntityIllum_Post GetEntityIllum_Post -// #define FN_FindEntityInSphere_Post FindEntityInSphere_Post -// #define FN_FindClientInPVS_Post FindClientInPVS_Post -// #define FN_EntitiesInPVS_Post EntitiesInPVS_Post -// #define FN_MakeVectors_Post MakeVectors_Post -// #define FN_AngleVectors_Post AngleVectors_Post -// #define FN_CreateEntity_Post CreateEntity_Post -// #define FN_RemoveEntity_Post RemoveEntity_Post -// #define FN_CreateNamedEntity_Post CreateNamedEntity_Post -// #define FN_MakeStatic_Post MakeStatic_Post -// #define FN_EntIsOnFloor_Post EntIsOnFloor_Post -// #define FN_DropToFloor_Post DropToFloor_Post -// #define FN_WalkMove_Post WalkMove_Post -// #define FN_SetOrigin_Post SetOrigin_Post -// #define FN_EmitSound_Post EmitSound_Post -// #define FN_EmitAmbientSound_Post EmitAmbientSound_Post -// #define FN_TraceLine_Post TraceLine_Post -// #define FN_TraceToss_Post TraceToss_Post -// #define FN_TraceMonsterHull_Post TraceMonsterHull_Post -// #define FN_TraceHull_Post TraceHull_Post -// #define FN_TraceModel_Post TraceModel_Post -// #define FN_TraceTexture_Post TraceTexture_Post -// #define FN_TraceSphere_Post TraceSphere_Post -// #define FN_GetAimVector_Post GetAimVector_Post -// #define FN_ServerCommand_Post ServerCommand_Post -// #define FN_ServerExecute_Post ServerExecute_Post -// #define FN_engClientCommand_Post engClientCommand_Post -// #define FN_ParticleEffect_Post ParticleEffect_Post -// #define FN_LightStyle_Post LightStyle_Post -// #define FN_DecalIndex_Post DecalIndex_Post -// #define FN_PointContents_Post PointContents_Post -// #define FN_MessageBegin_Post MessageBegin_Post -// #define FN_MessageEnd_Post MessageEnd_Post -// #define FN_WriteByte_Post WriteByte_Post -// #define FN_WriteChar_Post WriteChar_Post -// #define FN_WriteShort_Post WriteShort_Post -// #define FN_WriteLong_Post WriteLong_Post -// #define FN_WriteAngle_Post WriteAngle_Post -// #define FN_WriteCoord_Post WriteCoord_Post -// #define FN_WriteString_Post WriteString_Post -// #define FN_WriteEntity_Post WriteEntity_Post -// #define FN_CVarRegister_Post CVarRegister_Post -// #define FN_CVarGetFloat_Post CVarGetFloat_Post -// #define FN_CVarGetString_Post CVarGetString_Post -// #define FN_CVarSetFloat_Post CVarSetFloat_Post -// #define FN_CVarSetString_Post CVarSetString_Post -// #define FN_AlertMessage_Post AlertMessage_Post -// #define FN_EngineFprintf_Post EngineFprintf_Post -// #define FN_PvAllocEntPrivateData_Post PvAllocEntPrivateData_Post -// #define FN_PvEntPrivateData_Post PvEntPrivateData_Post -// #define FN_FreeEntPrivateData_Post FreeEntPrivateData_Post -// #define FN_SzFromIndex_Post SzFromIndex_Post -// #define FN_AllocString_Post AllocString_Post -// #define FN_GetVarsOfEnt_Post GetVarsOfEnt_Post -// #define FN_PEntityOfEntOffset_Post PEntityOfEntOffset_Post -// #define FN_EntOffsetOfPEntity_Post EntOffsetOfPEntity_Post -// #define FN_IndexOfEdict_Post IndexOfEdict_Post -// #define FN_PEntityOfEntIndex_Post PEntityOfEntIndex_Post -// #define FN_FindEntityByVars_Post FindEntityByVars_Post -// #define FN_GetModelPtr_Post GetModelPtr_Post -// #define FN_RegUserMsg_Post RegUserMsg_Post -// #define FN_AnimationAutomove_Post AnimationAutomove_Post -// #define FN_GetBonePosition_Post GetBonePosition_Post -// #define FN_FunctionFromName_Post FunctionFromName_Post -// #define FN_NameForFunction_Post NameForFunction_Post -// #define FN_ClientPrintf_Post ClientPrintf_Post -// #define FN_ServerPrint_Post ServerPrint_Post -// #define FN_Cmd_Args_Post Cmd_Args_Post -// #define FN_Cmd_Argv_Post Cmd_Argv_Post -// #define FN_Cmd_Argc_Post Cmd_Argc_Post -// #define FN_GetAttachment_Post GetAttachment_Post -// #define FN_CRC32_Init_Post CRC32_Init_Post -// #define FN_CRC32_ProcessBuffer_Post CRC32_ProcessBuffer_Post -// #define FN_CRC32_ProcessByte_Post CRC32_ProcessByte_Post -// #define FN_CRC32_Final_Post CRC32_Final_Post -// #define FN_RandomLong_Post RandomLong_Post -// #define FN_RandomFloat_Post RandomFloat_Post -// #define FN_SetView_Post SetView_Post -// #define FN_Time_Post Time_Post -// #define FN_CrosshairAngle_Post CrosshairAngle_Post -// #define FN_LoadFileForMe_Post LoadFileForMe_Post -// #define FN_FreeFile_Post FreeFile_Post -// #define FN_EndSection_Post EndSection_Post -// #define FN_CompareFileTime_Post CompareFileTime_Post -// #define FN_GetGameDir_Post GetGameDir_Post -// #define FN_Cvar_RegisterVariable_Post Cvar_RegisterVariable_Post -// #define FN_FadeClientVolume_Post FadeClientVolume_Post -// #define FN_SetClientMaxspeed_Post SetClientMaxspeed_Post -// #define FN_CreateFakeClient_Post CreateFakeClient_Post -// #define FN_RunPlayerMove_Post RunPlayerMove_Post -// #define FN_NumberOfEntities_Post NumberOfEntities_Post -// #define FN_GetInfoKeyBuffer_Post GetInfoKeyBuffer_Post -// #define FN_InfoKeyValue_Post InfoKeyValue_Post -// #define FN_SetKeyValue_Post SetKeyValue_Post -// #define FN_SetClientKeyValue_Post SetClientKeyValue_Post -// #define FN_IsMapValid_Post IsMapValid_Post -// #define FN_StaticDecal_Post StaticDecal_Post -// #define FN_PrecacheGeneric_Post PrecacheGeneric_Post -// #define FN_GetPlayerUserId_Post GetPlayerUserId_Post -// #define FN_BuildSoundMsg_Post BuildSoundMsg_Post -// #define FN_IsDedicatedServer_Post IsDedicatedServer_Post -// #define FN_CVarGetPointer_Post CVarGetPointer_Post -// #define FN_GetPlayerWONId_Post GetPlayerWONId_Post -// #define FN_Info_RemoveKey_Post Info_RemoveKey_Post -// #define FN_GetPhysicsKeyValue_Post GetPhysicsKeyValue_Post -// #define FN_SetPhysicsKeyValue_Post SetPhysicsKeyValue_Post -// #define FN_GetPhysicsInfoString_Post GetPhysicsInfoString_Post -//#define FN_PrecacheEvent_Post PrecacheEvent_Post -// #define FN_PlaybackEvent_Post PlaybackEvent_Post -// #define FN_SetFatPVS_Post SetFatPVS_Post -// #define FN_SetFatPAS_Post SetFatPAS_Post -// #define FN_CheckVisibility_Post CheckVisibility_Post -// #define FN_DeltaSetField_Post DeltaSetField_Post -// #define FN_DeltaUnsetField_Post DeltaUnsetField_Post -// #define FN_DeltaAddEncoder_Post DeltaAddEncoder_Post -// #define FN_GetCurrentPlayer_Post GetCurrentPlayer_Post -// #define FN_CanSkipPlayer_Post CanSkipPlayer_Post -// #define FN_DeltaFindField_Post DeltaFindField_Post -// #define FN_DeltaSetFieldByIndex_Post DeltaSetFieldByIndex_Post -// #define FN_DeltaUnsetFieldByIndex_Post DeltaUnsetFieldByIndex_Post -// #define FN_SetGroupMask_Post SetGroupMask_Post -// #define FN_engCreateInstancedBaseline_Post engCreateInstancedBaseline_Post -// #define FN_Cvar_DirectSet_Post Cvar_DirectSet_Post -// #define FN_ForceUnmodified_Post ForceUnmodified_Post -// #define FN_GetPlayerStats_Post GetPlayerStats_Post -// #define FN_AddServerCommand_Post AddServerCommand_Post -// #define FN_Voice_GetClientListening_Post Voice_GetClientListening_Post -// #define FN_Voice_SetClientListening_Post Voice_SetClientListening_Post -// #define FN_GetPlayerAuthId_Post GetPlayerAuthId_Post - -// #define FN_OnFreeEntPrivateData OnFreeEntPrivateData -// #define FN_GameShutdown GameShutdown -// #define FN_ShouldCollide ShouldCollide - -// #define FN_OnFreeEntPrivateData_Post OnFreeEntPrivateData_Post -// #define FN_GameShutdown_Post GameShutdown_Post -// #define FN_ShouldCollide_Post ShouldCollide_Post - - -#endif // USE_METAMOD - -#endif // __MODULECONFIG_H__ diff --git a/dlls/hamsandwich/tableentries/AddPlayerItem.cpp b/dlls/hamsandwich/tableentries/AddPlayerItem.cpp deleted file mode 100644 index 844e6352..00000000 --- a/dlls/hamsandwich/tableentries/AddPlayerItem.cpp +++ /dev/null @@ -1,371 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableAddPlayerItem -#define ThisEntries AddPlayerItemEntries - -#define ThisKey "addplayeritem" -#define ThisNative "ham_addplayeritem" -#define ThisENative "ham_eaddplayeritem" -#define ThisRegisterID HAM_AddPlayerItem -#define ThisParamCount 1 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0, /*fastcall buffer*/ - INDEXENT_NEW(params[2])->pvPrivateData /*item*/ - ); -#else - return reinterpret_cast(func)( - pthis, /*this*/ - INDEXENT_NEW(params[2])->pvPrivateData /*item*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall1( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - INDEXENT_NEW(params[3])->pvPrivateData /*item*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_CELL/*item*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param inflictor Damage inflictor. - * @param attacker The attacker who caused the inflictor to damage the victim. - * @param damage How much damage was caused. - * @param type Damage type (usually in bitmask form). - * @return Unsure. Does not appear to be used. - */ -int ThisVTable::Execute(void *pthis, void *item) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - int iItem=PrivateToIndex(item); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0,item); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis,item); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis,item); -} diff --git a/dlls/hamsandwich/tableentries/AddPoints.cpp b/dlls/hamsandwich/tableentries/AddPoints.cpp deleted file mode 100644 index 346299bf..00000000 --- a/dlls/hamsandwich/tableentries/AddPoints.cpp +++ /dev/null @@ -1,363 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableAddPoints -#define ThisEntries AddPointsEntries -#define ThisKey "addpoints" -#define ThisNative "ham_addpoints" -#define ThisENative "ham_eaddpoints" -#define ThisRegisterID HAM_AddPoints -#define ThisParamCount 0 -#define ThisVoidCall 1 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - return; - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - // class was not found - // throw an error alerting console that this hook did not happen - char *function=MF_GetAmxString(amx,params[2],0,NULL); - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - reinterpret_cast(func)( - pthis, /*this*/ - 0, /*fastcall buffer*/ - params[2], - params[3] - ); -#else - reinterpret_cast(func)( - pthis, /*this*/ - params[2], - params[3] - ); -#endif - return 0; -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - VoidVCall2( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - params[2], - params[3] - ); - return 1; -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_CELL,FP_CELL,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @return Unsure. Does not appear to be used. - */ -void ThisVTable::Execute(void *pthis,int points, int allownegative) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - - if (result(function)(pthis,0,points,allownegative); -#elif defined __linux__ - reinterpret_cast(function)(pthis,points,allownegative); -#endif - } - - i=0; - end=PostForwards.size(); - - while (iExecute(pthis,points,allownegative); -} diff --git a/dlls/hamsandwich/tableentries/AddPointsToTeam.cpp b/dlls/hamsandwich/tableentries/AddPointsToTeam.cpp deleted file mode 100644 index 04a2a81a..00000000 --- a/dlls/hamsandwich/tableentries/AddPointsToTeam.cpp +++ /dev/null @@ -1,362 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableAddPointsToTeam -#define ThisEntries AddPointsToTeamEntries -#define ThisKey "addpointstoteam" -#define ThisNative "ham_addpointstoteam" -#define ThisENative "ham_eaddpointstoteam" -#define ThisRegisterID HAM_AddPointsToTeam -#define ThisParamCount 2 -#define ThisVoidCall 1 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - // class was not found - // throw an error alerting console that this hook did not happen - char *function=MF_GetAmxString(amx,params[2],0,NULL); - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - reinterpret_cast(func)( - pthis, /*this*/ - 0, /*fastcall buffer*/ - params[2], - params[3] - ); -#else - reinterpret_cast(func)( - pthis, /*this*/ - params[2], - params[3] - ); -#endif - return 0; -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - VoidVCall2( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - params[2], - params[3] - ); - return 1; -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_CELL,FP_CELL,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @return Unsure. Does not appear to be used. - */ -void ThisVTable::Execute(void *pthis,int points, int allownegative) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - - if (result(function)(pthis,0,points,allownegative); -#elif defined __linux__ - reinterpret_cast(function)(pthis,points,allownegative); -#endif - } - - i=0; - end=PostForwards.size(); - - while (iExecute(pthis,points,allownegative); -} diff --git a/dlls/hamsandwich/tableentries/Blocked.cpp b/dlls/hamsandwich/tableentries/Blocked.cpp deleted file mode 100644 index ae0e86eb..00000000 --- a/dlls/hamsandwich/tableentries/Blocked.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableBlocked -#define ThisEntries BlockedEntries - -#define ThisKey "blocked" -#define ThisNative "ham_blocked" -#define ThisENative "ham_eblocked" -#define ThisRegisterID HAM_Blocked -#define ThisParamCount 1 -#define ThisVoidCall 1 - - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - // class was not found - // throw an error alerting console that this hook did not happen - char *function=MF_GetAmxString(amx,params[2],0,NULL); - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - reinterpret_cast(func)( - pthis, /*this*/ - 0, /*fastcall buffer*/ - INDEXENT_NEW(params[2])->pvPrivateData /*other*/ - ); -#else - reinterpret_cast(func)( - pthis, /*this*/ - INDEXENT_NEW(params[2])->pvPrivateData /*other*/ - ); -#endif - return 1; -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - VoidVCall1( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - INDEXENT_NEW(params[2])->pvPrivateData /*other*/ - ); - - return 1; -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_CELL/*other*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param activator Entity causing the opening. - * @param caller Entity controlling the caller. - * @param type USE_TYPE (USE_{ON,OFF,SET} - * @param value Use value, only seen set when USE_SET is used. - * @noreturn - */ -void ThisVTable::Execute(void *pthis, void *other) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - int iOther=PrivateToIndex(other); - - while (iresult) - { - result=thisresult; - } - }; - - if (result(function)(pthis,0,other); -#elif defined __linux__ - reinterpret_cast(function)(pthis,other); -#endif - } - - i=0; - end=PostForwards.size(); - while (iExecute(pthis,other); -} diff --git a/dlls/hamsandwich/tableentries/BloodColor.cpp b/dlls/hamsandwich/tableentries/BloodColor.cpp deleted file mode 100644 index e5a06596..00000000 --- a/dlls/hamsandwich/tableentries/BloodColor.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableBloodColor -#define ThisEntries BloodColorEntries - -#define ThisKey "bloodcolor" -#define ThisNative "ham_bloodcolor" -#define ThisENative "ham_ebloodcolor" -#define ThisRegisterID HAM_BloodColor -#define ThisParamCount 0 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - return reinterpret_cast(func)( - pthis /*this*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ -int ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/Classify.cpp b/dlls/hamsandwich/tableentries/Classify.cpp deleted file mode 100644 index 01cda95c..00000000 --- a/dlls/hamsandwich/tableentries/Classify.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableClassify -#define ThisEntries ClassifyEntries - -#define ThisKey "classify" -#define ThisNative "ham_classify" -#define ThisENative "ham_eclassify" -#define ThisRegisterID HAM_Classify -#define ThisParamCount 0 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - return reinterpret_cast(func)( - pthis /*this*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ -int ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/GetToggleState.cpp b/dlls/hamsandwich/tableentries/GetToggleState.cpp deleted file mode 100644 index a7a60073..00000000 --- a/dlls/hamsandwich/tableentries/GetToggleState.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableGetToggleState -#define ThisEntries GetToggleStateEntries - -#define ThisKey "gettogglestate" -#define ThisNative "ham_gettogglestate" -#define ThisENative "ham_egettogglestate" -#define ThisRegisterID HAM_GetToggleState -#define ThisParamCount 0 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - return reinterpret_cast(func)( - pthis /*this*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ -int ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/IsAlive.cpp b/dlls/hamsandwich/tableentries/IsAlive.cpp deleted file mode 100644 index 36be3632..00000000 --- a/dlls/hamsandwich/tableentries/IsAlive.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableIsAlive -#define ThisEntries IsAliveEntries - -#define ThisKey "isalive" -#define ThisNative "ham_isalive" -#define ThisENative "ham_eisalive" -#define ThisRegisterID HAM_IsAlive -#define ThisParamCount 0 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - return reinterpret_cast(func)( - pthis /*this*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ -int ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/IsBSPModel.cpp b/dlls/hamsandwich/tableentries/IsBSPModel.cpp deleted file mode 100644 index e66c8a93..00000000 --- a/dlls/hamsandwich/tableentries/IsBSPModel.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableIsBSPModel -#define ThisEntries IsBSPModelEntries - -#define ThisKey "isbspmodel" -#define ThisNative "ham_isbspmodel" -#define ThisENative "ham_eisbspmodel" -#define ThisRegisterID HAM_IsBSPModel -#define ThisParamCount 0 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - return reinterpret_cast(func)( - pthis /*this*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ -int ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/IsInWorld.cpp b/dlls/hamsandwich/tableentries/IsInWorld.cpp deleted file mode 100644 index 1cb1bb44..00000000 --- a/dlls/hamsandwich/tableentries/IsInWorld.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableIsInWorld -#define ThisEntries IsInWorldEntries - -#define ThisKey "isinworld" -#define ThisNative "ham_isinworld" -#define ThisENative "ham_eisinworld" -#define ThisRegisterID HAM_IsInWorld -#define ThisParamCount 0 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - return reinterpret_cast(func)( - pthis /*this*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ -int ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/IsMoving.cpp b/dlls/hamsandwich/tableentries/IsMoving.cpp deleted file mode 100644 index 071fa891..00000000 --- a/dlls/hamsandwich/tableentries/IsMoving.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableIsMoving -#define ThisEntries IsMovingEntries - -#define ThisKey "ismoving" -#define ThisNative "ham_ismoving" -#define ThisENative "ham_eismoving" -#define ThisRegisterID HAM_IsMoving -#define ThisParamCount 0 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - return reinterpret_cast(func)( - pthis /*this*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ -int ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/IsNetClient.cpp b/dlls/hamsandwich/tableentries/IsNetClient.cpp deleted file mode 100644 index 8e20c080..00000000 --- a/dlls/hamsandwich/tableentries/IsNetClient.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableIsNetClient -#define ThisEntries IsNetClientEntries - -#define ThisKey "isnetclient" -#define ThisNative "ham_isnetclient" -#define ThisENative "ham_eisnetclient" -#define ThisRegisterID HAM_IsNetClient -#define ThisParamCount 0 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - return reinterpret_cast(func)( - pthis /*this*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ -int ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/IsPlayer.cpp b/dlls/hamsandwich/tableentries/IsPlayer.cpp deleted file mode 100644 index 7a18d2a2..00000000 --- a/dlls/hamsandwich/tableentries/IsPlayer.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableIsPlayer -#define ThisEntries IsPlayerEntries - -#define ThisKey "isplayer" -#define ThisNative "ham_isplayer" -#define ThisENative "ham_eisplayer" -#define ThisRegisterID HAM_IsPlayer -#define ThisParamCount 0 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - return reinterpret_cast(func)( - pthis /*this*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ -int ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/IsSneaking.cpp b/dlls/hamsandwich/tableentries/IsSneaking.cpp deleted file mode 100644 index 33320cff..00000000 --- a/dlls/hamsandwich/tableentries/IsSneaking.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableIsSneaking -#define ThisEntries IsSneakingEntries - -#define ThisKey "issneaking" -#define ThisNative "ham_issneaking" -#define ThisENative "ham_eissneaking" -#define ThisRegisterID HAM_IsSneaking -#define ThisParamCount 0 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - return reinterpret_cast(func)( - pthis /*this*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ -int ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/Killed.cpp b/dlls/hamsandwich/tableentries/Killed.cpp deleted file mode 100644 index 07de882a..00000000 --- a/dlls/hamsandwich/tableentries/Killed.cpp +++ /dev/null @@ -1,368 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableKilled -#define ThisEntries KilledEntries - -#define ThisKey "killed" -#define ThisNative "ham_killed" -#define ThisENative "ham_ekilled" -#define ThisRegisterID HAM_Killed -#define ThisParamCount 2 -#define ThisVoidCall 1 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - // class was not found - // throw an error alerting console that this hook did not happen - char *function=MF_GetAmxString(amx,params[2],0,NULL); - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0, /*fastcall buffer*/ - &(INDEXENT_NEW(params[2])->v), /*pevattacker*/ - (int)params[3] /*gib*/ - ); -#else - return reinterpret_cast(func)( - pthis, /*this*/ - &(INDEXENT_NEW(params[2])->v), /*pevattacker*/ - (int)params[3] /*gib*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - VoidVCall2( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*pevattacker*/ - (int)params[3] /*gib*/ - ); - return 1; -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_CELL/*attacker*/,FP_CELL/*gib*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param inflictor Damage inflictor. - * @param attacker The attacker who caused the inflictor to damage the victim. - * @param damage How much damage was caused. - * @param type Damage type (usually in bitmask form). - * @return Unsure. Does not appear to be used. - */ -void ThisVTable::Execute(void *pthis, void *attacker, int gib) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - int iAttacker=EntvarToIndex((entvars_t *)attacker); - - while (iresult) - { - result=thisresult; - } - }; - - if (result(function)(pthis,0,attacker,gib); -#elif defined __linux__ - reinterpret_cast(function)(pthis,attacker,gib); -#endif - } - - i=0; - end=PostForwards.size(); - - while (iExecute(pthis,attacker,gib); -} - diff --git a/dlls/hamsandwich/tableentries/ObjectCaps.cpp b/dlls/hamsandwich/tableentries/ObjectCaps.cpp deleted file mode 100644 index da31ab65..00000000 --- a/dlls/hamsandwich/tableentries/ObjectCaps.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableObjectCaps -#define ThisEntries ObjectCapsEntries - -#define ThisKey "objectcaps" -#define ThisNative "ham_objectcaps" -#define ThisENative "ham_eobjectcaps" -#define ThisRegisterID HAM_ObjectCaps -#define ThisParamCount 0 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - return reinterpret_cast(func)( - pthis /*this*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ -int ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/RemovePlayerItem.cpp b/dlls/hamsandwich/tableentries/RemovePlayerItem.cpp deleted file mode 100644 index 3836ef17..00000000 --- a/dlls/hamsandwich/tableentries/RemovePlayerItem.cpp +++ /dev/null @@ -1,371 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableRemovePlayerItem -#define ThisEntries RemovePlayerItemEntries - -#define ThisKey "removeplayeritem" -#define ThisNative "ham_removeplayeritem" -#define ThisENative "ham_eremoveplayeritem" -#define ThisRegisterID HAM_RemovePlayerItem -#define ThisParamCount 1 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0, /*fastcall buffer*/ - INDEXENT_NEW(params[2])->pvPrivateData /*item*/ - ); -#else - return reinterpret_cast(func)( - pthis, /*this*/ - INDEXENT_NEW(params[2])->pvPrivateData /*item*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall1( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - INDEXENT_NEW(params[3])->pvPrivateData /*item*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_CELL/*item*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param inflictor Damage inflictor. - * @param attacker The attacker who caused the inflictor to damage the victim. - * @param damage How much damage was caused. - * @param type Damage type (usually in bitmask form). - * @return Unsure. Does not appear to be used. - */ -int ThisVTable::Execute(void *pthis, void *item) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - int iItem=PrivateToIndex(item); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0,item); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis,item); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis,item); -} diff --git a/dlls/hamsandwich/tableentries/Respawn.cpp b/dlls/hamsandwich/tableentries/Respawn.cpp deleted file mode 100644 index b106f3dc..00000000 --- a/dlls/hamsandwich/tableentries/Respawn.cpp +++ /dev/null @@ -1,356 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableRespawn -#define ThisEntries RespawnEntries -#define ThisKey "respawn" -#define ThisNative "ham_respawn" -#define ThisENative "ham_erespawn" -#define ThisRegisterID HAM_Respawn -#define ThisParamCount 0 -#define ThisVoidCall 1 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - // class was not found - // throw an error alerting console that this hook did not happen - char *function=MF_GetAmxString(amx,params[2],0,NULL); - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return PrivateToIndex(reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - )); -#else - return PrivateToIndex(reinterpret_cast(func)( - pthis /*this*/ - )); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return PrivateToIndex(VCall0( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset) /*size of class*/ - )); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @return Pointer to the this object it seems? Pointless - */ -void *ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - - void *ret=NULL; - if (result(function)(pthis,0); -#elif defined __linux__ - ret=reinterpret_cast(function)(pthis); -#endif - } - - i=0; - end=PostForwards.size(); - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/Restart.cpp b/dlls/hamsandwich/tableentries/Restart.cpp deleted file mode 100644 index c862f7fb..00000000 --- a/dlls/hamsandwich/tableentries/Restart.cpp +++ /dev/null @@ -1,356 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableRestart -#define ThisEntries RestartEntries -#define ThisKey "restart" -#define ThisNative "ham_restart" -#define ThisENative "ham_erestart" -#define ThisRegisterID HAM_Restart -#define ThisParamCount 0 -#define ThisVoidCall 1 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - // class was not found - // throw an error alerting console that this hook did not happen - char *function=MF_GetAmxString(amx,params[2],0,NULL); - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - reinterpret_cast(func)( - pthis /*this*/ - ); -#endif - return 0; -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - VoidVCall0( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset) /*size of class*/ - ); - return 1; -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - 0, // param count - 1, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @return Unsure. Does not appear to be used. - */ -void ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - - if (result(function)(pthis,0); -#elif defined __linux__ - reinterpret_cast(function)(pthis); -#endif - } - - i=0; - end=PostForwards.size(); - - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/TakeDamage.cpp b/dlls/hamsandwich/tableentries/TakeDamage.cpp deleted file mode 100644 index 6010db8a..00000000 --- a/dlls/hamsandwich/tableentries/TakeDamage.cpp +++ /dev/null @@ -1,381 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableTakeDamage -#define ThisEntries TakeDamageEntries - -#define ThisKey "takedamage" -#define ThisNative "ham_takedamage" -#define ThisENative "ham_etakedamage" -#define ThisRegisterID HAM_TakeDamage -#define ThisParamCount 4 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - //MF_AddNatives(registernatives); - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0, /*fastcall buffer*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -#else - return reinterpret_cast(func)( - pthis, /*this*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_CELL/*inflictor*/,FP_CELL/*attacker*/,FP_CELL/*damage*/,FP_CELL/*type*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param inflictor Damage inflictor. - * @param attacker The attacker who caused the inflictor to damage the victim. - * @param damage How much damage was caused. - * @param type Damage type (usually in bitmask form). - * @return Unsure. Does not appear to be used. - */ -int ThisVTable::Execute(void *pthis, void *inflictor, void *attacker, float damage, int type) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - int iInflictor=EntvarToIndex((entvars_t *)inflictor); - int iAttacker=EntvarToIndex((entvars_t *)attacker); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0,inflictor,attacker,damage,type); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis,inflictor,attacker,damage,type); -#endif - } - - i=0; - - end=PostForwards.size(); - while (iExecute(pthis,inflictor,attacker,damage,type); -} diff --git a/dlls/hamsandwich/tableentries/TakeHealth.cpp b/dlls/hamsandwich/tableentries/TakeHealth.cpp deleted file mode 100644 index c59a4578..00000000 --- a/dlls/hamsandwich/tableentries/TakeHealth.cpp +++ /dev/null @@ -1,374 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableTakeHealth -#define ThisEntries TakeHealthEntries - -#define ThisKey "takehealth" -#define ThisNative "ham_takehealth" -#define ThisENative "ham_etakehealth" -#define ThisRegisterID HAM_TakeHealth -#define ThisParamCount 2 -#define ThisVoidCall 0 - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_TakeHealth - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - return reinterpret_cast(func)( - pthis, /*this*/ - 0, /*fastcall buffer*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -#else - return reinterpret_cast(func)( - pthis, /*this*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -#endif -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - return VCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - &(INDEXENT_NEW(params[2])->v), /*inflictor*/ - &(INDEXENT_NEW(params[3])->v), /*attacker*/ - amx_ctof2(params[4]), /*damage*/ - (int)params[5] /*dmgtype*/ - ); -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_CELL/*amount*/,FP_CELL/*type*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param inflictor Damage inflictor. - * @param attacker The attacker who caused the inflictor to damage the victim. - * @param damage How much damage was caused. - * @param type Damage type (usually in bitmask form). - * @return Unsure. Does not appear to be used. - */ -int ThisVTable::Execute(void *pthis, float amount, int type) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - int ireturn=0; - - if (result(function)(pthis,0,amount,type); -#elif defined __linux__ - ireturn=reinterpret_cast(function)(pthis,amount,type); -#endif - } - - i=0; - - end=PostForwards.size(); - while (i__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - // class was not found - // throw an error alerting console that this hook did not happen - char *function=MF_GetAmxString(amx,params[2],0,NULL); - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - reinterpret_cast(func)( - pthis, /*this*/ - 0 /*fastcall buffer*/ - ); -#else - reinterpret_cast(func)( - pthis /*this*/ - ); -#endif - return 0; -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - VoidVCall0( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset) /*size of class*/ - ); - return 1; -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - 0, // param count - 1, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @return Unsure. Does not appear to be used. - */ -void ThisVTable::Execute(void *pthis) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - - while (iresult) - { - result=thisresult; - } - }; - - if (result(function)(pthis,0); -#elif defined __linux__ - reinterpret_cast(function)(pthis); -#endif - } - - i=0; - end=PostForwards.size(); - - while (iExecute(pthis); -} diff --git a/dlls/hamsandwich/tableentries/Touch.cpp b/dlls/hamsandwich/tableentries/Touch.cpp deleted file mode 100644 index 806497ab..00000000 --- a/dlls/hamsandwich/tableentries/Touch.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableTouch -#define ThisEntries TouchEntries - -#define ThisKey "touch" -#define ThisNative "ham_touch" -#define ThisENative "ham_etouch" -#define ThisRegisterID HAM_Touch -#define ThisParamCount 1 -#define ThisVoidCall 1 - - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - // class was not found - // throw an error alerting console that this hook did not happen - char *function=MF_GetAmxString(amx,params[2],0,NULL); - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - reinterpret_cast(func)( - pthis, /*this*/ - 0, /*fastcall buffer*/ - INDEXENT_NEW(params[2])->pvPrivateData /*other*/ - ); -#else - reinterpret_cast(func)( - pthis, /*this*/ - INDEXENT_NEW(params[2])->pvPrivateData /*other*/ - ); -#endif - return 1; -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - VoidVCall1( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - INDEXENT_NEW(params[2])->pvPrivateData /*other*/ - ); - - return 1; -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_CELL/*other*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddPostForward(fwd); - } - else - { - entry->AddForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param activator Entity causing the opening. - * @param caller Entity controlling the caller. - * @param type USE_TYPE (USE_{ON,OFF,SET} - * @param value Use value, only seen set when USE_SET is used. - * @noreturn - */ -void ThisVTable::Execute(void *pthis, void *other) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - int iOther=PrivateToIndex(other); - - while (iresult) - { - result=thisresult; - } - }; - - if (result(function)(pthis,0,other); -#elif defined __linux__ - reinterpret_cast(function)(pthis,other); -#endif - } - - i=0; - end=PostForwards.size(); - while (iExecute(pthis,other); -} diff --git a/dlls/hamsandwich/tableentries/Use.cpp b/dlls/hamsandwich/tableentries/Use.cpp deleted file mode 100644 index 59ee5940..00000000 --- a/dlls/hamsandwich/tableentries/Use.cpp +++ /dev/null @@ -1,379 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "vfunc_gcc295.h" -#include "vfunc_msvc.h" - -#include "NEW_Util.h" - -// Change these on a per-hook basis! Auto-changes all the annoying fields in the following functions -#define ThisVTable VTableUse -#define ThisEntries UseEntries - -#define ThisKey "use" -#define ThisNative "ham_use" -#define ThisENative "ham_euse" -#define ThisRegisterID HAM_Use -#define ThisParamCount 4 -#define ThisVoidCall 1 - - -unsigned int *ThisVTable::pevoffset=NULL; -unsigned int *ThisVTable::pevset=NULL; -unsigned int *ThisVTable::baseoffset=NULL; -unsigned int *ThisVTable::baseset=0; -unsigned int ThisVTable::index=0; -unsigned int ThisVTable::indexset=0; - -static AMX_NATIVE_INFO callnatives[] = { - { ThisNative, ThisVTable::NativeCall }, - { ThisENative, ThisVTable::ENativeCall }, - { NULL, NULL } -}; - -/** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ -void ThisVTable::Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset) -{ - ThisVTable::pevoffset=poffset; - ThisVTable::pevset=pset; - - ThisVTable::baseoffset=baseoffs; - ThisVTable::baseset=baseset; - - ThisVTable::index=0; - ThisVTable::indexset=0; - - RegisterConfigCallback(ThisVTable::ConfigDone); - - RegisterKeySuffix(ThisKey,ThisVTable::KeyValue); - - RegisterThisRegisterName(ThisRegisterID,ThisKey); -}; - -/** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ -void ThisVTable::KeyValue(const char *key, const char *data) -{ - if (strcmp(key,ThisKey)==0) - { - ThisVTable::index=HAM_StrToNum(data); - ThisVTable::indexset=1; - } -}; - -/** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ -void ThisVTable::ConfigDone(void) -{ - if (ThisVTable::indexset && *(ThisVTable::baseset)) - { - MF_AddNatives(callnatives); - - if (*(ThisVTable::pevset)) - { - RegisterThisRegister(ThisRegisterID,ThisVTable::RegisterNative,ThisVTable::RegisterIDNative); - } - } -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterNative(AMX *amx, cell *params) -{ - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],1,NULL); - - // create an entity, assign it the gamedll's class, hook it and destroy it - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - // Simulate a call to hs_register_id_takedamage - cell tempparams[4]; - memcpy(tempparams,params,sizeof(cell)*4); - tempparams[1]=ENTINDEX_NEW(Entity); - ThisVTable::RegisterIDNative(amx,&tempparams[0]); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - char *function=MF_GetAmxString(amx,params[2],0,NULL); - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function); - - return 0; - -}; - -/** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::RegisterIDNative(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - edict_t *Entity=INDEXENT_NEW(params[1]); - - if (Entity->pvPrivateData) - { - ThisVTable::Hook(&VTMan,EdictToVTable(Entity),amx,funcid,params[0] / sizeof(cell) > 2 ? params[3] : 0); - return 1; - } - - // class was not found - // throw an error alerting console that this hook did not happen - MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id %d, hook for \"%s\" not active.",params[1],function); - - return 0; - -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::NativeCall(AMX *amx, cell *params) -{ - // scan to see if this virtual function is a trampoline - void *pthis=INDEXENT_NEW(params[1])->pvPrivateData; - void *func=GetVTableEntry(pthis,ThisVTable::index,*ThisVTable::baseoffset); - - int i=0; - int end=VTMan.ThisEntries.size(); - - while (iIsTrampoline(func)) - { - // this function is a trampoline - // use the original function instead - func=VTMan.ThisEntries[i]->GetOriginalFunction(); - break; - } - ++i; - } - // TODO: Inline ASM this -#ifdef _WIN32 - reinterpret_cast(func)( - pthis, /*this*/ - 0, /*fastcall buffer*/ - INDEXENT_NEW(params[2])->pvPrivateData, - INDEXENT_NEW(params[3])->pvPrivateData, - params[4], - amx_ctof2(params[5]) - ); -#else - reinterpret_cast(func)( - pthis, /*this*/ - INDEXENT_NEW(params[2])->pvPrivateData, - INDEXENT_NEW(params[3])->pvPrivateData, - params[4], - amx_ctof2(params[5]) - ); -#endif - return 0; -}; - -/** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ -cell ThisVTable::ENativeCall(AMX *amx, cell *params) -{ - VoidVCall4( - INDEXENT_NEW(params[1])->pvPrivateData, /*this*/ - ThisVTable::index, /*vtable entry*/ - *(ThisVTable::baseoffset), /*size of class*/ - INDEXENT_NEW(params[2])->pvPrivateData, /*activator*/ - INDEXENT_NEW(params[3])->pvPrivateData, /*caller*/ - params[4], /*type*/ - amx_ctof2(params[5])); /*value*/ - - return 1; -}; - -/** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ -void ThisVTable::CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc) -{ - - VTableEntryBase::CreateGenericTrampoline(manager, - vtable, - ThisVTable::index, - id, - outtrampoline, - origfunc, - reinterpret_cast(ThisVTable::EntryPoint), - ThisParamCount, // param count - ThisVoidCall, // voidcall - 1); // thiscall - -}; - -/** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ -void ThisVTable::Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post) -{ - void *ptr=vtable[ThisVTable::index]; - - int i=0; - int end=manager->ThisEntries.size(); - int fwd=MF_RegisterSPForward(plugin,funcid,FP_CELL/*this*/,FP_CELL/*inflictor*/,FP_CELL/*attacker*/,FP_CELL/*damage*/,FP_CELL/*type*/,FP_DONE); - while (iThisEntries[i]->IsTrampoline(ptr)) - { - // this function is already hooked! - - if (post) - { - manager->ThisEntries[i]->AddPostForward(fwd); - } - else - { - manager->ThisEntries[i]->AddForward(fwd); - } - - return; - } - - ++i; - } - // this function is NOT hooked - void *tramp; - void *func; - ThisVTable::CreateHook(manager,vtable,manager->ThisEntries.size(),&tramp,&func); - ThisVTable *entry=new ThisVTable; - - entry->Setup(&vtable[ThisVTable::index],tramp,func); - - manager->ThisEntries.push_back(entry); - - if (post) - { - entry->AddForward(fwd); - } - else - { - entry->AddPostForward(fwd); - } - -} - -/** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param activator Entity causing the opening. - * @param caller Entity controlling the caller. - * @param type USE_TYPE (USE_{ON,OFF,SET} - * @param value Use value, only seen set when USE_SET is used. - * @noreturn - */ -void ThisVTable::Execute(void *pthis, void *activator, void *caller, int type, float value) -{ - int i=0; - - int end=Forwards.size(); - - int result=HAM_UNSET; - int thisresult=HAM_UNSET; - - int iThis=PrivateToIndex(pthis); - int iActivator=PrivateToIndex(activator); - int iCaller=PrivateToIndex(caller); - - while (iresult) - { - result=thisresult; - } - }; - - - if (result(function)(pthis,0,activator,caller,type,value); -#elif defined __linux__ - reinterpret_cast(function)(pthis,activator,caller,type,value); -#endif - } - - i=0; - - end=PostForwards.size(); - - while (iExecute(pthis,activator,caller,type,value); -} diff --git a/dlls/hamsandwich/tableentries/VTableEntries.h b/dlls/hamsandwich/tableentries/VTableEntries.h deleted file mode 100644 index 7ff6061b..00000000 --- a/dlls/hamsandwich/tableentries/VTableEntries.h +++ /dev/null @@ -1,3274 +0,0 @@ -/* Ham Sandwich - * - * by the AMX Mod X Dev Team - * - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - */ - - -#ifndef VTABLEENTRIES_H -#define VTABLEENTRIES_H - -#ifdef _WIN32 -#define HAM_CDECL __cdecl -#else -#define HAM_CDECL __attribute__((cdecl)) -#endif - -#include "CVector.h" - -class VTableManager; - -class VTableEntryBase -{ -public: - void *function; /**< The pointer to the original function that is being hooked. */ - void **location; /**< The location of the vtable entry that is being hooked. */ - void *trampoline; /**< Our trampoline (needs to be freed when it's not hooking any more!). */ - CVector Forwards; /**< Vector of forwards to call for this hook.*/ - CVector PostForwards; /**< Vector of forwards to call for this post hook.*/ - - /** - * Saves virtual table location, trampoline and function pointers. - * - * @param vt Pointer to the index in the virtual table. - * @param tramp Pointer to the trampoline. - * @param func Pointer to the original function. - * @noreturn - */ - void Setup(void **vt,void *tramp, void *func) - { - location=vt; - trampoline=tramp; - function=func; - - }; - - /** - * Manually called by VTableManager at destruction. Treat this like a dtor. - * - * @see VTableManager::Cleanup() - * @noreturn - */ - void Destroy() - { - // restore original location - if (location) - { -#if defined _WIN32 - DWORD OldFlags; - VirtualProtect(location,sizeof(int*),PAGE_READWRITE,&OldFlags); -#elif defined __linux__ - mprotect(location,sizeof(int*),PROT_READ|PROT_WRITE); -#endif - - *location=function; - } - - // free the trampoline - free(trampoline); - - Forwards.clear(); - PostForwards.clear(); - - }; - /** - * Tells whether the given pointer is this entry's trampoline. - * - * @param ptr Pointer (cast to void*) of the function in question. - * @return true: Yes, the pointer in question is this entry's trampoline. - * fase: No, the pointer in question is not this entry's trampoline. - */ - bool IsTrampoline(void *ptr) - { - return (ptr==trampoline); - }; - - /** - * Returns the pointer (cast to void*) of the original function which is being hooked. - * - * @return Original function pointer, cast to void*. - */ - void *GetOriginalFunction(void) - { - return function; - }; - - /** - * Returns the location of this entry's virtual table entry itself. - * - * @return Pointer to this entry's virtual table entry. - */ - void **GetLocation(void) - { - return location; - }; - - /** - * Returns a pointer to this entry's trampoline. - * - * @return Trampoline pointer, cast to void*. - */ - void *GetTrampoline(void) - { - return trampoline; - }; - /** - * Adds a forward to this entry's forward vector. - * - * @param fwd Forward index to add. - * @noreturn - */ - void AddForward(int fwd) - { - Forwards.push_back(fwd); - }; - - /** - * Adds a forward to this entry's post forward vector. - * - * @param fwd Forward index to add. - * @noreturn - */ - void AddPostForward(int fwd) - { - PostForwards.push_back(fwd); - }; - - /** - * Creates a generic trampoline. - * - * @param manager The VTableManager this entry belongs to. - * @param vtable Pointer to the virtual table to molest. - * @param vindex VTable index to replace. - * @param id The unique id of this trampoline. - * @param outtrampoline Gets set to the location of the trampoline. - * @param origfunc Gets set to the original function which is being hooked. - * @param calee Target function this trampoline will call. - * @param paramcount How many parameters this trampoline pushes. - * @param voidcall Set to 1, this function does not return. 0 otherwise. - * @param thiscall Set to 1, treat this function like a thiscall. - */ - static void CreateGenericTrampoline(VTableManager *manager, void **vtable, int vtableindex, int id, void **outtrampoline, void **origfunc, void *calee, int paramcount, int voidcall=1, int thiscall=1); - -}; - - -// int ObjectCaps(void) TODO -class VTableObjectCaps : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ - int Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis); -}; - - -// int Classify(void) TODO -class VTableClassify : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ - int Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis); -}; - - -class VTableTraceAttack : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param inflictor Damage inflictor. - * @param attacker The attacker who caused the inflictor to damage the victim. - * @param damage How much damage was caused. - * @param type Damage type (usually in bitmask form). - * @return Unsure. Does not appear to be used. - */ - int Execute(void *pthis, void *pevattacker, float flDamage, float *direction, void *tr, int bitsDamageType); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static void HAM_CDECL EntryPoint(int id,void *pthis,void *pevattacker,float flDamage,float *direction,void *tr,int bits); -}; -// int TakeDamage(entvars_t *inflictor, entvars_t *attacker, float damage, int type); -class VTableTakeDamage : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param inflictor Damage inflictor. - * @param attacker The attacker who caused the inflictor to damage the victim. - * @param damage How much damage was caused. - * @param type Damage type (usually in bitmask form). - * @return Unsure. Does not appear to be used. - */ - int Execute(void *pthis, void *inflictor, void *attacker, float damage, int type); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis,void *inflictor,void *attacker,float damage,int type); -}; -// int BloodColor(void) TODO -class VTableBloodColor : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ - int Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis); -}; - - - -// void Killed(entvars_t *attacker, int gib) -class VTableKilled : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param attacker The attacker who caused the inflictor to damage the victim. - * @param gib Whether to gib or not. - * @noreturn - */ - void Execute(void *pthis, void *attacker, int gib); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static void HAM_CDECL EntryPoint(int id,void *pthis,void *attacker, int gib); -}; -// void Restart(void) CS ONLY -class VTableRestart : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param other Entity that's blocking. - * @noreturn - */ - void Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static void HAM_CDECL EntryPoint(int id,void *pthis); -}; -// int GetToggleState(void) TODO -class VTableGetToggleState : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ - int Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis); -}; - - - -// void AddPoints(int points, int allownegative) -class VTableAddPoints : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param other Entity that's blocking. - * @noreturn - */ - void Execute(void *pthis, int points, int allowneg); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static void HAM_CDECL EntryPoint(int id,void *pthis,int points,int allownegative); -}; -// void AddPointsToTeam(int points, int allownegative) -class VTableAddPointsToTeam : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param other Entity that's blocking. - * @noreturn - */ - void Execute(void *pthis, int points, int allowneg); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static void HAM_CDECL EntryPoint(int id,void *pthis,int points,int allownegative); -}; - -// int AddPlayerItem(CBasePlayerItem *item); -class VTableAddPlayerItem : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param item The private data of the item being added. - * @return Unsure. Does not appear to be used. - */ - int Execute(void *pthis, void *item); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - * @param item The private data of the item being added. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis,void *item); -}; -// int RemovePlayerItem(CBasePlayerItem *item); -class VTableRemovePlayerItem : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param item The private data of the item being added. - * @return Unsure. Does not appear to be used. - */ - int Execute(void *pthis, void *item); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - * @param item The private data of the item being added. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis,void *item); -}; - - - - - - - - - - -// int Is(void) TODO -class VTableIsMoving : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ - int Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis); -}; - - - -// int Is(void) TODO -class VTableDamageDecal : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ - int Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis); -}; - - - - -// int Is(void) TODO -class VTableIsSneaking : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ - int Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis); -}; - - -// int Is(void) TODO -class VTableIsAlive : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ - int Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis); -}; - - -// int Is(void) TODO -class VTableIsBSPModel : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ - int Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis); -}; - - -// int IsInWorld(void) TODO -class VTableIsInWorld : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ - int Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis); -}; - - -// int IsPlayer(void) TODO -class VTableIsPlayer : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ - int Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis); -}; - - -// int IsNetClient(void) TODO -class VTableIsNetClient : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - */ - int Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static int HAM_CDECL EntryPoint(int id,void *pthis); -}; - - -// const char *TeamID(void) TODO -class VTableTeamID : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param other Entity that's blocking. - * @noreturn - */ - const char *Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static const char* HAM_CDECL EntryPoint(int id,void *pthis); -}; - -// void Think(void) TODO -class VTableThink : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param other Entity that's blocking. - * @noreturn - */ - void Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static void HAM_CDECL EntryPoint(int id,void *pthis); -}; -// void Touch(void *pOther) TODO -class VTableTouch : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param other Entity that's blocking. - * @noreturn - */ - void Execute(void *pthis, void *other); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static void HAM_CDECL EntryPoint(int id,void *pthis,void *other); -}; -// void Use(CBaseEntity *activator, CBaseEntity *caller, USE_TYPE type, float value) -class VTableUse : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param activator Entity causing the opening. - * @param caller Entity controlling the caller. - * @param type USE_TYPE (USE_{ON,OFF,SET} - * @param value Use value, only seen set when USE_SET is used. - * @noreturn - */ - void Execute(void *pthis, void *activator, void *caller, int type, float value); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static void HAM_CDECL EntryPoint(int id,void *pthis, void *activator, void *caller, int type, float value); - -}; -// void Blocked(CBaseEntity *pOther) -class VTableBlocked : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param other Entity that's blocking. - * @noreturn - */ - void Execute(void *pthis, void *other); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static void HAM_CDECL EntryPoint(int id,void *pthis,void *other); -}; - -// CBaseEntity *Respawn(void) -class VTableRespawn : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param other Entity that's blocking. - * @noreturn - */ - void *Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static void* HAM_CDECL EntryPoint(int id,void *pthis); -}; - -// void UpdateOwner(void) TODO -class VTableUpdateOwner : public VTableEntryBase -{ -public: - static unsigned int *pevoffset; /**< Offset of pev value (globally stored) */ - static unsigned int *pevset; /**< Whether or not pev entry has been set */ - static unsigned int *baseoffset; /**< Offset of the base class (only needed for GCC 2.95). */ - static unsigned int *baseset; /**< Whether or base offset value has been set. */ - static unsigned int index; /**< This entry's virtual table index. */ - static unsigned int indexset; /**< Whether or not this entry's virtual table index has been set. */ - - /** - * Initialize this table hook. This also registers our required keyvalue suffixes to the file parser. - * - * @param poffset Pointer to an integer that stores the pev offset for this mod. - * @param pset Pointer to an integer that tells whether pev offset was set or not. - * @param baseoffs Pointer to an integer that stores the class base offset for this mod. (GCC 2.95 only required) - * @param baseset Pointer to an integer that tells whether class base offset has been set. - * @noreturn - */ - static void Initialize(unsigned int *poffset, unsigned int *pset, unsigned int *baseoffs, unsigned int *baseset); - - /** - * Called when one of this table entry's keyvalues is caught in a config file. - * - * @param key The keyvalue suffix ("__" is removed) - * @param data The data this keyvalue is set to. - * @noreturn - */ - static void KeyValue(const char *key, const char *data); - - /** - * Called immediately after the config file is done being parsed. Register our natives here. - * - * @noreturn - */ - static void ConfigDone(void); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterNative(AMX *amx, cell *params); - - /** - * A plugin is registering this entry's virtual hook. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell RegisterIDNative(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell NativeCall(AMX *amx, cell *params); - - /** - * A plugin is requesting a direct call of this entry's virtual function, and will be exposed to all hooks. This is a normal native callback. - * - * @param amx The AMX structure for the plugin. - * @param params The parameters passed from the plugin. - * @return 1 on success, 0 on failure. It only fails if the callback function is not found. - */ - static cell ENativeCall(AMX *amx, cell *params); - - /** - * Hook this entry's function! This creates our trampoline and modifies the virtual table. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param outtrampoline The trampoline that was created. - * @param origfunc The original function that was hooked. - * @noreturn - */ - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - - /** - * Checks if the virtual function is already being hooked or not. If it's not, it begins hooking it. Either way it registers a forward and adds it to our vector. - * - * @param manager The VTableManager this is a child of. - * @param vtable The virtual table we're molesting. - * @param plugin The plugin that's requesting this. - * @param funcid The function id of the callback. - * @noreturn - */ - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid, int post); - - /** - * Execute the command. This is called directly from our global hook function. - * - * @param pthis The "this" pointer, cast to a void. The victim. - * @param other Entity that's blocking. - * @noreturn - */ - void Execute(void *pthis); - - /** - * The hook that is directly called by the trampoline. - * - * @param id The index of the hook to call. - * @param pthis The "this" pointer. - */ - static void HAM_CDECL EntryPoint(int id,void *pthis); -}; - - - -//TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); -/*class VTableTraceAttack : public VTableEntryBase -{ -public: - static void CreateHook(VTableManager *manager, void **vtable, int id, void **outtrampoline, void **origfunc); - static void Hook(VTableManager *manager, void **vtable, AMX *plugin, int funcid); - void Execute(void *pthis, entvars_t *attacker, float damage, float *direction, TraceResult *tr, int damagetype); -}; -*/ -#endif // VTABLEENTRIES_H diff --git a/dlls/hamsandwich/tableentries/VTableManager.cpp b/dlls/hamsandwich/tableentries/VTableManager.cpp deleted file mode 100644 index 56b31320..00000000 --- a/dlls/hamsandwich/tableentries/VTableManager.cpp +++ /dev/null @@ -1,193 +0,0 @@ -#include "sdk/amxxmodule.h" - -#include "hamsandwich.h" - -#include "VTableManager.h" -#include "VTableEntries.h" - -#include "NEW_Util.h" - -VTableManager VTMan; - -NATIVEFUNC VTableManager::RegisterNatives[HAM_END_DONT_USE_ME]; -NATIVEFUNC VTableManager::RegisterIDNatives[HAM_END_DONT_USE_ME]; -const char *VTableManager::RegisterNames[HAM_END_DONT_USE_ME]; - -void RegisterThisRegister(int index,NATIVEFUNC byname, NATIVEFUNC byid) -{ - VTableManager::RegisterNatives[index]=byname; - VTableManager::RegisterIDNatives[index]=byid; -} -void RegisterThisRegisterName(int index, const char *name) -{ - VTableManager::RegisterNames[index]=name; -} - -static AMX_NATIVE_INFO registernatives[] = { - { "ham_register", VTableManager::Register }, - { "ham_registerid", VTableManager::RegisterID }, - - { NULL, NULL } -}; -void RegisterRegisterNatives(void) -{ - MF_AddNatives(registernatives); -} -cell VTableManager::Register(AMX *amx, cell *params) -{ - int id=params[1]; - - if (id<0 || id>=HAM_END_DONT_USE_ME || RegisterIDNatives[id]==NULL) - { - // this register is not found, fail the plugin - int fwd=MF_RegisterSPForwardByName(amx,"__fatal_ham_error",FP_STRING,FP_DONE); - char error[256]; - - snprintf(&error[0],sizeof(error)-1,"Requested to ham_registerid a function ID that is not registered in configs/hamdata.ini, cannot continue. (Requested: %d)",id); - - MF_ExecuteForward(fwd,&error[0]); - - MF_UnregisterSPForward(fwd); - return 0; - - } - - cell tempparams[4]; - - // remove one parameter from this param count - tempparams[0]=(params[0]-(sizeof(cell))); - tempparams[1]=params[2]; - tempparams[2]=params[3]; - tempparams[3]=params[4]; - - return RegisterNatives[id](amx,&tempparams[0]); -} -cell VTableManager::RegisterID(AMX *amx, cell *params) -{ - int id=params[1]; - - if (id<0 || id>=HAM_END_DONT_USE_ME || RegisterNatives[id]==NULL) - { - // this register is not found, fail the plugin - int fwd=MF_RegisterSPForwardByName(amx,"__fatal_ham_error",FP_STRING,FP_DONE); - - char error[256]; - - snprintf(&error[0],sizeof(error)-1,"Requested to ham_register a function ID that is not registered in configs/hamdata.ini, cannot continue. (Requested: %d)",id); - - MF_ExecuteForward(fwd,&error[0]); - - MF_UnregisterSPForward(fwd); - return 0; - - } - - cell tempparams[4]; - - // remove one parameter from this param count - tempparams[0]=(params[0]-(sizeof(cell))); - tempparams[1]=params[2]; - tempparams[2]=params[3]; - tempparams[3]=params[4]; - - return RegisterIDNatives[id](amx,&tempparams[0]); -} - - -void *VTableManager::InsertIntoVTable(void **vtable, int index, void *trampoline) -{ - void *func; -#if defined _WIN32 - DWORD OldFlags; - VirtualProtect(&vtable[index],sizeof(int*),PAGE_READWRITE,&OldFlags); -#elif defined __linux__ - mprotect(&vtable[index],sizeof(int*),PROT_READ|PROT_WRITE); -#endif - func=vtable[index]; - vtable[index]=trampoline; - - return func; -}; - - -#define CLEAR_ENTRIES(Container) \ - i=Container.size(); \ - while (i--) \ - { \ - Container[i]->Destroy(); \ - delete Container[i]; \ - } \ - Container.clear() - - -void VTableManager::Cleanup(void) -{ - int i; - - CLEAR_ENTRIES(UseEntries); - CLEAR_ENTRIES(TakeDamageEntries); -}; - - - -void VTableEntryBase::CreateGenericTrampoline(VTableManager *manager, void **vtable, int vtid, int id, void **outtrampoline, void **origfunc, void *callee, int paramcount, int voidcall, int thiscall) -{ - Trampolines::TrampolineMaker tramp; - - if (voidcall) - { - if (thiscall) - { - tramp.ThisVoidPrologue(); - } - else - { - tramp.VoidPrologue(); - } - } - else - { - if (thiscall) - { - tramp.ThisReturnPrologue(); - } - else - { - tramp.ReturnPrologue(); - } - } - - while (paramcount) - { - tramp.PushParam(paramcount--); - } - if (thiscall) - { - tramp.PushThis(); - } - tramp.PushNum(id); - tramp.Call(callee); - tramp.FreeTargetStack(); - if (voidcall) - { -#if defined _WIN32 - tramp.VoidEpilogueAndFree(); -#elif defined __linux__ - tramp.VoidEpilogue(); -#endif - } - else - { -#if defined _WIN32 - tramp.ReturnEpilogueAndFree(); -#elif defined __linux__ - tramp.ReturnEpilogue(); -#endif - } - - void *trampoline=tramp.Finish(NULL); - - *outtrampoline=trampoline; - - *origfunc=manager->InsertIntoVTable(vtable,vtid,trampoline); -}; diff --git a/dlls/hamsandwich/tableentries/VTableManager.h b/dlls/hamsandwich/tableentries/VTableManager.h deleted file mode 100644 index be8a812f..00000000 --- a/dlls/hamsandwich/tableentries/VTableManager.h +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef VTABLEMANAGER_H -#define VTABLEMANAGER_H - -#include "Trampolines.h" - -#include "hamsandwich.h" - -#include "CVector.h" -#include "VTableEntries.h" - -/* !!WARNING: HERE BE DRAGONS - - .~))>> - .~)>> - .~))))>>> - .~))>> ___ - .~))>>)))>> .-~))>> - .~)))))>> .-~))>>)> - .~)))>>))))>> .-~)>>)> - ) .~))>>))))>> .-~)))))>>)> - ( )@@*) //)>)))))) .-~))))>>)> - ).@(@@ //))>>))) .-~))>>)))))>>)> - (( @.@). //))))) .-~)>>)))))>>)> - )) )@@*.@@ ) //)>))) //))))))>>))))>>)> - (( ((@@@.@@ |/))))) //)))))>>)))>>)> - )) @@*. )@@ ) (\_(\-\b |))>)) //)))>>)))))))>>)> - (( @@@(.@(@ . _/`-` ~|b |>))) //)>>)))))))>>)> - )* @@@ )@* (@) (@) /\b|))) //))))))>>))))>> - (( @. )@( @ . _/ / / \b)) //))>>)))))>>>_._ - )@@ (@@*)@@. (6///6)- / ^ \b)//))))))>>)))>> ~~-. - ( @jgs@@. @@@.*@_ VvvvvV// ^ \b/)>>))))>> _. `bb - ((@@ @@@*.(@@ . - | o |' \ ( ^ \b)))>> .' b`, - ((@@).*@@ )@ ) \^^^/ (( ^ ~)_ \ / b `, - (@@. (@@ ). `-' ((( ^ `\ \ \ \ \| b `. - (*.@* / (((( \| | | \ . b `. - / / ((((( \ \ / _.-~\ Y, b ; - / / / (((((( \ \.-~ _.`" _.-~`, b ; - / / `(((((() ) (((((~ `, b ; - _/ _/ `"""/ /' ; b ; - _.-~_.-~ / /' _.'~bb _.' - ((((~~ / /' _.'~bb.--~ - (((( __.-~bb.-~ - .' b .~~ - :bb ,' - ~~~~ -*/ - - -enum -{ - HAM_UNSET = 0, - HAM_IGNORED, - HAM_HANDLED, - HAM_OVERRIDE, - HAM_SUPERCEDE -}; - -enum -{ - HAM_TYPE_UNKNOWN = 0, - HAM_TYPE_CBASE, - HAM_TYPE_ENTVAR, - HAM_TYPE_EDICT, - HAM_TYPE_INT, - HAM_TYPE_FLOAT -}; - -enum -{ - HAM_ERROR_BOUNDS = -2, - HAM_ERROR_TYPE = -1, - HAM_ERROR_NONE = 0 -}; - - -typedef cell (*NATIVEFUNC)(AMX *, cell *); - -class VTableManager -{ -public: -#define VTINIT(Type) CVector Type##Entries - VTINIT(Use); - VTINIT(TakeDamage); - VTINIT(Blocked); - VTINIT(Killed); - VTINIT(Respawn); - VTINIT(Restart); - VTINIT(AddPoints); - VTINIT(AddPointsToTeam); - VTINIT(AddPlayerItem); - VTINIT(RemovePlayerItem); - VTINIT(BloodColor); - VTINIT(Classify); - VTINIT(GetToggleState); - VTINIT(IsAlive); - VTINIT(IsBSPModel); - VTINIT(IsInWorld); - VTINIT(IsMoving); - VTINIT(IsNetClient); - VTINIT(IsPlayer); - VTINIT(IsSneaking); - VTINIT(ObjectCaps); - VTINIT(Think); - VTINIT(Touch); - -#undef VTINIT - static NATIVEFUNC RegisterNatives[HAM_END_DONT_USE_ME]; - static NATIVEFUNC RegisterIDNatives[HAM_END_DONT_USE_ME]; - static const char *RegisterNames[HAM_END_DONT_USE_ME]; - - static cell Register(AMX *amx, cell *params); - static cell RegisterID(AMX *amx, cell *params); - - /* returns the original function */ - void *InsertIntoVTable(void **vtable, int index, void *trampoline); - void Cleanup(void); -}; - -void RegisterThisRegister(int index,NATIVEFUNC byname, NATIVEFUNC byid); -void RegisterThisRegisterName(int index, const char *name); -void RegisterRegisterNatives(void); - -extern VTableManager VTMan; - - -#endif // VTABLEMANAGER_H diff --git a/dlls/hamsandwich/vfunc_gcc295.h b/dlls/hamsandwich/vfunc_gcc295.h deleted file mode 100644 index 5202ae15..00000000 --- a/dlls/hamsandwich/vfunc_gcc295.h +++ /dev/null @@ -1,165 +0,0 @@ -/* Ham Sandwich - * - * by sawce - * - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - */ -// Calling virtual functions on binaries compiled with GCC 2.95 -// 2.95 and before stores the virtual table at the end of the -// inheritable size of the base class. -// I have no idea how it does it for multiple inheritance; i don't -// really care. Everything I'm calling does it in single inheritence. -// GCC doesn't put this on a register like MSVC does, so -// just pass it like a normal parameter (the first one) -// For GCC 3.3 compiled binaries, set the "size" parameter to 0 - -#ifdef __linux__ -#ifndef VFUNC_GCC295_H -#define VFUNC_GCC295_H - -inline void *GetVTableEntry(void *pThis, int ventry, int size) -{ - char *pcThis=*(char **)&pThis; - - pcThis+=size; - - void **vtbl=*(void ***)pcThis; - - return vtbl[ventry]; -} - -// I only comment on the first call, because it's jut copy/paste after -// the rest are compacted for copy/paste ease -template -inline void VoidVCall4(void *pThis, int ventry, int size, PTypeA pa, PTypeB pb, PTypeC pc, PTypeD pd) -{ - // First move up past the size of the class - char *pcThis=*(char **)&pThis; - - pcThis+=size; - - void **vtbl=*(void ***)pcThis; - - // now points to the vtable of this object - - typedef void (*fptr)(void*,PTypeA,PTypeB,PTypeC,PTypeD); - fptr function=reinterpret_cast(vtbl[ventry]); - - function(pThis,pa,pb,pc,pd); -}; -template -inline RetType VCall4(void *pThis, int ventry, int size, PTypeA pa, PTypeB pb, PTypeC pc, PTypeD pd) -{ - char *pcThis=*(char **)&pThis; - pcThis+=size; - int **vtbl=*(int ***)pcThis; - typedef RetType (*fptr)(void*,PTypeA,PTypeB,PTypeC,PTypeD); - fptr function=reinterpret_cast(vtbl[ventry]); - return function(pThis,pa,pb,pc,pd); -}; -template -inline void VoidVCall3(void *pThis, int ventry, int size, PTypeA pa, PTypeB pb, PTypeC pc) -{ - char *pcThis=*(char **)&pThis; - pcThis+=size; - int **vtbl=*(int ***)pcThis; - typedef void (*fptr)(void*,PTypeA,PTypeB,PTypeC); - fptr function=reinterpret_cast(vtbl[ventry]); - function(pThis,pa,pb,pc); -}; -template -inline RetType VCall3(void *pThis, int ventry, int size, PTypeA pa, PTypeB pb, PTypeC pc) -{ - char *pcThis=*(char **)&pThis; - pcThis+=size; - int **vtbl=*(int ***)pcThis; - typedef RetType (*fptr)(void*,PTypeA,PTypeB,PTypeC); - fptr function=reinterpret_cast(vtbl[ventry]); - return function(pThis,pa,pb,pc); -}; -template -inline void VoidVCall2(void *pThis, int ventry, int size, PTypeA pa, PTypeB pb) -{ - char *pcThis=*(char **)&pThis; - pcThis+=size; - int **vtbl=*(int ***)pcThis; - typedef void (*fptr)(void*,PTypeA,PTypeB); - fptr function=reinterpret_cast(vtbl[ventry]); - function(pThis,pa,pb); -}; -template -inline RetType VCall2(void *pThis, int ventry, int size, PTypeA pa, PTypeB pb) -{ - char *pcThis=*(char **)&pThis; - pcThis+=size; - int **vtbl=*(int ***)pcThis; - typedef RetType (*fptr)(void*,PTypeA,PTypeB); - fptr function=reinterpret_cast(vtbl[ventry]); - return function(pThis,pa,pb); -}; -template -inline void VoidVCall1(void *pThis, int ventry, int size, PTypeA pa) -{ - char *pcThis=*(char **)&pThis; - pcThis+=size; - int **vtbl=*(int ***)pcThis; - typedef void (*fptr)(void*,PTypeA); - fptr function=reinterpret_cast(vtbl[ventry]); - function(pThis,pa); -}; -template -inline RetType VCall1(void *pThis, int ventry, int size, PTypeA pa) -{ - char *pcThis=*(char **)&pThis; - pcThis+=size; - int **vtbl=*(int ***)pcThis; - typedef RetType (*fptr)(void*,PTypeA); - fptr function=reinterpret_cast(vtbl[ventry]); - return function(pThis,pa); -}; -inline void VoidVCall0(void *pThis, int ventry, int size) -{ - char *pcThis=*(char **)&pThis; - pcThis+=size; - int **vtbl=*(int ***)pcThis; - typedef void (*fptr)(void*); - fptr function=reinterpret_cast(vtbl[ventry]); - function(pThis); -}; -template -inline RetType VCall0(void *pThis, int ventry, int size) -{ - char *pcThis=*(char **)&pThis; - pcThis+=size; - int **vtbl=*(int ***)pcThis; - typedef RetType (*fptr)(void*); - fptr function=reinterpret_cast(vtbl[ventry]); - return function(pThis); -}; - - -#endif //VFUNC_GCC295_H -#endif // __linux__ diff --git a/dlls/hamsandwich/vfunc_msvc.h b/dlls/hamsandwich/vfunc_msvc.h deleted file mode 100644 index 340c48fb..00000000 --- a/dlls/hamsandwich/vfunc_msvc.h +++ /dev/null @@ -1,245 +0,0 @@ -/* Ham Sandwich - * - * by sawce - * - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - */ - -// MSVC stores vtable like normal at the front as well -// however these are thiscall functions -// i use inline assembly to call them -#ifdef _WIN32 -#ifndef VFUNC_MSVC_H -#define VFUNC_MSVC_H - -inline void *GetVTableEntry(void *pThis, int ventry, int size) -{ - void **vtbl=*(void ***)pThis; - - return vtbl[ventry]; -} -template -inline void VoidVCall4(void *pThis, int ventry, int size, PTypeA pa, PTypeB pb, PTypeC pc, PTypeD pd) -{ - // vtable pointer is stored in the first dword of the object - // reference it as an array of objects - void **vtbl=*(void ***)pThis; - - void *func=vtbl[ventry]; - - // Simulate a thiscall - // this on ecx, all other parameters pushed normally - _asm { - push ecx; // save ecx - push eax; // save eax - shouldn't be needed, but just incase - - push pd; // push param 4 - push pc; // push param 3 - push pb; // push param 2 - push pa; // push param 1 - - mov ecx, pThis; // store this in ecx - - call [func]; // call function - - pop eax; // restore eax - pop ecx; // restore ecx - }; -}; -template -inline RetType VCall4(void *pThis, int ventry, int size, PTypeA pa, PTypeB pb, PTypeC pc, PTypeD pd) -{ - void **vtbl=*(void ***)pThis; - - void *func=vtbl[ventry]; - - RetType _ret; - _asm { - push ecx; - push eax; - push pd; - push pc; - push pb; - push pa; - mov ecx, pThis; - call [func]; - mov _ret, eax; - pop eax; - pop ecx; - }; - - return _ret; -}; -template -inline void VoidVCall3(void *pThis, int ventry, int size, PTypeA pa, PTypeB pb, PTypeC pc) -{ - void **vtbl=*(void ***)pThis; - void *func=vtbl[ventry]; - _asm { - push ecx; - push eax; - push pc; - push pb; - push pa; - mov ecx, pThis; - call [func]; - pop eax; - pop ecx; - }; -}; -template -inline RetType VCall3(void *pThis, int ventry, int size, PTypeA pa, PTypeB pb, PTypeC pc) -{ - void **vtbl=*(void ***)pThis; - void *func=vtbl[ventry]; - RetType _ret; - _asm { - push ecx; - push eax; - push pc; - push pb; - push pa; - mov ecx, pThis; - call [func]; - mov _ret, eax; - pop eax; - pop ecx; - }; - return _ret; -}; -template -inline void VoidVCall2(void *pThis, int ventry, int size, PTypeA pa, PTypeB pb) -{ - void **vtbl=*(void ***)pThis; - void *func=vtbl[ventry]; - _asm { - push ecx; - push eax; - push pb; - push pa; - mov ecx, pThis; - call [func]; - pop eax; - pop ecx; - }; -}; -template -inline RetType VCall2(void *pThis, int ventry, int size, PTypeA pa, PTypeB pb) -{ - void **vtbl=*(void ***)pThis; - void *func=vtbl[ventry]; - RetType _ret; - _asm { - push ecx; - push eax; - push pb; - push pa; - mov ecx, pThis; - call [func]; - mov _ret, eax; - pop eax; - pop ecx; - }; - return _ret; -}; -template -inline void VoidVCall1(void *pThis, int ventry, int size, PTypeA pa) -{ - void **vtbl=*(void ***)pThis; - - void *func=vtbl[ventry]; - - _asm { - push ecx; - push eax; - push pa; - mov ecx, pThis; - call [func]; - pop eax; - pop ecx; - }; -}; -template -inline RetType VCall1(void *pThis, int ventry, int size, PTypeA pa) -{ - void **vtbl=*(void ***)pThis; - - void *func=vtbl[ventry]; - - RetType _ret; - _asm { - push ecx; - push eax; - push pa; - mov ecx, pThis; - call [func]; - mov _ret, eax; - pop eax; - pop ecx; - }; - - return _ret; -}; - -inline void VoidVCall0(void *pThis, int ventry, int size) -{ - void **vtbl=*(void ***)pThis; - - void *func=vtbl[ventry]; - - _asm { - push ecx; - push eax; - mov ecx, pThis; - call [func]; - pop eax; - pop ecx; - }; -}; -template -inline RetType VCall0(void *pThis, int ventry, int size) -{ - void **vtbl=*(void ***)pThis; - - void *func=vtbl[ventry]; - - RetType _ret; - _asm { - push ecx; - push eax; - mov ecx, pThis; - call [func]; - mov _ret, eax; - pop eax; - pop ecx; - }; - - return _ret; -}; - - -#endif //VFUNC_MSVC_H -#endif // _WIN32 diff --git a/dlls/hamsandwich/vtable.cpp b/dlls/hamsandwich/vtable.cpp deleted file mode 100644 index 15380ac0..00000000 --- a/dlls/hamsandwich/vtable.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -/** - * These are the functions called by the trampolines - * I explicitly declare them as cdecl so I know exactly - * how to work the stack in the trampoline. - */ -/* -static cell AMX_NATIVE_CALL register_takedamage(AMX *amx, cell *params) -{ -}; -static cell AMX_NATIVE_CALL register_use(AMX *amx, cell *params) -{ - int funcid; - char *function=MF_GetAmxString(amx,params[2],0,NULL); - if (MF_AmxFindPublic(amx,function,&funcid)!=AMX_ERR_NONE) - { - MF_LogError(amx,AMX_ERR_NATIVE,"Can not find function \"%s\"",function); - return 0; - } - // Get the classname - char *classname=MF_GetAmxString(amx,params[1],0,NULL); - - edict_t *Entity=CREATE_ENTITY(); - - CALL_GAME_ENTITY(PLID,classname,&Entity->v); - - if (Entity->pvPrivateData) - { - VTableUse::Hook(&VTMan,EdictToVTable(Entity),amx,funcid); - REMOVE_ENTITY(Entity); - return 1; - } - - REMOVE_ENTITY(Entity); - - return 0; - -}; - -static AMX_NATIVE_INFO tdhooks[] = { - { "register_takedamage", register_takedamage }, - { "register_use", register_use }, - { NULL, NULL } -}; - -void VTH_Natives() -{ - MF_AddNatives(tdhooks); -}; - -*/