Move dlls/ to modules/

This commit is contained in:
xPaw
2015-03-13 15:18:47 +02:00
parent 54c978addb
commit e09f434ed8
365 changed files with 2233 additions and 2233 deletions

View File

@ -0,0 +1,27 @@
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
import os.path
binary = AMXX.MetaModule(builder, 'hamsandwich')
binary.compiler.defines += [
'HAVE_STDINT_H',
]
binary.sources = [
'../../public/sdk/amxxmodule.cpp',
'amxx_api.cpp',
'config_parser.cpp',
'hook_callbacks.cpp',
'hook_native.cpp',
'srvcmd.cpp',
'call_funcs.cpp',
'hook_create.cpp',
'DataHandler.cpp',
'pdata.cpp',
'hook_specialbot.cpp',
]
if builder.target_platform == 'windows':
binary.sources += ['version.rc']
AMXX.modules += [builder.Add(binary)]

View File

@ -0,0 +1,497 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#include "amxxmodule.h"
#include <am-vector.h>
#include <am-string.h>
#include <sh_stack.h>
#include "DataHandler.h"
#include "ham_const.h"
#include "ham_utils.h"
#include "NEW_Util.h"
CStack< Data * > ReturnStack;
CStack< Data * > OrigReturnStack;
CStack< ke::Vector< Data * > * > ParamStack;
CStack< int * > ReturnStatus;
#define CHECK_STACK(__STACK__) \
if ( ( __STACK__ ).size() <= 0) \
{ \
MF_LogError(amx, AMX_ERR_NATIVE, "%s is empty!", #__STACK__); \
return 0; \
}
#define PARSE_RETURN() \
if (ret==-2) \
{ \
MF_LogError(amx, AMX_ERR_NATIVE, "Data pointer is NULL!"); \
} \
else if (ret==-1) \
{ \
MF_LogError(amx, AMX_ERR_NATIVE, "Wrong data type (data is of type %s)", returntypes[dat->GetType()]); \
} \
return ret
static const char *returntypes[] =
{
"void",
"integer",
"float",
"vector",
"string",
"entity",
"entity",
"traceresult",
"iteminfo"
};
static cell AMX_NATIVE_CALL GetHamReturnInteger(AMX *amx, cell *params)
{
CHECK_STACK(ReturnStack);
Data *dat=ReturnStack.front();
int ret=dat->GetInt(MF_GetAmxAddr(amx, params[1]));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL GetOrigHamReturnInteger(AMX *amx, cell *params)
{
CHECK_STACK(OrigReturnStack);
Data *dat=OrigReturnStack.front();
int ret=dat->GetInt(MF_GetAmxAddr(amx, params[1]));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL GetHamReturnFloat(AMX *amx, cell *params)
{
CHECK_STACK(ReturnStack);
Data *dat=ReturnStack.front();
int ret=dat->GetFloat(MF_GetAmxAddr(amx, params[1]));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL GetOrigHamReturnFloat(AMX *amx, cell *params)
{
CHECK_STACK(OrigReturnStack);
Data *dat=OrigReturnStack.front();
int ret=dat->GetFloat(MF_GetAmxAddr(amx, params[1]));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL GetHamReturnVector(AMX *amx, cell *params)
{
CHECK_STACK(ReturnStack);
Data *dat=ReturnStack.front();
int ret=dat->GetVector(MF_GetAmxAddr(amx, params[1]));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL GetOrigHamReturnVector(AMX *amx, cell *params)
{
CHECK_STACK(OrigReturnStack);
Data *dat=OrigReturnStack.front();
int ret=dat->GetVector(MF_GetAmxAddr(amx, params[1]));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL GetHamReturnEntity(AMX *amx, cell *params)
{
CHECK_STACK(ReturnStack);
Data *dat=ReturnStack.front();
int ret=dat->GetEntity(MF_GetAmxAddr(amx, params[1]));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL GetOrigHamReturnEntity(AMX *amx, cell *params)
{
CHECK_STACK(OrigReturnStack);
Data *dat=OrigReturnStack.front();
int ret=dat->GetEntity(MF_GetAmxAddr(amx, params[1]));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL GetHamReturnString(AMX *amx, cell *params)
{
CHECK_STACK(ReturnStack);
Data *dat=ReturnStack.front();
int ret=dat->GetString(MF_GetAmxAddr(amx, params[1]), params[2]);
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL GetOrigHamReturnString(AMX *amx, cell *params)
{
CHECK_STACK(OrigReturnStack);
Data *dat=OrigReturnStack.front();
int ret=dat->GetString(MF_GetAmxAddr(amx, params[1]), params[2]);
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamReturnInteger(AMX *amx, cell *params)
{
CHECK_STACK(ReturnStack);
Data *dat=ReturnStack.front();
int ret=dat->SetInt(&params[1]);
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamReturnFloat(AMX *amx, cell *params)
{
CHECK_STACK(ReturnStack);
Data *dat=ReturnStack.front();
int ret=dat->SetFloat(&params[1]);
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamReturnVector(AMX *amx, cell *params)
{
CHECK_STACK(ReturnStack);
Data *dat=ReturnStack.front();
int ret=dat->SetVector(MF_GetAmxAddr(amx, params[1]));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamReturnEntity(AMX *amx, cell *params)
{
CHECK_STACK(ReturnStack);
Data *dat=ReturnStack.front();
int ret=dat->SetEntity(&params[1]);
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamReturnString(AMX *amx, cell *params)
{
CHECK_STACK(ReturnStack);
Data *dat=ReturnStack.front();
int ret=dat->SetString(MF_GetAmxAddr(amx, params[1]));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamParamInteger(AMX *amx, cell *params)
{
CHECK_STACK(ParamStack);
ke::Vector<Data *> *vec = ParamStack.front();
if (vec->length() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->length());
return 0;
}
Data *dat=vec->at(params[1] - 1);
int ret=dat->SetInt(&params[2]);
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamParamTraceResult(AMX *amx, cell *params)
{
if (params[2] == 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Null traceresult provided.");
return 0;
}
CHECK_STACK(ParamStack);
ke::Vector<Data *> *vec = ParamStack.front();
if (vec->length() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->length());
return 0;
}
Data *dat=vec->at(params[1] - 1);
int ret=dat->SetInt(&params[2]);
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamParamFloat(AMX *amx, cell *params)
{
CHECK_STACK(ParamStack);
ke::Vector<Data *> *vec = ParamStack.front();
if (vec->length() < (unsigned)params[1] || params[1] < 1)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->length());
return 0;
}
Data *dat=vec->at(params[1] - 1);
int ret=dat->SetFloat(&params[2]);
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamParamVector(AMX *amx, cell *params)
{
CHECK_STACK(ParamStack);
ke::Vector<Data *> *vec = ParamStack.front();
if (vec->length() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->length());
return 0;
}
Data *dat=vec->at(params[1] - 1);
int ret=dat->SetVector(MF_GetAmxAddr(amx, params[2]));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamParamEntity(AMX *amx, cell *params)
{
CHECK_STACK(ParamStack);
ke::Vector<Data *> *vec = ParamStack.front();
if (vec->length() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->length());
return 0;
}
Data *dat=vec->at(params[1] - 1);
int ret=dat->SetEntity(&params[2]);
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamParamString(AMX *amx, cell *params)
{
CHECK_STACK(ParamStack);
ke::Vector<Data *> *vec=ParamStack.front();
if (vec->length() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->length());
return 0;
}
Data *dat=vec->at(params[1] - 1);
int ret=dat->SetString(MF_GetAmxAddr(amx, params[2]));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamParamItemInfo(AMX *amx, cell *params)
{
if (params[2] == 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Null ItemInfo handle provided.");
return 0;
}
CHECK_STACK(ParamStack);
ke::Vector<Data *> *vec = ParamStack.front();
if (vec->length() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->length());
return 0;
}
Data *dat = vec->at(params[1] - 1);
int ret = dat->SetInt(&params[2]);
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL GetHamItemInfo(AMX *amx, cell *params)
{
if (params[1] == 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Null iteminfo handle provided.");
return 0;
}
int type = params[2];
if ((type == ItemInfo_pszAmmo1 || type == ItemInfo_pszAmmo2 || type == ItemInfo_pszName) && (*params / sizeof(cell)) != 4)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Bad arg count. Expected %d, got %d.", 4, *params / sizeof(cell));
return 0;
}
ItemInfo *pItem = reinterpret_cast<ItemInfo *>(params[1]);
switch (type)
{
case ItemInfo_iSlot:
return pItem->iSlot;
case ItemInfo_iPosition:
return pItem->iPosition;
case ItemInfo_pszAmmo1:
return MF_SetAmxString( amx, params[3], pItem->pszAmmo1 > 0 ? pItem->pszAmmo1 : "", params[4] );
case ItemInfo_iMaxAmmo1:
return pItem->iMaxAmmo1;
case ItemInfo_pszAmmo2:
return MF_SetAmxString( amx, params[3], pItem->pszAmmo2 > 0 ? pItem->pszAmmo2 : "", params[4] );
case ItemInfo_iMaxAmmo2:
return pItem->iMaxAmmo2;
case ItemInfo_pszName:
return MF_SetAmxString( amx, params[3], pItem->pszName > 0 ? pItem->pszName : "", params[4] );
case ItemInfo_iMaxClip:
return pItem->iMaxClip;
case ItemInfo_iId:
return pItem->iId;
case ItemInfo_iFlags:
return pItem->iFlags;
case ItemInfo_iWeight:
return pItem->iWeight;
}
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown ItemInfo type %d", type);
return 0;
}
CStack<ItemInfo *> g_FreeIIs;
static cell AMX_NATIVE_CALL CreateHamItemInfo(AMX *amx, cell *params)
{
ItemInfo *ii;
if (g_FreeIIs.empty())
{
ii = new ItemInfo;
}
else
{
ii = g_FreeIIs.front();
g_FreeIIs.pop();
}
memset(ii, 0, sizeof(ItemInfo));
return reinterpret_cast<cell>(ii);
}
static cell AMX_NATIVE_CALL FreeHamItemInfo(AMX *amx, cell *params)
{
ItemInfo *ii = reinterpret_cast<ItemInfo *>(params[1]);
if (!ii)
{
return 0;
}
g_FreeIIs.push(ii);
return 1;
}
static cell AMX_NATIVE_CALL SetHamItemInfo(AMX *amx, cell *params)
{
if (params[1] == 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Null iteminfo handle provided.");
return 0;
}
ItemInfo *pItem = reinterpret_cast<ItemInfo *>(params[1]);
cell *ptr = MF_GetAmxAddr(amx, params[3]);
int iLen;
switch (params[2])
{
case ItemInfo_iSlot:
pItem->iSlot = *ptr;
break;
case ItemInfo_iPosition:
pItem->iPosition = *ptr;
break;
case ItemInfo_pszAmmo1:
pItem->pszAmmo1 = MF_GetAmxString(amx, params[3], 0, &iLen);
return iLen;
case ItemInfo_iMaxAmmo1:
pItem->iMaxAmmo1 = *ptr;
break;
case ItemInfo_pszAmmo2:
pItem->pszAmmo2 = MF_GetAmxString(amx, params[3], 0, &iLen);
return iLen;
case ItemInfo_iMaxAmmo2:
pItem->iMaxAmmo2 = *ptr;
break;
case ItemInfo_pszName:
pItem->pszName = MF_GetAmxString(amx, params[3], 0, &iLen);
return iLen;
case ItemInfo_iMaxClip:
pItem->iMaxClip = *ptr;
break;
case ItemInfo_iId:
pItem->iId = *ptr;
break;
case ItemInfo_iFlags:
pItem->iFlags = *ptr;
break;
case ItemInfo_iWeight:
pItem->iWeight = *ptr;
break;
default:
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown ItemInfo type %d", params[2]);
return 0;
}
return 1;
}
static cell AMX_NATIVE_CALL GetHamReturnStatus(AMX *amx, cell *params)
{
CHECK_STACK(ReturnStatus);
int *i=ReturnStatus.front();
return *i;
}
AMX_NATIVE_INFO ReturnNatives[] =
{
{ "GetHamReturnInteger", GetHamReturnInteger },
{ "GetHamReturnFloat", GetHamReturnFloat },
{ "GetHamReturnVector", GetHamReturnVector },
{ "GetHamReturnEntity", GetHamReturnEntity },
{ "GetHamReturnString", GetHamReturnString },
{ "GetOrigHamReturnInteger", GetOrigHamReturnInteger },
{ "GetOrigHamReturnFloat", GetOrigHamReturnFloat },
{ "GetOrigHamReturnVector", GetOrigHamReturnVector },
{ "GetOrigHamReturnEntity", GetOrigHamReturnEntity },
{ "GetOrigHamReturnString", GetOrigHamReturnString },
{ "SetHamReturnInteger", SetHamReturnInteger },
{ "SetHamReturnFloat", SetHamReturnFloat },
{ "SetHamReturnVector", SetHamReturnVector },
{ "SetHamReturnEntity", SetHamReturnEntity },
{ "SetHamReturnString", SetHamReturnString },
{ "GetHamReturnStatus", GetHamReturnStatus },
{ "SetHamParamInteger", SetHamParamInteger },
{ "SetHamParamFloat", SetHamParamFloat },
{ "SetHamParamVector", SetHamParamVector },
{ "SetHamParamEntity", SetHamParamEntity },
{ "SetHamParamString", SetHamParamString },
{ "SetHamParamTraceResult", SetHamParamTraceResult },
{ "SetHamParamItemInfo", SetHamParamItemInfo },
{ "GetHamItemInfo", GetHamItemInfo },
{ "SetHamItemInfo", SetHamItemInfo },
{ "CreateHamItemInfo", CreateHamItemInfo },
{ "FreeHamItemInfo", FreeHamItemInfo },
{ NULL, NULL },
};

View File

@ -0,0 +1,374 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#ifndef RETURNHANDLER_H
#define RETURNHANDLER_H
#include "ham_utils.h"
#include <am-vector.h>
#include <am-string.h>
#include <sh_stack.h>
enum
{
RET_VOID,
RET_BOOL,
RET_INTEGER,
RET_SHORT,
RET_FLOAT,
RET_VECTOR,
RET_STRING,
RET_CBASE,
RET_ENTVAR,
RET_EDICT,
RET_TRACE,
RET_ITEMINFO
};
typedef struct
{
int iSlot;
int iPosition;
const char *pszAmmo1;
int iMaxAmmo1;
const char *pszAmmo2;
int iMaxAmmo2;
const char *pszName;
int iMaxClip;
int iId;
int iFlags;
int iWeight;
}
ItemInfo;
enum
{
ItemInfo_iSlot,
ItemInfo_iPosition,
ItemInfo_pszAmmo1,
ItemInfo_iMaxAmmo1,
ItemInfo_pszAmmo2,
ItemInfo_iMaxAmmo2,
ItemInfo_pszName,
ItemInfo_iMaxClip,
ItemInfo_iId,
ItemInfo_iFlags,
ItemInfo_iWeight
};
// Container for return and parameter data.
// Contains a void pointer, and a flag telling what it contains.
class Data
{
private:
void *m_data;
int *m_index;
int m_type;
bool IsSet(void)
{
return (m_type != RET_VOID &&
m_data != NULL);
};
bool IsType(const int type)
{
return (m_type == type);
};
public:
Data() : m_data(NULL), m_index(NULL), m_type(RET_VOID)
{ /* nothing */ };
Data(int type, void *ptr) : m_data(ptr), m_index(NULL), m_type(type)
{ /* nothing */ };
Data(int type, void *ptr, int *cptr) : m_data(ptr), m_index(NULL), m_type(type)
{ /* nothing */ };
~Data()
{ /* nothing */ };
int GetType()
{
return m_type;
};
// All Get/Set value natives return < 0 on failure.
// -1: Wrong type
// -2: Bad data pointer (void, etc).
int SetInt(cell *data)
{
if (!IsSet())
{
return -2;
}
if (IsType(RET_INTEGER))
{
*(reinterpret_cast<int *>(m_data))=*data;
return 0;
}
else if (IsType(RET_BOOL))
{
*(reinterpret_cast<bool *>(m_data)) = *data > 0;
return 0;
}
else if (IsType(RET_SHORT))
{
*(reinterpret_cast<short *>(m_data)) = *data;
return 0;
}
else if (IsType(RET_ITEMINFO))
{
*(reinterpret_cast<int *>(m_data)) = *data;
return 0;
}
else if (IsType(RET_TRACE))
{
*(reinterpret_cast<int *>(m_data))=*data;
return 0;
}
return -1;
};
int SetFloat(cell *data)
{
if (!IsSet())
{
return -2;
}
if (!IsType(RET_FLOAT))
{
return -1;
}
*(reinterpret_cast<REAL *>(m_data))=amx_ctof2(*data);
return 0;
};
int SetVector(cell *data)
{
if (!IsSet())
{
return -2;
}
if (!IsType(RET_VECTOR))
{
return -1;
}
Vector *vec=reinterpret_cast<Vector *>(m_data);
vec->x=amx_ctof2(data[0]);
vec->y=amx_ctof2(data[1]);
vec->z=amx_ctof2(data[2]);
return 0;
};
int SetString(cell *data)
{
if (!IsSet())
{
return -2;
}
if (!IsType(RET_STRING))
{
return -1;
}
ke::AString *str=reinterpret_cast<ke::AString *>(m_data);
cell *i=data;
size_t len=0;
while (*i!=0)
{
i++;
len++;
};
char *temp=new char[len+1];
i=data;
char *j=temp;
while ((*j++=*i++)!=0)
{
/* nothing */
}
*str = temp;
delete[] temp;
return 0;
};
int SetEntity(cell *data)
{
if (!IsSet())
{
return -2;
}
if (IsType(RET_CBASE))
{
*(reinterpret_cast<void **>(m_data))=IndexToPrivate(*data);
if (m_index != 0)
{
*m_index=*data;
}
return 0;
}
else if (IsType(RET_ENTVAR))
{
*(reinterpret_cast<entvars_t **>(m_data))=IndexToEntvar(*data);
if (m_index != 0)
{
*m_index=*data;
}
return 0;
}
else if (IsType(RET_EDICT))
{
*(reinterpret_cast<edict_t **>(m_data)) = IndexToEdict(*data);
if (m_index != 0)
{
*m_index = *data;
}
return 0;
}
return -1;
};
int GetInt(cell *data)
{
if (!IsSet())
{
return -2;
}
if (IsType(RET_INTEGER))
{
*data=*(reinterpret_cast<int *>(m_data));
return 0;
}
else if (IsType(RET_BOOL))
{
*data = *(reinterpret_cast<bool *>(m_data));
return 0;
}
else if (IsType(RET_SHORT))
{
*data = *(reinterpret_cast<short *>(m_data));
return 0;
}
else if (IsType(RET_ITEMINFO))
{
*data = *(reinterpret_cast<int *>(m_data));
return 0;
}
else if (IsType(RET_TRACE))
{
*data=*(reinterpret_cast<int *>(m_data));
return 0;
}
return -1;
};
int GetFloat(cell *data)
{
if (!IsSet())
{
return -2;
}
if (!IsType(RET_FLOAT))
{
return -1;
}
*data=amx_ftoc2(*(reinterpret_cast<REAL *>(m_data)));
return 0;
};
int GetVector(cell *data)
{
if (!IsSet())
{
return -2;
}
if (!IsType(RET_VECTOR))
{
return -1;
}
Vector *vec=reinterpret_cast<Vector *>(m_data);
data[0]=amx_ftoc2(vec->x);
data[1]=amx_ftoc2(vec->y);
data[2]=amx_ftoc2(vec->z);
return 0;
};
int GetString(cell *data, int len)
{
if (!IsSet())
{
return -2;
}
if (!IsType(RET_STRING))
{
return -1;
}
const char *i=(reinterpret_cast<ke::AString *>(m_data)->chars());
while (len-- &&
(*data++=*i++)!='\0')
{
/* nothing */
};
return 0;
};
int GetEntity(cell *data)
{
if (!IsSet())
{
return -2;
}
if (IsType(RET_CBASE))
{
*data=PrivateToIndex(m_data);
return 0;
}
else if (IsType(RET_ENTVAR))
{
*data=EntvarToIndex(reinterpret_cast<entvars_t *>(m_data));
return 0;
}
else if (IsType(RET_EDICT))
{
*data = EdictToIndex(reinterpret_cast<edict_t *>(m_data));
return 0;
}
return -1;
}
};
extern CStack< Data * > ReturnStack;
extern CStack< Data * > OrigReturnStack;
extern CStack< ke::Vector< Data * > * > ParamStack;
extern CStack< int * > ReturnStatus;
#endif

View File

@ -0,0 +1,125 @@
# (C)2004-2013 AMX Mod X Development Team
# Makefile written by David "BAILOPAN" Anderson
###########################################
### EDIT THESE PATHS FOR YOUR OWN SETUP ###
###########################################
HLSDK = ../../../hlsdk
MM_ROOT = ../../../metamod/metamod
PUBLIC_ROOT = ../../public
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################
PROJECT = hamsandwich
OBJECTS = amxxmodule.cpp amxx_api.cpp config_parser.cpp hook_callbacks.cpp hook_native.cpp \
srvcmd.cpp call_funcs.cpp hook_create.cpp DataHandler.cpp pdata.cpp hook_specialbot.cpp
##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
##############################################
C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -fomit-frame-pointer -pipe
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
C_GCC4_FLAGS = -fvisibility=hidden
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
CPP = gcc
CPP_OSX = clang
LINK =
INCLUDE = -I. -I$(PUBLIC_ROOT) -I$(PUBLIC_ROOT)/sdk -I$(PUBLIC_ROOT)/amtl \
-I$(HLSDK) -I$(HLSDK)/public -I$(HLSDK)/common -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/pm_shared\
-I$(MM_ROOT)
################################################
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
################################################
OS := $(shell uname -s)
ifeq "$(OS)" "Darwin"
CPP = $(CPP_OSX)
LIB_EXT = dylib
LIB_SUFFIX = _amxx
CFLAGS += -DOSX
LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5
else
LIB_EXT = so
LIB_SUFFIX = _amxx_i386
CFLAGS += -DLINUX
LINK += -shared
endif
LINK += -m32 -lm -ldl
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32 -DHAVE_STDINT_H -fno-strict-aliasing -m32 -Wall -Werror
CPPFLAGS += -fno-exceptions -fno-rtti
BINARY = $(PROJECT)$(LIB_SUFFIX).$(LIB_EXT)
ifeq "$(DEBUG)" "true"
BIN_DIR = Debug
CFLAGS += $(C_DEBUG_FLAGS)
else
BIN_DIR = Release
CFLAGS += $(C_OPT_FLAGS)
LINK += -s
endif
IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0")
ifeq "$(IS_CLANG)" "1"
CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/")
CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/")
else
CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1)
CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3)
endif
# Clang || GCC >= 4
ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1"
CFLAGS += $(C_GCC4_FLAGS)
CPPFLAGS += $(CPP_GCC4_FLAGS)
endif
# Clang >= 3 || GCC >= 4.7
ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1"
CPPFLAGS += -Wno-delete-non-virtual-dtor
endif
# OS is Linux and not using clang
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1"
LINK += -static-libgcc
endif
OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
# This will break if we include other Makefiles, but is fine for now. It allows
# us to make a copy of this file that uses altered paths (ie. Makefile.mine)
# or other changes without mucking up the original.
MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
$(BIN_DIR)/%.o: %.cpp
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
all:
mkdir -p $(BIN_DIR)
ln -sf $(PUBLIC_ROOT)/sdk/amxxmodule.cpp
$(MAKE) -f $(MAKEFILE_NAME) $(PROJECT)
$(PROJECT): $(OBJ_BIN)
$(CPP) $(INCLUDE) $(OBJ_BIN) $(LINK) -o $(BIN_DIR)/$(BINARY)
debug:
$(MAKE) -f $(MAKEFILE_NAME) all DEBUG=true
default: all
clean:
rm -rf $(BIN_DIR)/*.o
rm -f $(BIN_DIR)/$(BINARY)

View File

@ -0,0 +1,71 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
/* 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)
{
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

View File

@ -0,0 +1,635 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#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 <windows.h>
#elif defined(__linux__) || defined(__APPLE__)
#include <sys/mman.h>
#if defined (__linux__)
#include <malloc.h>
#endif
#endif
#include <stddef.h> // size_t
#include <string.h> // memcpy
#include <stdlib.h> // memalign
#include <stdio.h>
#include <am-utility.h>
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 function
*/
const unsigned char codePrologue[] = {
0x55, // push ebp
0x89, 0xE5, // mov ebp, esp
};
/**
* Align stack on 16 byte boundary
*/
const unsigned char codeAlignStack16[] = {
0x83, 0xE4, 0xF0, // and esp, 0xFFFFFFF0
};
/**
* Allocate stack space (8-bit) by adding to ESP
*/
const unsigned char codeAllocStack[] = {
0x83, 0xEC, 0xFF, // sub esp, 0xFF
};
/**
* Offset of codeAllocStack to modify at runtime
* to contain amount of stack space to allocate.
*/
const unsigned int codeAllocStackReplace = 2;
/**
* 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__) || defined(__APPLE__)
0xFF, 0x75, 0x04 // pushl [ebp+0x08h]
#endif
};
#if defined(__linux__) || defined(__APPLE__)
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 function
*/
const unsigned char codeEpilogue[] = {
0x89, 0xEC, // mov esp, ebp
0x5D, // pop ebp
0xC3 // ret
};
const unsigned char codeEpilogueN[] = {
0x89, 0xEC, // mov esp, ebp
0x5D, // pop ebp
0xC2, 0xCD, 0xAB // retn 0xABCD
};
const int codeEpilogueNReplace = 4;
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;
int m_maxsize;
/**
* 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_maxsize=512;
m_buffer=(unsigned char *)malloc(m_maxsize);
}
else if (m_size > m_maxsize)
{
m_maxsize = m_size + 512;
m_buffer=(unsigned char *)realloc(m_buffer,m_maxsize);
}
unsigned char *dat=m_buffer+orig; // point dat to the end of the prewritten
while (orig<m_size)
{
*dat++=*src++;
orig++;
};
};
public:
TrampolineMaker()
{
m_buffer=NULL;
m_size=0;
m_mystack=0;
m_calledstack=0;
m_paramstart=0;
m_thiscall=0;
m_maxsize=0;
};
/**
* Inserts a breakpoint (int 3) into the trampoline.
*/
void Breakpoint()
{
Append(&::Trampolines::Bytecode::codeBreakpoint[0],sizeof(::Trampolines::Bytecode::codeBreakpoint));
};
/**
* Adds the prologue, pushes registers, prepares the stack
*/
void Prologue()
{
Append(&::Trampolines::Bytecode::codePrologue[0],sizeof(::Trampolines::Bytecode::codePrologue));
m_paramstart=0;
m_thiscall=0;
};
/**
* Flags this trampoline as a thiscall trampoline, and prepares the prologue.
*/
void ThisPrologue()
{
this->Prologue();
m_thiscall=1;
};
/**
* Epilogue for a function pops registers but does not free any more of the stack!
*/
void Epilogue()
{
Append(&::Trampolines::Bytecode::codeEpilogue[0],sizeof(::Trampolines::Bytecode::codeEpilogue));
};
/**
* Epilogue that also frees it's estimated stack usage. Useful for stdcall/thiscall/fastcall.
*/
void EpilogueAndFree()
{
this->Epilogue(m_mystack);
};
/**
* Epilogue. Pops registers, and frees given amount of data from the stack.
*
* @param howmuch How many bytes to free from the stack.
*/
void Epilogue(int howmuch)
{
unsigned char code[sizeof(::Trampolines::Bytecode::codeEpilogueN)];
memcpy(&code[0],&::Trampolines::Bytecode::codeEpilogueN[0],sizeof(::Trampolines::Bytecode::codeEpilogueN));
unsigned char *c=&code[0];
union
{
int i;
unsigned char b[4];
} bi;
bi.i=howmuch;
c+=::Trampolines::Bytecode::codeEpilogueNReplace;
*c++=bi.b[0];
*c++=bi.b[1];
Append(&code[0],sizeof(::Trampolines::Bytecode::codeEpilogueN));
};
/**
* Aligns stack on 16 byte boundary for functions that use aligned SSE instructions.
* This also allocates extra stack space to allow the specified number of slots to be used
* for function paramaters that will be pushed onto the stack.
*/
void AlignStack16(int slots)
{
const size_t stackNeeded = slots * sizeof(void *);
const size_t stackReserve = ke::Align(stackNeeded, 16);
const size_t stackExtra = stackReserve - stackNeeded;
// Stack space should fit in a byte
assert(stackExtra <= 0xFF);
const size_t codeAlignStackSize = sizeof(::Trampolines::Bytecode::codeAlignStack16);
const size_t codeAllocStackSize = sizeof(::Trampolines::Bytecode::codeAllocStack);
unsigned char code[codeAlignStackSize + codeAllocStackSize];
memcpy(&code[0], &::Trampolines::Bytecode::codeAlignStack16[0], codeAlignStackSize);
if (stackExtra > 0)
{
unsigned char *c = &code[codeAlignStackSize];
memcpy(c, &::Trampolines::Bytecode::codeAllocStack[0], codeAllocStackSize);
c += ::Trampolines::Bytecode::codeAllocStackReplace;
*c = (unsigned char)stackExtra;
Append(&code[0], codeAlignStackSize + codeAllocStackSize);
}
else
{
Append(&code[0], codeAlignStackSize);
}
}
/**
* 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__) || defined(__APPLE__)
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__) || defined(__APPLE__)
m_mystack+=4;
#endif
m_calledstack+=4;
};
/**
* Frees what is estimated as the stack usage of the trampoline.
*/
void FreeMyStack(void)
{
this->FreeStack(m_mystack);
};
/**
* Frees the estimated stack usage of the callee.
*/
void FreeTargetStack(void)
{
this->FreeStack(m_calledstack);
};
/**
* Frees the estimated stack usage of the callee and the trampoline.
*/
void FreeBothStacks(void)
{
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));
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__) || defined(__APPLE__)
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));
m_calledstack+=4; // increase auto detected stack size
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;
}
// Reallocate with proper flags
#if defined(_WIN32)
void *ret=VirtualAlloc(NULL, m_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
#elif defined(__GNUC__)
# if defined(__APPLE__)
void *ret = valloc(m_size);
# else
void *ret=memalign(sysconf(_SC_PAGESIZE), m_size);
# endif
mprotect(ret,m_size,PROT_READ|PROT_WRITE|PROT_EXEC);
#endif
memcpy(ret, m_buffer, m_size);
m_size=0;
free(m_buffer);
m_buffer=NULL; // so we don't accidentally rewrite!
m_mystack=0;
m_calledstack=0;
m_maxsize=512;
return ret;
};
};
};
/**
* Utility to make a generic trampoline.
*/
inline void *CreateGenericTrampoline(bool thiscall, bool voidcall, bool retbuf, int paramcount, void *extraptr, void *callee)
{
Trampolines::TrampolineMaker tramp;
if (thiscall)
{
tramp.ThisPrologue();
tramp.AlignStack16(paramcount + 2); // Param count + this ptr + extra ptr
}
else
{
tramp.Prologue();
tramp.AlignStack16(paramcount + 1); // Param count + extra ptr
}
while (paramcount)
{
tramp.PushParam(paramcount--);
}
if (thiscall)
{
tramp.PushThis();
}
tramp.PushNum(reinterpret_cast<int>(extraptr));
tramp.Call(callee);
tramp.FreeTargetStack();
#if defined(_WIN32)
tramp.EpilogueAndFree();
#elif defined(__linux__) || defined(__APPLE__)
if (retbuf)
{
tramp.Epilogue(4);
}
else
{
tramp.Epilogue();
}
#endif
return tramp.Finish(NULL);
};
#endif // TRAMPOLINEMANAGER_H

View File

@ -0,0 +1,132 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#include "amxxmodule.h"
#include <extdll.h>
#include "NEW_Util.h"
#include <am-vector.h>
#include "forward.h"
#include "hook.h"
#include "ham_const.h"
#include "hooklist.h"
#include "offsets.h"
#include <assert.h>
#include "DataHandler.h"
#include "hook_specialbot.h"
edict_t *NEW_FirstEdict;
bool NEW_Initialized;
extern ke::Vector<Hook*> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
extern CHamSpecialBotHandler SpecialbotHandler;
extern AMX_NATIVE_INFO RegisterNatives[];
extern AMX_NATIVE_INFO ReturnNatives[];
extern AMX_NATIVE_INFO pdata_natives[];
extern AMX_NATIVE_INFO pdata_natives_safe[];
extern hook_t hooklist[];
int ReadConfig(void);
void OnAmxxAttach(void)
{
// Assert that the enum is aligned properly with the table
assert(strcmp(hooklist[Ham_FVecVisible].name, "fvecvisible")==0);
assert(strcmp(hooklist[Ham_Player_UpdateClientData].name, "player_updateclientdata")==0);
assert(strcmp(hooklist[Ham_Item_AddToPlayer].name, "item_addtoplayer")==0);
assert(strcmp(hooklist[Ham_Weapon_ExtractAmmo].name, "weapon_extractammo")==0);
assert(strcmp(hooklist[Ham_TS_BreakableRespawn].name, "ts_breakablerespawn")==0);
assert(strcmp(hooklist[Ham_NS_UpdateOnRemove].name, "ns_updateonremove")==0);
assert(strcmp(hooklist[Ham_TS_ShouldCollide].name, "ts_shouldcollide")==0);
assert(strcmp(hooklist[Ham_GetDeathActivity].name, "getdeathactivity")==0);
assert(strcmp(hooklist[Ham_StopFollowing].name, "stopfollowing")==0);
assert(strcmp(hooklist[Ham_CS_Player_OnTouchingWeapon].name, "cstrike_player_ontouchingweapon")==0);
assert(strcmp(hooklist[Ham_DOD_Weapon_Special].name, "dod_weapon_special")==0);
assert(strcmp(hooklist[Ham_TFC_RadiusDamage2].name, "tfc_radiusdamage2")==0);
assert(strcmp(hooklist[Ham_ESF_Weapon_HolsterWhenMeleed].name, "esf_weapon_holsterwhenmeleed") == 0);
assert(strcmp(hooklist[Ham_NS_Weapon_GetDeployTime].name, "ns_weapon_getdeploytime")==0);
assert(strcmp(hooklist[Ham_SC_MedicCallSound].name, "sc_mediccallsound")==0);
assert(strcmp(hooklist[Ham_SC_Player_CanTouchPlayer].name, "sc_player_cantouchplayer")==0);
assert(strcmp(hooklist[Ham_SC_Weapon_ChangeWeaponSkin].name, "sc_weapon_changeweaponskin")==0);
assert(strcmp(hooklist[Ham_Item_GetItemInfo].name, "item_getiteminfo") == 0);
MF_AddNatives(pdata_natives_safe);
if (ReadConfig() > 0)
{
if (Offsets.IsValid())
{
MF_AddNatives(RegisterNatives);
MF_AddNatives(ReturnNatives);
MF_AddNatives(pdata_natives);
}
else
{
#ifdef _WIN32
MF_Log("Error: pev and base not set for section \"%s windows\", cannot register natives.", MF_GetModname());
#elif defined(__linux__)
MF_Log("Error: pev and base not set for section \"%s linux\", cannot register natives.", MF_GetModname());
#elif defined(__APPLE__)
MF_Log("Error: pev and base not set for section \"%s mac\", cannot register natives.", MF_GetModname());
#endif
}
}
else
{
MF_Log("Error: Cannot read config file, natives not registered!");
}
}
extern CStack<ItemInfo *> g_FreeIIs;
void OnAmxxDetach()
{
while (!g_FreeIIs.empty())
{
delete g_FreeIIs.front();
g_FreeIIs.pop();
}
}
void HamCommand(void);
void OnPluginsUnloaded(void)
{
for (size_t i = 0; i < HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++)
{
for (size_t j = 0; j < hooks[i].length(); ++j)
{
delete hooks[i].at(j);
}
hooks[i].clear();
}
}
void OnPluginsLoaded(void)
{
NEW_Initialize(INDEXENT(0));
}
void OnMetaAttach(void)
{
REG_SVR_COMMAND("ham", HamCommand);
}
void SetClientKeyValue(int clientIndex, char *infobuffer, const char *key, const char *value)
{
SpecialbotHandler.CheckClientKeyValue(clientIndex, infobuffer, key, value);
RETURN_META(MRES_IGNORED);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,191 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#ifndef HOOK_Call_H
#define HOOK_Call_H
cell Call_Void_Void(AMX *amx, cell *params);
cell Call_Int_Void(AMX *amx, cell *params);
cell Call_Void_Entvar(AMX *amx, cell *params);
cell Call_Void_Cbase(AMX *amx, cell *params);
cell Call_Int_Float_Int(AMX *amx, cell *params);
cell Call_Int_Float_Int_Int(AMX *amx, cell *params);
cell Call_Void_Entvar_Int(AMX *amx, cell *params);
cell Call_Void_Entvar_Entvar_Int(AMX *amx, cell *params);
cell Call_Int_Cbase(AMX *amx, cell *params);
cell Call_Void_Int_Int(AMX *amx, cell *params);
cell Call_Int_Int_Str_Int(AMX *amx, cell *params);
cell Call_Int_Int_Str_Int_Int(AMX *amx, cell *params);
cell Call_Int_Int(AMX *amx, cell *params);
cell Call_Int_Entvar(AMX *amx, cell *params);
cell Call_Int_Entvar_Entvar_Float_Int(AMX *amx, cell *params);
cell Call_Int_Entvar_Entvar_Float_Float_Int(AMX *amx, cell *params);
cell Call_Void_Int(AMX *amx, cell *params);
cell Call_Vector_Float_Cbase_Int(AMX *amx, cell *params);
cell Call_Void_Cbase_Cbase_Int_Float(AMX *amx, cell *params);
cell Call_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, cell *params);
cell Call_Void_Float_Vector_Trace_Int(AMX *amx, cell *params);
cell Call_Str_Void(AMX *amx, cell *params);
cell Call_Cbase_Void(AMX *amx, cell *params);
cell Call_Vector_Void(AMX *amx, cell *params);
cell Call_Vector_pVector(AMX *amx, cell *params);
cell Call_Int_pVector(AMX *amx, cell *params);
cell Call_Void_Entvar_Float_Float(AMX *amx, cell *params);
cell Call_Void_pFloat_pFloat(AMX *amx, cell *params);
cell Call_Void_Entvar_Float(AMX *amx, cell *params);
cell Call_Void_Int_Int_Int(AMX *amx, cell *params);
cell Call_Void_ItemInfo(AMX *amx, cell *params);
cell Call_Float_Void(AMX *amx, cell *params);
cell Call_Void_Float_Int(AMX* amx, cell* params);
cell Call_Float_Float_Cbase(AMX* amx, cell* params);
cell Call_Void_Float(AMX* amx, cell* params);
cell Call_Void_Float_Float_Float_Int(AMX* amx, cell* params);
cell Call_Float_Int(AMX* amx, cell* params);
cell Call_Vector_Float(AMX* amx, cell* params);
cell Call_Void_Float_Cbase(AMX *amx, cell *params);
cell Call_Int_Float_Float(AMX *amx, cell *params);
cell Call_Int_Float(AMX *amx, cell *params);
cell Call_Int_Int_Int(AMX *amx, cell *params);
cell Call_Void_Str_Float_Float_Float(AMX *amx, cell *params);
cell Call_Void_Str_Float_Float_Float_Int_Cbase(AMX *amx, cell *params);
cell Call_Int_Vector_Vector_Float_Float(AMX *amx, cell *params);
cell Call_Int_Short(AMX *amx, cell *params);
cell Call_Void_Entvar_Entvar_Float_Int_Int(AMX *amx, cell *params);
cell Call_Void_Vector_Entvar_Entvar_Float_Int_Int(AMX *amx, cell *params);
cell Call_Float_Int_Float(AMX* amx, cell* params);
cell Call_Int_Str(AMX* amx, cell* params);
cell Call_Void_Edict(AMX* amx, cell* params);
cell Call_Void_Int_Str_Bool(AMX* amx, cell* params);
cell Call_Void_Vector_Vector(AMX* amx, cell* params);
cell Call_Void_Str_Bool(AMX* amx, cell* params);
cell Call_Int_Str_Str_Int_Str_Int_Int(AMX* amx, cell* params);
cell Call_Int_Int_Int_Float_Int(AMX* amx, cell* params);
cell Call_Void_Str_Int(AMX* amx, cell* params);
cell Call_Void_Cbase_Int(AMX* amx, cell* params);
cell Call_Void_Str(AMX* amx, cell* params);
cell Call_Void_Vector(AMX* amx, cell* params);
cell Call_Int_Str_Vector_Str(AMX* amx, cell* params);
cell Call_Int_Str_Str(AMX* amx, cell* params);
cell Call_Void_Float_Float(AMX* amx, cell* params);
cell Call_Void_Str_Str_Int(AMX* amx, cell* params);
cell Call_Int_pVector_pVector_Cbase_pFloat(AMX* amx, cell* params);
cell Call_Void_Cbase_pVector_Float(AMX* amx, cell* params);
cell Call_Int_pVector_pVector_Float_Cbase_pVector(AMX* amx, cell* params);
cell Call_Int_Cbase_Bool(AMX* amx, cell* params);
cell Call_Int_Vector_Vector(AMX *amx, cell *params);
cell Call_Int_Entvar_Float(AMX *amx, cell *params);
cell Call_Float_Float(AMX* amx, cell* params);
cell Call_Void_Entvar_Entvar_Float(AMX *amx, cell *params);
cell Call_Bool_Void(AMX *amx, cell *params);
cell Call_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(AMX* amx, cell* params);
cell Call_Int_Vector_Cbase(AMX *amx, cell *params);
cell Call_Int_Vector(AMX *amx, cell *params);
cell Call_Int_Cbase_pVector(AMX *amx, cell *params);
cell Call_Void_Bool(AMX *amx, cell *params);
cell Call_Bool_Cbase(AMX *amx, cell *params);
cell Call_Bool_Int(AMX *amx, cell *params);
cell Call_Void_Cbase_Float(AMX* amx, cell* params);
cell Call_Void_Cbase_Bool(AMX* amx, cell* params);
cell Call_Vector_Vector_Vector_Vector(AMX *amx, cell *params);
cell Call_Str_Str(AMX *amx, cell *params);
cell Call_Void_Short(AMX *amx, cell *params);
cell Call_Deprecated(AMX* amx, cell* params);
#endif

View File

@ -0,0 +1,67 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#ifndef CELLTOTYPE_H
#define CELLTOTYPE_H
#include <extdll.h>
#include "sdk/amxxmodule.h"
#include "CVector.h"
#include "hook.h"
#include "forward.h"
#include "ham_const.h"
#include "ham_utils.h"
inline void CellToType(const AMX*& amx, const cell& in, int& out)
{
out=static_cast<int>(in);
}
inline void CellToType(const AMX*& amx, const cell& in, float& out)
{
out=amx_ctof2(in);
}
inline void CellToType(const AMX*& amx, const cell& in, edict_t*& out)
{
out=INDEXENT_NEW(in);
}
inline void CellToType(const AMX*& amx, const cell& in, entvars_t*& out)
{
out=&(INDEXENT_NEW(in)->v);
}
inline void CellToType(const AMX*& amx, const cell& in, HLBaseEntity*& out)
{
out=(HLBaseEntity *)(INDEXENT_NEW(in)->pvPrivateData);
}
inline void CellToType(const AMX*& amx, const cell& in, Vector& out)
{
float *v=(float *)MF_GetAmxAddr(amx, in);
out.x=v[0];
out.y=v[1];
out.z=v[2];
}
inline void CellToType(const AMX*& amx, const cell& in, TraceResult*& out)
{
out=reinterpret_cast<TraceResult*>(in);
}
#endif

View File

@ -0,0 +1,388 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#include "amxxmodule.h"
#include "ham_const.h"
#include "hooklist.h"
#include "offsets.h"
extern hook_t hooklist[];
enum
{
LEX_INVALID = 0,
LEX_UNKNOWN,
LEX_START_SEC,
LEX_END_SEC,
LEX_MIRROR,
LEX_PEV,
LEX_BASE,
LEX_END
};
const char *tokens[] =
{
"", // LEX_INVALID
"", // LEX_UNKNOWN
"@section", // LEX_START_SEC
"@end", // LEX_END_SEC
"@mirror", // LEX_MIRROR
"pev", // LEX_PEV
"base", // LEX_BASE
"", // LEX_END
};
static void trim_line(char *input);
static void read_mirror(char *input);
static void skip_to_end_of_section(FILE *fp);
static int lex(char*& buffer);
int lex(char*& buffer)
{
trim_line(buffer);
size_t len;
for (int i=0; i<LEX_END; i++)
{
if (tokens[i]!=NULL && *(tokens[i])!='\0')
{
len=strlen(tokens[i]);
if (strncmp(buffer,tokens[i],len)==0)
{
buffer+=len+1;
return i;
}
}
}
return LEX_UNKNOWN;
}
// How we handle "mirrors"
// We just note down the current mod name, and every time
// we come across a mirror with the destination that matches
// the current mod name, we change the current mod name to
// the source for that mirror.
char CurrentModName[64];
static void read_mirror(char *input)
{
char *data=input;
char *data2;
char source[64];
char dest[64];
char old;
while ( *data!=' ' &&
*data!='\t' &&
*data!='\0')
{
data++;
}
old=*data;
*data='\0';
// mark down the source
UTIL_Format(source, sizeof(source)-1, "%s", input);
*data=old;
while ( *data==' ' ||
*data=='\t')
{
data++;
}
data2=data;
while ( *data!=' ' &&
*data!='\t' &&
*data!='\0')
{
data++;
}
old=*data;
*data='\0';
UTIL_Format(dest, sizeof(dest)-1, "%s", data2);
*data=old;
if (strcmp(dest, CurrentModName)==0)
{
UTIL_Format(CurrentModName, sizeof(CurrentModName)-1, "%s", source);
}
}
static void trim_line(char *input)
{
char *oldinput=input;
char *start=input;
while ( *start==' ' ||
*start=='\t' ||
*start=='\r' ||
*start=='\n')
{
start++;
}
// Overwrite the whitespace
if (start != input)
{
while ((*input++=*start++)!='\0')
/* do nothing */ ;
}
start=oldinput;
start+=strlen(start) - 1;
while ( start >= oldinput &&
( *start == '\0' ||
*start == ' ' ||
*start == '\r' ||
*start == '\n' ||
*start == '\t'))
{
start--;
}
start++;
*start='\0';
// Now find any comments and cut off at the start
while (*start != '\0')
{
if (*start == ';')
{
*start='\0';
break;
}
start++;
}
}
void skip_to_end_of_section(FILE *fp)
{
char buffer[1024];
while (!feof(fp))
{
buffer[0]='\0';
fgets(buffer, sizeof(buffer)-1, fp);
trim_line(buffer);
char *b=&buffer[0];
if (lex(b)==LEX_END_SEC)
{
break;
}
}
}
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;
}
int read_start_section(char *data)
{
if (strncasecmp(data, CurrentModName, strlen(CurrentModName))==0)
{
data+=strlen(CurrentModName)+1;
trim_line(data);
#ifdef _WIN32
if (strcmp(data, "windows")==0)
#elif defined(__linux__)
if (strcmp(data, "linux")==0)
#elif defined(__APPLE__)
if (strcmp(data, "mac")==0)
#endif
{
return 1;
}
}
return 0;
}
int read_number(char *input)
{
char *end; /* Temporary pointer, needed for strtoul(). */
// if begins with 0x or 0X it's to be interpretted as hex
if (*input=='0' &&
(*(input+1)=='x' || *(input+1)=='X'))
{
return strtoul(input,&end,16);
}
// otherwise it's to be interpretted as base 10
return strtoul(input,&end,10);
}
void process_pev(char *data)
{
trim_line(data);
Offsets.SetPev(read_number(data));
}
void process_base(char *data)
{
trim_line(data);
Offsets.SetBase(read_number(data));
}
void process_key(char *data)
{
size_t size=0;
char *a=data;
while (*a != ' ' && *a != '\t' && *a != '\0')
{
a++;
size++;
}
if (size==0)
{
return;
}
int set=0;
for (int i=0; i< HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++)
{
if (strncmp(data, hooklist[i].name, size)==0)
{
data+=size+1;
trim_line(data);
int value=read_number(data);
hooklist[i].isset=1;
hooklist[i].vtid=value;
set=1;
break;
}
}
if (set==0)
{
printf("stray key in process_key: %s\n", data);
}
}
int ReadConfig(void)
{
char FileName[512];
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");
UTIL_Format(CurrentModName, sizeof(CurrentModName)-1, "%s", MF_GetModname());
if (!fp)
{
MF_Log("Unable to open \"%s\" for reading.", FileName);
return -1;
}
char data[2048];
int insec=0;
while (!feof(fp))
{
data[0]='\0';
fgets(data, sizeof(data)-1, fp);
char *b=&data[0];
switch(lex(b))
{
case LEX_PEV:
{
if (insec)
{
process_pev(b);
}
break;
};
case LEX_BASE:
{
if (insec)
{
process_base(b);
}
break;
};
case LEX_MIRROR:
{
read_mirror(b);
break;
};
case LEX_START_SEC:
{
insec=read_start_section(b);
if (!insec)
{
skip_to_end_of_section(fp);
}
break;
};
case LEX_END_SEC:
{
insec=0;
break;
};
case LEX_UNKNOWN:
{
if (insec)
{
process_key(b);
}
};
}
}
return 1;
}

View File

@ -0,0 +1,53 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#include "amxxmodule.h"
#ifndef FORWARD_H
#define FORWARD_H
enum fwdstate
{
FSTATE_INVALID = 0,
FSTATE_OK,
FSTATE_PAUSE,
FSTATE_STOP,
FSTATE_DESTROY
};
class Forward
{
public:
int id; // id of the forward
fwdstate state;
Forward(int id_) : id(id_), state(FSTATE_OK)
{
/* do nothing */
};
Forward() : id(-1), state(FSTATE_INVALID)
{
/* do nothing */
}
~Forward()
{
MF_UnregisterSPForward(id);
}
inline void Set(int i)
{
state=FSTATE_OK;
id=i;
};
};
#endif

View File

@ -0,0 +1,500 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#ifndef HAM_CONST_H
#define HAM_CONST_H
enum
{
HAM_UNSET = 0,
HAM_IGNORED,
HAM_HANDLED,
HAM_OVERRIDE,
HAM_SUPERCEDE
};
enum
{
Ham_Spawn = 0,
Ham_Precache,
Ham_Keyvalue,
Ham_ObjectCaps,
Ham_Activate,
Ham_SetObjectCollisionBox,
Ham_Classify,
Ham_DeathNotice,
Ham_TraceAttack,
Ham_TakeDamage,
Ham_TakeHealth,
Ham_Killed,
Ham_BloodColor,
Ham_TraceBleed,
Ham_IsTriggered,
Ham_MyMonsterPointer,
Ham_MySquadMonsterPointer,
Ham_GetToggleState,
Ham_AddPoints,
Ham_AddPointsToTeam,
Ham_AddPlayerItem,
Ham_RemovePlayerItem,
Ham_GiveAmmo,
Ham_GetDelay,
Ham_IsMoving,
Ham_OverrideReset,
Ham_DamageDecal,
Ham_SetToggleState,
Ham_StartSneaking,
Ham_StopSneaking,
Ham_OnControls,
Ham_IsSneaking,
Ham_IsAlive,
Ham_IsBSPModel,
Ham_ReflectGauss,
Ham_HasTarget,
Ham_IsInWorld,
Ham_IsPlayer,
Ham_IsNetClient,
Ham_TeamId,
Ham_GetNextTarget,
Ham_Think,
Ham_Touch,
Ham_Use,
Ham_Blocked,
Ham_Respawn,
Ham_UpdateOwner,
Ham_FBecomeProne,
Ham_Center,
Ham_EyePosition,
Ham_EarPosition,
Ham_BodyTarget,
Ham_Illumination,
Ham_FVisible,
Ham_FVecVisible,
Ham_Player_Jump,
Ham_Player_Duck,
Ham_Player_PreThink,
Ham_Player_PostThink,
Ham_Player_GetGunPosition,
Ham_Player_ShouldFadeOnDeath,
Ham_Player_ImpulseCommands,
Ham_Player_UpdateClientData,
Ham_Item_AddToPlayer,
Ham_Item_AddDuplicate,
Ham_Item_CanDeploy,
Ham_Item_Deploy,
Ham_Item_CanHolster,
Ham_Item_Holster,
Ham_Item_UpdateItemInfo,
Ham_Item_PreFrame,
Ham_Item_PostFrame,
Ham_Item_Drop,
Ham_Item_Kill,
Ham_Item_AttachToPlayer,
Ham_Item_PrimaryAmmoIndex,
Ham_Item_SecondaryAmmoIndex,
Ham_Item_UpdateClientData,
Ham_Item_GetWeaponPtr,
Ham_Item_ItemSlot,
Ham_Weapon_ExtractAmmo,
Ham_Weapon_ExtractClipAmmo,
Ham_Weapon_AddWeapon,
Ham_Weapon_PlayEmptySound,
Ham_Weapon_ResetEmptySound,
Ham_Weapon_SendWeaponAnim,
Ham_Weapon_IsUsable,
Ham_Weapon_PrimaryAttack,
Ham_Weapon_SecondaryAttack,
Ham_Weapon_Reload,
Ham_Weapon_WeaponIdle,
Ham_Weapon_RetireWeapon,
Ham_Weapon_ShouldWeaponIdle,
Ham_Weapon_UseDecrement,
Ham_TS_BreakableRespawn,
Ham_TS_CanUsedThroughWalls,
Ham_TS_RespawnWait,
Ham_CS_Restart,
Ham_CS_RoundRespawn,
Ham_CS_Item_CanDrop,
Ham_CS_Item_GetMaxSpeed,
Ham_DOD_RoundRespawn,
Ham_DOD_RoundRespawnEnt,
Ham_DOD_RoundStore,
Ham_DOD_AreaSetIndex,
Ham_DOD_AreaSendStatus,
Ham_DOD_GetState,
Ham_DOD_GetStateEnt,
Ham_DOD_Item_CanDrop,
Ham_TFC_EngineerUse,
Ham_TFC_Finished,
Ham_TFC_EmpExplode,
Ham_TFC_CalcEmpDmgRad,
Ham_TFC_TakeEmpBlast,
Ham_TFC_EmpRemove,
Ham_TFC_TakeConcussionBlast,
Ham_TFC_Concuss,
Ham_ESF_IsEnvModel, // Only valid in ESF Open Beta
Ham_ESF_TakeDamage2, // Only valid in ESF Open Beta
Ham_NS_GetPointValue,
Ham_NS_AwardKill,
Ham_NS_ResetEntity,
Ham_NS_UpdateOnRemove,
Ham_TS_GiveSlowMul,
Ham_TS_GoSlow,
Ham_TS_InSlow,
Ham_TS_IsObjective,
Ham_TS_EnableObjective,
Ham_TS_OnFreeEntPrivateData,
Ham_TS_ShouldCollide,
//
// New addition - 2011
//
Ham_ChangeYaw,
Ham_HasHumanGibs,
Ham_HasAlienGibs,
Ham_FadeMonster,
Ham_GibMonster,
Ham_BecomeDead,
Ham_IRelationship,
Ham_PainSound,
Ham_ReportAIState,
Ham_MonsterInitDead,
Ham_Look,
Ham_BestVisibleEnemy,
Ham_FInViewCone,
Ham_FVecInViewCone,
Ham_GetDeathActivity,
// Not valid in CS, NS and TS.
Ham_RunAI,
Ham_MonsterThink,
Ham_MonsterInit,
Ham_CheckLocalMove,
Ham_Move,
Ham_MoveExecute,
Ham_ShouldAdvanceRoute,
Ham_GetStoppedActivity,
Ham_Stop,
Ham_CheckRangeAttack1,
Ham_CheckRangeAttack2,
Ham_CheckMeleeAttack1,
Ham_CheckMeleeAttack2,
Ham_ScheduleChange,
Ham_CanPlaySequence,
Ham_CanPlaySentence,
Ham_PlaySentence,
Ham_PlayScriptedSentence,
Ham_SentenceStop,
Ham_GetIdealState,
Ham_SetActivity,
Ham_CheckEnemy,
Ham_FTriangulate,
Ham_SetYawSpeed,
Ham_BuildNearestRoute,
Ham_FindCover,
Ham_CoverRadius,
Ham_FCanCheckAttacks,
Ham_CheckAmmo,
Ham_IgnoreConditions,
Ham_FValidateHintType,
Ham_FCanActiveIdle,
Ham_ISoundMask,
Ham_HearingSensitivity,
Ham_BarnacleVictimBitten,
Ham_BarnacleVictimReleased,
Ham_PrescheduleThink,
Ham_DeathSound,
Ham_AlertSound,
Ham_IdleSound,
Ham_StopFollowing,
Ham_CS_Weapon_SendWeaponAnim,
Ham_CS_Player_ResetMaxSpeed,
Ham_CS_Player_IsBot,
Ham_CS_Player_GetAutoaimVector,
Ham_CS_Player_Blind,
Ham_CS_Player_OnTouchingWeapon,
Ham_DOD_SetScriptReset,
Ham_DOD_Item_SpawnDeploy,
Ham_DOD_Item_SetDmgTime,
Ham_DOD_Item_DropGren,
Ham_DOD_Weapon_IsUseable,
Ham_DOD_Weapon_Aim,
Ham_DOD_Weapon_flAim,
Ham_DOD_Weapon_RemoveStamina,
Ham_DOD_Weapon_ChangeFOV,
Ham_DOD_Weapon_ZoomOut,
Ham_DOD_Weapon_ZoomIn,
Ham_DOD_Weapon_GetFOV,
Ham_DOD_Weapon_IsWaterSniping,
Ham_DOD_Weapon_UpdateZoomSpeed,
Ham_DOD_Weapon_Special,
Ham_TFC_DB_GetItemName,
Ham_TFC_RadiusDamage,
Ham_TFC_RadiusDamage2,
Ham_ESF_IsFighter,
Ham_ESF_IsBuddy,
Ham_ESF_EmitSound,
Ham_ESF_EmitNullSound,
Ham_ESF_IncreaseStrength,
Ham_ESF_IncreasePL,
Ham_ESF_SetPowerLevel,
Ham_ESF_SetMaxPowerLevel,
Ham_ESF_StopAniTrigger,
Ham_ESF_StopFly,
Ham_ESF_HideWeapon,
Ham_ESF_ClientRemoveWeapon,
Ham_ESF_SendClientsCustomModel,
Ham_ESF_CanTurbo,
Ham_ESF_CanPrimaryFire,
Ham_ESF_CanSecondaryFire,
Ham_ESF_CanStopFly,
Ham_ESF_CanBlock,
Ham_ESF_CanRaiseKi,
Ham_ESF_CanRaiseStamina,
Ham_ESF_CanTeleport,
Ham_ESF_CanStartFly,
Ham_ESF_CanStartPowerup,
Ham_ESF_CanJump,
Ham_ESF_CanWallJump,
Ham_ESF_IsSuperJump,
Ham_ESF_IsMoveBack,
Ham_ESF_CheckWallJump,
Ham_ESF_EnableWallJump,
Ham_ESF_DisableWallJump,
Ham_ESF_ResetWallJumpVars,
Ham_ESF_GetWallJumpAnim,
Ham_ESF_GetWallJumpAnim2,
Ham_ESF_SetWallJumpAnimation,
Ham_ESF_SetFlyMoveType,
Ham_ESF_IsFlyMoveType,
Ham_ESF_IsWalkMoveType,
Ham_ESF_SetWalkMoveType,
Ham_ESF_DrawChargeBar,
Ham_ESF_StartBlock,
Ham_ESF_StopBlock,
Ham_ESF_StartFly,
Ham_ESF_GetMaxSpeed,
Ham_ESF_SetAnimation,
Ham_ESF_PlayAnimation,
Ham_ESF_GetMoveForward,
Ham_ESF_GetMoveRight,
Ham_ESF_GetMoveUp,
Ham_ESF_AddBlindFX,
Ham_ESF_RemoveBlindFX,
Ham_ESF_DisablePSBar,
Ham_ESF_AddBeamBoxCrosshair,
Ham_ESF_RemoveBeamBoxCrosshair,
Ham_ESF_DrawPSWinBonus,
Ham_ESF_DrawPSBar,
Ham_ESF_LockCrosshair,
Ham_ESF_UnLockCrosshair,
Ham_ESF_RotateCrosshair,
Ham_ESF_UnRotateCrosshair,
Ham_ESF_WaterMove,
Ham_ESF_CheckTimeBasedDamage,
Ham_ESF_DoesSecondaryAttack,
Ham_ESF_DoesPrimaryAttack,
Ham_ESF_RemoveSpecialModes,
Ham_ESF_StopTurbo,
Ham_ESF_TakeBean,
Ham_ESF_GetPowerLevel,
Ham_ESF_RemoveAllOtherWeapons,
Ham_ESF_StopSwoop,
Ham_ESF_SetDeathAnimation,
Ham_ESF_SetModel,
Ham_ESF_AddAttacks,
Ham_ESF_EmitClassSound,
Ham_ESF_CheckLightning,
Ham_ESF_FreezeControls,
Ham_ESF_UnFreezeControls,
Ham_ESF_UpdateKi,
Ham_ESF_UpdateHealth,
Ham_ESF_GetTeleportDir,
Ham_ESF_Weapon_HolsterWhenMeleed,
Ham_NS_SetBoneController,
Ham_NS_SaveDataForReset,
Ham_NS_GetHull,
Ham_NS_GetMaxWalkSpeed,
Ham_NS_SetTeamID,
Ham_NS_GetEffectivePlayerClass,
Ham_NS_GetAuthenticationMask,
Ham_NS_EffectivePlayerClassChanged,
Ham_NS_NeedsTeamUpdate,
Ham_NS_SendTeamUpdate,
Ham_NS_SendWeaponUpdate,
Ham_NS_InitPlayerFromSpawn,
Ham_NS_PackDeadPlayerItems,
Ham_NS_GetAnimationForActivity,
Ham_NS_StartObserver,
Ham_NS_StopObserver,
Ham_NS_GetAdrenalineFactor,
Ham_NS_GetNamedItem,
Ham_NS_Suicide,
Ham_NS_GetCanUseWeapon,
Ham_NS_Weapon_GetWeapPrimeTime,
Ham_NS_Weapon_PrimeWeapon,
Ham_NS_Weapon_GetIsWeaponPrimed,
Ham_NS_Weapon_GetIsWeaponPriming,
Ham_NS_Weapon_DefaultDeploy,
Ham_NS_Weapon_DefaultReload,
Ham_NS_Weapon_GetDeployTime,
Ham_SC_GetClassification,
Ham_SC_IsMonster,
Ham_SC_IsPhysX,
Ham_SC_IsPointEntity,
Ham_SC_IsMachine,
Ham_SC_CriticalRemove,
Ham_SC_UpdateOnRemove,
Ham_SC_FVisible,
Ham_SC_FVisibleFromPos,
Ham_SC_IsFacings,
Ham_SC_GetPointsForDamage,
Ham_SC_GetDamagePoints,
Ham_SC_OnCreate,
Ham_SC_OnDestroy,
Ham_SC_IsValidEntity,
Ham_SC_ShouldFadeOnDeath,
Ham_SC_SetupFriendly,
Ham_SC_ReviveThink,
Ham_SC_Revive,
Ham_SC_StartMonster,
Ham_SC_CheckRangeAttack1_Move,
Ham_SC_CheckRangeAttack2_Move,
Ham_SC_CheckMeleeAttack1_Move,
Ham_SC_CheckMeleeAttack2_Move,
Ham_SC_CheckTankUsage,
Ham_SC_SetGaitActivity,
Ham_SC_FTriangulate,
Ham_SC_FTriangulateExtension,
Ham_SC_FindCoverGrenade,
Ham_SC_FindCoverDistance,
Ham_SC_FindAttackPoint,
Ham_SC_FValidateCover,
Ham_SC_NoFriendlyFire1,
Ham_SC_NoFriendlyFire2,
Ham_SC_NoFriendlyFire3,
Ham_SC_NoFriendlyFireToPos,
Ham_SC_FVisibleGunPos,
Ham_SC_FInBulletCone,
Ham_SC_CallGibMonster,
Ham_SC_CheckTimeBasedDamage,
Ham_SC_IsMoving,
Ham_SC_IsPlayerFollowing,
Ham_SC_StartPlayerFollowing,
Ham_SC_StopPlayerFollowing,
Ham_SC_UseSound,
Ham_SC_UnUseSound,
Ham_SC_RideMonster,
Ham_SC_CheckApplyGenericAttacks,
Ham_SC_CheckScared,
Ham_SC_CheckCreatureDanger,
Ham_SC_CheckFallDamage,
Ham_SC_CheckRevival,
Ham_SC_MedicCallSound,
Ham_SC_Player_MenuInputPerformed,
Ham_SC_Player_IsMenuInputDone,
Ham_SC_Player_SpecialSpawn,
Ham_SC_Player_IsValidInfoEntity,
Ham_SC_Player_LevelEnd,
Ham_SC_Player_VoteStarted,
Ham_SC_Player_CanStartNextVote,
Ham_SC_Player_Vote,
Ham_SC_Player_HasVoted,
Ham_SC_Player_ResetVote,
Ham_SC_Player_LastVoteInput,
Ham_SC_Player_InitVote,
Ham_SC_Player_TimeToStartNextVote,
Ham_SC_Player_ResetView,
Ham_SC_Player_GetLogFrequency,
Ham_SC_Player_LogPlayerStats,
Ham_SC_Player_DisableCollisionWithPlayer,
Ham_SC_Player_EnableCollisionWithPlayer,
Ham_SC_Player_CanTouchPlayer,
Ham_SC_Item_Materialize,
Ham_SC_Weapon_BulletAccuracy,
Ham_SC_Weapon_TertiaryAttack,
Ham_SC_Weapon_BurstSupplement,
Ham_SC_Weapon_GetP_Model,
Ham_SC_Weapon_GetW_Model,
Ham_SC_Weapon_GetV_Model,
Ham_SC_Weapon_PrecacheCustomModels,
Ham_SC_Weapon_IsMultiplayer,
Ham_SC_Weapon_FRunfuncs,
Ham_SC_Weapon_SetFOV,
Ham_SC_Weapon_FCanRun,
Ham_SC_Weapon_CustomDecrement,
Ham_SC_Weapon_SetV_Model,
Ham_SC_Weapon_SetP_Model,
Ham_SC_Weapon_ChangeWeaponSkin,
//
// New addition - 2013
//
Ham_TFC_Killed,
Ham_TFC_IsTriggered,
Ham_TFC_Weapon_SendWeaponAnim,
Ham_TFC_Weapon_GetNextAttackDelay,
Ham_SC_TakeHealth,
Ham_SC_TakeArmor,
Ham_SC_GiveAmmo,
Ham_SC_CheckAttacker,
Ham_SC_Player_IsConnected,
Ham_DOD_Weapon_SendWeaponAnim,
Ham_CS_Item_IsWeapon,
Ham_OPF_MySquadTalkMonsterPointer,
Ham_OPF_WeaponTimeBase,
Ham_TS_Weapon_AlternateAttack,
Ham_Item_GetItemInfo,
HAM_LAST_ENTRY_DONT_USE_ME_LOL
};
enum
{
HAM_OK = 0,
HAM_INVALID_FUNC, // The function is not valid
HAM_FUNC_NOT_CONFIGURED, // This function is not configured in hamdata.ini
HAM_ERR_END
};
#endif

View File

@ -0,0 +1,160 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#ifndef HAM_UTILS_H
#define HAM_UTILS_H
#include "amxxmodule.h"
#include "offsets.h"
#include "NEW_Util.h"
#define CHECK_FUNCTION(x) \
if (x < 0 || x >= HAM_LAST_ENTRY_DONT_USE_ME_LOL) { \
char msg[1024]; \
UTIL_Format(msg, sizeof(msg)-1, "Function out of bounds. Got: %d Max: %d", x, HAM_LAST_ENTRY_DONT_USE_ME_LOL - 1); \
FailPlugin(amx, x, HAM_INVALID_FUNC, msg); \
return 0; \
} else if (hooklist[x].isset == 0) { \
char msg[1024]; \
UTIL_Format(msg, sizeof(msg)-1, "Function %s is not configured in hamdata.ini.", hooklist[x].name); \
FailPlugin(amx, x, HAM_FUNC_NOT_CONFIGURED, msg); \
return 0; \
}
#define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (INDEXENT_NEW(x)->free) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity (%d)", x); \
return 0; \
} else if (INDEXENT_NEW(x)->pvPrivateData == NULL) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity has null private data (%d)", x); \
return 0; \
} \
}
inline edict_t *PrivateToEdict(const void *pdata)
{
if (!pdata)
{
return NULL;
}
char *ptr=(char*)pdata + Offsets.GetPev();
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+=Offsets.GetPev();
entvars_t *pev=*(entvars_t **)ptr;
if (pev==NULL)
{
return -1;
}
if (pev->pContainingEntity==NULL)
{
return -1;
}
return ENTINDEX_NEW(pev->pContainingEntity);
};
inline void *IndexToPrivate(int index)
{
return INDEXENT_NEW(index)->pvPrivateData;
};
inline entvars_t *IndexToEntvar(int index)
{
return &(INDEXENT_NEW(index)->v);
};
inline int EntvarToIndex(entvars_t *pev)
{
if (pev==NULL)
{
return -1;
}
if (pev->pContainingEntity==NULL)
{
return -1;
}
return ENTINDEX_NEW(pev->pContainingEntity);
};
inline int EdictToIndex(edict_t *v)
{
if (v==NULL)
{
return -1;
}
return ENTINDEX_NEW(v);
}
inline edict_t *IndexToEdict(int index)
{
return INDEXENT_NEW(index);
};
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+=Offsets.GetBase();
return *((void ***)btbl);
};
inline void **GetVTable(void *pthis, int size)
{
return *((void***)(((char*)pthis)+size));
}
inline void *GetVTableEntry(void *pthis, int ventry, int size)
{
void **vtbl=GetVTable(pthis, size);
return vtbl[ventry];
}
void print_srvconsole(const char *fmt, ...);
#endif

105
modules/hamsandwich/hook.h Normal file
View File

@ -0,0 +1,105 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#ifndef HOOK_H
#define HOOK_H
#include "forward.h"
#include "Trampolines.h"
#include <am-vector.h>
#define ALIGN(ar) ((intptr_t)ar & ~(sysconf(_SC_PAGESIZE)-1))
// This is just a simple container for data so I only have to add 1 extra
// parameter to calls that get trampolined
class Hook
{
public:
ke::Vector<Forward *> pre; // pre forwards
ke::Vector<Forward *> post; // post forwards
void *func; // original function
void **vtable; // vtable of the original location
int entry; // vtable entry of the function
void *target; // target function being called (the hook)
int exec; // 1 when this hook is in execution
int del; // 1 if this hook should be destroyed after exec
void *tramp; // trampoline for this hook
char *ent; // ent name that's being hooked
Hook(void **vtable_, int entry_, void *target_, bool voidcall, bool retbuf, int paramcount, char *name) :
func(NULL), vtable(vtable_), entry(entry_), target(target_), exec(0), del(0), tramp(NULL)
{
// original function is vtable[entry]
// to not make the compiler whine, cast vtable to int **
int **ivtable=(int **)vtable;
func=(void *)ivtable[entry];
// now install a trampoline
// (int thiscall, int voidcall, int paramcount, void *extraptr)
tramp = CreateGenericTrampoline(true, voidcall, retbuf, paramcount, (void*)this, target);
// Insert into vtable
#if defined(_WIN32)
DWORD OldFlags;
VirtualProtect(&ivtable[entry],sizeof(int*),PAGE_READWRITE,&OldFlags);
#elif defined(__linux__) || defined(__APPLE__)
void *addr = (void *)ALIGN(&ivtable[entry]);
mprotect(addr,sysconf(_SC_PAGESIZE),PROT_READ|PROT_WRITE);
#endif
ivtable[entry]=(int*)tramp;
size_t len=strlen(name);
ent=new char[len+1];
UTIL_Format(ent, len + 1, "%s", name);
};
~Hook()
{
// Insert the original function back into the vtable
int **ivtable=(int **)vtable;
#if defined(_WIN32)
DWORD OldFlags;
VirtualProtect(&ivtable[entry],sizeof(int*),PAGE_READWRITE,&OldFlags);
#elif defined(__linux__) || defined(__APPLE__)
void *addr = (void *)ALIGN(&ivtable[entry]);
mprotect(addr,sysconf(_SC_PAGESIZE),PROT_READ|PROT_WRITE);
#endif
ivtable[entry]=(int *)func;
#if defined(_WIN32)
VirtualFree(tramp, 0, MEM_RELEASE);
#elif defined(__linux__) || defined(__APPLE__)
free(tramp);
#endif
delete[] ent;
for (size_t i = 0; i < pre.length(); ++i)
{
delete pre.at(i);
}
for (size_t i = 0; i < post.length(); ++i)
{
delete post.at(i);
}
pre.clear();
post.clear();
}
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,498 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#ifndef HOOK_CALLBACKS_H
#define HOOK_CALLBACKS_H
// RT_<TYPE> is true if the function returns void, false otherwise
// (it also would be true for large return functions such as Vector)
// RB_<TYPE> is true if the function returns an object and requires a pointer to a buffer as its first parameter in order to store its value
// PC_<TYPE> is how many dwords get passed to the function (minus the "this" pointer)
// (it is one larger for large return functions such as Vector)
const bool RT_Void_Void = true;
const bool RB_Void_Void = false;
const int PC_Void_Void = 0;
void Hook_Void_Void(Hook *hook, void *pthis);
const bool RT_Int_Void = false;
const bool RB_Int_Void = false;
const int PC_Int_Void = 0;
int Hook_Int_Void(Hook *hook, void *pthis);
const bool RT_Void_Entvar = true;
const bool RB_Void_Entvar = false;
const int PC_Void_Entvar = 1;
void Hook_Void_Entvar(Hook *hook, void *pthis, entvars_t *entvar);
const bool RT_Void_Cbase = true;
const bool RB_Void_Cbase = false;
const int PC_Void_Cbase = 1;
void Hook_Void_Cbase(Hook *hook, void *pthis, void *other);
const bool RT_Int_Float_Int = false;
const bool RB_Int_Float_Int = false;
const int PC_Int_Float_Int = 2;
int Hook_Int_Float_Int(Hook *hook, void *pthis, float f1, int i1);
const bool RT_Int_Float_Int_Int = false;
const bool RB_Int_Float_Int_Int = false;
const int PC_Int_Float_Int_Int = 3;
int Hook_Int_Float_Int_Int(Hook *hook, void *pthis, float f1, int i1, int i2);
const bool RT_Void_Entvar_Int = true;
const bool RB_Void_Entvar_Int = false;
const int PC_Void_Entvar_Int = 2;
void Hook_Void_Entvar_Int(Hook *hook, void *ptis, entvars_t *ev1, int i1);
const bool RT_Void_Entvar_Entvar_Int = true;
const bool RB_Void_Entvar_Entvar_Int = false;
const int PC_Void_Entvar_Entvar_Int = 3;
void Hook_Void_Entvar_Entvar_Int(Hook *hook, void *ptis, entvars_t *ev1, entvars_t *ev2, int i1);
const bool RT_Int_Cbase = false;
const bool RB_Int_Cbase = false;
const int PC_Int_Cbase = 1;
int Hook_Int_Cbase(Hook *hook, void *pthis, void *cb1);
const bool RT_Void_Int_Int = true;
const bool RB_Void_Int_Int = false;
const int PC_Void_Int_Int = 2;
void Hook_Void_Int_Int(Hook *hook, void *pthis, int i1, int i2);
const bool RT_Int_Int_Str_Int = false;
const bool RB_Int_Int_Str_Int = false;
const int PC_Int_Int_Str_Int = 3;
int Hook_Int_Int_Str_Int(Hook *hook, void *pthis, int i1, const char *sz1,
int i2);
const bool RT_Int_Int_Str_Int_Int = false;
const bool RB_Int_Int_Str_Int_Int = false;
const int PC_Int_Int_Str_Int_Int = 4;
int Hook_Int_Int_Str_Int_Int(Hook *hook, void *pthis, int i1, const char *sz1, int i2, int i3);
const bool RT_Int_Int = false;
const bool RB_Int_Int = false;
const int PC_Int_Int = 1;
int Hook_Int_Int(Hook *hook, void *pthis, int i1);
const bool RT_Int_Entvar = false;
const bool RB_Int_Entvar = false;
const int PC_Int_Entvar = 1;
int Hook_Int_Entvar(Hook *hook, void *pthis, entvars_t *ev1);
const bool RT_Int_Entvar_Entvar_Float_Int = false;
const bool RB_Int_Entvar_Entvar_Float_Int = false;
const int PC_Int_Entvar_Entvar_Float_Int = 4;
int Hook_Int_Entvar_Entvar_Float_Int(Hook *hook, void *pthis,
entvars_t *inflictor,
entvars_t *attacker, float damage,
int damagebits);
const bool RT_Int_Entvar_Entvar_Float_Float_Int = false;
const bool RB_Int_Entvar_Entvar_Float_Float_Int = false;
const int PC_Int_Entvar_Entvar_Float_Float_Int = 5;
int Hook_Int_Entvar_Entvar_Float_Float_Int(Hook *hook, void *pthis,
entvars_t *inflictor,
entvars_t *attacker, float damage,
float unknown, int damagebits);
const bool RT_Void_Int = true;
const bool RB_Void_Int = false;
const int PC_Void_Int = 1;
void Hook_Void_Int(Hook *hook, void *pthis, int i1);
const bool RT_Void_Cbase_Cbase_Int_Float = true;
const bool RB_Void_Cbase_Cbase_Int_Float = false;
const int PC_Void_Cbase_Cbase_Int_Float = 4;
void Hook_Void_Cbase_Cbase_Int_Float(Hook *hook, void *pthis, void *cb1,
void *cb2, int i1, float f1);
const bool RT_Vector_Float_Cbase_Int = true;
const bool RB_Vector_Float_Cbase_Int = true;
const int PC_Vector_Float_Cbase_Int = 4;
#if defined(_WIN32)
void Hook_Vector_Float_Cbase_Int(Hook *hook, void *pthis, Vector *out, float f1, void *cb, int i1);
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_Float_Cbase_Int(Hook *hook, Vector *out, void *pthis, float f1, void *cb, int i1);
#endif
const bool RT_Void_Entvar_Float_Vector_Trace_Int = true;
const bool RB_Void_Entvar_Float_Vector_Trace_Int = false;
const int PC_Void_Entvar_Float_Vector_Trace_Int = 7;
void Hook_Void_Entvar_Float_Vector_Trace_Int(Hook *hook, void *pthis,
entvars_t *ev1, float f1,
Vector v1, TraceResult *tr1,
int i1);
const bool RT_Void_Float_Vector_Trace_Int = true;
const bool RB_Void_Float_Vector_Trace_Int = false;
const int PC_Void_Float_Vector_Trace_Int = 6;
void Hook_Void_Float_Vector_Trace_Int(Hook *hook, void *pthis, float f1,
Vector v1, TraceResult *tr1,
int i1);
const bool RT_Str_Void = false;
const bool RB_Str_Void = false;
const int PC_Str_Void = 0;
const char *Hook_Str_Void(Hook *hook, void *pthis);
const bool RT_Cbase_Void = false;
const bool RB_Cbase_Void = false;
const int PC_Cbase_Void = 0;
void *Hook_Cbase_Void(Hook *hook, void *pthis);
// HACK: I'm too lazy to fix up trampoline generator to deal with
// special return values. this is so much easier.
const bool RT_Vector_Void = true;
const bool RB_Vector_Void = true;
const int PC_Vector_Void = 1;
#if defined(_WIN32)
void Hook_Vector_Void(Hook *hook, void *pthis, Vector *out);
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis);
#endif
const bool RT_Vector_pVector = true;
const bool RB_Vector_pVector = true;
const int PC_Vector_pVector = 2;
#if defined(_WIN32)
void Hook_Vector_pVector(Hook *hook, void *pthis, Vector *out, Vector *v1);
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_pVector(Hook *hook, Vector *out, void *pthis, Vector *v1);
#endif
const bool RT_Int_pVector = false;
const bool RB_Int_pVector = false;
const int PC_Int_pVector = 1;
int Hook_Int_pVector(Hook *hook, void *pthis, Vector *v1);
const bool RT_Void_Entvar_Float_Float = true;
const bool RB_Void_Entvar_Float_Float = false;
const int PC_Void_Entvar_Float_Float = 3;
void Hook_Void_Entvar_Float_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1, float f2);
const bool RT_Void_pFloat_pFloat = true;
const bool RB_Void_pFloat_pFloat = false;
const int PC_Void_pFloat_pFloat = 2;
void Hook_Void_pFloat_pFloat(Hook *hook, void *pthis, float *f1, float *f2);
const bool RT_Void_Entvar_Float = true;
const bool RB_Void_Entvar_Float = false;
const int PC_Void_Entvar_Float = 2;
void Hook_Void_Entvar_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1);
const bool RT_Void_Int_Int_Int = true;
const bool RB_Void_Int_Int_Int = false;
const int PC_Void_Int_Int_Int = 3;
void Hook_Void_Int_Int_Int(Hook *hook, void *pthis, int i1, int i2, int i3);
const bool RT_Void_ItemInfo = true;
const bool RB_Void_ItemInfo = false;
const int PC_Void_ItemInfo = 1;
void Hook_Void_ItemInfo(Hook *hook, void *pthis, void *iteminfo);
const bool RT_Float_Void = false;
const bool RB_Float_Void = false;
const int PC_Float_Void = 0;
float Hook_Float_Void(Hook *hook, void *pthis);
const bool RT_Float_Int = false;
const bool RB_Float_Int = false;
const int PC_Float_Int = 1;
float Hook_Float_Int(Hook *hook, void *pthis, int i1);
const bool RT_Void_Float_Int = true;
const bool RB_Void_Float_Int = false;
const int PC_Void_Float_Int = 2;
void Hook_Void_Float_Int(Hook *hook, void *pthis, float f1, int i1);
const bool RT_Float_Float_Cbase = true;
const bool RB_Float_Float_Cbase = false;
const int PC_Float_Float_Cbase = 2;
float Hook_Float_Float_Cbase(Hook *hook, void *pthis, float f1, void *cb1);
const bool RT_Void_Float = true;
const bool RB_Void_Float = false;
const int PC_Void_Float = 1;
void Hook_Void_Float(Hook *hook, void *pthis, float f1);
const bool RT_Void_Float_Float_Float_Int = true;
const bool RB_Void_Float_Float_Float_Int = false;
const int PC_Void_Float_Float_Float_Int = 4;
void Hook_Void_Float_Float_Float_Int(Hook *hook, void *pthis, float f1, float f2, float f3, int i1);
const bool RT_Vector_Float = true;
const bool RB_Vector_Float = true;
const int PC_Vector_Float = 2;
#if defined(_WIN32)
void Hook_Vector_Float(Hook *hook, void *pthis, Vector *out, float f1);
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_Float(Hook *hook, Vector *out, void *pthis, float f1);
#endif
const bool RT_Void_Float_Cbase = true;
const bool RB_Void_Float_Cbase = false;
const int PC_Void_Float_Cbase = 2;
void Hook_Void_Float_Cbase(Hook *hook, void *pthis, float f1, void *cb);
const bool RT_Int_Float_Float = false;
const bool RB_Int_Float_Float = false;
const int PC_Int_Float_Float = 2;
int Hook_Int_Float_Float(Hook *hook, void *pthis, float f1, float f2);
const bool RT_Int_Float = false;
const bool RB_Int_Float = false;
const int PC_Int_Float = 1;
int Hook_Int_Float(Hook *hook, void *pthis, float f1);
const bool RT_Int_Int_Int = false;
const bool RB_Int_Int_Int = false;
const int PC_Int_Int_Int = 2;
int Hook_Int_Int_Int(Hook *hook, void *pthis, int i1, int i2);
const bool RT_Void_Str_Float_Float_Float = true;
const bool RB_Void_Str_Float_Float_Float = false;
const int PC_Void_Str_Float_Float_Float = 4;
void Hook_Void_Str_Float_Float_Float(Hook *hook, void *pthis, const char *sz1, float f1, float f2, float f3);
const bool RT_Void_Str_Float_Float_Float_Int_Cbase = true;
const bool RB_Void_Str_Float_Float_Float_Int_Cbase = false;
const int PC_Void_Str_Float_Float_Float_Int_Cbase = 6;
void Hook_Void_Str_Float_Float_Float_Int_Cbase(Hook *hook, void *pthis, const char *sz1, float f1, float f2, float f3, int i1, void *cb);
const bool RT_Int_Vector_Vector_Float_Float= false;
const bool RB_Int_Vector_Vector_Float_Float = false;
const int PC_Int_Vector_Vector_Float_Float = 8;
int Hook_Int_Vector_Vector_Float_Float(Hook *hook, void *pthis, Vector v1, Vector v2, float f1, float f2);
const bool RT_Int_Short = false;
const bool RB_Int_Short = false;
const int PC_Int_Short = 1;
int Hook_Int_Short(Hook *hook, void *pthis, short s1);
const bool RT_Void_Entvar_Entvar_Float_Int_Int = true;
const bool RB_Void_Entvar_Entvar_Float_Int_Int = false;
const int PC_Void_Entvar_Entvar_Float_Int_Int = 5;
void Hook_Void_Entvar_Entvar_Float_Int_Int(Hook *hook, void *pthis,
entvars_t *inflictor,
entvars_t *attacker, float damage,
int classignore, int damagebits);
const bool RT_Void_Vector_Entvar_Entvar_Float_Int_Int = true;
const bool RB_Void_Vector_Entvar_Entvar_Float_Int_Int = false;
const int PC_Void_Vector_Entvar_Entvar_Float_Int_Int = 8;
void Hook_Void_Vector_Entvar_Entvar_Float_Int_Int(Hook *hook, void *pthis,
Vector source,
entvars_t *inflictor,
entvars_t *attacker, float damage,
int classignore, int damagebits);
const bool RT_Float_Int_Float = false;
const bool RB_Float_Int_Float = false;
const int PC_Float_Int_Float = 2;
float Hook_Float_Int_Float(Hook *hook, void *pthis, int i1, float f2);
const bool RT_Int_Str = false;
const bool RB_Int_Str = false;
const int PC_Int_Str = 1;
int Hook_Int_Str(Hook *hook, void *pthis, const char *sz1);
const bool RT_Void_Edict = true;
const bool RB_Void_Edict = false;
const int PC_Void_Edict = 1;
void Hook_Void_Edict(Hook *hook, void *pthis, edict_t *ed1 );
const bool RT_Void_Int_Str_Bool = true;
const bool RB_Void_Int_Str_Bool = false;
const int PC_Void_Int_Str_Bool = 3;
void Hook_Void_Int_Str_Bool(Hook *hook, void *pthis, int i1, const char *sz2, bool b3);
const bool RT_Void_Vector_Vector= true;
const bool RB_Void_Vector_Vector = false;
const int PC_Void_Vector_Vector = 6;
void Hook_Void_Vector_Vector(Hook *hook, void *pthis, Vector v1, Vector v2);
const bool RT_Void_Str_Bool = true;
const bool RB_Void_Str_Bool = false;
const int PC_Void_Str_Bool = 2;
void Hook_Void_Str_Bool(Hook *hook, void *pthis, const char *sz1, bool b2);
const bool RT_Int_Str_Str_Int_Str_Int_Int = false;
const bool RB_Int_Str_Str_Int_Str_Int_Int = false;
const int PC_Int_Str_Str_Int_Str_Int_Int = 6;
int Hook_Int_Str_Str_Int_Str_Int_Int(Hook *hook, void *pthis, const char *sz1, const char *sz2, int i1, const char *sz3, int i2, int i3);
const bool RT_Int_Int_Int_Float_Int = false;
const bool RB_Int_Int_Int_Float_Int = false;
const int PC_Int_Int_Int_Float_Int = 4;
int Hook_Int_Int_Int_Float_Int(Hook *hook, void *pthis, int i1, int i2, float f1, int i3);
const bool RT_Void_Str_Int = true;
const bool RB_Void_Str_Int = false;
const int PC_Void_Str_Int = 2;
void Hook_Void_Str_Int(Hook *hook, void *pthis, const char *sz1, int i2);
const bool RT_Void_Cbase_Int = true;
const bool RB_Void_Cbase_Int = false;
const int PC_Void_Cbase_Int = 2;
void Hook_Void_Cbase_Int(Hook *hook, void *pthis, void *p1, int i1);
const bool RT_Void_Str = true;
const bool RB_Void_Str = false;
const int PC_Void_Str = 1;
void Hook_Void_Str(Hook *hook, void *pthis, const char *sz1);
const bool RT_Void_Vector = true;
const bool RB_Void_Vector = false;
const int PC_Void_Vector = 3;
void Hook_Void_Vector(Hook *hook, void *pthis, Vector v1);
const bool RT_Int_Str_Vector_Str = false;
const bool RB_Int_Str_Vector_Str = false;
const int PC_Int_Str_Vector_Str = 5;
int Hook_Int_Str_Vector_Str(Hook *hook, void *pthis, const char *sz1, Vector v2, const char *sz2);
const bool RT_Int_Str_Str = false;
const bool RB_Int_Str_Str = false;
const int PC_Int_Str_Str = 2;
int Hook_Int_Str_Str(Hook *hook, void *pthis, const char *sz1, const char *sz2);
const bool RT_Void_Float_Float = true;
const bool RB_Void_Float_Float = false;
const int PC_Void_Float_Float = 2;
void Hook_Void_Float_Float(Hook *hook, void *pthis, float f1, float f2);
const bool RT_Void_Str_Str_Int = true;
const bool RB_Void_Str_Str_Int = false;
const int PC_Void_Str_Str_Int = 3;
void Hook_Void_Str_Str_Int(Hook *hook, void *pthis, const char *sz1, const char *sz2, int i3);
const bool RT_Int_pVector_pVector_Cbase_pFloat = false;
const bool RB_Int_pVector_pVector_Cbase_pFloat = false;
const int PC_Int_pVector_pVector_Cbase_pFloat = 4;
int Hook_Int_pVector_pVector_Cbase_pFloat(Hook *hook, void *pthis, Vector *v1, Vector *v2, void* cb, float* fl);
const bool RT_Void_Cbase_pVector_Float = true;
const bool RB_Void_Cbase_pVector_Float = false;
const int PC_Void_Cbase_pVector_Float = 3;
void Hook_Void_Cbase_pVector_Float(Hook *hook, void *pthis, void *p1, Vector *v1, float fl);
const bool RT_Int_pVector_pVector_Float_Cbase_pVector = false;
const bool RB_Int_pVector_pVector_Float_Cbase_pVector = false;
const int PC_Int_pVector_pVector_Float_Cbase_pVector = 5;
int Hook_Int_pVector_pVector_Float_Cbase_pVector(Hook *hook, void *pthis, Vector *v1, Vector *v2, float fl, void* cb, Vector *v3);
const bool RT_Int_Cbase_Bool = false;
const bool RB_Int_Cbase_Bool = false;
const int PC_Int_Cbase_Bool = 2;
int Hook_Int_Cbase_Bool(Hook *hook, void *pthis, void *cb1, bool b1);
const bool RT_Int_Vector_Vector = false;
const bool RB_Int_Vector_Vector = false;
const int PC_Int_Vector_Vector = 6;
int Hook_Int_Vector_Vector(Hook *hook, void *pthis, Vector v1, Vector v2);
const bool RT_Int_Entvar_Float = false;
const bool RB_Int_Entvar_Float = false;
const int PC_Int_Entvar_Float = 2;
int Hook_Int_Entvar_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1);
const bool RT_Float_Float = false;
const bool RB_Float_Float = false;
const int PC_Float_Float = 1;
float Hook_Float_Float(Hook *hook, void *pthis, float f1);
const bool RT_Void_Entvar_Entvar_Float = true;
const bool RB_Void_Entvar_Entvar_Float = false;
const int PC_Void_Entvar_Entvar_Float = 3;
void Hook_Void_Entvar_Entvar_Float(Hook *hook, void *pthis, entvars_t *attacker, entvars_t *inflictor, float damage);
const bool RT_Bool_Void = false;
const bool RB_Bool_Void = false;
const int PC_Bool_Void = 0;
bool Hook_Bool_Void(Hook *hook, void *pthis);
const bool RT_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool = false;
const bool RB_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool = false;
const int PC_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool = 7;
int Hook_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(Hook *hook, void *pthis, Vector *v1, Vector *v2, float fl, void* cb, Vector *v3, Vector *v4, bool b1);
const bool RT_Int_Vector_Cbase = false;
const bool RB_Int_Vector_Cbase = false;
const int PC_Int_Vector_Cbase = 4;
int Hook_Int_Vector_Cbase(Hook *hook, void *pthis, Vector v1, void *cb);
const bool RT_Int_Vector= false;
const bool RB_Int_Vector = false;
const int PC_Int_Vector = 3;
int Hook_Int_Vector(Hook *hook, void *pthis, Vector v1);
const bool RT_Int_Cbase_pVector = false;
const bool RB_Int_Cbase_pVector = false;
const int PC_Int_Cbase_pVector = 2;
int Hook_Int_Cbase_pVector(Hook *hook, void *pthis, void *cb1, Vector *v1);
const bool RT_Void_Bool = true;
const bool RB_Void_Bool = false;
const int PC_Void_Bool = 1;
void Hook_Void_Bool(Hook *hook, void *pthis, bool b1);
const bool RT_Bool_Cbase = false;
const bool RB_Bool_Cbase = false;
const int PC_Bool_Cbase = 1;
bool Hook_Bool_Cbase(Hook *hook, void *pthis, void *cb);
const bool RT_Bool_Int = false;
const bool RB_Bool_Int = false;
const int PC_Bool_Int = 1;
bool Hook_Bool_Int(Hook *hook, void *pthis, int i1);
const bool RT_Void_Cbase_Float = true;
const bool RB_Void_Cbase_Float = false;
const int PC_Void_Cbase_Float = 2;
void Hook_Void_Cbase_Float(Hook *hook, void *pthis, void *p1, float f1);
const bool RT_Void_Cbase_Bool = true;
const bool RB_Void_Cbase_Bool = false;
const int PC_Void_Cbase_Bool = 2;
void Hook_Void_Cbase_Bool(Hook *hook, void *pthis, void *p1, bool b1);
const bool RT_Vector_Vector_Vector_Vector = true;
const bool RB_Vector_Vector_Vector_Vector = true;
const int PC_Vector_Vector_Vector_Vector = 10;
#if defined(_WIN32)
void Hook_Vector_Vector_Vector_Vector(Hook *hook, void *pthis, Vector *out, Vector v1, Vector v2, Vector v3);
#elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_Vector_Vector_Vector(Hook *hook, Vector *out, void *pthis, Vector v1, Vector v2, Vector v3);
#endif
const bool RT_Str_Str = false;
const bool RB_Str_Str = false;
const int PC_Str_Str = 1;
const char *Hook_Str_Str(Hook *hook, void *pthis, const char* str);
const bool RT_Void_Short = true;
const bool RB_Void_Short = false;
const int PC_Void_Short = 1;
void Hook_Void_Short(Hook *hook, void *pthis, short i1);
const bool RT_Deprecated = true;
const bool RB_Deprecated = false;
const int PC_Deprecated = 0;
void Hook_Deprecated(Hook* hook);
#endif

View File

@ -0,0 +1,446 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#include "amxxmodule.h"
int Create_Void_Void(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_DONE);
}
int Create_Int_Void(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_DONE);
}
int Create_Void_Entvar(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Cbase(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Float_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Int_Float_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Entvar_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Entvar_Entvar_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Cbase(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Int_Str_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Int_Int_Str_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_STRING, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Entvar(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Entvar_Entvar_Float_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Int_Entvar_Entvar_Float_Float_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Void_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Cbase_Cbase_Int_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Vector_Float_Cbase_Int(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_ARRAY, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Float_Vector_Trace_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_ARRAY, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Str_Void(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_DONE);
}
int Create_Cbase_Void(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_DONE);
}
int Create_Vector_Void(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_DONE);
}
int Create_Vector_pVector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Int_pVector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Void_Entvar_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Void_pFloat_pFloat(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Void_Entvar_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Int_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_ItemInfo(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Float_Void(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_DONE);
}
int Create_Float_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Float_Int(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Float_Float_Cbase(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Void_Float(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Float_Float_Float_Int(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_FLOAT, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Vector_Float(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Float_Cbase(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Int_Float_Float(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Int_Float(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Int_Int_Int(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Str_Float_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_FLOAT, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Void_Str_Float_Float_Float_Int_Cbase(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_FLOAT, FP_FLOAT, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Vector_Vector_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Int_Short(AMX* amx, const char* func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Vector_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Float_Int_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Int_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_DONE);
}
int Create_Void_Edict(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Int_Str_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Void_Vector_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_DONE);
}
int Create_Void_Str_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Int_Str_Str_Int_Str_Int_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_STRING, FP_CELL, FP_STRING, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Int_Int_Float_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
}
int Create_Void_Str_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Void_Cbase_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_DONE);
}
int Create_Void_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Int_Str_Vector_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_ARRAY, FP_STRING, FP_DONE);
}
int Create_Int_Str_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_STRING, FP_DONE);
}
int Create_Void_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_FLOAT, FP_DONE);
}
int Create_Void_Str_Str_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_STRING, FP_CELL, FP_DONE);
}
int Create_Int_pVector_pVector_Cbase_pFloat(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Cbase_pVector_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_ARRAY, FP_FLOAT, FP_DONE);
}
int Create_Int_pVector_pVector_Float_Cbase_pVector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_FLOAT, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Int_Cbase_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Int_Vector_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_DONE);
}
int Create_Int_Entvar_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Float_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Entvar_Entvar_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Bool_Void(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_DONE);
}
int Create_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_FLOAT, FP_CELL, FP_ARRAY, FP_ARRAY, FP_CELL, FP_DONE);
}
int Create_Int_Vector_Cbase(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_CELL, FP_DONE);
}
int Create_Int_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Int_Cbase_pVector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_ARRAY, FP_DONE);
}
int Create_Void_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Bool_Cbase(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Bool_Int(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Void_Cbase_Float(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
}
int Create_Void_Cbase_Bool(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Vector_Vector_Vector_Vector(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_ARRAY, FP_DONE);
}
int Create_Str_Str(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_DONE);
}
int Create_Void_Short(AMX *amx, const char *func)
{
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
}
int Create_Deprecated(AMX* amx, const char* func)
{
return -1;
}

View File

@ -0,0 +1,191 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#ifndef HOOK_CREATE_H
#define HOOK_CREATE_H
int Create_Void_Void(AMX *amx, const char *func);
int Create_Int_Void(AMX *amx, const char *func);
int Create_Void_Entvar(AMX *amx, const char *func);
int Create_Void_Cbase(AMX *amx, const char *func);
int Create_Int_Float_Int(AMX *amx, const char *func);
int Create_Int_Float_Int_Int(AMX *amx, const char *func);
int Create_Void_Entvar_Int(AMX *amx, const char *func);
int Create_Void_Entvar_Entvar_Int(AMX *amx, const char *func);
int Create_Int_Cbase(AMX *amx, const char *func);
int Create_Void_Int_Int(AMX *amx, const char *func);
int Create_Int_Int_Str_Int(AMX *amx, const char *func);
int Create_Int_Int_Str_Int_Int(AMX *amx, const char *func);
int Create_Int_Int(AMX *amx, const char *func);
int Create_Int_Entvar(AMX *amx, const char *func);
int Create_Int_Entvar_Entvar_Float_Int(AMX *amx, const char *func);
int Create_Int_Entvar_Entvar_Float_Float_Int(AMX *amx, const char *func);
int Create_Void_Int(AMX *amx, const char *func);
int Create_Vector_Float_Cbase_Int(AMX *amx, const char *func);
int Create_Void_Cbase_Cbase_Int_Float(AMX *amx, const char *func);
int Create_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, const char *func);
int Create_Void_Float_Vector_Trace_Int(AMX *amx, const char *func);
int Create_Str_Void(AMX *amx, const char *func);
int Create_Cbase_Void(AMX *amx, const char *func);
int Create_Vector_Void(AMX *amx, const char *func);
int Create_Vector_pVector(AMX *amx, const char *func);
int Create_Int_pVector(AMX *amx, const char *func);
int Create_Void_Entvar_Float_Float(AMX *amx, const char *func);
int Create_Void_pFloat_pFloat(AMX *amx, const char *func);
int Create_Void_Entvar_Float(AMX *amx, const char *func);
int Create_Void_Int_Int_Int(AMX *amx, const char *func);
int Create_Void_ItemInfo(AMX *amx, const char *func);
int Create_Float_Void(AMX *amx, const char *func);
int Create_Float_Int(AMX *amx, const char *func);
int Create_Void_Float_Int(AMX *amx, const char *func);
int Create_Float_Float_Cbase(AMX *amx, const char *func);
int Create_Void_Float(AMX *amx, const char *func);
int Create_Void_Float_Float_Float_Int(AMX *amx, const char *func);
int Create_Vector_Float(AMX *amx, const char *func);
int Create_Void_Float_Cbase(AMX *amx, const char *func);
int Create_Int_Float_Float(AMX* amx, const char* func);
int Create_Int_Float(AMX* amx, const char* func);
int Create_Int_Int_Int(AMX* amx, const char* func);
int Create_Void_Str_Float_Float_Float(AMX* amx, const char* func);
int Create_Void_Str_Float_Float_Float_Int_Cbase(AMX *amx, const char *func);
int Create_Int_Vector_Vector_Float_Float(AMX *amx, const char *func);
int Create_Int_Short(AMX* amx, const char* func);
int Create_Void_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func);
int Create_Void_Vector_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func);
int Create_Float_Int_Float(AMX *amx, const char *func);
int Create_Int_Str(AMX *amx, const char *func);
int Create_Void_Edict(AMX *amx, const char *func);
int Create_Void_Int_Str_Bool(AMX *amx, const char *func);
int Create_Void_Vector_Vector(AMX *amx, const char *func);
int Create_Void_Str_Bool(AMX *amx, const char *func);
int Create_Int_Str_Str_Int_Str_Int_Int(AMX *amx, const char *func);
int Create_Int_Int_Int_Float_Int(AMX *amx, const char *func);
int Create_Void_Str_Int(AMX *amx, const char *func);
int Create_Void_Cbase_Int(AMX *amx, const char *func);
int Create_Void_Str(AMX *amx, const char *func);
int Create_Void_Vector(AMX *amx, const char *func);
int Create_Int_Str_Vector_Str(AMX *amx, const char *func);
int Create_Int_Str_Str(AMX *amx, const char *func);
int Create_Void_Float_Float(AMX *amx, const char *func);
int Create_Void_Str_Str_Int(AMX *amx, const char *func);
int Create_Int_pVector_pVector_Cbase_pFloat(AMX *amx, const char *func);
int Create_Void_Cbase_pVector_Float(AMX *amx, const char *func);
int Create_Int_pVector_pVector_Float_Cbase_pVector(AMX *amx, const char *func);
int Create_Int_Cbase_Bool(AMX *amx, const char *func);
int Create_Int_Vector_Vector(AMX *amx, const char *func);
int Create_Int_Entvar_Float(AMX *amx, const char *func);
int Create_Float_Float(AMX *amx, const char *func);
int Create_Void_Entvar_Entvar_Float(AMX *amx, const char *func);
int Create_Bool_Void(AMX *amx, const char *func);
int Create_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(AMX *amx, const char *func);
int Create_Int_Vector_Cbase(AMX *amx, const char *func);
int Create_Int_Vector(AMX *amx, const char *func);
int Create_Int_Cbase_pVector(AMX *amx, const char *func);
int Create_Void_Bool(AMX *amx, const char *func);
int Create_Bool_Cbase(AMX *amx, const char *func);
int Create_Bool_Int(AMX *amx, const char *func);
int Create_Void_Cbase_Float(AMX *amx, const char *func);
int Create_Void_Cbase_Bool(AMX *amx, const char *func);
int Create_Vector_Vector_Vector_Vector(AMX *amx, const char *func);
int Create_Str_Str(AMX *amx, const char *func);
int Create_Void_Short(AMX *amx, const char *func);
int Create_Deprecated(AMX* amx, const char* func);
#endif

View File

@ -0,0 +1,795 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <extdll.h>
#include "amxxmodule.h"
#include "hook.h"
#include "forward.h"
#include "hook_callbacks.h"
#include "call_funcs.h"
#include "hook_create.h"
#include "offsets.h"
#include "hooklist.h"
#include "ham_utils.h"
#include "hook_specialbot.h"
#include <am-vector.h>
OffsetManager Offsets;
bool gDoForwards=true;
ke::Vector<Hook *> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
CHamSpecialBotHandler SpecialbotHandler;
#define V(__KEYNAME, __STUFF__) 0, 0, __KEYNAME, RT_##__STUFF__, RB_##__STUFF__, PC_##__STUFF__, reinterpret_cast<void *>(Hook_##__STUFF__), Create_##__STUFF__, Call_##__STUFF__
hook_t hooklist[] =
{
{ V("spawn", Void_Void) },
{ V("precache", Void_Void) },
{ V("keyvalue", Void_Int) },
{ V("objectcaps", Int_Void) },
{ V("activate", Void_Void) },
{ V("setobjectcollisionbox", Void_Void) },
{ V("classify", Int_Void) },
{ V("deathnotice", Void_Entvar) },
{ V("traceattack", Void_Entvar_Float_Vector_Trace_Int) },
{ V("takedamage", Int_Entvar_Entvar_Float_Int) },
{ V("takehealth", Int_Float_Int) },
{ V("killed", Void_Entvar_Int) },
{ V("bloodcolor", Int_Void) },
{ V("tracebleed", Void_Float_Vector_Trace_Int) },
{ V("istriggered", Int_Cbase) },
{ V("mymonsterpointer", Cbase_Void) },
{ V("mysquadmonsterpointer", Cbase_Void) },
{ V("gettogglestate", Int_Void) },
{ V("addpoints", Void_Int_Int) },
{ V("addpointstoteam", Void_Int_Int) },
{ V("addplayeritem", Int_Cbase) },
{ V("removeplayeritem", Int_Cbase) },
{ V("giveammo", Int_Int_Str_Int) },
{ V("getdelay", Float_Void) },
{ V("ismoving", Int_Void) },
{ V("overridereset", Void_Void) },
{ V("damagedecal", Int_Int) },
{ V("settogglestate", Void_Int) },
{ V("startsneaking", Void_Void) },
{ V("stopsneaking", Void_Void) },
{ V("oncontrols", Int_Entvar) },
{ V("issneaking", Int_Void) },
{ V("isalive", Int_Void) },
{ V("isbspmodel", Int_Void) },
{ V("reflectgauss", Int_Void) },
{ V("hastarget", Int_Int) },
{ V("isinworld", Int_Void) },
{ V("isplayer", Int_Void) },
{ V("isnetclient", Int_Void) },
{ V("teamid", Str_Void) },
{ V("getnexttarget", Cbase_Void) },
{ V("think", Void_Void) },
{ V("touch", Void_Cbase) },
{ V("use", Void_Cbase_Cbase_Int_Float) },
{ V("blocked", Void_Cbase) },
{ V("respawn", Cbase_Void) },
{ V("updateowner", Void_Void) },
{ V("fbecomeprone", Int_Void) },
{ V("center", Vector_Void) },
{ V("eyeposition", Vector_Void) },
{ V("earposition", Vector_Void) },
{ V("bodytarget", Vector_pVector) },
{ V("illumination", Int_Void) },
{ V("fvisible", Int_Cbase) },
{ V("fvecvisible", Int_pVector) },
/** Entity specific hooks **/
/* CBasePlayer */
{ V("player_jump", Void_Void) },
{ V("player_duck", Void_Void) },
{ V("player_prethink", Void_Void) },
{ V("player_postthink", Void_Void) },
{ V("player_getgunposition", Vector_Void) },
{ V("player_shouldfadeondeath", Int_Void) },
{ V("player_impulsecommands", Void_Void) },
{ V("player_updateclientdata", Void_Void) },
/* CBasePlayerItem */
{ V("item_addtoplayer", Int_Cbase) },
{ V("item_addduplicate", Int_Cbase) },
{ V("item_candeploy", Int_Void) },
{ V("item_deploy", Int_Void) },
{ V("item_canholster", Int_Void) },
{ V("item_holster", Void_Int) },
{ V("item_updateiteminfo", Void_Void) },
{ V("item_preframe", Void_Void) },
{ V("item_postframe", Void_Void) },
{ V("item_drop", Void_Void) },
{ V("item_kill", Void_Void) },
{ V("item_attachtoplayer", Void_Cbase) },
{ V("item_primaryammoindex", Int_Void) },
{ V("item_secondaryammoindex", Int_Void) },
{ V("item_updateclientdata", Int_Cbase) },
{ V("item_getweaponptr", Cbase_Void) },
{ V("item_itemslot", Int_Void) },
/* CBasePlayerWeapon */
{ V("weapon_extractammo", Int_Cbase) },
{ V("weapon_extractclipammo", Int_Cbase) },
{ V("weapon_addweapon", Int_Void) },
{ V("weapon_playemptysound", Int_Void) },
{ V("weapon_resetemptysound", Void_Void) },
{ V("weapon_sendweaponanim", Void_Int_Int_Int) },
{ V("weapon_isusable", Int_Void) },
{ V("weapon_primaryattack", Void_Void) },
{ V("weapon_secondaryattack", Void_Void) },
{ V("weapon_reload", Void_Void) },
{ V("weapon_weaponidle", Void_Void) },
{ V("weapon_retireweapon", Void_Void) },
{ V("weapon_shouldweaponidle", Int_Void) },
{ V("weapon_usedecrement", Int_Void) },
/** Mod specific hooks **/
/* The Specialists */
{ V("ts_breakablerespawn", Int_Int) },
{ V("ts_canusedthroughwalls", Int_Void) },
{ V("ts_respawnwait", Deprecated) },
/* Counter-Strike */
{ V("cstrike_restart", Void_Void) },
{ V("cstrike_roundrespawn", Void_Void) },
{ V("cstrike_item_candrop", Int_Void) },
{ V("cstrike_item_getmaxspeed", Float_Void) },
/* Day of Defeat */
{ V("dod_roundrespawn", Void_Void) },
{ V("dod_roundrespawnent", Void_Void) },
{ V("dod_roundstore", Void_Void) },
{ V("dod_areasetindex", Void_Int) },
{ V("dod_areasendstatus", Void_Cbase) },
{ V("dod_getstate", Int_Void) },
{ V("dod_getstateent", Int_Cbase) },
{ V("dod_item_candrop", Int_Void) },
/* Team Fortress Classic */
{ V("tfc_engineeruse", Int_Cbase) },
{ V("tfc_finished", Void_Void) },
{ V("tfc_empexplode", Void_Entvar_Float_Float) },
{ V("tfc_calcempdmgrad", Void_pFloat_pFloat) },
{ V("tfc_takeempblast", Void_Entvar) },
{ V("tfc_empremove", Void_Void) },
{ V("tfc_takeconcussionblast", Void_Entvar_Float) },
{ V("tfc_concuss", Void_Entvar) },
/* Earth's Special Forces */
{ V("esf_isenvmodel", Int_Void) },
{ V("esf_takedamage2", Int_Entvar_Entvar_Float_Float_Int) },
/* Natural-Selection */
{ V("ns_getpointvalue", Int_Void) },
{ V("ns_awardkill", Void_Entvar) },
{ V("ns_resetentity", Void_Void) },
{ V("ns_updateonremove", Void_Void) },
{ V("ts_giveslowmul", Void_Void) },
{ V("ts_goslow", Void_Float_Int) },
{ V("ts_inslow", Int_Void) },
{ V("ts_isobjective", Int_Void) },
{ V("ts_enableobjective", Void_Int) },
{ V("ts_onfreeentprivatedata", Void_Void) },
{ V("ts_shouldcollide", Int_Cbase) },
/** New Additions (2011) **/
{ V("changeyaw", Float_Int) },
{ V("hashumangibs", Int_Void) },
{ V("hasaliengibs", Int_Void) },
{ V("fademonster", Void_Void) },
{ V("gibmonster", Void_Void) },
{ V("becomedead", Void_Void) },
{ V("irelationship", Int_Cbase) },
{ V("painsound", Void_Void) },
{ V("reportaistate", Void_Void) },
{ V("monsterinitdead", Void_Void) },
{ V("look", Void_Int) },
{ V("bestvisibleenemy", Cbase_Void) },
{ V("finviewcone", Int_Cbase) },
{ V("fvecinviewcone", Int_pVector) },
{ V("getdeathactivity", Int_Void) },
/* Not supported by Counter-Strike, The Specialists and Natural Selection mods. */
{ V("runai", Void_Void) },
{ V("monsterthink", Void_Void) },
{ V("monsterinit", Void_Void) },
{ V("checklocalmove", Int_pVector_pVector_Cbase_pFloat) },
{ V("move", Void_Float) },
{ V("moveexecute", Void_Cbase_pVector_Float) },
{ V("shouldadvanceroute", Int_Float) },
{ V("getstoppedactivity", Int_Void) },
{ V("stop", Void_Void) },
{ V("checkrangeattack1", Int_Float_Float) },
{ V("checkrangeattack2", Int_Float_Float) },
{ V("checkmeleeattack1", Int_Float_Float) },
{ V("checkmeleeattack2", Int_Float_Float) },
{ V("schedulechange", Void_Void) },
{ V("canplaysequence", Int_Int_Int) },
{ V("canplaysentence", Int_Int) },
{ V("playsentence", Void_Str_Float_Float_Float) },
{ V("playscriptedsentence", Void_Str_Float_Float_Float_Int_Cbase) },
{ V("sentencestop", Void_Void) },
{ V("getidealstate", Int_Void) },
{ V("setactivity", Void_Int) },
{ V("checkenemy", Int_Cbase) },
{ V("ftriangulate", Int_pVector_pVector_Float_Cbase_pVector) },
{ V("setyawspeed", Void_Void) },
{ V("buildnearestroute", Int_Vector_Vector_Float_Float) },
{ V("findcover", Int_Vector_Vector_Float_Float) },
{ V("coverradius", Float_Void) },
{ V("fcancheckattacks", Int_Void) },
{ V("checkammo", Void_Void) },
{ V("ignoreconditions", Int_Void) },
{ V("fvalidatehinttype", Int_Short) },
{ V("fcanactiveidle", Int_Void) },
{ V("isoundmask", Int_Void) },
{ V("hearingsensitivity", Float_Void) },
{ V("barnaclevictimbitten", Void_Entvar) },
{ V("barnaclevictimreleased", Void_Void) },
{ V("preschedulethink", Void_Void) },
{ V("deathsound", Void_Void) },
{ V("alertsound", Void_Void) },
{ V("idlesound", Void_Void) },
{ V("stopfollowing", Void_Int) },
/** Mod specific hooks **/
/* Counter-Strike */
{ V("cstrike_weapon_sendweaponanim",Void_Int_Int) },
{ V("cstrike_player_resetmaxspeed", Void_Void) },
{ V("cstrike_player_isbot", Int_Void) },
{ V("cstrike_player_getautoaimvector", Vector_Float) },
{ V("cstrike_player_blind", Void_Float_Float_Float_Int) },
{ V("cstrike_player_ontouchingweapon",Void_Cbase) },
/* Day of Defeat */
{ V("dod_setscriptreset", Void_Void) },
{ V("dod_item_spawndeploy", Int_Void) },
{ V("dod_item_setdmgtime", Void_Float) },
{ V("dod_item_dropgren", Void_Void) },
{ V("dod_weapon_isuseable", Int_Void) },
{ V("dod_weapon_aim", Vector_Float_Cbase_Int) },
{ V("dod_weapon_flaim", Float_Float_Cbase) },
{ V("dod_weapon_removestamina", Void_Float_Cbase) },
{ V("dod_weapon_changefov", Int_Int) },
{ V("dod_weapon_zoomout", Int_Void) },
{ V("dod_weapon_zoomin", Int_Void) },
{ V("dod_weapon_getfov", Int_Void) },
{ V("dod_weapon_playeriswatersniping", Bool_Void) },
{ V("dod_weapon_updatezoomspeed", Void_Void) },
{ V("dod_weapon_special", Void_Void) },
/* Team Fortress Classic */
{ V("tfc_dbgetitemname", Str_Void) },
{ V("tfc_radiusdamage", Void_Entvar_Entvar_Float_Int_Int) },
{ V("tfc_radiusdamage2", Void_Vector_Entvar_Entvar_Float_Int_Int) },
/* Earth's Special Forces */
{ V("esf_isfighter", Int_Void) },
{ V("esf_isbuddy", Int_Void) },
{ V("esf_emitsound", Void_Str_Int) },
{ V("esf_emitnullsound", Void_Int) },
{ V("esf_increasestrength", Void_Cbase_Int) },
{ V("esf_increasepl", Void_Int) },
{ V("esf_setpowerlevel", Void_Int) },
{ V("esf_setmaxpowerlevel", Void_Int) },
{ V("esf_stopanitrigger", Void_Int) },
{ V("esf_stopfly", Void_Void) },
{ V("esf_hideweapon", Void_Void) },
{ V("esf_clientremoveweapon", Void_Int) },
{ V("esf_sendclientcustommodel",Void_Str) },
{ V("esf_canturbo", Int_Void) },
{ V("esf_canprimaryfire", Int_Void) },
{ V("esf_cansecondaryfire", Int_Void) },
{ V("esf_canstopfly", Int_Void) },
{ V("esf_canblock", Int_Void) },
{ V("esf_canraiseKi", Int_Void) },
{ V("esf_canraisestamina", Int_Void) },
{ V("esf_canteleport", Int_Void) },
{ V("esf_canstartfly", Int_Void) },
{ V("esf_canstartpowerup", Int_Void) },
{ V("esf_canjump", Int_Void) },
{ V("esf_canwalljump", Int_Void) },
{ V("esf_issuperjump", Int_Void) },
{ V("esf_ismoveback", Int_Void) },
{ V("esf_checkwalljump", Int_Void) },
{ V("esf_enablewalljump", Void_Vector) },
{ V("esf_disablewalljump", Void_Void) },
{ V("esf_resetwalljumpvars", Void_Void) },
{ V("esf_getwalljumpanim", Int_Str_Vector_Str) },
{ V("esf_getwalljumpanim2", Int_Str_Str) },
{ V("esf_setwalljumpanimation", Void_Void) },
{ V("esf_setflymovetype", Void_Void) },
{ V("esf_isflymovetype", Int_Void) },
{ V("esf_iswalkmovetype", Int_Void) },
{ V("esf_setwalkmovetype", Void_Void) },
{ V("esf_drawchargebar", Void_Int) },
{ V("esf_startblock", Void_Void) },
{ V("esf_stopblock", Void_Void) },
{ V("esf_startfly", Void_Void) },
{ V("esf_getmaxspeed", Float_Void) },
{ V("esf_setanimation", Void_Int) },
{ V("esf_playanimation", Void_Void) },
{ V("esf_getmoveforward", Int_Void) },
{ V("esf_getmoveright", Int_Void) },
{ V("esf_getmoveup", Void_Void) },
{ V("esf_addblindfx", Void_Void) },
{ V("esf_removeblindfx", Void_Void) },
{ V("esf_disablepsbar", Void_Void) },
{ V("esf_addbeamboxcrosshair", Void_Int) },
{ V("esf_removebeamboxcrosshair", Void_Void) },
{ V("esf_drawpswinbonus", Void_Void) },
{ V("esf_drawpsbar", Void_Float_Float) },
{ V("esf_lockcrosshair", Void_Void) },
{ V("esf_unlockcrosshair", Void_Void) },
{ V("esf_rotatecrosshair", Void_Void) },
{ V("esf_unrotatecrosshair", Void_Void) },
{ V("esf_watermove", Void_Void) },
{ V("esf_checktimebaseddamage", Void_Void) },
{ V("esf_doessecondaryattack", Int_Void) },
{ V("esf_doesprimaryattack", Int_Void) },
{ V("esf_removespecialmodes", Void_Void) },
{ V("esf_stopturbo", Void_Void) },
{ V("esf_takebean", Void_Void) },
{ V("esf_getpowerlevel", Void_Void) },
{ V("esf_removeallotherweapons",Void_Void) },
{ V("esf_stopswoop", Void_Void) },
{ V("esf_setdeathanimation", Void_Void) },
{ V("esf_setmodel", Void_Void) },
{ V("esf_addattacks", Void_Void) },
{ V("esf_emitclasssound", Void_Str_Str_Int) },
{ V("esf_checklightning", Void_Void) },
{ V("esf_freezecontrols", Void_Void) },
{ V("esf_unfreezecontrols", Void_Void) },
{ V("esf_updateki", Void_Void) },
{ V("esf_updatehealth", Void_Void) },
{ V("esf_getteleportdir", Vector_Void) },
{ V("esf_weapon_holsterwhenmeleed", Void_Void) },
/* Natural-Selection */
{ V("ns_setbonecontroller", Float_Int_Float) },
{ V("ns_savedataforreset", Void_Void) },
{ V("ns_gethull", Int_Void) },
{ V("ns_getmaxwalkspeed", Float_Void) },
{ V("ns_setteamid", Str_Str) },
{ V("ns_geteffectiveplayerclass", Int_Void) },
{ V("ns_getauthenticationmask", Int_Void) },
{ V("ns_effectiveplayerclasschanged", Void_Void) },
{ V("ns_needsteamupdate", Void_Void) },
{ V("ns_sendteamupdate", Void_Void) },
{ V("ns_sendweaponupdate", Void_Void) },
{ V("ns_initplayerfromspawn", Void_Edict) },
{ V("ns_packdeadplayeritems", Void_Void) },
{ V("ns_getanimationforactivity",Void_Int_Str_Bool) },
{ V("ns_startobserver", Void_Vector_Vector) },
{ V("ns_stopobserver", Void_Void) },
{ V("ns_getadrenalinefactor", Float_Void) },
{ V("ns_givenameditem", Void_Str_Bool) },
{ V("ns_suicide", Void_Void) },
{ V("ns_getcanuseweapon", Int_Void) },
{ V("ns_weapon_getweaponprimetime", Float_Void) },
{ V("ns_weapon_primeweapon", Void_Void) },
{ V("ns_weapon_getisweaponprimed", Int_Void) },
{ V("ns_weapon_getisweaponpriming", Int_Void) },
{ V("ns_weapon_defaultdeploy", Int_Str_Str_Int_Str_Int_Int) },
{ V("ns_weapon_defaultreload", Int_Int_Int_Float_Int) },
{ V("ns_weapon_getdeploytime", Float_Void) },
/* Sven co-op */
{ V("sc_getclassification", Int_Int) },
{ V("sc_ismonster", Int_Void) },
{ V("sc_isphysx", Int_Void) },
{ V("sc_ispointentity", Int_Void) },
{ V("sc_ismachine", Int_Void) },
{ V("sc_criticalremove", Int_Void) },
{ V("sc_updateonremove", Void_Void) },
{ V("sc_fvisible", Int_Cbase_Bool) },
{ V("sc_fvisiblefrompos", Int_Vector_Vector) },
{ V("sc_isfacing", Int_Entvar_Float) },
{ V("sc_getpointsfordamage", Float_Float) },
{ V("sc_getdamagepoints", Void_Entvar_Entvar_Float) },
{ V("sc_oncreate", Void_Void) },
{ V("sc_ondestroy", Void_Void) },
{ V("sc_isvalidentity", Bool_Void) },
{ V("sc_shouldfadeondeath", Int_Void) },
{ V("sc_setupfriendly", Void_Void) },
{ V("sc_revivethink", Void_Void) },
{ V("sc_revive", Void_Void) },
{ V("sc_startmonster", Void_Void) },
{ V("sc_checkrangeattack1_move",Int_Float_Float) },
{ V("sc_checkrangeattack2_move",Int_Float_Float) },
{ V("sc_checkmeleeattack1_move",Int_Float_Float) },
{ V("sc_checkmeleeattack2_move",Int_Float_Float) },
{ V("sc_checktankusage", Int_Void) },
{ V("sc_setgaitactivity", Int_Void) },
{ V("sc_ftriangulate", Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool) },
{ V("sc_ftriangulateextension", Int_pVector_pVector_Float_Cbase_pVector) },
{ V("sc_findcovergrenade", Int_Vector_Vector_Float_Float) },
{ V("sc_findcoverdistance", Int_Vector_Vector_Float_Float) },
{ V("sc_findattackpoint", Int_Vector_Vector_Float_Float) },
{ V("sc_fvalidatecover", Int_pVector) },
{ V("sc_nofriendlyfire1", Int_Void) },
{ V("sc_nofriendlyfire2", Int_Vector) },
{ V("sc_nofriendlyfire3", Int_Vector_Cbase) },
{ V("sc_nofriendlyfiretopos", Int_Vector) },
{ V("sc_fvisiblegunpos", Int_Cbase_pVector) },
{ V("sc_finbulletcone", Int_Cbase_pVector) },
{ V("sc_callgibmonster", Void_Void) },
{ V("sc_checktimebaseddamage", Void_Void) },
{ V("sc_ismoving", Int_Void) },
{ V("sc_isplayerfollowing", Int_Void) },
{ V("sc_startplayerfollowing", Void_Cbase) },
{ V("sc_stopplayerfollowing", Void_Int) },
{ V("sc_usesound", Void_Void) },
{ V("sc_unusesound", Void_Void) },
{ V("sc_ridemonster", Void_Cbase) },
{ V("sc_checkandapplygenericattacks", Void_Void) },
{ V("sc_checkscared", Bool_Void) },
{ V("sc_checkcreaturedanger", Void_Void) },
{ V("sc_checkfalldamage", Void_Void) },
{ V("sc_checkrevival", Void_Void) },
{ V("sc_mediccallsound", Void_Void) },
{ V("sc_player_menuinputperformed", Void_Bool) },
{ V("sc_player_ismenuinputdone",Bool_Void) },
{ V("sc_player_specialspawn", Void_Void) },
{ V("sc_player_isvalidinfoentity", Bool_Void) },
{ V("sc_player_levelend", Void_Void) },
{ V("sc_player_votestarted", Void_Int) },
{ V("sc_player_canstartnextvote", Bool_Int) },
{ V("sc_player_vote", Void_Int) },
{ V("sc_player_hasvoted", Bool_Void) },
{ V("sc_player_resetvote", Void_Void) },
{ V("sc_player_lastvoteinput", Int_Void) },
{ V("sc_player_initvote", Void_Void) },
{ V("sc_player_timetostartnextvote", Float_Void) },
{ V("sc_player_resetview", Void_Void) },
{ V("sc_player_getlogfrequency",Float_Void) },
{ V("sc_player_logplayerstats", Bool_Void) },
{ V("sc_player_disablecollisionwithplayer", Void_Cbase_Float) },
{ V("sc_player_enablecollisionwithplayer", Void_Cbase_Bool) },
{ V("sc_player_cantouchplayer", Bool_Cbase) },
{ V("sc_item_materialize", Void_Void) },
{ V("sc_weapon_bulletaccuracy", Vector_Vector_Vector_Vector) },
{ V("sc_weapon_tertiaryattack", Void_Void) },
{ V("sc_weapon_burstsupplement",Void_Void) },
{ V("sc_weapon_getp_model", Str_Str) },
{ V("sc_weapon_getw_model", Str_Str) },
{ V("sc_weapon_getv_model", Str_Str) },
{ V("sc_weapon_precachecustommodels", Void_Void) },
{ V("sc_weapon_ismultiplayer", Int_Void) },
{ V("sc_weapon_frunfuncs", Int_Void) },
{ V("sc_weapon_setfov", Void_Int) },
{ V("sc_weapon_fcanrun", Int_Void) },
{ V("sc_weapon_customdecrement",Void_Float) },
{ V("sc_weapon_setv_model", Void_Str) },
{ V("sc_weapon_setp_model", Void_Str) },
{ V("sc_weapon_changeweaponskin",Void_Short) },
/** New Additions (2013) **/
{ V("tfc_killed",Void_Entvar_Entvar_Int) },
{ V("tfc_istriggered", Int_Void) },
{ V("tfc_weapon_sendweaponanim", Void_Int_Int) },
{ V("tfc_weapon_getnextattackdelay", Float_Float) },
{ V("sc_takehealth",Int_Float_Int_Int) },
{ V("sc_takearmor", Int_Float_Int_Int) },
{ V("sc_giveammo", Int_Int_Str_Int_Int) },
{ V("sc_checkattacker", Int_Cbase) },
{ V("sc_player_isconnected", Int_Void) },
{ V("dod_weapon_sendweaponanim", Void_Int_Int) },
{ V("cstrike_item_isweapon", Int_Void) },
{ V("gearbox_mysquadtalkmonsterpointer", Cbase_Void) },
{ V("gearbox_weapontimebase", Float_Void) },
{ V("ts_weapon_alternateattack", Void_Void) },
{ V("item_getiteminfo", Void_ItemInfo) }
};
void FailPlugin(AMX *amx, int id, int err, const char *reason)
{
int fwd=MF_RegisterSPForwardByName(amx, "__fatal_ham_error", FP_CELL, FP_CELL, FP_STRING, FP_DONE);
MF_ExecuteForward(fwd, id, err, reason);
MF_UnregisterSPForward(fwd);
}
static cell AMX_NATIVE_CALL RegisterHam(AMX *amx, cell *params)
{
// Make sure the function we're requesting is within bounds
int func=params[1];
int post=params[4];
CHECK_FUNCTION(func);
char *function=MF_GetAmxString(amx, params[3], 0, NULL);
char *classname=MF_GetAmxString(amx, params[2], 1, NULL);
// Check the entity
// 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 == NULL)
{
REMOVE_ENTITY(Entity);
MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for \"%s\", hook for \"%s\" not active.",classname,function);
return 0;
}
void **vtable=GetVTable(Entity->pvPrivateData, Offsets.GetBase());
REMOVE_ENTITY(Entity);
if (vtable == NULL)
{
MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve vtable for \"%s\", hook for \"%s\" not active.",classname,function);
return 0;
}
// Verify that the function is valid
// Don't fail the plugin if this fails, just emit a normal error
int fwd=hooklist[func].makefunc(amx, function);
if (fwd == -1)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Function %s not found.", function);
return 0;
}
bool enableSpecialBot = false;
// Old plugin doesn't have this param.
if (*params / sizeof(cell) == 5)
{
enableSpecialBot = params[5] > 0;
}
Forward *pfwd = new Forward(fwd);
// We've passed all tests...
if (strcmp(classname, "player") == 0 && enableSpecialBot)
{
SpecialbotHandler.RegisterHamSpecialBot(amx, func, function, post, pfwd);
}
int **ivtable=(int **)vtable;
void *vfunction=(void *)ivtable[hooklist[func].vtid];
// Check the list of this function's hooks, see if the function we have is a hook
for (size_t i = 0; i < hooks[func].length(); ++i)
{
if (hooks[func].at(i)->tramp == vfunction)
{
// Yes, this function is hooked
if (post)
{
hooks[func].at(i)->post.append(pfwd);
}
else
{
hooks[func].at(i)->pre.append(pfwd);
}
return reinterpret_cast<cell>(pfwd);
}
}
// If we got here, the function is not hooked
Hook *hook = new Hook(vtable, hooklist[func].vtid, hooklist[func].targetfunc, hooklist[func].isvoid, hooklist[func].needsretbuf, hooklist[func].paramcount, classname);
hooks[func].append(hook);
if (post)
{
hook->post.append(pfwd);
}
else
{
hook->pre.append(pfwd);
}
return reinterpret_cast<cell>(pfwd);
}
// RegisterHamFromEntity(Ham:function, EntityId, const Callback[], Post=0);
static cell AMX_NATIVE_CALL RegisterHamFromEntity(AMX *amx, cell *params)
{
// Make sure the function we're requesting is within bounds
int func=params[1];
int post=params[4];
CHECK_FUNCTION(func);
char *function=MF_GetAmxString(amx, params[3], 0, NULL);
int entid=params[2];
char classname[64];
// Check the entity
edict_t *Entity=INDEXENT_NEW(entid);
if (Entity->pvPrivateData == NULL)
{
MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id \"%d\", hook for \"%s\" not active.",entid,function);
return 0;
}
void **vtable=GetVTable(Entity->pvPrivateData, Offsets.GetBase());
if (vtable == NULL)
{
MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve vtable for entity id \"%d\", hook for \"%s\" not active.",entid,function);
return 0;
}
// Verify that the function is valid
// Don't fail the plugin if this fails, just emit a normal error
int fwd=hooklist[func].makefunc(amx, function);
if (fwd == -1)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Function %s not found.", function);
return 0;
}
// We've passed all tests...
int **ivtable=(int **)vtable;
void *vfunction=(void *)ivtable[hooklist[func].vtid];
// Check the list of this function's hooks, see if the function we have is a hook
for (size_t i = 0; i < hooks[func].length(); ++i)
{
if (hooks[func].at(i)->tramp == vfunction)
{
// Yes, this function is hooked
Forward *pfwd=new Forward(fwd);
if (post)
{
hooks[func].at(i)->post.append(pfwd);
}
else
{
hooks[func].at(i)->pre.append(pfwd);
}
return reinterpret_cast<cell>(pfwd);
}
}
// Note down the classname for the given class
// It may very well be wrong (such as lots of TS weapons have the same classname)
// but it's the best we can do, and better than nothing.
// (only used for display)
UTIL_Format(classname, sizeof(classname) - 1, "%s", STRING(Entity->v.classname));
// If we got here, the function is not hooked
Hook *hook = new Hook(vtable, hooklist[func].vtid, hooklist[func].targetfunc, hooklist[func].isvoid, hooklist[func].needsretbuf, hooklist[func].paramcount, classname);
hooks[func].append(hook);
Forward *pfwd=new Forward(fwd);
if (post)
{
hook->post.append(pfwd);
}
else
{
hook->pre.append(pfwd);
}
return reinterpret_cast<cell>(pfwd);
}
static cell AMX_NATIVE_CALL ExecuteHam(AMX *amx, cell *params)
{
int func=params[1];
CHECK_FUNCTION(func);
gDoForwards=false;
return hooklist[func].call(amx, params);
}
static cell AMX_NATIVE_CALL ExecuteHamB(AMX *amx, cell *params)
{
int func=params[1];
CHECK_FUNCTION(func);
gDoForwards=true;
return hooklist[func].call(amx, params);
}
static cell AMX_NATIVE_CALL IsHamValid(AMX *amx, cell *params)
{
int func=params[1];
if (func >= 0 &&
func < HAM_LAST_ENTRY_DONT_USE_ME_LOL &&
hooklist[func].isset!=0)
{
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL DisableHamForward(AMX *amx, cell *params)
{
Forward *fwd=reinterpret_cast<Forward *>(params[1]);
if (fwd == 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid HamHook handle.");
return -1;
}
fwd->state=FSTATE_STOP;
return 0;
}
static cell AMX_NATIVE_CALL EnableHamForward(AMX *amx, cell *params)
{
Forward *fwd=reinterpret_cast<Forward *>(params[1]);
if (fwd == 0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid HamHook handle.");
return -1;
}
fwd->state=FSTATE_OK;
return 0;
}
AMX_NATIVE_INFO RegisterNatives[] =
{
{ "RegisterHam", RegisterHam },
{ "RegisterHamFromEntity", RegisterHamFromEntity },
{ "ExecuteHam", ExecuteHam },
{ "ExecuteHamB", ExecuteHamB },
{ "IsHamValid", IsHamValid },
{ "DisableHamForward", DisableHamForward },
{ "EnableHamForward", EnableHamForward },
{ NULL, NULL }
};

View File

@ -0,0 +1,123 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#include "hook_specialbot.h"
#include "hooklist.h"
#include "hook.h"
extern ke::Vector<Hook*> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
extern hook_t hooklist[];
CRegisterHamParams::CRegisterHamParams(AMX *arg_amx, int &arg_func, const char *arg_function, int &arg_post, Forward *arg_pfwd)
{
amx = arg_amx;
func = arg_func;
function = new char[strlen(arg_function)+1];
strcpy(function, arg_function);
post = arg_post;
pfwd = arg_pfwd;
}
CRegisterHamParams::~CRegisterHamParams()
{
delete[] function;
}
CHamSpecialBotHandler::CHamSpecialBotHandler()
{
m_specialbot_vtable = NULL;
}
void CHamSpecialBotHandler::CheckClientKeyValue(int &clientIndex, char *infobuffer, const char *key, const char *value)
{
if(m_specialbot_vtable != NULL)
return;
edict_t *pEdict = MF_GetPlayerEdict(clientIndex);
if((pEdict->v.flags & FL_FAKECLIENT) != FL_FAKECLIENT)
{
const char *auth = GETPLAYERAUTHID(pEdict);
if (auth && (strcmp(auth, "BOT") != 0))
return;
}
if(strcmp(key, "*bot") != 0 || strcmp(value, "1") != 0)
return;
m_specialbot_vtable = GetVTable(pEdict->pvPrivateData, Offsets.GetBase());
if(m_RHP_list.empty())
return;
for (size_t i = 0; i < m_RHP_list.length(); ++i)
{
CRegisterHamParams *item = m_RHP_list.at(i);
RegisterChecked(item->amx, item->func, item->function, item->post, item->pfwd);
delete item;
}
m_RHP_list.clear();
}
void CHamSpecialBotHandler::RegisterHamSpecialBot(AMX *amx, int &func, const char *function, int &post, Forward *pfwd)
{
if(m_specialbot_vtable == NULL)
{
m_RHP_list.append(new CRegisterHamParams(amx, func, function, post, pfwd));
return;
}
RegisterChecked(amx, func, function, post, pfwd);
}
void CHamSpecialBotHandler::RegisterChecked(AMX *amx, int &func, const char *function, int &post, Forward *pfwd)
{
void **vtable = m_specialbot_vtable;
int **ivtable=(int **)vtable;
void *vfunction=(void *)ivtable[hooklist[func].vtid];
for (size_t i = 0; i < hooks[func].length(); ++i)
{
if (hooks[func].at(i)->tramp == vfunction)
{
// Yes, this function is hooked
if (post)
{
hooks[func].at(i)->post.append(pfwd);
}
else
{
hooks[func].at(i)->pre.append(pfwd);
}
return;
}
}
char classname[] = "player";
// If we got here, the function is not hooked
Hook *hook = new Hook(vtable, hooklist[func].vtid, hooklist[func].targetfunc, hooklist[func].isvoid, hooklist[func].needsretbuf, hooklist[func].paramcount, classname);
hooks[func].append(hook);
if (post)
{
hook->post.append(pfwd);
}
else
{
hook->pre.append(pfwd);
}
}

View File

@ -0,0 +1,50 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#ifndef HOOK_SPECIALBOT_H
#define HOOK_SPECIALBOT_H
#include "ham_utils.h"
#include <am-vector.h>
#include "forward.h"
class CRegisterHamParams
{
public:
AMX *amx;
int func;
char *function;
int post;
Forward *pfwd;
CRegisterHamParams(AMX *arg_amx, int &arg_func, const char *arg_function, int &arg_post, Forward *arg_pfwd);
~CRegisterHamParams();
private:
CRegisterHamParams(){}
};
class CHamSpecialBotHandler
{
public:
CHamSpecialBotHandler();
void CheckClientKeyValue(int &clientIndex, char *infobuffer, const char *key, const char *value);
void RegisterHamSpecialBot(AMX *amx, int &func, const char *function, int &post, Forward *pfwd);
private:
void RegisterChecked(AMX *amx, int &func, const char *function, int &post, Forward *pfwd);
ke::Vector<CRegisterHamParams*> m_RHP_list;
void **m_specialbot_vtable;
};
#endif // HOOK_SPECIALBOT_H

View File

@ -0,0 +1,32 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#ifndef HOOKLIST_T_H
#define HOOKLIST_T_H
typedef struct hook_s
{
int isset; // whether or not this hook is registered with hamdata
int vtid; // vtable index of this function
const char *name; // name used in the keys
bool isvoid; // whether or not the target trampoline uses voids
bool needsretbuf; // whether or not a pointer to a memory buffer is needed to store a return value
int paramcount; // how many parameters are in the func
void *targetfunc; // the target hook
int (*makefunc)(AMX *, const char*); // function that creates forwards
cell (*call)(AMX *, cell*); // function to call the vcall
} hook_t;
extern hook_t hooklist[];
#endif

View File

@ -0,0 +1,506 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
// Parts Copyright (C) 2001-2003 Will Day <willday@hpgx.net>
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Module Config
//
#ifndef __MODULECONFIG_H__
#define __MODULECONFIG_H__
#include <amxmodx_version.h>
// Module info
#define MODULE_NAME "Ham Sandwich"
#define MODULE_VERSION AMXX_VERSION
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org"
#define MODULE_LOGTAG "HAMSANDWICH"
#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 FMH_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__

View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hamsandwich", "hamsandwich.vcxproj", "{5E393C37-22F2-4CA2-9022-6400DC582447}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5E393C37-22F2-4CA2-9022-6400DC582447}.Debug|Win32.ActiveCfg = Debug|Win32
{5E393C37-22F2-4CA2-9022-6400DC582447}.Debug|Win32.Build.0 = Debug|Win32
{5E393C37-22F2-4CA2-9022-6400DC582447}.Release|Win32.ActiveCfg = Release|Win32
{5E393C37-22F2-4CA2-9022-6400DC582447}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A8B3717F-2663-4099-AE96-AF5B7266FDA8}</ProjectGuid>
<RootNamespace>hamsandwich</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)_amxx</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName)_amxx</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\;..\..\..\public;..\..\..\public\sdk; ..\..\..\public\amtl\include;..\..\third_party;..\..\third_party\hashing;$(METAMOD)\metamod;$(HLSDK)\common;$(HLSDK)\engine;$(HLSDK)\dlls;$(HLSDK)\pm_shared;$(HLSDK)\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;HAMSANDWICH_EXPORTS; HAVE_STDINT_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)hamsandwich.pdb</ProgramDatabaseFile>
<SubSystem>Windows</SubSystem>
<ImportLibrary>$(OutDir)hamsandwich.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
<IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\;..\..\..\public;..\..\..\public\sdk; ..\..\..\public\amtl\include;..\..\third_party;..\..\third_party\hashing;$(METAMOD)\metamod;$(HLSDK)\common;$(HLSDK)\engine;$(HLSDK)\dlls;$(HLSDK)\pm_shared;$(HLSDK)\public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;HAMSANDWICH_EXPORTS; HAVE_STDINT_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<ImportLibrary>$(OutDir)hamsandwich.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\call_funcs.cpp" />
<ClCompile Include="..\hook_callbacks.cpp" />
<ClCompile Include="..\hook_create.cpp" />
<ClCompile Include="..\hook_native.cpp" />
<ClCompile Include="..\hook_specialbot.cpp" />
<ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp" />
<ClCompile Include="..\config_parser.cpp" />
<ClCompile Include="..\DataHandler.cpp" />
<ClCompile Include="..\pdata.cpp" />
<ClCompile Include="..\amxx_api.cpp" />
<ClCompile Include="..\srvcmd.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\call_funcs.h" />
<ClInclude Include="..\forward.h" />
<ClInclude Include="..\hook.h" />
<ClInclude Include="..\hook_callbacks.h" />
<ClInclude Include="..\hook_create.h" />
<ClInclude Include="..\hooklist.h" />
<ClInclude Include="..\hook_specialbot.h" />
<ClInclude Include="..\typetocell.h" />
<ClInclude Include="..\Trampolines.h" />
<ClInclude Include="..\moduleconfig.h" />
<ClInclude Include="..\..\..\public\sdk\amxxmodule.h" />
<ClInclude Include="..\DataHandler.h" />
<ClInclude Include="..\ham_const.h" />
<ClInclude Include="..\ham_utils.h" />
<ClInclude Include="..\NEW_Util.h" />
<ClInclude Include="..\offsets.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\plugins\include\ham_const.inc" />
<None Include="..\..\..\plugins\include\hamsandwich.inc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Hooks">
<UniqueIdentifier>{0d21fbb8-146c-4b20-b066-62edc14749d4}</UniqueIdentifier>
</Filter>
<Filter Include="Hooks\Trampolines">
<UniqueIdentifier>{ce417f8e-c1e8-44dc-9838-ca41d802f420}</UniqueIdentifier>
</Filter>
<Filter Include="Module SDK">
<UniqueIdentifier>{bba09eb2-251f-40e6-8921-114143fad232}</UniqueIdentifier>
</Filter>
<Filter Include="Module SDK\SDK Base">
<UniqueIdentifier>{4fb419c2-3177-4389-9713-a7b032b57c1c}</UniqueIdentifier>
</Filter>
<Filter Include="Config File">
<UniqueIdentifier>{f626de6a-9bea-468b-97e9-4f5d62307d78}</UniqueIdentifier>
</Filter>
<Filter Include="Data Handler">
<UniqueIdentifier>{1915e746-1906-4cac-bc08-e7fcc5c4b36b}</UniqueIdentifier>
</Filter>
<Filter Include="Pawn Includes">
<UniqueIdentifier>{02bee5ba-ea8c-474f-819f-02e86f937cac}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{cc96b3b3-d6ef-4d37-9f33-9717aa162f52}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{1f536280-a798-4422-847e-ed6e8df80258}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\call_funcs.cpp">
<Filter>Hooks</Filter>
</ClCompile>
<ClCompile Include="..\hook_callbacks.cpp">
<Filter>Hooks</Filter>
</ClCompile>
<ClCompile Include="..\hook_create.cpp">
<Filter>Hooks</Filter>
</ClCompile>
<ClCompile Include="..\hook_native.cpp">
<Filter>Hooks</Filter>
</ClCompile>
<ClCompile Include="..\config_parser.cpp">
<Filter>Config File</Filter>
</ClCompile>
<ClCompile Include="..\DataHandler.cpp">
<Filter>Data Handler</Filter>
</ClCompile>
<ClCompile Include="..\pdata.cpp">
<Filter>Data Handler</Filter>
</ClCompile>
<ClCompile Include="..\amxx_api.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\srvcmd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\hook_specialbot.cpp">
<Filter>Hooks</Filter>
</ClCompile>
<ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp">
<Filter>Module SDK\SDK Base</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\call_funcs.h">
<Filter>Hooks</Filter>
</ClInclude>
<ClInclude Include="..\forward.h">
<Filter>Hooks</Filter>
</ClInclude>
<ClInclude Include="..\hook.h">
<Filter>Hooks</Filter>
</ClInclude>
<ClInclude Include="..\hook_callbacks.h">
<Filter>Hooks</Filter>
</ClInclude>
<ClInclude Include="..\hook_create.h">
<Filter>Hooks</Filter>
</ClInclude>
<ClInclude Include="..\hooklist.h">
<Filter>Hooks</Filter>
</ClInclude>
<ClInclude Include="..\typetocell.h">
<Filter>Hooks</Filter>
</ClInclude>
<ClInclude Include="..\Trampolines.h">
<Filter>Hooks\Trampolines</Filter>
</ClInclude>
<ClInclude Include="..\DataHandler.h">
<Filter>Data Handler</Filter>
</ClInclude>
<ClInclude Include="..\ham_const.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\ham_utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\NEW_Util.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\offsets.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\hook_specialbot.h">
<Filter>Hooks</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\sdk\amxxmodule.h">
<Filter>Module SDK\SDK Base</Filter>
</ClInclude>
<ClInclude Include="..\moduleconfig.h">
<Filter>Module SDK</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\plugins\include\ham_const.inc">
<Filter>Pawn Includes</Filter>
</None>
<None Include="..\..\..\plugins\include\hamsandwich.inc">
<Filter>Pawn Includes</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,68 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#ifndef OFFSETS_H
#define OFFSETS_H
#include "ham_const.h"
// Just a singleton class that keeps pev/base/offset values managed.
class OffsetManager
{
private:
size_t pev;
size_t baseclass;
int baseset;
int pevset;
public:
OffsetManager()
{
memset(this,0x0,sizeof(*this));
}
void SetPev(size_t value)
{
pevset=1;
pev=value;
};
size_t GetPev(void)
{
return pev;
};
int IsPevSet()
{
return pevset;
};
int IsBaseSet()
{
return baseset;
};
void SetBase(size_t value)
{
baseset=1;
baseclass=value;
};
size_t GetBase(void)
{
return baseclass;
};
bool IsValid()
{
return pevset != 0 && baseset != 0;
}
};
extern OffsetManager Offsets;
#endif

View File

@ -0,0 +1,167 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#include "amxxmodule.h"
#include "offsets.h"
#include "NEW_Util.h"
#include "ham_utils.h"
inline edict_t* INDEXENT2( int iEdictNum )
{
if (iEdictNum >= 1 && iEdictNum <= gpGlobals->maxClients)
return MF_GetPlayerEdict(iEdictNum);
else
return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum);
}
#ifdef DONT_TOUCH_THIS_AGAIN_BAIL
#define FM_CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else { \
if (x <= gpGlobals->maxClients) { \
if (!MF_IsPlayerIngame(x)) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
return 0; \
} \
} else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
} \
} \
}
#endif
#define FM_CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \
} else if (x != 0 && FNullEnt(INDEXENT2(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \
}
// Return -1 on null, -2 on invalid, and the the index of any other.
static cell AMX_NATIVE_CALL get_pdata_cbase_safe(AMX *amx, cell *params)
{
int index=params[1];
FM_CHECK_ENTITY(index);
int iOffset=params[2];
#ifdef __linux__
iOffset += params[3];
#elif defined __APPLE__
// Use Linux offset in older plugins
if (params[0] / sizeof(cell) == 3)
iOffset += params[3];
else
iOffset += params[4];
#endif
if (iOffset <0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset);
return 0;
}
void *ptr=*((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset));
if (ptr == 0)
{
return -1;
}
for (int i=0; i<gpGlobals->maxEntities; ++i)
{
if (ptr == INDEXENT_NEW(i)->pvPrivateData)
{
return i;
}
}
return -2;
}
static cell AMX_NATIVE_CALL get_pdata_cbase(AMX *amx, cell *params)
{
int index=params[1];
FM_CHECK_ENTITY(index);
int iOffset=params[2];
#ifdef __linux__
iOffset += params[3];
#elif defined __APPLE__
// Use Linux offset in older plugins
if (params[0] / sizeof(cell) == 3)
iOffset += params[3];
else
iOffset += params[4];
#endif
if (iOffset <0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset);
return 0;
}
void *ptr=*((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset));
return PrivateToIndex(ptr);
}
static cell AMX_NATIVE_CALL set_pdata_cbase(AMX *amx, cell *params)
{
int index=params[1];
FM_CHECK_ENTITY(index);
int target=params[3];
if (target != -1)
{
FM_CHECK_ENTITY(target);
}
int iOffset=params[2];
#ifdef __linux__
iOffset += params[4];
#elif defined __APPLE__
// Use Linux offset in older plugins
if (params[0] / sizeof(cell) == 4)
iOffset += params[4];
else
iOffset += params[5];
#endif
if (iOffset <0)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset);
return 0;
}
if (target == -1)
{
*((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset)) = NULL;
}
else
{
*((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset)) = INDEXENT_NEW(target)->pvPrivateData;
}
return 1;
}
AMX_NATIVE_INFO pdata_natives_safe[] =
{
{ "get_pdata_cbase_safe", get_pdata_cbase_safe },
{ NULL, NULL }
};
AMX_NATIVE_INFO pdata_natives[] =
{
{ "get_pdata_cbase", get_pdata_cbase },
{ "set_pdata_cbase", set_pdata_cbase },
{ NULL, NULL }
};

View File

@ -0,0 +1,116 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#include "amxxmodule.h"
#include <stdarg.h>
#include <am-vector.h>
#include "ham_const.h"
#include "hooklist.h"
#include "offsets.h"
#include "forward.h"
#include "hook.h"
extern hook_t hooklist[];
extern ke::Vector<Hook *> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
void print_srvconsole(const char *fmt, ...)
{
va_list argptr;
static char string[384];
va_start(argptr, fmt);
vsnprintf(string, sizeof(string) - 1, fmt, argptr);
string[sizeof(string) - 1] = '\0';
va_end(argptr);
SERVER_PRINT(string);
}
void HamCommand(void)
{
const char *cmd=CMD_ARGV(1);
if (strcmp(cmd, "list")==0)
{
unsigned int Total=0;
print_srvconsole("%-24s | %10s\n","Name","Set","Value");
print_srvconsole("------------------------------------\n");
print_srvconsole("%-24s | %10d\n", "pev", Offsets.GetPev());
print_srvconsole("%-24s | %10d\n", "base", Offsets.GetBase());
if (Offsets.IsPevSet())
{
Total++;
}
if (Offsets.IsBaseSet())
{
Total++;
}
int count=2;
for (int i=0; i<HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++)
{
if (hooklist[i].isset != 0)
{
print_srvconsole("%-24s | %10d\n", hooklist[i].name, hooklist[i].vtid);
Total++;
count++;
}
if (count >= 5)
{
count = 0;
print_srvconsole("------------------------------------\n");
}
}
print_srvconsole("\n%u keys, %u set.\n\n", HAM_LAST_ENTRY_DONT_USE_ME_LOL, Total);
return;
}
else if (strcmp(cmd, "hooks")==0)
{
print_srvconsole("%-24s | %-27s | %10s | %10s\n", "Key", "Classname", "Pre", "Post");
print_srvconsole("--------------------------------------------------------------------------------\n");
unsigned int ForwardCount=0;
unsigned int HookCount=0;
int count = 0;
for (int i=0; i<HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++)
{
for (size_t j = 0; j < hooks[i].length(); ++i)
{
HookCount++;
ForwardCount += hooks[i].at(j)->pre.length() + hooks[i].at(j)->post.length();
print_srvconsole("%-24s | %-27s | %10d | %10d\n", hooklist[i].name, hooks[i].at(j)->ent, hooks[i].at(j)->pre.length(), hooks[i].at(j)->post.length());
if (count >= 5)
{
print_srvconsole("--------------------------------------------------------------------------------\n");
}
}
}
print_srvconsole("\n%u hooks, %u forwards.\n\n", HookCount, ForwardCount);
return;
}
// Unknown command
print_srvconsole("Usage: ham < command > [ argument ]\n");
print_srvconsole("Commands:\n");
print_srvconsole(" %-22s - %s\n", "list", "list all keys and their values from the config file.");
print_srvconsole(" %-22s - %s\n", "hooks", "list all active hooks");
}

View File

@ -0,0 +1,72 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
#ifndef TYPETOCELL_H
#define TYPETOCELL_H
#include <extdll.h>
#include "amxxmodule.h"
#include "hook.h"
#include "forward.h"
#include "ham_const.h"
#include "ham_utils.h"
inline cell TypeToCell(const float& value)
{
return amx_ftoc2(value);
}
inline cell TypeToCell(const float*& value)
{
return amx_ftoc2(*value);
}
inline cell TypeToCell(const Vector*& value)
{
return reinterpret_cast<cell>(value);
}
inline cell TypeToCell(const int& value)
{
return value;
}
inline cell TypeToCell(const edict_t*& value)
{
if (value == NULL)
{
return -1;
}
return ENTINDEX_NEW(value);
}
inline cell TypeToCell(const entvars_t*& value)
{
if (value == NULL)
{
return -1;
}
return ENTINDEX_NEW(value->pContainingEntity);
}
inline cell TypeToCell(const HLBaseEntity*& value)
{
return PrivateToIndex(reinterpret_cast<const void *>(value));
}
#endif

View File

@ -0,0 +1,101 @@
// Microsoft Visual C++ generated resource script.
//
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include <winresrc.h>
#include <moduleconfig.h>
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION AMXX_VERSION_FILE
PRODUCTVERSION AMXX_VERSION_FILE
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "AMX Mod X"
VALUE "FileDescription", "AMX Mod X"
VALUE "FileVersion", AMXX_VERSION
VALUE "InternalName", MODULE_LIBRARY
VALUE "LegalCopyright", "Copyright (c) AMX Mod X Dev Team"
VALUE "OriginalFilename", MODULE_LIBRARY "_amxx.dll"
VALUE "ProductName", MODULE_NAME
VALUE "ProductVersion", AMXX_VERSION
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED