Update globally Hamsandwich module (bug 5611, r=sawce)

This commit is contained in:
Arkshine 2014-04-09 16:35:46 +02:00
parent 9815050287
commit 1a7daad657
29 changed files with 17823 additions and 11404 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,321 +1,512 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#include "amxxmodule.h" #include "amxxmodule.h"
#include "CVector.h" #include "CVector.h"
#include "CString.h" #include "CString.h"
#include "sh_stack.h" #include "sh_stack.h"
#include "DataHandler.h" #include "DataHandler.h"
#include "ham_const.h" #include "ham_const.h"
#include "ham_utils.h" #include "ham_utils.h"
#include "NEW_Util.h" #include "NEW_Util.h"
CStack< Data * > ReturnStack; CStack< Data * > ReturnStack;
CStack< Data * > OrigReturnStack; CStack< Data * > OrigReturnStack;
CStack< CVector< Data * > * > ParamStack; CStack< CVector< Data * > * > ParamStack;
CStack< int * > ReturnStatus; CStack< int * > ReturnStatus;
#define CHECK_STACK(__STACK__) \ #define CHECK_STACK(__STACK__) \
if ( ( __STACK__ ).size() <= 0) \ if ( ( __STACK__ ).size() <= 0) \
{ \ { \
MF_LogError(amx, AMX_ERR_NATIVE, "%s is empty!", #__STACK__); \ MF_LogError(amx, AMX_ERR_NATIVE, "%s is empty!", #__STACK__); \
return 0; \ 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);
CVector<Data *> *vec=ParamStack.front();
if (vec->size() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
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);
CVector<Data *> *vec=ParamStack.front();
if (vec->size() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
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);
CVector<Data *> *vec=ParamStack.front();
if (vec->size() < (unsigned)params[1] || params[1] < 1)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
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);
CVector<Data *> *vec=ParamStack.front();
if (vec->size() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
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);
CVector<Data *> *vec=ParamStack.front();
if (vec->size() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
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);
CVector<Data *> *vec=ParamStack.front();
if (vec->size() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
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);
CVector<Data *> *vec = ParamStack.front();
if (vec->size() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
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;
} }
#define PARSE_RETURN() \ int type = params[2];
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[] = if ((type == ItemInfo_pszAmmo1 || type == ItemInfo_pszAmmo2 || type == ItemInfo_pszName) && (*params / sizeof(cell)) != 4)
{
"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);
CVector<Data *> *vec=ParamStack.front();
if (vec->size() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
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."); MF_LogError(amx, AMX_ERR_NATIVE, "Bad arg count. Expected %d, got %d.", 4, *params / sizeof(cell));
return 0; return 0;
} }
CHECK_STACK(ParamStack);
CVector<Data *> *vec=ParamStack.front();
if (vec->size() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
return 0;
}
Data *dat=vec->at(params[1] - 1);
int ret=dat->SetInt(&params[2]); ItemInfo *pItem = reinterpret_cast<ItemInfo *>(params[1]);
PARSE_RETURN();
} switch (type)
static cell AMX_NATIVE_CALL SetHamParamFloat(AMX *amx, cell *params) {
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)
{ {
CHECK_STACK(ParamStack); ItemInfo *ii;
CVector<Data *> *vec=ParamStack.front();
if (vec->size() < (unsigned)params[1] || params[1] < 1)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
return 0;
}
Data *dat=vec->at(params[1] - 1);
int ret=dat->SetFloat(&params[2]); if (g_FreeIIs.empty())
PARSE_RETURN(); {
} ii = new ItemInfo;
static cell AMX_NATIVE_CALL SetHamParamVector(AMX *amx, cell *params) }
{ else
CHECK_STACK(ParamStack); {
CVector<Data *> *vec=ParamStack.front(); ii = g_FreeIIs.front();
if (vec->size() < (unsigned)params[1]) g_FreeIIs.pop();
{ }
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
return 0;
}
Data *dat=vec->at(params[1] - 1);
int ret=dat->SetVector(MF_GetAmxAddr(amx, params[2])); memset(ii, 0, sizeof(ItemInfo));
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamParamEntity(AMX *amx, cell *params)
{
CHECK_STACK(ParamStack);
CVector<Data *> *vec=ParamStack.front();
if (vec->size() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
return 0;
}
Data *dat=vec->at(params[1] - 1);
int ret=dat->SetEntity(&params[2]); return reinterpret_cast<cell>(ii);
PARSE_RETURN();
}
static cell AMX_NATIVE_CALL SetHamParamString(AMX *amx, cell *params)
{
CHECK_STACK(ParamStack);
CVector<Data *> *vec=ParamStack.front();
if (vec->size() < (unsigned)params[1])
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid parameter number, got %d, expected %d", params[1], vec->size());
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 GetHamReturnStatus(AMX *amx, cell *params)
{
CHECK_STACK(ReturnStatus);
int *i=ReturnStatus.front();
return *i;
} }
AMX_NATIVE_INFO ReturnNatives[] = static cell AMX_NATIVE_CALL FreeHamItemInfo(AMX *amx, cell *params)
{ {
{ "GetHamReturnInteger", GetHamReturnInteger }, ItemInfo *ii = reinterpret_cast<ItemInfo *>(params[1]);
{ "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 }, if (!ii)
{
return 0;
}
{ "SetHamParamInteger", SetHamParamInteger }, g_FreeIIs.push(ii);
{ "SetHamParamFloat", SetHamParamFloat },
{ "SetHamParamVector", SetHamParamVector },
{ "SetHamParamEntity", SetHamParamEntity },
{ "SetHamParamString", SetHamParamString },
{ "SetHamParamTraceResult", SetHamParamTraceResult },
{ NULL, NULL }, 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

@ -1,304 +1,389 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#ifndef RETURNHANDLER_H #ifndef RETURNHANDLER_H
#define RETURNHANDLER_H #define RETURNHANDLER_H
#include "ham_utils.h" #include "ham_utils.h"
#include "CVector.h" #include "CVector.h"
#include "CString.h" #include "CString.h"
#include "sh_stack.h" #include "sh_stack.h"
enum 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
{ {
RET_VOID, int iSlot;
RET_INTEGER, int iPosition;
RET_FLOAT, const char *pszAmmo1;
RET_VECTOR, int iMaxAmmo1;
RET_STRING, const char *pszAmmo2;
RET_CBASE, int iMaxAmmo2;
RET_ENTVAR, const char *pszName;
RET_TRACE, int iMaxClip;
RET_ITEMINFO int iId;
}; int iFlags;
// Container for return and parameter data. int iWeight;
// Contains a void pointer, and a flag telling what it contains. }
class Data ItemInfo;
{
private: enum
void *m_data; {
int *m_index; ItemInfo_iSlot,
int m_type; ItemInfo_iPosition,
ItemInfo_pszAmmo1,
bool IsSet(void) ItemInfo_iMaxAmmo1,
{ ItemInfo_pszAmmo2,
return (m_type != RET_VOID && ItemInfo_iMaxAmmo2,
m_data != NULL); ItemInfo_pszName,
}; ItemInfo_iMaxClip,
bool IsType(const int type) ItemInfo_iId,
{ ItemInfo_iFlags,
return (m_type == type); ItemInfo_iWeight
}; };
public: // Container for return and parameter data.
Data() : m_data(NULL), m_index(NULL), m_type(RET_VOID) // Contains a void pointer, and a flag telling what it contains.
{ /* nothing */ }; class Data
{
Data(int type, void *ptr) : m_data(ptr), m_index(NULL), m_type(type) private:
{ /* nothing */ }; void *m_data;
int *m_index;
Data(int type, void *ptr, int *cptr) : m_data(ptr), m_index(NULL), m_type(type) int m_type;
{ /* nothing */ };
bool IsSet(void)
~Data() {
{ /* nothing */ }; return (m_type != RET_VOID &&
m_data != NULL);
int GetType() };
{ bool IsType(const int type)
return m_type; {
}; return (m_type == type);
};
// All Get/Set value natives return < 0 on failure.
// -1: Wrong type public:
// -2: Bad data pointer (void, etc). Data() : m_data(NULL), m_index(NULL), m_type(RET_VOID)
int SetInt(cell *data) { /* nothing */ };
{
if (!IsSet()) Data(int type, void *ptr) : m_data(ptr), m_index(NULL), m_type(type)
{ { /* nothing */ };
return -2;
} Data(int type, void *ptr, int *cptr) : m_data(ptr), m_index(NULL), m_type(type)
if (IsType(RET_INTEGER)) { /* nothing */ };
{
*(reinterpret_cast<int *>(m_data))=*data; ~Data()
return 0; { /* nothing */ };
}
else if (IsType(RET_TRACE)) int GetType()
{ {
*(reinterpret_cast<int *>(m_data))=*data; return m_type;
return 0; };
}
// All Get/Set value natives return < 0 on failure.
return -1; // -1: Wrong type
}; // -2: Bad data pointer (void, etc).
int SetInt(cell *data)
int SetFloat(cell *data) {
{ if (!IsSet())
if (!IsSet()) {
{ return -2;
return -2; }
} if (IsType(RET_INTEGER))
if (!IsType(RET_FLOAT)) {
{ *(reinterpret_cast<int *>(m_data))=*data;
return -1; return 0;
} }
*(reinterpret_cast<REAL *>(m_data))=amx_ctof2(*data); else if (IsType(RET_BOOL))
{
return 0; *(reinterpret_cast<bool *>(m_data)) = *data > 0;
}; return 0;
int SetVector(cell *data) }
{ else if (IsType(RET_SHORT))
if (!IsSet()) {
{ *(reinterpret_cast<short *>(m_data)) = *data;
return -2; return 0;
} }
if (!IsType(RET_VECTOR)) else if (IsType(RET_ITEMINFO))
{ {
return -1; *(reinterpret_cast<int *>(m_data)) = *data;
} return 0;
Vector *vec=reinterpret_cast<Vector *>(m_data); }
else if (IsType(RET_TRACE))
vec->x=amx_ctof2(data[0]); {
vec->y=amx_ctof2(data[1]); *(reinterpret_cast<int *>(m_data))=*data;
vec->z=amx_ctof2(data[2]); return 0;
}
return 0;
}; return -1;
int SetString(cell *data) };
{
if (!IsSet()) int SetFloat(cell *data)
{ {
return -2; if (!IsSet())
} {
if (!IsType(RET_STRING)) return -2;
{ }
return -1; if (!IsType(RET_FLOAT))
} {
return -1;
String *str=reinterpret_cast<String *>(m_data); }
*(reinterpret_cast<REAL *>(m_data))=amx_ctof2(*data);
cell *i=data;
size_t len=0; return 0;
};
while (*i!=0) int SetVector(cell *data)
{ {
i++; if (!IsSet())
len++; {
}; return -2;
char *temp=new char[len+1]; }
i=data; if (!IsType(RET_VECTOR))
char *j=temp; {
return -1;
while ((*j++=*i++)!=0) }
{ Vector *vec=reinterpret_cast<Vector *>(m_data);
/* nothing */
} vec->x=amx_ctof2(data[0]);
vec->y=amx_ctof2(data[1]);
str->assign(temp); vec->z=amx_ctof2(data[2]);
delete[] temp; return 0;
};
return 0; int SetString(cell *data)
}; {
if (!IsSet())
int SetEntity(cell *data) {
{ return -2;
if (!IsSet()) }
{ if (!IsType(RET_STRING))
return -2; {
} return -1;
if (IsType(RET_CBASE)) }
{
*(reinterpret_cast<void **>(m_data))=IndexToPrivate(*data); String *str=reinterpret_cast<String *>(m_data);
if (m_index != 0)
{ cell *i=data;
*m_index=*data; size_t len=0;
}
while (*i!=0)
return 0; {
} i++;
else if (IsType(RET_ENTVAR)) len++;
{ };
*(reinterpret_cast<entvars_t **>(m_data))=IndexToEntvar(*data); char *temp=new char[len+1];
if (m_index != 0) i=data;
{ char *j=temp;
*m_index=*data;
} while ((*j++=*i++)!=0)
{
return 0; /* nothing */
} }
return -1;
}; str->assign(temp);
int GetInt(cell *data) delete[] temp;
{
if (!IsSet()) return 0;
{ };
return -2;
} int SetEntity(cell *data)
if (IsType(RET_INTEGER)) {
{ if (!IsSet())
*data=*(reinterpret_cast<int *>(m_data)); {
return -2;
return 0; }
} if (IsType(RET_CBASE))
else if (IsType(RET_TRACE)) {
{ *(reinterpret_cast<void **>(m_data))=IndexToPrivate(*data);
*data=*(reinterpret_cast<int *>(m_data)); if (m_index != 0)
{
return 0; *m_index=*data;
} }
return -1; return 0;
}; }
int GetFloat(cell *data) else if (IsType(RET_ENTVAR))
{ {
if (!IsSet()) *(reinterpret_cast<entvars_t **>(m_data))=IndexToEntvar(*data);
{ if (m_index != 0)
return -2; {
} *m_index=*data;
if (!IsType(RET_FLOAT)) }
{
return -1; return 0;
} }
*data=amx_ftoc2(*(reinterpret_cast<REAL *>(m_data))); else if (IsType(RET_EDICT))
{
return 0; *(reinterpret_cast<edict_t **>(m_data)) = IndexToEdict(*data);
}; if (m_index != 0)
int GetVector(cell *data) {
{ *m_index = *data;
if (!IsSet()) }
{
return -2; return 0;
} }
if (!IsType(RET_VECTOR)) return -1;
{ };
return -1;
} int GetInt(cell *data)
Vector *vec=reinterpret_cast<Vector *>(m_data); {
data[0]=amx_ftoc2(vec->x); if (!IsSet())
data[1]=amx_ftoc2(vec->y); {
data[2]=amx_ftoc2(vec->z); return -2;
}
return 0; if (IsType(RET_INTEGER))
}; {
int GetString(cell *data, int len) *data=*(reinterpret_cast<int *>(m_data));
{
if (!IsSet()) return 0;
{ }
return -2; else if (IsType(RET_BOOL))
} {
if (!IsType(RET_STRING)) *data = *(reinterpret_cast<bool *>(m_data));
{
return -1; return 0;
} }
const char *i=(reinterpret_cast<String *>(m_data)->c_str());
else if (IsType(RET_SHORT))
while (len-- && {
(*data++=*i++)!='\0') *data = *(reinterpret_cast<short *>(m_data));
{
/* nothing */ return 0;
}; }
return 0; else if (IsType(RET_ITEMINFO))
}; {
int GetEntity(cell *data) *data = *(reinterpret_cast<int *>(m_data));
{
if (!IsSet()) return 0;
{ }
return -2; else if (IsType(RET_TRACE))
} {
if (IsType(RET_CBASE)) *data=*(reinterpret_cast<int *>(m_data));
{
*data=PrivateToIndex(m_data); return 0;
}
return 0;
} return -1;
else if (IsType(RET_ENTVAR)) };
{ int GetFloat(cell *data)
*data=EntvarToIndex(reinterpret_cast<entvars_t *>(m_data)); {
if (!IsSet())
return 0; {
} return -2;
return -1; }
} if (!IsType(RET_FLOAT))
}; {
return -1;
extern CStack< Data * > ReturnStack; }
extern CStack< Data * > OrigReturnStack; *data=amx_ftoc2(*(reinterpret_cast<REAL *>(m_data)));
extern CStack< CVector< Data * > * > ParamStack;
extern CStack< int * > ReturnStatus; return 0;
#endif };
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<String *>(m_data)->c_str());
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< CVector< Data * > * > ParamStack;
extern CStack< int * > ReturnStatus;
#endif

View File

@ -1,87 +1,87 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
/* Inlined replacements for INDEXENT/ENTINDEX /* Inlined replacements for INDEXENT/ENTINDEX
* It only really removes the overhead of the push/jump * It only really removes the overhead of the push/jump
* but since INDEXENT/ENTINDEX are used a lot with amxx * but since INDEXENT/ENTINDEX are used a lot with amxx
* it might be beneficial to include. * it might be beneficial to include.
* NOTE: Bad stuff will happen if you call these before * NOTE: Bad stuff will happen if you call these before
* NEW_Initialize() * NEW_Initialize()
* NOTE: No bounds checking is done because natives * NOTE: No bounds checking is done because natives
* should use their own bounds checking! * should use their own bounds checking!
*/ */
#ifndef NEW_UTIL_H #ifndef NEW_UTIL_H
#define NEW_UTIL_H #define NEW_UTIL_H
extern edict_t *NEW_FirstEdict; extern edict_t *NEW_FirstEdict;
extern bool NEW_Initialized; extern bool NEW_Initialized;
/** /**
* This is called on the first Spawn() ever hooked. This would be worldspawn (index 0) * This is called on the first Spawn() ever hooked. This would be worldspawn (index 0)
*/ */
inline void NEW_Initialize(edict_t *Entity) inline void NEW_Initialize(edict_t *Entity)
{ {
NEW_FirstEdict=Entity; NEW_FirstEdict=Entity;
NEW_Initialized=true; NEW_Initialized=true;
} }
/** /**
* Converts an integer index into an edict pointer * Converts an integer index into an edict pointer
*/ */
inline edict_t *INDEXENT_NEW(const int Index) inline edict_t *INDEXENT_NEW(const int Index)
{ {
return (edict_t *)(NEW_FirstEdict + Index); return (edict_t *)(NEW_FirstEdict + Index);
}; };
/** /**
* Converts an edict pointer into an integer index * Converts an edict pointer into an integer index
*/ */
inline int ENTINDEX_NEW(const edict_t *Ent) inline int ENTINDEX_NEW(const edict_t *Ent)
{ {
return (int)(Ent - NEW_FirstEdict); return (int)(Ent - NEW_FirstEdict);
}; };
// Inlined replacement of MF_GetAmxAddr // Inlined replacement of MF_GetAmxAddr
inline REAL amx_ctof2(cell x) inline REAL amx_ctof2(cell x)
{ {
return *(REAL*)&x; return *(REAL*)&x;
} }
inline cell amx_ftoc2(REAL x) inline cell amx_ftoc2(REAL x)
{ {
return *(cell*)&x; return *(cell*)&x;
} }
#endif // NEW_UTIL_H #endif // NEW_UTIL_H

View File

@ -641,9 +641,9 @@ namespace Trampolines
/** /**
* Utility to make a generic trampoline. * Utility to make a generic trampoline.
*/ */
inline void *CreateGenericTrampoline(bool thiscall, bool voidcall, int paramcount, void *extraptr, void *callee) inline void *CreateGenericTrampoline(bool thiscall, bool voidcall, bool retbuf, int paramcount, void *extraptr, void *callee)
{ {
Trampolines::TrampolineMaker tramp; Trampolines::TrampolineMaker tramp;
if (voidcall) if (voidcall)
{ {
@ -684,7 +684,14 @@ inline void *CreateGenericTrampoline(bool thiscall, bool voidcall, int paramcoun
#if defined(_WIN32) #if defined(_WIN32)
tramp.VoidEpilogueAndFree(); tramp.VoidEpilogueAndFree();
#elif defined(__linux__) || defined(__APPLE__) #elif defined(__linux__) || defined(__APPLE__)
tramp.VoidEpilogue(); if (retbuf)
{
tramp.VoidEpilogue(4);
}
else
{
tramp.ThisVoidPrologue();
}
#endif #endif
} }
else else

View File

@ -1,122 +1,146 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#include "amxxmodule.h"
#include <extdll.h>
#include "NEW_Util.h"
#include "CVector.h"
#include "forward.h"
#include "hook.h"
#include "ham_const.h"
#include "hooklist.h"
#include "offsets.h"
#include <assert.h>
#include "DataHandler.h"
edict_t *NEW_FirstEdict;
bool NEW_Initialized;
extern CVector<Hook*> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
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);
#include "amxxmodule.h" MF_AddNatives(pdata_natives_safe);
#include <extdll.h> 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;
#include "NEW_Util.h" void OnAmxxDetach()
#include "CVector.h"
#include "forward.h"
#include "hook.h"
#include "ham_const.h"
#include "hooklist.h"
#include "offsets.h"
#include <assert.h>
edict_t *NEW_FirstEdict;
bool NEW_Initialized;
extern CVector<Hook*> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
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 while (!g_FreeIIs.empty())
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);
MF_AddNatives(pdata_natives_safe);
if (ReadConfig() > 0)
{ {
if (Offsets.IsValid()) delete g_FreeIIs.front();
{ g_FreeIIs.pop();
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!"); void HamCommand(void);
}
} void OnPluginsUnloaded(void)
{
void HamCommand(void);
CVector <Hook *>::iterator end;
void OnPluginsUnloaded(void) for (int i = 0; i < HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++)
{ {
end=hooks[i].end();
CVector <Hook *>::iterator end;
for (int i = 0; i < HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++) for (CVector<Hook*>::iterator j=hooks[i].begin();
{ j!=end;
end=hooks[i].end(); ++j)
{
for (CVector<Hook*>::iterator j=hooks[i].begin(); delete (*j);
j!=end; }
++j) hooks[i].clear();
{ }
delete (*j); }
}
hooks[i].clear(); void OnPluginsLoaded(void)
} {
} NEW_Initialize(INDEXENT(0));
}
void OnPluginsLoaded(void) void OnMetaAttach(void)
{ {
NEW_Initialize(INDEXENT(0)); REG_SVR_COMMAND("ham", HamCommand);
} }
void OnMetaAttach(void)
{
REG_SVR_COMMAND("ham", HamCommand);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,93 +1,206 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#ifndef HOOK_Call_H #ifndef HOOK_Call_H
#define 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_Void_Void(AMX *amx, cell *params); cell Call_Deprecated(AMX* amx, cell* params);
cell Call_Int_Void(AMX *amx, cell *params); #endif
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_Void_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(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_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_Int_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_Deprecated(AMX* amx, cell* params);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,403 +1,403 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#include "amxxmodule.h" #include "amxxmodule.h"
#include "ham_const.h" #include "ham_const.h"
#include "hooklist.h" #include "hooklist.h"
#include "offsets.h" #include "offsets.h"
extern hook_t hooklist[]; extern hook_t hooklist[];
enum enum
{ {
LEX_INVALID = 0, LEX_INVALID = 0,
LEX_UNKNOWN, LEX_UNKNOWN,
LEX_START_SEC, LEX_START_SEC,
LEX_END_SEC, LEX_END_SEC,
LEX_MIRROR, LEX_MIRROR,
LEX_PEV, LEX_PEV,
LEX_BASE, LEX_BASE,
LEX_END LEX_END
}; };
const char *tokens[] = const char *tokens[] =
{ {
"", // LEX_INVALID "", // LEX_INVALID
"", // LEX_UNKNOWN "", // LEX_UNKNOWN
"@section", // LEX_START_SEC "@section", // LEX_START_SEC
"@end", // LEX_END_SEC "@end", // LEX_END_SEC
"@mirror", // LEX_MIRROR "@mirror", // LEX_MIRROR
"pev", // LEX_PEV "pev", // LEX_PEV
"base", // LEX_BASE "base", // LEX_BASE
"", // LEX_END "", // LEX_END
}; };
static void trim_line(char *input); static void trim_line(char *input);
static void read_mirror(char *input); static void read_mirror(char *input);
static void skip_to_end_of_section(FILE *fp); static void skip_to_end_of_section(FILE *fp);
static int lex(char*& buffer); static int lex(char*& buffer);
int lex(char*& buffer) int lex(char*& buffer)
{ {
trim_line(buffer); trim_line(buffer);
size_t len; size_t len;
for (int i=0; i<LEX_END; i++) for (int i=0; i<LEX_END; i++)
{ {
if (tokens[i]!=NULL && *(tokens[i])!='\0') if (tokens[i]!=NULL && *(tokens[i])!='\0')
{ {
len=strlen(tokens[i]); len=strlen(tokens[i]);
if (strncmp(buffer,tokens[i],len)==0) if (strncmp(buffer,tokens[i],len)==0)
{ {
buffer+=len+1; buffer+=len+1;
return i; return i;
} }
} }
} }
return LEX_UNKNOWN; return LEX_UNKNOWN;
} }
// How we handle "mirrors" // How we handle "mirrors"
// We just note down the current mod name, and every time // We just note down the current mod name, and every time
// we come across a mirror with the destination that matches // we come across a mirror with the destination that matches
// the current mod name, we change the current mod name to // the current mod name, we change the current mod name to
// the source for that mirror. // the source for that mirror.
char CurrentModName[64]; char CurrentModName[64];
static void read_mirror(char *input) static void read_mirror(char *input)
{ {
char *data=input; char *data=input;
char *data2; char *data2;
char source[64]; char source[64];
char dest[64]; char dest[64];
char old; char old;
while ( *data!=' ' && while ( *data!=' ' &&
*data!='\t' && *data!='\t' &&
*data!='\0') *data!='\0')
{ {
data++; data++;
} }
old=*data; old=*data;
*data='\0'; *data='\0';
// mark down the source // mark down the source
snprintf(source, sizeof(source)-1, "%s", input); snprintf(source, sizeof(source)-1, "%s", input);
*data=old; *data=old;
while ( *data==' ' || while ( *data==' ' ||
*data=='\t') *data=='\t')
{ {
data++; data++;
} }
data2=data; data2=data;
while ( *data!=' ' && while ( *data!=' ' &&
*data!='\t' && *data!='\t' &&
*data!='\0') *data!='\0')
{ {
data++; data++;
} }
old=*data; old=*data;
*data='\0'; *data='\0';
snprintf(dest, sizeof(dest)-1, "%s", data2); snprintf(dest, sizeof(dest)-1, "%s", data2);
*data=old; *data=old;
if (strcmp(dest, CurrentModName)==0) if (strcmp(dest, CurrentModName)==0)
{ {
snprintf(CurrentModName, sizeof(CurrentModName)-1, "%s", source); snprintf(CurrentModName, sizeof(CurrentModName)-1, "%s", source);
} }
} }
static void trim_line(char *input) static void trim_line(char *input)
{ {
char *oldinput=input; char *oldinput=input;
char *start=input; char *start=input;
while ( *start==' ' || while ( *start==' ' ||
*start=='\t' || *start=='\t' ||
*start=='\r' || *start=='\r' ||
*start=='\n') *start=='\n')
{ {
start++; start++;
} }
// Overwrite the whitespace // Overwrite the whitespace
if (start != input) if (start != input)
{ {
while ((*input++=*start++)!='\0') while ((*input++=*start++)!='\0')
/* do nothing */ ; /* do nothing */ ;
} }
start=oldinput; start=oldinput;
start+=strlen(start) - 1; start+=strlen(start) - 1;
while ( start >= oldinput && while ( start >= oldinput &&
( *start == '\0' || ( *start == '\0' ||
*start == ' ' || *start == ' ' ||
*start == '\r' || *start == '\r' ||
*start == '\n' || *start == '\n' ||
*start == '\t')) *start == '\t'))
{ {
start--; start--;
} }
start++; start++;
*start='\0'; *start='\0';
// Now find any comments and cut off at the start // Now find any comments and cut off at the start
while (*start != '\0') while (*start != '\0')
{ {
if (*start == ';') if (*start == ';')
{ {
*start='\0'; *start='\0';
break; break;
} }
start++; start++;
} }
} }
void skip_to_end_of_section(FILE *fp) void skip_to_end_of_section(FILE *fp)
{ {
char buffer[1024]; char buffer[1024];
while (!feof(fp)) while (!feof(fp))
{ {
buffer[0]='\0'; buffer[0]='\0';
fgets(buffer, sizeof(buffer)-1, fp); fgets(buffer, sizeof(buffer)-1, fp);
trim_line(buffer); trim_line(buffer);
char *b=&buffer[0]; char *b=&buffer[0];
if (lex(b)==LEX_END_SEC) if (lex(b)==LEX_END_SEC)
{ {
break; break;
} }
} }
} }
static const char* get_localinfo( const char* name , const char* def = 0 ) static const char* get_localinfo( const char* name , const char* def = 0 )
{ {
const char* b = LOCALINFO( (char*)name ); const char* b = LOCALINFO( (char*)name );
if (((b==0)||(*b==0)) && def ) if (((b==0)||(*b==0)) && def )
SET_LOCALINFO((char*)name,(char*)(b = def) ); SET_LOCALINFO((char*)name,(char*)(b = def) );
return b; return b;
} }
int read_start_section(char *data) int read_start_section(char *data)
{ {
if (strncmp(data, CurrentModName, strlen(CurrentModName))==0) if (strncasecmp(data, CurrentModName, strlen(CurrentModName))==0)
{ {
data+=strlen(CurrentModName)+1; data+=strlen(CurrentModName)+1;
trim_line(data); trim_line(data);
#ifdef _WIN32 #ifdef _WIN32
if (strcmp(data, "windows")==0) if (strcmp(data, "windows")==0)
#elif defined(__linux__) #elif defined(__linux__)
if (strcmp(data, "linux")==0) if (strcmp(data, "linux")==0)
#elif defined(__APPLE__) #elif defined(__APPLE__)
if (strcmp(data, "mac")==0) if (strcmp(data, "mac")==0)
#endif #endif
{ {
return 1; return 1;
} }
} }
return 0; return 0;
} }
int read_number(char *input) int read_number(char *input)
{ {
char *end; /* Temporary pointer, needed for strtoul(). */ char *end; /* Temporary pointer, needed for strtoul(). */
// if begins with 0x or 0X it's to be interpretted as hex // if begins with 0x or 0X it's to be interpretted as hex
if (*input=='0' && if (*input=='0' &&
(*(input+1)=='x' || *(input+1)=='X')) (*(input+1)=='x' || *(input+1)=='X'))
{ {
return strtoul(input,&end,16); return strtoul(input,&end,16);
} }
// otherwise it's to be interpretted as base 10 // otherwise it's to be interpretted as base 10
return strtoul(input,&end,10); return strtoul(input,&end,10);
} }
void process_pev(char *data) void process_pev(char *data)
{ {
trim_line(data); trim_line(data);
Offsets.SetPev(read_number(data)); Offsets.SetPev(read_number(data));
} }
void process_base(char *data) void process_base(char *data)
{ {
trim_line(data); trim_line(data);
Offsets.SetBase(read_number(data)); Offsets.SetBase(read_number(data));
} }
void process_key(char *data) void process_key(char *data)
{ {
size_t size=0; size_t size=0;
char *a=data; char *a=data;
while (*a != ' ' && *a != '\t' && *a != '\0') while (*a != ' ' && *a != '\t' && *a != '\0')
{ {
a++; a++;
size++; size++;
} }
if (size==0) if (size==0)
{ {
return; return;
} }
int set=0; int set=0;
for (int i=0; i< HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++) for (int i=0; i< HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++)
{ {
if (strncmp(data, hooklist[i].name, size)==0) if (strncmp(data, hooklist[i].name, size)==0)
{ {
data+=size+1; data+=size+1;
trim_line(data); trim_line(data);
int value=read_number(data); int value=read_number(data);
hooklist[i].isset=1; hooklist[i].isset=1;
hooklist[i].vtid=value; hooklist[i].vtid=value;
set=1; set=1;
break; break;
} }
} }
if (set==0) if (set==0)
{ {
printf("stray key in process_key: %s\n", data); printf("stray key in process_key: %s\n", data);
} }
} }
int ReadConfig(void) int ReadConfig(void)
{ {
char FileName[512]; char FileName[512];
MF_BuildPathnameR(FileName,sizeof(FileName)-1,"%s",get_localinfo("amxx_configsdir","addons/amxmodx/configs")); MF_BuildPathnameR(FileName,sizeof(FileName)-1,"%s",get_localinfo("amxx_configsdir","addons/amxmodx/configs"));
strncat(FileName,"/hamdata.ini",sizeof(FileName)-1); strncat(FileName,"/hamdata.ini",sizeof(FileName)-1);
FILE *fp=fopen(FileName,"r"); FILE *fp=fopen(FileName,"r");
snprintf(CurrentModName, sizeof(CurrentModName)-1, "%s", MF_GetModname()); snprintf(CurrentModName, sizeof(CurrentModName)-1, "%s", MF_GetModname());
if (!fp) if (!fp)
{ {
MF_Log("Unable to open \"%s\" for reading.", FileName); MF_Log("Unable to open \"%s\" for reading.", FileName);
return -1; return -1;
} }
char data[2048]; char data[2048];
int insec=0; int insec=0;
while (!feof(fp)) while (!feof(fp))
{ {
data[0]='\0'; data[0]='\0';
fgets(data, sizeof(data)-1, fp); fgets(data, sizeof(data)-1, fp);
char *b=&data[0]; char *b=&data[0];
switch(lex(b)) switch(lex(b))
{ {
case LEX_PEV: case LEX_PEV:
{ {
if (insec) if (insec)
{ {
process_pev(b); process_pev(b);
} }
break; break;
}; };
case LEX_BASE: case LEX_BASE:
{ {
if (insec) if (insec)
{ {
process_base(b); process_base(b);
} }
break; break;
}; };
case LEX_MIRROR: case LEX_MIRROR:
{ {
read_mirror(b); read_mirror(b);
break; break;
}; };
case LEX_START_SEC: case LEX_START_SEC:
{ {
insec=read_start_section(b); insec=read_start_section(b);
if (!insec) if (!insec)
{ {
skip_to_end_of_section(fp); skip_to_end_of_section(fp);
} }
break; break;
}; };
case LEX_END_SEC: case LEX_END_SEC:
{ {
insec=0; insec=0;
break; break;
}; };
case LEX_UNKNOWN: case LEX_UNKNOWN:
{ {
if (insec) if (insec)
{ {
process_key(b); process_key(b);
} }
}; };
} }
} }
return 1; return 1;
} }

View File

@ -1,68 +1,68 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#include "amxxmodule.h" #include "amxxmodule.h"
#ifndef FORWARD_H #ifndef FORWARD_H
#define FORWARD_H #define FORWARD_H
enum fwdstate enum fwdstate
{ {
FSTATE_INVALID = 0, FSTATE_INVALID = 0,
FSTATE_OK, FSTATE_OK,
FSTATE_PAUSE, FSTATE_PAUSE,
FSTATE_STOP, FSTATE_STOP,
FSTATE_DESTROY FSTATE_DESTROY
}; };
class Forward class Forward
{ {
public: public:
int id; // id of the forward int id; // id of the forward
fwdstate state; fwdstate state;
Forward(int id_) : id(id_), state(FSTATE_OK) Forward(int id_) : id(id_), state(FSTATE_OK)
{ {
/* do nothing */ /* do nothing */
}; };
Forward() : id(-1), state(FSTATE_INVALID) Forward() : id(-1), state(FSTATE_INVALID)
{ {
/* do nothing */ /* do nothing */
} }
~Forward() ~Forward()
{ {
MF_UnregisterSPForward(id); MF_UnregisterSPForward(id);
} }
inline void Set(int i) inline void Set(int i)
{ {
state=FSTATE_OK; state=FSTATE_OK;
id=i; id=i;
}; };
}; };
#endif #endif

View File

@ -1,199 +1,516 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#ifndef HAM_CONST_H #ifndef HAM_CONST_H
#define HAM_CONST_H #define HAM_CONST_H
enum enum
{ {
HAM_UNSET = 0, HAM_UNSET = 0,
HAM_IGNORED, HAM_IGNORED,
HAM_HANDLED, HAM_HANDLED,
HAM_OVERRIDE, HAM_OVERRIDE,
HAM_SUPERCEDE HAM_SUPERCEDE
}; };
enum enum
{ {
Ham_Spawn = 0, Ham_Spawn = 0,
Ham_Precache, Ham_Precache,
Ham_Keyvalue, Ham_Keyvalue,
Ham_ObjectCaps, Ham_ObjectCaps,
Ham_Activate, Ham_Activate,
Ham_SetObjectCollisionBox, Ham_SetObjectCollisionBox,
Ham_Classify, Ham_Classify,
Ham_DeathNotice, Ham_DeathNotice,
Ham_TraceAttack, Ham_TraceAttack,
Ham_TakeDamage, Ham_TakeDamage,
Ham_TakeHealth, Ham_TakeHealth,
Ham_Killed, Ham_Killed,
Ham_BloodColor, Ham_BloodColor,
Ham_TraceBleed, Ham_TraceBleed,
Ham_IsTriggered, Ham_IsTriggered,
Ham_MyMonsterPointer, Ham_MyMonsterPointer,
Ham_MySquadMonsterPointer, Ham_MySquadMonsterPointer,
Ham_GetToggleState, Ham_GetToggleState,
Ham_AddPoints, Ham_AddPoints,
Ham_AddPointsToTeam, Ham_AddPointsToTeam,
Ham_AddPlayerItem, Ham_AddPlayerItem,
Ham_RemovePlayerItem, Ham_RemovePlayerItem,
Ham_GiveAmmo, Ham_GiveAmmo,
Ham_GetDelay, Ham_GetDelay,
Ham_IsMoving, Ham_IsMoving,
Ham_OverrideReset, Ham_OverrideReset,
Ham_DamageDecal, Ham_DamageDecal,
Ham_SetToggleState, Ham_SetToggleState,
Ham_StartSneaking, Ham_StartSneaking,
Ham_StopSneaking, Ham_StopSneaking,
Ham_OnControls, Ham_OnControls,
Ham_IsSneaking, Ham_IsSneaking,
Ham_IsAlive, Ham_IsAlive,
Ham_IsBSPModel, Ham_IsBSPModel,
Ham_ReflectGauss, Ham_ReflectGauss,
Ham_HasTarget, Ham_HasTarget,
Ham_IsInWorld, Ham_IsInWorld,
Ham_IsPlayer, Ham_IsPlayer,
Ham_IsNetClient, Ham_IsNetClient,
Ham_TeamId, Ham_TeamId,
Ham_GetNextTarget, Ham_GetNextTarget,
Ham_Think, Ham_Think,
Ham_Touch, Ham_Touch,
Ham_Use, Ham_Use,
Ham_Blocked, Ham_Blocked,
Ham_Respawn, Ham_Respawn,
Ham_UpdateOwner, Ham_UpdateOwner,
Ham_FBecomeProne, Ham_FBecomeProne,
Ham_Center, Ham_Center,
Ham_EyePosition, Ham_EyePosition,
Ham_EarPosition, Ham_EarPosition,
Ham_BodyTarget, Ham_BodyTarget,
Ham_Illumination, Ham_Illumination,
Ham_FVisible, Ham_FVisible,
Ham_FVecVisible, Ham_FVecVisible,
Ham_Player_Jump, Ham_Player_Jump,
Ham_Player_Duck, Ham_Player_Duck,
Ham_Player_PreThink, Ham_Player_PreThink,
Ham_Player_PostThink, Ham_Player_PostThink,
Ham_Player_GetGunPosition, Ham_Player_GetGunPosition,
Ham_Player_ShouldFadeOnDeath, Ham_Player_ShouldFadeOnDeath,
Ham_Player_ImpulseCommands, Ham_Player_ImpulseCommands,
Ham_Player_UpdateClientData, 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,
HAM_LAST_ENTRY_DONT_USE_ME_LOL
};
enum
{
HAM_OK = 0,
HAM_INVALID_FUNC, // The function is not valid Ham_Item_AddToPlayer,
HAM_FUNC_NOT_CONFIGURED, // This function is not configured in hamdata.ini Ham_Item_AddDuplicate,
Ham_Item_CanDeploy,
HAM_ERR_END 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
//
#endif 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

@ -1,161 +1,176 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#ifndef HAM_UTILS_H #ifndef HAM_UTILS_H
#define HAM_UTILS_H #define HAM_UTILS_H
#include "amxxmodule.h" #include "amxxmodule.h"
#include "offsets.h" #include "offsets.h"
#include "NEW_Util.h" #include "NEW_Util.h"
#define CHECK_FUNCTION(x) \ #define CHECK_FUNCTION(x) \
if (x < 0 || x >= HAM_LAST_ENTRY_DONT_USE_ME_LOL) { \ if (x < 0 || x >= HAM_LAST_ENTRY_DONT_USE_ME_LOL) { \
char msg[1024]; \ char msg[1024]; \
snprintf(msg, sizeof(msg)-1, "Function out of bounds. Got: %d Max: %d",x, HAM_LAST_ENTRY_DONT_USE_ME_LOL - 1); \ snprintf(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); \ FailPlugin(amx, x, HAM_INVALID_FUNC, msg); \
return 0; \ return 0; \
} else if (hooklist[x].isset == 0) { \ } else if (hooklist[x].isset == 0) { \
char msg[1024]; \ char msg[1024]; \
snprintf(msg, sizeof(msg)-1, "Function %s is not configured in hamdata.ini.",hooklist[x].name); \ snprintf(msg, sizeof(msg)-1, "Function %s is not configured in hamdata.ini.",hooklist[x].name); \
FailPlugin(amx, x, HAM_FUNC_NOT_CONFIGURED, msg); \ FailPlugin(amx, x, HAM_FUNC_NOT_CONFIGURED, msg); \
return 0; \ return 0; \
} }
#define CHECK_ENTITY(x) \ #define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \ if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \ return 0; \
} else { \ } else { \
if (INDEXENT_NEW(x)->free) { \ if (INDEXENT_NEW(x)->free) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity (%d)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity (%d)", x); \
return 0; \ return 0; \
} else if (INDEXENT_NEW(x)->pvPrivateData == NULL) { \ } else if (INDEXENT_NEW(x)->pvPrivateData == NULL) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity has null private data (%d)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Entity has null private data (%d)", x); \
return 0; \ return 0; \
} \ } \
} }
inline edict_t *PrivateToEdict(const void *pdata) 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)
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 -1;
} }
return ENTINDEX_NEW(pev->pContainingEntity); return ENTINDEX_NEW(v);
};
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 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(char *fmt, ...); inline edict_t *IndexToEdict(int index)
#endif {
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

View File

@ -1,124 +1,124 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#ifndef HOOK_H #ifndef HOOK_H
#define HOOK_H #define HOOK_H
#include "forward.h" #include "forward.h"
#include "Trampolines.h" #include "Trampolines.h"
// This is just a simple container for data so I only have to add 1 extra
// parameter to calls that get trampolined
#define ALIGN(ar) ((intptr_t)ar & ~(sysconf(_SC_PAGESIZE)-1)) #define ALIGN(ar) ((intptr_t)ar & ~(sysconf(_SC_PAGESIZE)-1))
class Hook // This is just a simple container for data so I only have to add 1 extra
{ // parameter to calls that get trampolined
public:
CVector<Forward *> pre; // pre forwards class Hook
CVector<Forward *> post; // post forwards {
void *func; // original function public:
void **vtable; // vtable of the original location CVector<Forward *> pre; // pre forwards
int entry; // vtable entry of the function CVector<Forward *> post; // post forwards
void *target; // target function being called (the hook) void *func; // original function
int exec; // 1 when this hook is in execution void **vtable; // vtable of the original location
int del; // 1 if this hook should be destroyed after exec int entry; // vtable entry of the function
void *tramp; // trampoline for this hook void *target; // target function being called (the hook)
char *ent; // ent name that's being hooked int exec; // 1 when this hook is in execution
int del; // 1 if this hook should be destroyed after exec
Hook(void **vtable_, int entry_, void *target_, bool voidcall, int paramcount, char *name) : void *tramp; // trampoline for this hook
func(NULL), vtable(vtable_), entry(entry_), target(target_), exec(0), del(0), tramp(NULL) char *ent; // ent name that's being hooked
{
// original function is vtable[entry] Hook(void **vtable_, int entry_, void *target_, bool voidcall, bool retbuf, int paramcount, char *name) :
// to not make the compiler whine, cast vtable to int ** func(NULL), vtable(vtable_), entry(entry_), target(target_), exec(0), del(0), tramp(NULL)
int **ivtable=(int **)vtable; {
func=(void *)ivtable[entry]; // original function is vtable[entry]
// to not make the compiler whine, cast vtable to int **
// now install a trampoline int **ivtable=(int **)vtable;
// (int thiscall, int voidcall, int paramcount, void *extraptr) func=(void *)ivtable[entry];
tramp=CreateGenericTrampoline(true, voidcall, paramcount, (void*)this, target);
// now install a trampoline
// Insert into vtable // (int thiscall, int voidcall, int paramcount, void *extraptr)
#if defined(_WIN32) tramp = CreateGenericTrampoline(true, voidcall, retbuf, paramcount, (void*)this, target);
DWORD OldFlags;
VirtualProtect(&ivtable[entry],sizeof(int*),PAGE_READWRITE,&OldFlags); // 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];
snprintf(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__) #elif defined(__linux__) || defined(__APPLE__)
void *addr = (void *)ALIGN(&ivtable[entry]); void *addr = (void *)ALIGN(&ivtable[entry]);
mprotect(addr,sysconf(_SC_PAGESIZE),PROT_READ|PROT_WRITE); mprotect(addr,sysconf(_SC_PAGESIZE),PROT_READ|PROT_WRITE);
#endif #endif
ivtable[entry]=(int*)tramp;
ivtable[entry]=(int *)func;
size_t len=strlen(name); #if defined(_WIN32)
ent=new char[len+1]; VirtualFree(tramp, 0, MEM_RELEASE);
#elif defined(__linux__) || defined(__APPLE__)
snprintf(ent,len+1,"%s",name); free(tramp);
}; #endif
~Hook() delete[] ent;
{
// Insert the original function back into the vtable CVector<Forward *>::iterator end=pre.end();
int **ivtable=(int **)vtable;
for (CVector<Forward *>::iterator i=pre.begin();
#if defined(_WIN32) i!=end;
DWORD OldFlags; ++i)
VirtualProtect(&ivtable[entry],sizeof(int*),PAGE_READWRITE,&OldFlags); {
#elif defined(__linux_) || defined(__APPLE__) delete (*i);
void *addr = (void *)ALIGN(&ivtable[entry]); }
mprotect(addr,sysconf(_SC_PAGESIZE),PROT_READ|PROT_WRITE); end=post.end();
#endif for (CVector<Forward *>::iterator i=post.begin();
i!=end;
ivtable[entry]=(int *)func; ++i)
#if defined(_WIN32) {
VirtualFree(tramp, 0, MEM_RELEASE); delete (*i);
#elif defined(__linux__) || defined(__APPLE__) }
free(tramp); pre.clear();
#endif post.clear();
}
delete[] ent; };
CVector<Forward *>::iterator end=pre.end(); #endif
for (CVector<Forward *>::iterator i=pre.begin();
i!=end;
++i)
{
delete (*i);
}
end=post.end();
for (CVector<Forward *>::iterator i=post.begin();
i!=end;
++i)
{
delete (*i);
}
pre.clear();
post.clear();
}
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,187 +1,513 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#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);
#ifndef HOOK_CALLBACKS_H const bool RT_Void_Entvar_Int = true;
#define HOOK_CALLBACKS_H 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);
// RT_<TYPE> is true if the function returns void, false otherwise const bool RT_Int_Cbase = false;
// (it also would be true for large return functions such as Vector) const bool RB_Int_Cbase = false;
// PC_<TYPE> is how many dwords get passed to the function (minus the "this" pointer) const int PC_Int_Cbase = 1;
// (it is one larger for large return functions such as Vector) int Hook_Int_Cbase(Hook *hook, void *pthis, void *cb1);
const bool RT_Void_Void = true; const bool RT_Void_Int_Int = true;
const int PC_Void_Void = 0; const bool RB_Void_Int_Int = false;
void Hook_Void_Void(Hook *hook, void *pthis); const int PC_Void_Int_Int = 2;
void Hook_Void_Int_Int(Hook *hook, void *pthis, int i1, int i2);
const bool RT_Int_Void = false;
const int PC_Int_Void = 0; const bool RT_Int_Int_Str_Int = false;
int Hook_Int_Void(Hook *hook, void *pthis); const bool RB_Int_Int_Str_Int = false;
const int PC_Int_Int_Str_Int = 3;
const bool RT_Void_Entvar = true; int Hook_Int_Int_Str_Int(Hook *hook, void *pthis, int i1, const char *sz1,
const int PC_Void_Entvar = 1; int i2);
void Hook_Void_Entvar(Hook *hook, void *pthis, entvars_t *entvar);
const bool RT_Int_Int_Str_Int_Int = false;
const bool RT_Void_Cbase = true; const bool RB_Int_Int_Str_Int_Int = false;
const int PC_Void_Cbase = 1; const int PC_Int_Int_Str_Int_Int = 4;
void Hook_Void_Cbase(Hook *hook, void *pthis, void *other); int Hook_Int_Int_Str_Int_Int(Hook *hook, void *pthis, int i1, const char *sz1, int i2, int i3);
const bool RT_Int_Float_Int = false; const bool RT_Int_Int = false;
const int PC_Int_Float_Int = 2; const bool RB_Int_Int = false;
int Hook_Int_Float_Int(Hook *hook, void *pthis, float f1, int i1); const int PC_Int_Int = 1;
int Hook_Int_Int(Hook *hook, void *pthis, int i1);
const bool RT_Void_Entvar_Int = true;
const int PC_Void_Entvar_Int = 2; const bool RT_Int_Entvar = false;
void Hook_Void_Entvar_Int(Hook *hook, void *ptis, entvars_t *ev1, int i1); const bool RB_Int_Entvar = false;
const int PC_Int_Entvar = 1;
const bool RT_Int_Cbase = false; int Hook_Int_Entvar(Hook *hook, void *pthis, entvars_t *ev1);
const int PC_Int_Cbase = 1;
int Hook_Int_Cbase(Hook *hook, void *pthis, void *cb1); const bool RT_Int_Entvar_Entvar_Float_Int = false;
const bool RB_Int_Entvar_Entvar_Float_Int = false;
const bool RT_Void_Int_Int = true; const int PC_Int_Entvar_Entvar_Float_Int = 4;
const int PC_Void_Int_Int = 2; int Hook_Int_Entvar_Entvar_Float_Int(Hook *hook, void *pthis,
void Hook_Void_Int_Int(Hook *hook, void *pthis, int i1, int i2); entvars_t *inflictor,
entvars_t *attacker, float damage,
const bool RT_Int_Int_Str_Int = false; int damagebits);
const int PC_Int_Int_Str_Int = 3;
int Hook_Int_Int_Str_Int(Hook *hook, void *pthis, int i1, const char *sz1, const bool RT_Int_Entvar_Entvar_Float_Float_Int = false;
int i2); const bool RB_Int_Entvar_Entvar_Float_Float_Int = false;
const int PC_Int_Entvar_Entvar_Float_Float_Int = 5;
const bool RT_Int_Int = false; int Hook_Int_Entvar_Entvar_Float_Float_Int(Hook *hook, void *pthis,
const int PC_Int_Int = 1; entvars_t *inflictor,
int Hook_Int_Int(Hook *hook, void *pthis, int i1); entvars_t *attacker, float damage,
float unknown, int damagebits);
const bool RT_Int_Entvar = false;
const int PC_Int_Entvar = 1; const bool RT_Void_Int = true;
int Hook_Int_Entvar(Hook *hook, void *pthis, entvars_t *ev1); const bool RB_Void_Int = false;
const int PC_Void_Int = 1;
const bool RT_Int_Entvar_Entvar_Float_Int = false; void Hook_Void_Int(Hook *hook, void *pthis, int i1);
const int PC_Int_Entvar_Entvar_Float_Int = 4;
int Hook_Int_Entvar_Entvar_Float_Int(Hook *hook, void *pthis, const bool RT_Void_Cbase_Cbase_Int_Float = true;
entvars_t *inflictor, const bool RB_Void_Cbase_Cbase_Int_Float = false;
entvars_t *attacker, float damage, const int PC_Void_Cbase_Cbase_Int_Float = 4;
int damagebits); void Hook_Void_Cbase_Cbase_Int_Float(Hook *hook, void *pthis, void *cb1,
void *cb2, int i1, float f1);
const bool RT_Int_Entvar_Entvar_Float_Float_Int = false;
const int PC_Int_Entvar_Entvar_Float_Float_Int = 5; const bool RT_Vector_Float_Cbase_Int = true;
int Hook_Int_Entvar_Entvar_Float_Float_Int(Hook *hook, void *pthis, const bool RB_Vector_Float_Cbase_Int = true;
entvars_t *inflictor, const int PC_Vector_Float_Cbase_Int = 4;
entvars_t *attacker, float damage, #if defined(_WIN32)
float unknown, int damagebits); void Hook_Vector_Float_Cbase_Int(Hook *hook, void *pthis, Vector *out, float f1, void *cb, int i1);
#elif defined(__linux__) || defined(__APPLE__)
const bool RT_Void_Int = true; void Hook_Vector_Float_Cbase_Int(Hook *hook, Vector *out, void *pthis, float f1, void *cb, int i1);
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 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_Void_Entvar_Float_Vector_Trace_Int = true;
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 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 int PC_Str_Void = 0;
const char *Hook_Str_Void(Hook *hook, void *pthis);
const bool RT_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 int PC_Vector_Void = 1;
#ifdef _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 #endif
const bool RT_Vector_pVector = true; const bool RT_Void_Entvar_Float_Vector_Trace_Int = true;
const int PC_Vector_pVector = 2; const bool RB_Void_Entvar_Float_Vector_Trace_Int = false;
#ifdef _WIN32 const int PC_Void_Entvar_Float_Vector_Trace_Int = 7;
void Hook_Vector_pVector(Hook *hook, void *pthis, Vector *out, Vector *v1); 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__) #elif defined(__linux__) || defined(__APPLE__)
void Hook_Vector_pVector(Hook *hook, Vector *out, void *pthis, Vector *v1); void Hook_Vector_Float(Hook *hook, Vector *out, void *pthis, float f1);
#endif #endif
const bool RT_Int_pVector = false; const bool RT_Void_Float_Cbase = true;
const int PC_Int_pVector = 1; const bool RB_Void_Float_Cbase = false;
int Hook_Int_pVector(Hook *hook, void *pthis, Vector *v1); const int PC_Void_Float_Cbase = 2;
void Hook_Void_Float_Cbase(Hook *hook, void *pthis, float f1, void *cb);
const bool RT_Void_Entvar_Float_Float = true; const bool RT_Int_Float_Float = false;
const int PC_Void_Entvar_Float_Float = 3; const bool RB_Int_Float_Float = false;
void Hook_Void_Entvar_Float_Float(Hook *hook, void *pthis, entvars_t *ev1, const int PC_Int_Float_Float = 2;
float f1, float f2); int Hook_Int_Float_Float(Hook *hook, void *pthis, float f1, float f2);
const bool RT_Int_pFloat_pFloat = false; const bool RT_Int_Float = false;
const int PC_Int_pFloat_pFloat = 2; const bool RB_Int_Float = false;
int Hook_Int_pFloat_pFloat(Hook *hook, void *pthis, float *f1, const int PC_Int_Float = 1;
float *f2); int Hook_Int_Float(Hook *hook, void *pthis, float f1);
const bool RT_Void_Entvar_Float = true; const bool RT_Int_Int_Int = false;
const int PC_Void_Entvar_Float = 2; const bool RB_Int_Int_Int = false;
void Hook_Void_Entvar_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1); 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_Void_Int_Int_Int = true; const bool RT_Float_Int_Float = false;
const int PC_Void_Int_Int_Int = 3; const bool RB_Float_Int_Float = false;
void Hook_Void_Int_Int_Int(Hook *hook, void *pthis, int i1, int i2, int i3); const int PC_Float_Int_Float = 2;
float Hook_Float_Int_Float(Hook *hook, void *pthis, int i1, float f2);
const bool RT_Void_ItemInfo = true; const bool RT_Int_Str = false;
const int PC_Void_ItemInfo = 1; const bool RB_Int_Str = false;
void Hook_Void_ItemInfo(Hook *hook, void *pthis, void *iteminfo); 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_Float_Void = false; const bool RT_Int_Str_Str_Int_Str_Int_Int = false;
const int PC_Float_Void = 0; const bool RB_Int_Str_Str_Int_Str_Int_Int = false;
float Hook_Float_Void(Hook *hook, void *pthis); 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_Void_Float_Int = true;
const int PC_Void_Float_Int = 2;
void Hook_Void_Float_Int(Hook *hook, void *pthis, float f1, int i1);
const bool RT_Deprecated = true; const bool RT_Deprecated = true;
const bool RB_Deprecated = false;
const int PC_Deprecated = 0; const int PC_Deprecated = 0;
void Hook_Deprecated(Hook* hook); void Hook_Deprecated(Hook* hook);
#endif
#endif

View File

@ -1,177 +1,461 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#include "amxxmodule.h" #include "amxxmodule.h"
int Create_Void_Void(AMX *amx, const char *func) 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_DONE); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
} }
int Create_Int_Void(AMX *amx, const char *func) 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_DONE); 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(AMX *amx, const char *func) 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); 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_Void_Cbase(AMX *amx, const char *func) int Create_Float_Float_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); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE);
} }
int Create_Void_Float(AMX* amx, const char* func)
int Create_Void_Entvar_Int(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); 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_Int_Cbase(AMX *amx, const char *func) 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); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE);
} }
int Create_Void_Int_Int(AMX *amx, const char *func) 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_DONE); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_CELL, FP_DONE);
} }
int Create_Int_Int_Str_Int(AMX *amx, const char *func) 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); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
} }
int Create_Int_Int(AMX *amx, const char *func) int Create_Void_Vector_Vector(AMX *amx, const char *func)
{ {
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_ARRAY, FP_ARRAY, FP_DONE);
} }
int Create_Int_Entvar(AMX *amx, const char *func) int Create_Void_Str_Bool(AMX *amx, const char *func)
{ {
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
} }
int Create_Int_Entvar_Entvar_Float_Int(AMX *amx, const char *func) 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); 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) int Create_Void_Str_Int(AMX *amx, const char *func)
{ {
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_STRING, FP_CELL, FP_DONE);
} }
int Create_Void_Int(AMX *amx, const char *func) int Create_Void_Cbase_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_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_Int_pFloat_pFloat(AMX *amx, const char *func)
{ {
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
} }
int Create_Void_Entvar_Float(AMX *amx, const char *func) 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); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
} }
int Create_Void_Int_Int_Int(AMX *amx, const char *func)
int Create_Float_Float(AMX *amx, const char *func)
{ {
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_DONE);
} }
int Create_Void_ItemInfo(AMX *amx, const char *func)
int Create_Void_Entvar_Entvar_Float(AMX *amx, const char *func)
{ {
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE);
} }
int Create_Float_Void(AMX *amx, const char *func)
int Create_Bool_Void(AMX *amx, const char *func)
{ {
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_DONE); return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_DONE);
} }
int Create_Void_Float_Int(AMX* amx, const char* func)
int Create_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(AMX *amx, const char *func)
{ {
return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_CELL, FP_DONE); 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_Deprecated(AMX* amx, const char* func)
int Create_Int_Vector_Cbase(AMX *amx, const char *func)
{ {
return -1; 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

@ -1,94 +1,206 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#ifndef HOOK_CREATE_H #ifndef HOOK_CREATE_H
#define 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_Void(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_Void(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_Entvar(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_Cbase(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_Int_Float_Int(AMX *amx, const char *func); int Create_Void_Float(AMX *amx, const char *func);
int Create_Void_Entvar_Int(AMX *amx, const char *func);
int Create_Int_Cbase(AMX *amx, const char *func); int Create_Void_Float_Float_Float_Int(AMX *amx, const char *func);
int Create_Void_Int_Int(AMX *amx, const char *func); int Create_Vector_Float(AMX *amx, const char *func);
int Create_Int_Int_Str_Int(AMX *amx, const char *func); int Create_Void_Float_Cbase(AMX *amx, const char *func);
int Create_Int_Int(AMX *amx, const char *func); int Create_Int_Float_Float(AMX* amx, const char* func);
int Create_Int_Entvar(AMX *amx, const char *func); int Create_Int_Float(AMX* amx, const char* func);
int Create_Int_Entvar_Entvar_Float_Int(AMX *amx, const char *func); int Create_Int_Int_Int(AMX* amx, const char* func);
int Create_Int_Entvar_Entvar_Float_Float_Int(AMX *amx, const char *func); int Create_Void_Str_Float_Float_Float(AMX* amx, const char* func);
int Create_Void_Int(AMX *amx, const char *func); int Create_Void_Str_Float_Float_Float_Int_Cbase(AMX *amx, const char *func);
int Create_Void_Cbase_Cbase_Int_Float(AMX *amx, const char *func); int Create_Int_Vector_Vector_Float_Float(AMX *amx, const char *func);
int Create_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, const char *func); int Create_Int_Short(AMX* amx, const char* func);
int Create_Void_Float_Vector_Trace_Int(AMX *amx, const char *func); int Create_Void_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func);
int Create_Str_Void(AMX *amx, const char *func); int Create_Void_Vector_Entvar_Entvar_Float_Int_Int(AMX *amx, const char *func);
int Create_Cbase_Void(AMX *amx, const char *func); int Create_Float_Int_Float(AMX *amx, const char *func);
int Create_Vector_Void(AMX *amx, const char *func); int Create_Int_Str(AMX *amx, const char *func);
int Create_Vector_pVector(AMX *amx, const char *func); int Create_Void_Edict(AMX *amx, const char *func);
int Create_Int_pVector(AMX *amx, const char *func); int Create_Void_Int_Str_Bool(AMX *amx, const char *func);
int Create_Void_Entvar_Float_Float(AMX *amx, const char *func); int Create_Void_Vector_Vector(AMX *amx, const char *func);
int Create_Int_pFloat_pFloat(AMX *amx, const char *func); int Create_Void_Str_Bool(AMX *amx, const char *func);
int Create_Void_Entvar_Float(AMX *amx, const char *func); int Create_Int_Str_Str_Int_Str_Int_Int(AMX *amx, const char *func);
int Create_Void_Int_Int_Int(AMX *amx, const char *func); int Create_Int_Int_Int_Float_Int(AMX *amx, const char *func);
int Create_Void_ItemInfo(AMX *amx, const char *func); int Create_Void_Str_Int(AMX *amx, const char *func);
int Create_Float_Void(AMX *amx, const char *func); int Create_Void_Cbase_Int(AMX *amx, const char *func);
int Create_Void_Float_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_Deprecated(AMX* amx, const char* func); int Create_Int_Str_Vector_Str(AMX *amx, const char *func);
#endif 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

File diff suppressed because it is too large Load Diff

View File

@ -1,46 +1,47 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#ifndef HOOKLIST_T_H #ifndef HOOKLIST_T_H
#define HOOKLIST_T_H #define HOOKLIST_T_H
typedef struct hook_s typedef struct hook_s
{ {
int isset; // whether or not this hook is registered with hamdata int isset; // whether or not this hook is registered with hamdata
int vtid; // vtable index of this function int vtid; // vtable index of this function
const char *name; // name used in the keys const char *name; // name used in the keys
bool isvoid; // whether or not the target trampoline uses voids bool isvoid; // whether or not the target trampoline uses voids
int paramcount; // how many parameters are in the func bool needsretbuf; // whether or not a pointer to a memory buffer is needed to store a return value
void *targetfunc; // the target hook int paramcount; // how many parameters are in the func
int (*makefunc)(AMX *, const char*); // function that creates forwards void *targetfunc; // the target hook
cell (*call)(AMX *, cell*); // function to call the vcall int (*makefunc)(AMX *, const char*); // function that creates forwards
} hook_t; cell (*call)(AMX *, cell*); // function to call the vcall
} hook_t;
extern hook_t hooklist[];
extern hook_t hooklist[];
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,379 +0,0 @@
/**
* Ham Sandwich module include file.
* (c) 2007, The AMX Mod X Development Team
*
* -
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/
/**
* Ham Sandwich is a module that is used to hook and call virtual functions of
* entities.
* Virtual functions are mod-specific functions. This means that in order
* for this to work on a mod, it needs to be configured with the hamdata.ini
* file.
* Be very careful with parameter passing to these functions.
*/
#if defined _hamsandwich_included
#endinput
#endif
#define _hamsandwich_included
#include <ham_const>
#if AMXX_VERSION_NUM >= 175
#pragma reqlib hamsandwich
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib hamsandwich
#endif
#else
#pragma library hamsandwich
#endif
/**
* Hooks the virtual table for the specified entity class.
* An example would be: RegisterHam(Ham_TakeDamage, "player", "player_hurt");
* Look at the Ham enum for parameter lists.
*
* @param function The function to hook.
* @param EntityClass The entity classname to hook.
* @param callback The forward to call.
* @param post Whether or not to forward this in post.
* @return Returns a handle to the forward. Use EnableHamForward/DisableHamForward to toggle the forward on or off.
*/
native HamHook:RegisterHam(Ham:function, const EntityClass[], const Callback[], Post=0);
/**
* Hooks the virtual table for the specified entity's class.
* An example would be: RegisterHam(Ham_TakeDamage, id, "player_hurt");
* Look at the Ham enum for parameter lists.
* Note: This will cause hooks for the entire internal class that the entity is
* not exclusively for the provided entity.
*
* @param function The function to hook.
* @param EntityId The entity classname to hook.
* @param callback The forward to call.
* @param post Whether or not to forward this in post.
* @return Returns a handle to the forward. Use EnableHamForward/DisableHamForward to toggle the forward on or off.
*/
native HamHook:RegisterHamFromEntity(Ham:function, EntityId, const Callback[], Post=0);
/**
* Stops a ham forward from triggering.
* Use the return value from RegisterHam as the parameter here!
*
* @param fwd The forward to stop.
*/
native DisableHamForward(HamHook:fwd);
/**
* Starts a ham forward back up.
* Use the return value from RegisterHam as the parameter here!
*
* @param fwd The forward to re-enable.
*/
native EnableHamForward(HamHook:fwd);
/**
* Executes the virtual function on the entity.
* Look at the Ham enum for parameter lists.
*
* @param function The function to call.
* @param id The id of the entity to execute it on.
*/
native ExecuteHam(Ham:function, this, any:...);
/**
* Executes the virtual function on the entity, this will trigger all hooks on that function.
* Be very careful about recursion!
* Look at the Ham enum for parameter lists.
*
* @param function The function to call.
* @param id The id of the entity to execute it on.
*/
native ExecuteHamB(Ham:function, this, any:...);
/**
* Gets the return status of the current hook.
* This is useful to determine what return natives to use.
*
* @return The current status of the hook (such as HAM_SUPERCEDE).
*/
native GetHamReturnStatus();
/**
* Gets the return value of a hook for hooks that return integers or booleans.
*
* @param output The variable to store the value in.
*/
native GetHamReturnInteger(&output);
/**
* Gets the return value of a hook for hooks that return float.
*
* @param output The variable to store the value in.
*/
native GetHamReturnFloat(&Float:output);
/**
* Gets the return value of a hook for hooks that return Vectors.
*
* @param output The variable to store the value in.
*/
native GetHamReturnVector(Float:output[3]);
/**
* Gets the return value of a hook for hooks that return entities.
*
* @param output The variable to store the value in. Will be -1 on null.
*/
native GetHamReturnEntity(&output);
/**
* Gets the return value of a hook for hooks that return strings.
*
* @param output The buffer to store the string in.
* @param size The string size of the buffer.
*/
native GetHamReturnString(output[], size);
/**
* Gets the original return value of a hook for hooks that return integers or booleans.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnInteger(&output);
/**
* Gets the original return value of a hook for hooks that return floats.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnFloat(&Float:output);
/**
* Gets the original return value of a hook for hooks that return Vectors.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnVector(Float:output[3]);
/**
* Gets the original return value of a hook for hooks that return entities.
*
* @param output The variable to store the value in. -1 on null.
*/
native GetOrigHamReturnEntity(&output);
/**
* Gets the original return value of a hook for hooks that return strings.
*
* @param output The buffer to store the string in.
* @param size The size of the buffer.
*/
native GetOrigHamReturnString(output[], size);
/**
* Sets the return value of a hook that returns an integer or boolean.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnInteger(value);
/**
* Sets the return value of a hook that returns a float.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnFloat(Float:value);
/**
* Sets the return value of a hook that returns a Vector.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnVector(const Float:value[3]);
/**
* Sets the return value of a hook that returns an entity. Set to -1 for null.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnEntity(value);
/**
* Sets the return value of a hook that returns a string.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnString(const value[]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are integers.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamInteger(which, value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are floats.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamFloat(which, Float:value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are Vectors.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamVector(which, const Float:value[3]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are entities.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamEntity(which, value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are strings.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamString(which, const output[]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are trace result handles.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamTraceResult(which, tr_handle);
/**
* Returns whether or not the function for the specified Ham is valid.
* Things that would make it invalid would be bounds (an older module version
* may not have all of the functions), and the function not being found in
* the mod's hamdata.ini file.
*
* @param function The function to look up.
* @return true if the function is valid, false otherwise.
*/
native bool:IsHamValid(Ham:function);
/**
* This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.
* This requires the mod to have the pev and base fields set in hamdata.ini.
* Note this dereferences memory! Improper use of this will crash the server.
* This will return an index of the corresponding cbase field in private data.
* Returns -1 on a null entry.
*
* @param id The entity to examine the private data.
* @param offset The windows offset of the data.
* @param linuxdiff The linux difference of the data.
* @return The index of the corresponding pdata field. -1 for none set.
*/
native get_pdata_cbase(id, offset, linuxdiff=5);
/**
* This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.
* This requires the mod to have the pev and base fields set in hamdata.ini.
* This will set the corresponding cbase field in private data with the index.
* Pass -1 to null the entry.
*
* @param id The entity to examine the private data.
* @param offset The windows offset of the data.
* @param value The index to store, -1 for invalid
* @param linuxdiff The linux difference of the data.
*/
native set_pdata_cbase(id, offset, value, linuxdiff=5);
/**
* This is similar to the get_pdata_cbase, however it does not dereference memory.
* This is many times slower than get_pdata_cbase, and this should only be used
* for testing and finding of offsets, not actual release quality plugins.
* This will return an index of the corresponding cbase field in private data.
* Returns -1 on a null entry. -2 on an invalid entry.
*
* @param id Entry to examine the private data.
* @param offset The windows offset of the data.
* @param linuxdiff The linux difference of the data.
* @return The index of the corresponding pdata field, -1 for null, -2 for invalid.
*/
native get_pdata_cbase_safe(id, offset, linuxdiff=5);
// This is the callback from the module, this handles any fatal errors.
// This will in turn call the "HamFilter(Ham:id, HamError:err, const reason[])" public, if it exists.
// Return PLUGIN_HANDLED from within the HamFilter to stop the plugin from failing.
// Any other return value will fail the plugin.
// You do not need to have a HamFilter, if there is none, all fatal errors will fail the plugin.
// Do not modify this!
public __fatal_ham_error(Ham:id, HamError:err, const reason[])
{
new func=get_func_id("HamFilter", -1);
new bool:fail=true;
if (func != -1 && callfunc_begin_i(func, -1)==1)
{
callfunc_push_int(_:id);
callfunc_push_int(_:err);
callfunc_push_str(reason, false);
if (callfunc_end()==PLUGIN_HANDLED)
{
fail=false;
}
}
if (fail)
{
set_fail_state(reason);
}
}

View File

@ -1,84 +1,84 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#ifndef OFFSETS_H #ifndef OFFSETS_H
#define OFFSETS_H #define OFFSETS_H
#include "ham_const.h" #include "ham_const.h"
// Just a singleton class that keeps pev/base/offset values managed. // Just a singleton class that keeps pev/base/offset values managed.
class OffsetManager class OffsetManager
{ {
private: private:
size_t pev; size_t pev;
size_t baseclass; size_t baseclass;
int baseset; int baseset;
int pevset; int pevset;
public: public:
OffsetManager() OffsetManager()
{ {
memset(this,0x0,sizeof(*this)); memset(this,0x0,sizeof(*this));
} }
void SetPev(size_t value) void SetPev(size_t value)
{ {
pevset=1; pevset=1;
pev=value; pev=value;
}; };
size_t GetPev(void) size_t GetPev(void)
{ {
return pev; return pev;
}; };
int IsPevSet() int IsPevSet()
{ {
return pevset; return pevset;
}; };
int IsBaseSet() int IsBaseSet()
{ {
return baseset; return baseset;
}; };
void SetBase(size_t value) void SetBase(size_t value)
{ {
baseset=1; baseset=1;
baseclass=value; baseclass=value;
}; };
size_t GetBase(void) size_t GetBase(void)
{ {
return baseclass; return baseclass;
}; };
bool IsValid() bool IsValid()
{ {
return pevset != 0 && baseset != 0; return pevset != 0 && baseset != 0;
} }
}; };
extern OffsetManager Offsets; extern OffsetManager Offsets;
#endif #endif

View File

@ -1,182 +1,182 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#include "amxxmodule.h" #include "amxxmodule.h"
#include "offsets.h" #include "offsets.h"
#include "NEW_Util.h" #include "NEW_Util.h"
#include "ham_utils.h" #include "ham_utils.h"
inline edict_t* INDEXENT2( int iEdictNum ) inline edict_t* INDEXENT2( int iEdictNum )
{ {
if (iEdictNum >= 1 && iEdictNum <= gpGlobals->maxClients) if (iEdictNum >= 1 && iEdictNum <= gpGlobals->maxClients)
return MF_GetPlayerEdict(iEdictNum); 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 else
return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum); iOffset += params[4];
} #endif
if (iOffset <0)
#ifdef DONT_TOUCH_THIS_AGAIN_BAIL {
#define FM_CHECK_ENTITY(x) \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset);
if (x < 0 || x > gpGlobals->maxEntities) { \ return 0;
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \ }
return 0; \ void *ptr=*((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset));
} else { \
if (x <= gpGlobals->maxClients) { \ if (ptr == 0)
if (!MF_IsPlayerIngame(x)) { \ {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \ return -1;
return 0; \ }
} \
} else { \ for (int i=0; i<gpGlobals->maxEntities; ++i)
if (x != 0 && FNullEnt(INDEXENT(x))) { \ {
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \ if (ptr == INDEXENT_NEW(i)->pvPrivateData)
return 0; \ {
} \ return i;
} \ }
} }
#endif
return -2;
#define FM_CHECK_ENTITY(x) \ }
if (x < 0 || x > gpGlobals->maxEntities) { \ static cell AMX_NATIVE_CALL get_pdata_cbase(AMX *amx, cell *params)
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \ {
return 0; \ int index=params[1];
} else if (x != 0 && FNullEnt(INDEXENT2(x))) { \ FM_CHECK_ENTITY(index);
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \ int iOffset=params[2];
return 0; \ #ifdef __linux__
} iOffset += params[3];
#elif defined __APPLE__
// Return -1 on null, -2 on invalid, and the the index of any other. // Use Linux offset in older plugins
static cell AMX_NATIVE_CALL get_pdata_cbase_safe(AMX *amx, cell *params) if (params[0] / sizeof(cell) == 3)
{ iOffset += params[3];
int index=params[1]; else
FM_CHECK_ENTITY(index); iOffset += params[4];
int iOffset=params[2]; #endif
#ifdef __linux__
iOffset += params[3]; if (iOffset <0)
#elif defined __APPLE__ {
// Use Linux offset in older plugins MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset);
if (params[0] / sizeof(cell) == 3) return 0;
iOffset += params[3]; }
else void *ptr=*((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset));
iOffset += params[4];
#endif return PrivateToIndex(ptr);
if (iOffset <0) }
{ static cell AMX_NATIVE_CALL set_pdata_cbase(AMX *amx, cell *params)
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset); {
return 0; int index=params[1];
} FM_CHECK_ENTITY(index);
void *ptr=*((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset)); int target=params[3];
if (ptr == 0) if (target != -1)
{ {
return -1; FM_CHECK_ENTITY(target);
} }
int iOffset=params[2];
for (int i=0; i<gpGlobals->maxEntities; ++i) #ifdef __linux__
{ iOffset += params[4];
if (ptr == INDEXENT_NEW(i)->pvPrivateData) #elif defined __APPLE__
{ // Use Linux offset in older plugins
return i; if (params[0] / sizeof(cell) == 4)
} iOffset += params[4];
} else
iOffset += params[5];
return -2; #endif
} if (iOffset <0)
static cell AMX_NATIVE_CALL get_pdata_cbase(AMX *amx, cell *params) {
{ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset);
int index=params[1]; return 0;
FM_CHECK_ENTITY(index); }
int iOffset=params[2];
#ifdef __linux__ if (target == -1)
iOffset += params[3]; {
#elif defined __APPLE__ *((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset)) = NULL;
// Use Linux offset in older plugins }
if (params[0] / sizeof(cell) == 3) else
iOffset += params[3]; {
else *((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset)) = INDEXENT_NEW(target)->pvPrivateData;
iOffset += params[4]; }
#endif
return 1;
if (iOffset <0) }
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset); AMX_NATIVE_INFO pdata_natives_safe[] =
return 0; {
} { "get_pdata_cbase_safe", get_pdata_cbase_safe },
void *ptr=*((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset));
{ NULL, NULL }
return PrivateToIndex(ptr); };
} AMX_NATIVE_INFO pdata_natives[] =
static cell AMX_NATIVE_CALL set_pdata_cbase(AMX *amx, cell *params) {
{ { "get_pdata_cbase", get_pdata_cbase },
int index=params[1]; { "set_pdata_cbase", set_pdata_cbase },
FM_CHECK_ENTITY(index);
int target=params[3]; { NULL, NULL }
};
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

@ -56,7 +56,7 @@
#define FN_AMXX_ATTACH OnAmxxAttach #define FN_AMXX_ATTACH OnAmxxAttach
/** AMXX Detach (unload) */ /** AMXX Detach (unload) */
//#define FN_AMXX_DETACH OnAmxxDetach #define FN_AMXX_DETACH OnAmxxDetach
/** All plugins loaded /** All plugins loaded
* Do forward functions init here (MF_RegisterForward) * Do forward functions init here (MF_RegisterForward)

View File

@ -1,140 +1,139 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#include "amxxmodule.h" #include "amxxmodule.h"
#include <stdarg.h> #include <stdarg.h>
#include "CVector.h" #include "CVector.h"
#include "ham_const.h" #include "ham_const.h"
#include "hooklist.h" #include "hooklist.h"
#include "offsets.h" #include "offsets.h"
#include "forward.h" #include "forward.h"
#include "hook.h" #include "hook.h"
extern hook_t hooklist[]; extern hook_t hooklist[];
extern CVector<Hook *> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL]; extern CVector<Hook *> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
void print_srvconsole(const char *fmt, ...) void print_srvconsole(const char *fmt, ...)
{ {
va_list argptr; va_list argptr;
static char string[384]; static char string[384];
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf(string, sizeof(string) - 1, fmt, argptr); vsnprintf(string, sizeof(string) - 1, fmt, argptr);
string[sizeof(string) - 1] = '\0'; string[sizeof(string) - 1] = '\0';
va_end(argptr); va_end(argptr);
SERVER_PRINT(string); SERVER_PRINT(string);
} }
void HamCommand(void) void HamCommand(void)
{ {
const char *cmd=CMD_ARGV(1); const char *cmd=CMD_ARGV(1);
if (strcmp(cmd, "list")==0) if (strcmp(cmd, "list")==0)
{ {
unsigned int Total=0; unsigned int Total=0;
print_srvconsole("%-24s | %10s\n","Name","Set","Value"); print_srvconsole("%-24s | %10s\n","Name","Set","Value");
print_srvconsole("------------------------------------\n"); print_srvconsole("------------------------------------\n");
print_srvconsole("%-24s | %10d\n", "pev", Offsets.GetPev()); print_srvconsole("%-24s | %10d\n", "pev", Offsets.GetPev());
print_srvconsole("%-24s | %10d\n", "base", Offsets.GetBase()); print_srvconsole("%-24s | %10d\n", "base", Offsets.GetBase());
if (Offsets.IsPevSet()) if (Offsets.IsPevSet())
{ {
Total++; Total++;
} }
if (Offsets.IsBaseSet()) if (Offsets.IsBaseSet())
{ {
Total++; Total++;
} }
int count=2; int count=2;
for (int i=0; i<HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++) for (int i=0; i<HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++)
{ {
if (hooklist[i].isset != 0) if (hooklist[i].isset != 0)
{ {
print_srvconsole("%-24s | %10d\n", hooklist[i].name, hooklist[i].vtid); print_srvconsole("%-24s | %10d\n", hooklist[i].name, hooklist[i].vtid);
Total++; Total++;
count++; count++;
} }
if (count >= 5) if (count >= 5)
{ {
count = 0; count = 0;
print_srvconsole("------------------------------------\n"); print_srvconsole("------------------------------------\n");
} }
} }
print_srvconsole("\n%u keys, %u set.\n\n", HAM_LAST_ENTRY_DONT_USE_ME_LOL, Total); print_srvconsole("\n%u keys, %u set.\n\n", HAM_LAST_ENTRY_DONT_USE_ME_LOL, Total);
return; return;
} }
else if (strcmp(cmd, "hooks")==0) else if (strcmp(cmd, "hooks")==0)
{ {
print_srvconsole("%-24s | %-27s | %10s | %10s\n", "Key", "Classname", "Pre", "Post"); print_srvconsole("%-24s | %-27s | %10s | %10s\n", "Key", "Classname", "Pre", "Post");
print_srvconsole("--------------------------------------------------------------------------------\n"); print_srvconsole("--------------------------------------------------------------------------------\n");
unsigned int ForwardCount=0; unsigned int ForwardCount=0;
unsigned int HookCount=0; unsigned int HookCount=0;
int count = 0; int count = 0;
for (int i=0; i<HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++) for (int i=0; i<HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++)
{ {
CVector<Hook *>::iterator end=hooks[i].end(); CVector<Hook *>::iterator end=hooks[i].end();
for (CVector<Hook *>::iterator j=hooks[i].begin(); for (CVector<Hook *>::iterator j=hooks[i].begin();
j!=end; j!=end;
++j) ++j)
{ {
HookCount++; HookCount++;
ForwardCount+=(*j)->pre.size() + (*j)->post.size(); ForwardCount+=(*j)->pre.size() + (*j)->post.size();
print_srvconsole("%-24s | %-27s | %10d | %10d\n",hooklist[i].name, (*j)->ent, (*j)->pre.size(), (*j)->post.size()); print_srvconsole("%-24s | %-27s | %10d | %10d\n",hooklist[i].name, (*j)->ent, (*j)->pre.size(), (*j)->post.size());
if (count >= 5) if (count >= 5)
{ {
print_srvconsole("--------------------------------------------------------------------------------\n"); print_srvconsole("--------------------------------------------------------------------------------\n");
} }
} }
} }
print_srvconsole("\n%u hooks, %u forwards.\n\n", HookCount, ForwardCount); print_srvconsole("\n%u hooks, %u forwards.\n\n", HookCount, ForwardCount);
return; return;
} }
// Unknown command // Unknown command
print_srvconsole("Usage: ham < command > [ argument ]\n"); print_srvconsole("Usage: ham < command > [ argument ]\n");
print_srvconsole("Commands:\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", "list", "list all keys and their values from the config file.");
print_srvconsole(" %-22s - %s\n", "hooks", "list all active hooks"); print_srvconsole(" %-22s - %s\n", "hooks", "list all active hooks");
} }

View File

@ -1,89 +1,89 @@
/* Ham Sandwich /* Ham Sandwich
* Copyright 2007 * Copyright 2007-2014
* By the AMX Mod X Development Team * By the AMX Mod X Development Team
* *
* Ham Sandwich is free software; you can redistribute it and/or modify it * Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at * Free Software Foundation; either version 2 of the License, or (at
* your option) any later version. * your option) any later version.
* *
* Ham Sandwich is distributed in the hope that it will be useful, but * Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of * WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation, * along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* In addition, as a special exception, the author gives permission to * In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL * link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve, * Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all * L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs * respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception * from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If * to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your * you do not wish to do so, delete this exception statement from your
* version. * version.
*/ */
#ifndef TYPETOCELL_H #ifndef TYPETOCELL_H
#define TYPETOCELL_H #define TYPETOCELL_H
#include <extdll.h> #include <extdll.h>
#include "amxxmodule.h" #include "amxxmodule.h"
#include "CVector.h" #include "CVector.h"
#include "hook.h" #include "hook.h"
#include "forward.h" #include "forward.h"
#include "ham_const.h" #include "ham_const.h"
#include "ham_utils.h" #include "ham_utils.h"
inline cell TypeToCell(const float& value) inline cell TypeToCell(const float& value)
{ {
return amx_ftoc2(value); return amx_ftoc2(value);
} }
inline cell TypeToCell(const float*& value) inline cell TypeToCell(const float*& value)
{ {
return amx_ftoc2(*value); return amx_ftoc2(*value);
} }
inline cell TypeToCell(const Vector*& value) inline cell TypeToCell(const Vector*& value)
{ {
return reinterpret_cast<cell>(value); return reinterpret_cast<cell>(value);
} }
inline cell TypeToCell(const int& value) inline cell TypeToCell(const int& value)
{ {
return value; return value;
} }
inline cell TypeToCell(const edict_t*& value) inline cell TypeToCell(const edict_t*& value)
{ {
if (value == NULL) if (value == NULL)
{ {
return -1; return -1;
} }
return ENTINDEX_NEW(value); return ENTINDEX_NEW(value);
} }
inline cell TypeToCell(const entvars_t*& value) inline cell TypeToCell(const entvars_t*& value)
{ {
if (value == NULL) if (value == NULL)
{ {
return -1; return -1;
} }
return ENTINDEX_NEW(value->pContainingEntity); return ENTINDEX_NEW(value->pContainingEntity);
} }
inline cell TypeToCell(const HLBaseEntity*& value) inline cell TypeToCell(const HLBaseEntity*& value)
{ {
return PrivateToIndex(reinterpret_cast<const void *>(value)); return PrivateToIndex(reinterpret_cast<const void *>(value));
} }
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,382 +1,429 @@
/* Ham Sandwich
* Copyright 2007-2014
* By the AMX Mod X Development Team
*
* Ham Sandwich is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* Ham Sandwich is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Ham Sandwich; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of Ham Sandwich with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/
/**
* Ham Sandwich is a module that is used to hook and call virtual functions of
* entities.
* Virtual functions are mod-specific functions. This means that in order
* for this to work on a mod, it needs to be configured with the hamdata.ini
* file.
* Be very careful with parameter passing to these functions.
*/
#if defined _hamsandwich_included
#endinput
#endif
#define _hamsandwich_included
#include <ham_const>
#if AMXX_VERSION_NUM >= 175
#pragma reqlib hamsandwich
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib hamsandwich
#endif
#else
#pragma library hamsandwich
#endif
/**
* Hooks the virtual table for the specified entity class.
* An example would be: RegisterHam(Ham_TakeDamage, "player", "player_hurt");
* Look at the Ham enum for parameter lists.
*
* @param function The function to hook.
* @param EntityClass The entity classname to hook.
* @param callback The forward to call.
* @param post Whether or not to forward this in post.
* @return Returns a handle to the forward. Use EnableHamForward/DisableHamForward to toggle the forward on or off.
*/
native HamHook:RegisterHam(Ham:function, const EntityClass[], const Callback[], Post=0);
/**
* Hooks the virtual table for the specified entity's class.
* An example would be: RegisterHam(Ham_TakeDamage, id, "player_hurt");
* Look at the Ham enum for parameter lists.
* Note: This will cause hooks for the entire internal class that the entity is
* not exclusively for the provided entity.
*
* @param function The function to hook.
* @param EntityId The entity classname to hook.
* @param callback The forward to call.
* @param post Whether or not to forward this in post.
* @return Returns a handle to the forward. Use EnableHamForward/DisableHamForward to toggle the forward on or off.
*/
native HamHook:RegisterHamFromEntity(Ham:function, EntityId, const Callback[], Post=0);
/**
* Stops a ham forward from triggering.
* Use the return value from RegisterHam as the parameter here!
*
* @param fwd The forward to stop.
*/
native DisableHamForward(HamHook:fwd);
/**
* Starts a ham forward back up.
* Use the return value from RegisterHam as the parameter here!
*
* @param fwd The forward to re-enable.
*/
native EnableHamForward(HamHook:fwd);
/**
* Executes the virtual function on the entity.
* Look at the Ham enum for parameter lists.
*
* @param function The function to call.
* @param id The id of the entity to execute it on.
*/
native ExecuteHam(Ham:function, this, any:...);
/**
* Executes the virtual function on the entity, this will trigger all hooks on that function.
* Be very careful about recursion!
* Look at the Ham enum for parameter lists.
*
* @param function The function to call.
* @param id The id of the entity to execute it on.
*/
native ExecuteHamB(Ham:function, this, any:...);
/**
* Gets the return status of the current hook.
* This is useful to determine what return natives to use.
*
* @return The current status of the hook (such as HAM_SUPERCEDE).
*/
native GetHamReturnStatus();
/**
* Gets the return value of a hook for hooks that return integers or booleans.
*
* @param output The variable to store the value in.
*/
native GetHamReturnInteger(&output);
/**
* Gets the return value of a hook for hooks that return float.
*
* @param output The variable to store the value in.
*/
native GetHamReturnFloat(&Float:output);
/**
* Gets the return value of a hook for hooks that return Vectors.
*
* @param output The variable to store the value in.
*/
native GetHamReturnVector(Float:output[3]);
/**
* Gets the return value of a hook for hooks that return entities.
*
* @param output The variable to store the value in. Will be -1 on null.
*/
native GetHamReturnEntity(&output);
/**
* Gets the return value of a hook for hooks that return strings.
*
* @param output The buffer to store the string in.
* @param size The string size of the buffer.
*/
native GetHamReturnString(output[], size);
/**
* Gets the original return value of a hook for hooks that return integers or booleans.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnInteger(&output);
/**
* Gets the original return value of a hook for hooks that return floats.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnFloat(&Float:output);
/**
* Gets the original return value of a hook for hooks that return Vectors.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnVector(Float:output[3]);
/**
* Gets the original return value of a hook for hooks that return entities.
*
* @param output The variable to store the value in. -1 on null.
*/
native GetOrigHamReturnEntity(&output);
/**
* Gets the original return value of a hook for hooks that return strings.
*
* @param output The buffer to store the string in.
* @param size The size of the buffer.
*/
native GetOrigHamReturnString(output[], size);
/**
* Sets the return value of a hook that returns an integer or boolean.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnInteger(value);
/**
* Sets the return value of a hook that returns a float.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnFloat(Float:value);
/**
* Sets the return value of a hook that returns a Vector.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnVector(const Float:value[3]);
/**
* Sets the return value of a hook that returns an entity. Set to -1 for null.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnEntity(value);
/**
* Sets the return value of a hook that returns a string.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnString(const value[]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are integers.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamInteger(which, value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are floats.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamFloat(which, Float:value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are Vectors.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamVector(which, const Float:value[3]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are entities.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamEntity(which, value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are strings.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param ouput The value to change it to.
*/
native SetHamParamString(which, const output[]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are trace result handles.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param tr_handle The value to change it to.
*/
native SetHamParamTraceResult(which, tr_handle);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are trace result handles.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param iteminfo_handle The value to change it to.
*/
native SetHamParamItemInfo(which, iteminfo_handle);
/**
* Gets a parameter on the fly of the current hook.
* Use this on parameters that are iteminfo result handles.
*
* @param iteminfo_handle Item info handle.
* @param type Item info type. See ItemInfo_ constants.
*/
native GetHamItemInfo(iteminfo_handle, ItemInfo:type, any:...);
/**
* Sets a parameter on the fly of the current hook.
* Use this on parameters that are iteminfo result handles.
*
* @param iteminfo_handle Item info handle.
* @param type Item info type. See HamItemInfo_ constants.
*/
native SetHamItemInfo(iteminfo_handle, ItemInfo:type, any:...);
/** /**
* Ham Sandwich module include file. * Creates an ItemInfo handle. This value should never be altered.
* (c) 2007, The AMX Mod X Development Team * The handle can be used in Get/SetHamItemInfo.
* *
* - * NOTE: You must call FreeHamItemInfo() on every handle made with CreateHamItemInfo().
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
* *
* This program is distributed in the hope that it will be useful, but * @return A new ItemInfo handle.
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/ */
native CreateHamItemInfo();
/** /**
* Ham Sandwich is a module that is used to hook and call virtual functions of * Frees an ItemIndo handle created with CreateHamItemInfo(). Do not call
* entities. * this more than once per handle, or on handles not created through
* Virtual functions are mod-specific functions. This means that in order * CreateHamItemInfo().
* for this to work on a mod, it needs to be configured with the hamdata.ini
* file.
* Be very careful with parameter passing to these functions.
*/
#if defined _hamsandwich_included
#endinput
#endif
#define _hamsandwich_included
#include <ham_const>
#if AMXX_VERSION_NUM >= 175
#pragma reqlib hamsandwich
#if !defined AMXMODX_NOAUTOLOAD
#pragma loadlib hamsandwich
#endif
#else
#pragma library hamsandwich
#endif
/**
* Hooks the virtual table for the specified entity class.
* An example would be: RegisterHam(Ham_TakeDamage, "player", "player_hurt");
* Look at the Ham enum for parameter lists.
* *
* @param function The function to hook. * @param itemInfo_handle ItemInfo handle created via CreateHamItemInfo().
* @param EntityClass The entity classname to hook. * @noreturn
* @param callback The forward to call.
* @param post Whether or not to forward this in post.
* @return Returns a handle to the forward. Use EnableHamForward/DisableHamForward to toggle the forward on or off.
*/ */
native HamHook:RegisterHam(Ham:function, const EntityClass[], const Callback[], Post=0); native FreeHamItemInfo(itemInfo_handle);
/**
* Hooks the virtual table for the specified entity's class. /**
* An example would be: RegisterHam(Ham_TakeDamage, id, "player_hurt"); * Returns whether or not the function for the specified Ham is valid.
* Look at the Ham enum for parameter lists. * Things that would make it invalid would be bounds (an older module version
* Note: This will cause hooks for the entire internal class that the entity is * may not have all of the functions), and the function not being found in
* not exclusively for the provided entity. * the mod's hamdata.ini file.
* *
* @param function The function to hook. * @param function The function to look up.
* @param EntityId The entity classname to hook. * @return true if the function is valid, false otherwise.
* @param callback The forward to call. */
* @param post Whether or not to forward this in post. native bool:IsHamValid(Ham:function);
* @return Returns a handle to the forward. Use EnableHamForward/DisableHamForward to toggle the forward on or off.
*/ /**
native HamHook:RegisterHamFromEntity(Ham:function, EntityId, const Callback[], Post=0); * This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.
* This requires the mod to have the pev and base fields set in hamdata.ini.
* Note this dereferences memory! Improper use of this will crash the server.
/** * This will return an index of the corresponding cbase field in private data.
* Stops a ham forward from triggering. * Returns -1 on a null entry.
* Use the return value from RegisterHam as the parameter here! *
* * @param id The entity to examine the private data.
* @param fwd The forward to stop. * @param offset The windows offset of the data.
*/ * @param linuxdiff The linux difference of the data.
native DisableHamForward(HamHook:fwd); * @param macdiff The mac os x difference of the data.
* @return The index of the corresponding pdata field. -1 for none set.
/** */
* Starts a ham forward back up. native get_pdata_cbase(id, offset, linuxdiff=5, macdiff=5);
* Use the return value from RegisterHam as the parameter here!
* /**
* @param fwd The forward to re-enable. * This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.
*/ * This requires the mod to have the pev and base fields set in hamdata.ini.
native EnableHamForward(HamHook:fwd); * This will set the corresponding cbase field in private data with the index.
* Pass -1 to null the entry.
/** *
* Executes the virtual function on the entity. * @param id The entity to examine the private data.
* Look at the Ham enum for parameter lists. * @param offset The windows offset of the data.
* * @param value The index to store, -1 for invalid
* @param function The function to call. * @param linuxdiff The linux difference of the data.
* @param id The id of the entity to execute it on. * @param macdiff The mac os x difference of the data.
*/ */
native ExecuteHam(Ham:function, this, any:...); native set_pdata_cbase(id, offset, value, linuxdiff=5, macdiff=5);
/** /**
* Executes the virtual function on the entity, this will trigger all hooks on that function. * This is similar to the get_pdata_cbase, however it does not dereference memory.
* Be very careful about recursion! * This is many times slower than get_pdata_cbase, and this should only be used
* Look at the Ham enum for parameter lists. * for testing and finding of offsets, not actual release quality plugins.
* * This will return an index of the corresponding cbase field in private data.
* @param function The function to call. * Returns -1 on a null entry. -2 on an invalid entry.
* @param id The id of the entity to execute it on. *
*/ * @param id Entry to examine the private data.
native ExecuteHamB(Ham:function, this, any:...); * @param offset The windows offset of the data.
* @param linuxdiff The linux difference of the data.
/** * @param macdiff The mac os x difference of the data.
* Gets the return status of the current hook. * @return The index of the corresponding pdata field, -1 for null, -2 for invalid.
* This is useful to determine what return natives to use. */
* native get_pdata_cbase_safe(id, offset, linuxdiff=5, macdiff=5);
* @return The current status of the hook (such as HAM_SUPERCEDE).
*/
native GetHamReturnStatus();
/** // This is the callback from the module, this handles any fatal errors.
* Gets the return value of a hook for hooks that return integers or booleans. // This will in turn call the "HamFilter(Ham:id, HamError:err, const reason[])" public, if it exists.
* // Return PLUGIN_HANDLED from within the HamFilter to stop the plugin from failing.
* @param output The variable to store the value in. // Any other return value will fail the plugin.
*/ // You do not need to have a HamFilter, if there is none, all fatal errors will fail the plugin.
native GetHamReturnInteger(&output); // Do not modify this!
public __fatal_ham_error(Ham:id, HamError:err, const reason[])
/** {
* Gets the return value of a hook for hooks that return float.
* new func=get_func_id("HamFilter", -1);
* @param output The variable to store the value in. new bool:fail=true;
*/
native GetHamReturnFloat(&Float:output); if (func != -1 && callfunc_begin_i(func, -1)==1)
{
/** callfunc_push_int(_:id);
* Gets the return value of a hook for hooks that return Vectors. callfunc_push_int(_:err);
* callfunc_push_str(reason, false);
* @param output The variable to store the value in. if (callfunc_end()==PLUGIN_HANDLED)
*/ {
native GetHamReturnVector(Float:output[3]); fail=false;
}
/** }
* Gets the return value of a hook for hooks that return entities. if (fail)
* {
* @param output The variable to store the value in. Will be -1 on null. set_fail_state(reason);
*/ }
native GetHamReturnEntity(&output);
}
/**
* Gets the return value of a hook for hooks that return strings.
*
* @param output The buffer to store the string in.
* @param size The string size of the buffer.
*/
native GetHamReturnString(output[], size);
/**
* Gets the original return value of a hook for hooks that return integers or booleans.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnInteger(&output);
/**
* Gets the original return value of a hook for hooks that return floats.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnFloat(&Float:output);
/**
* Gets the original return value of a hook for hooks that return Vectors.
*
* @param output The variable to store the value in.
*/
native GetOrigHamReturnVector(Float:output[3]);
/**
* Gets the original return value of a hook for hooks that return entities.
*
* @param output The variable to store the value in. -1 on null.
*/
native GetOrigHamReturnEntity(&output);
/**
* Gets the original return value of a hook for hooks that return strings.
*
* @param output The buffer to store the string in.
* @param size The size of the buffer.
*/
native GetOrigHamReturnString(output[], size);
/**
* Sets the return value of a hook that returns an integer or boolean.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnInteger(value);
/**
* Sets the return value of a hook that returns a float.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnFloat(Float:value);
/**
* Sets the return value of a hook that returns a Vector.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnVector(const Float:value[3]);
/**
* Sets the return value of a hook that returns an entity. Set to -1 for null.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnEntity(value);
/**
* Sets the return value of a hook that returns a string.
* This needs to be used in conjunction with HAM_OVERRIDE or HAM_SUPERCEDE.
*
* @param value The value to set the return to.
*/
native SetHamReturnString(const value[]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are integers.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamInteger(which, value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are floats.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamFloat(which, Float:value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are Vectors.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamVector(which, const Float:value[3]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are entities.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamEntity(which, value);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are strings.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamString(which, const output[]);
/**
* Sets a parameter on the fly of the current hook. This has no effect in post hooks.
* Use this on parameters that are trace result handles.
*
* @param which Which parameter to change. Starts at 1, and works up from the left to right. 1 is always "this".
* @param value The value to change it to.
*/
native SetHamParamTraceResult(which, tr_handle);
/**
* Returns whether or not the function for the specified Ham is valid.
* Things that would make it invalid would be bounds (an older module version
* may not have all of the functions), and the function not being found in
* the mod's hamdata.ini file.
*
* @param function The function to look up.
* @return true if the function is valid, false otherwise.
*/
native bool:IsHamValid(Ham:function);
/**
* This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.
* This requires the mod to have the pev and base fields set in hamdata.ini.
* Note this dereferences memory! Improper use of this will crash the server.
* This will return an index of the corresponding cbase field in private data.
* Returns -1 on a null entry.
*
* @param id The entity to examine the private data.
* @param offset The windows offset of the data.
* @param linuxdiff The linux difference of the data.
* @param macdiff The mac os x difference of the data.
* @return The index of the corresponding pdata field. -1 for none set.
*/
native get_pdata_cbase(id, offset, linuxdiff=5, macdiff=5);
/**
* This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.
* This requires the mod to have the pev and base fields set in hamdata.ini.
* This will set the corresponding cbase field in private data with the index.
* Pass -1 to null the entry.
*
* @param id The entity to examine the private data.
* @param offset The windows offset of the data.
* @param value The index to store, -1 for invalid
* @param linuxdiff The linux difference of the data.
* @param macdiff The mac os x difference of the data.
*/
native set_pdata_cbase(id, offset, value, linuxdiff=5, macdiff=5);
/**
* This is similar to the get_pdata_cbase, however it does not dereference memory.
* This is many times slower than get_pdata_cbase, and this should only be used
* for testing and finding of offsets, not actual release quality plugins.
* This will return an index of the corresponding cbase field in private data.
* Returns -1 on a null entry. -2 on an invalid entry.
*
* @param id Entry to examine the private data.
* @param offset The windows offset of the data.
* @param linuxdiff The linux difference of the data.
* @param macdiff The mac os x difference of the data.
* @return The index of the corresponding pdata field, -1 for null, -2 for invalid.
*/
native get_pdata_cbase_safe(id, offset, linuxdiff=5, macdiff=5);
// This is the callback from the module, this handles any fatal errors.
// This will in turn call the "HamFilter(Ham:id, HamError:err, const reason[])" public, if it exists.
// Return PLUGIN_HANDLED from within the HamFilter to stop the plugin from failing.
// Any other return value will fail the plugin.
// You do not need to have a HamFilter, if there is none, all fatal errors will fail the plugin.
// Do not modify this!
public __fatal_ham_error(Ham:id, HamError:err, const reason[])
{
new func=get_func_id("HamFilter", -1);
new bool:fail=true;
if (func != -1 && callfunc_begin_i(func, -1)==1)
{
callfunc_push_int(_:id);
callfunc_push_int(_:err);
callfunc_push_str(reason, false);
if (callfunc_end()==PLUGIN_HANDLED)
{
fail=false;
}
}
if (fail)
{
set_fail_state(reason);
}
}