2007-05-16 03:57:18 +00:00
|
|
|
/* Ham Sandwich
|
|
|
|
* Copyright 2007
|
|
|
|
* 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.
|
|
|
|
*/
|
2007-05-04 12:51:13 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <extdll.h>
|
2008-08-16 09:48:39 +00:00
|
|
|
#include "amxxmodule.h"
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "CVector.h"
|
2007-05-08 17:26:51 +00:00
|
|
|
#include "CString.h"
|
|
|
|
#include "sh_stack.h"
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
#include "hook.h"
|
|
|
|
#include "forward.h"
|
|
|
|
|
|
|
|
#include "ham_const.h"
|
|
|
|
#include "ham_utils.h"
|
|
|
|
|
2007-05-08 17:26:51 +00:00
|
|
|
#include "DataHandler.h"
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
|
2007-05-04 15:42:02 +00:00
|
|
|
|
|
|
|
extern bool gDoForwards;
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
// Return value pushes
|
2007-05-08 17:26:51 +00:00
|
|
|
#define PUSH_VOID() ReturnStack.push(new Data(RET_VOID, NULL)); OrigReturnStack.push(new Data(RET_VOID, NULL));
|
|
|
|
#define PUSH_INT() ReturnStack.push(new Data(RET_INTEGER, (void *)&ret)); OrigReturnStack.push(new Data(RET_INTEGER, (void *)&origret));
|
|
|
|
#define PUSH_FLOAT() ReturnStack.push(new Data(RET_FLOAT, (void *)&ret)); OrigReturnStack.push(new Data(RET_FLOAT, (void *)&origret));
|
|
|
|
#define PUSH_VECTOR() ReturnStack.push(new Data(RET_VECTOR, (void *)&ret)); OrigReturnStack.push(new Data(RET_VECTOR, (void *)&origret));
|
|
|
|
#define PUSH_CBASE() ReturnStack.push(new Data(RET_CBASE, (void *)&ret)); OrigReturnStack.push(new Data(RET_CBASE, (void *)&origret));
|
|
|
|
#define PUSH_STRING() ReturnStack.push(new Data(RET_STRING, (void *)&ret)); OrigReturnStack.push(new Data(RET_STRING, (void *)&origret));
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
// Pop off return values
|
2007-05-08 17:26:51 +00:00
|
|
|
#define POP() delete ReturnStack.front(); ReturnStack.pop(); delete OrigReturnStack.front(); OrigReturnStack.pop();
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
// Parameter value pushes
|
|
|
|
#define MAKE_VECTOR() \
|
|
|
|
int iThis=PrivateToIndex(pthis); \
|
|
|
|
CVector<Data *> *__vec=new CVector<Data *>; \
|
|
|
|
ParamStack.push(__vec); \
|
|
|
|
P_CBASE(pthis, iThis)
|
|
|
|
|
|
|
|
#define P_INT(___PARAM) __vec->push_back(new Data(RET_INTEGER, (void *) & (___PARAM)));
|
|
|
|
#define P_FLOAT(___PARAM) __vec->push_back(new Data(RET_FLOAT, (void *) & (___PARAM)));
|
|
|
|
#define P_VECTOR(___PARAM) __vec->push_back(new Data(RET_VECTOR, (void *) & (___PARAM)));
|
|
|
|
#define P_STR(___PARAM) __vec->push_back(new Data(RET_STRING, (void *) & (___PARAM)));
|
|
|
|
#define P_CBASE(__PARAM, __INDEX) __vec->push_back(new Data(RET_CBASE, (void *) & (__PARAM), reinterpret_cast<int *>(& (__INDEX))));
|
|
|
|
#define P_ENTVAR(__PARAM, __INDEX) __vec->push_back(new Data(RET_ENTVAR, (void *) & (__PARAM), reinterpret_cast<int *>(& (__INDEX))));
|
|
|
|
#define P_TRACE(__PARAM) __vec->push_back(new Data(RET_TRACE, (void *) (__PARAM)));
|
|
|
|
#define P_PTRVECTOR(__PARAM) __vec->push_back(new Data(RET_VECTOR, (void *) (__PARAM)));
|
|
|
|
#define P_PTRFLOAT(__PARAM) __vec->push_back(new Data(RET_FLOAT, (void *) (__PARAM)));
|
2007-05-10 16:08:02 +00:00
|
|
|
#define P_ITEMINFO(__PARAM) __vec->push_back(new Data(RET_ITEMINFO, (void *) & (__PARAM)));
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
#define KILL_VECTOR() \
|
|
|
|
CVector<Data *>::iterator end=__vec->end(); \
|
|
|
|
for (CVector<Data *>::iterator i=__vec->begin(); i!=end; ++i) \
|
|
|
|
{ \
|
|
|
|
delete (*i); \
|
|
|
|
} \
|
|
|
|
delete __vec; \
|
|
|
|
ParamStack.pop();
|
|
|
|
|
2007-05-04 15:42:02 +00:00
|
|
|
#define PRE_START() \
|
|
|
|
bool DoForwards=gDoForwards; \
|
|
|
|
gDoForwards=true; \
|
|
|
|
int result=HAM_UNSET; \
|
2007-05-09 14:58:55 +00:00
|
|
|
ReturnStatus.push(&result); \
|
2007-05-04 15:42:02 +00:00
|
|
|
int thisresult=HAM_UNSET; \
|
|
|
|
if (DoForwards) \
|
|
|
|
{ \
|
|
|
|
CVector<Forward*>::iterator end=hook->pre.end(); \
|
|
|
|
for (CVector<Forward*>::iterator i=hook->pre.begin(); i!=end; i++) \
|
|
|
|
{ \
|
|
|
|
if ((*i)->state == FSTATE_OK) \
|
|
|
|
{ \
|
|
|
|
thisresult=MF_ExecuteForward((*i)->id,iThis
|
|
|
|
|
|
|
|
#define PRE_END() \
|
|
|
|
); \
|
|
|
|
} \
|
|
|
|
if (thisresult > result) \
|
|
|
|
{ \
|
|
|
|
result=thisresult; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
if (result < HAM_SUPERCEDE) \
|
2007-05-04 12:51:13 +00:00
|
|
|
{
|
|
|
|
|
2007-05-04 15:42:02 +00:00
|
|
|
#define POST_START() \
|
|
|
|
} \
|
|
|
|
if (DoForwards) \
|
|
|
|
{ \
|
|
|
|
CVector<Forward*>::iterator end=hook->post.end(); \
|
|
|
|
for (CVector<Forward*>::iterator i=hook->post.begin(); i!=end; i++) \
|
|
|
|
{ \
|
|
|
|
if ((*i)->state == FSTATE_OK) \
|
|
|
|
{ \
|
|
|
|
MF_ExecuteForward((*i)->id,iThis
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
#define POST_END() \
|
2007-05-04 15:42:02 +00:00
|
|
|
); \
|
|
|
|
} \
|
2007-05-04 12:51:13 +00:00
|
|
|
} \
|
2007-05-09 14:58:55 +00:00
|
|
|
} \
|
|
|
|
ReturnStatus.pop();
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
|
2007-05-08 17:26:51 +00:00
|
|
|
#define CHECK_RETURN() \
|
|
|
|
if (thisresult < HAM_OVERRIDE) \
|
|
|
|
{ \
|
|
|
|
return origret; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHECK_RETURN_STR() \
|
|
|
|
if (thisresult < HAM_OVERRIDE) \
|
|
|
|
{ \
|
|
|
|
return origret.c_str(); \
|
|
|
|
}
|
2007-05-09 14:58:55 +00:00
|
|
|
#define CHECK_RETURN_VEC() \
|
|
|
|
if (thisresult < HAM_OVERRIDE) \
|
|
|
|
{ \
|
|
|
|
memcpy(out, &origret, sizeof(Vector)); \
|
2007-05-12 13:16:05 +00:00
|
|
|
return; \
|
2007-05-09 14:58:55 +00:00
|
|
|
}
|
|
|
|
|
2007-05-08 17:26:51 +00:00
|
|
|
|
|
|
|
|
2007-05-12 13:16:05 +00:00
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
void Hook_Void_Void(Hook *hook, void *pthis)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_VOID()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*,int)>(hook->func)(pthis,0);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (*)(void*)>(hook->func)(pthis);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
POST_END()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
int Hook_Int_Void(Hook *hook, void *pthis)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
int ret=0;
|
|
|
|
int origret=0;
|
2007-05-04 12:51:13 +00:00
|
|
|
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_INT()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
PRE_END()
|
|
|
|
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (__fastcall*)(void*,int)>(hook->func)(pthis,0);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (*)(void*)>(hook->func)(pthis);
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
2007-05-08 17:26:51 +00:00
|
|
|
CHECK_RETURN()
|
|
|
|
return ret;
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hook_Void_Entvar(Hook *hook, void *pthis, entvars_t *entvar)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_VOID()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
int iOther=EntvarToIndex(entvar);
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
MAKE_VECTOR()
|
|
|
|
|
|
|
|
P_ENTVAR(entvar, iOther)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
, iOther
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, entvars_t *)>(hook->func)(pthis, 0, entvar);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (*)(void*, entvars_t *)>(hook->func)(pthis, entvar);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
, iOther
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hook_Void_Cbase(Hook *hook, void *pthis, void *other)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_VOID()
|
2007-05-04 12:51:13 +00:00
|
|
|
int iOther=PrivateToIndex(other);
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
MAKE_VECTOR()
|
|
|
|
|
|
|
|
P_CBASE(other, iOther)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
, iOther
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, void *)>(hook->func)(pthis, 0, other);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (*)(void*, void *)>(hook->func)(pthis, other);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
, iOther
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Hook_Int_Float_Int(Hook *hook, void *pthis, float f1, int i1)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
int ret=0;
|
|
|
|
int origret=0;
|
|
|
|
PUSH_INT()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
|
|
|
|
P_FLOAT(f1)
|
|
|
|
P_INT(i1)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
, f1, i1
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (__fastcall*)(void*, int, float, int)>(hook->func)(pthis, 0, f1, i1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (*)(void*, float, int)>(hook->func)(pthis, f1, i1);
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
, f1, i1
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
|
|
|
POP()
|
|
|
|
CHECK_RETURN()
|
2007-05-08 17:26:51 +00:00
|
|
|
return ret;
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
void Hook_Void_Entvar_Int(Hook *hook, void *pthis, entvars_t *ev1, int i1)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_VOID()
|
2007-05-04 12:51:13 +00:00
|
|
|
int iOther=EntvarToIndex(ev1);
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
MAKE_VECTOR()
|
|
|
|
|
|
|
|
P_ENTVAR(ev1, iOther)
|
|
|
|
P_INT(i1)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
, iOther, i1
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, entvars_t *, int)>(hook->func)(pthis, 0, ev1, i1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (*)(void*, entvars_t *, int)>(hook->func)(pthis, ev1, i1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
, iOther, i1
|
|
|
|
POST_END()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Hook_Int_Cbase(Hook *hook, void *pthis, void *cb1)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
int ret=0;
|
|
|
|
int origret=0;
|
|
|
|
|
|
|
|
PUSH_INT()
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
int iOther=PrivateToIndex(cb1);
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
|
|
|
|
P_CBASE(cb1, iOther)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
, iOther
|
|
|
|
PRE_END()
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (__fastcall*)(void*, int, void *)>(hook->func)(pthis, 0, cb1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (*)(void*, void *)>(hook->func)(pthis, cb1);
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
, iOther
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
|
|
|
CHECK_RETURN()
|
|
|
|
return ret;
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hook_Void_Int_Int(Hook *hook, void *pthis, int i1, int i2)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_VOID()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
|
|
|
|
P_INT(i1)
|
|
|
|
P_INT(i2)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
,i1, i2
|
|
|
|
PRE_END()
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, int, int)>(hook->func)(pthis, 0, i1, i2);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (*)(void*, int, int)>(hook->func)(pthis, i1, i2);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
,i1, i2
|
|
|
|
POST_END()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Hook_Int_Int_Str_Int(Hook *hook, void *pthis, int i1, const char *sz1, int i2)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
int ret=0;
|
|
|
|
int origret=0;
|
|
|
|
PUSH_INT()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
String a=sz1;
|
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
|
|
|
|
P_INT(i1)
|
|
|
|
P_STR(a)
|
|
|
|
P_INT(i2)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
2007-05-09 14:58:55 +00:00
|
|
|
,i1, a.c_str(), i2
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_END()
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-09 14:58:55 +00:00
|
|
|
origret=reinterpret_cast<int (__fastcall*)(void*, int, int, const char *, int)>(hook->func)(pthis, 0, i1, a.c_str(), i2);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-09 14:58:55 +00:00
|
|
|
origret=reinterpret_cast<int (*)(void*, int, const char *, int)>(hook->func)(pthis, i1, a.c_str(), i2);
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
2007-05-09 14:58:55 +00:00
|
|
|
,i1, a.c_str(), i2
|
2007-05-04 12:51:13 +00:00
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
|
|
|
CHECK_RETURN()
|
|
|
|
return ret;
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Hook_Int_Int(Hook *hook, void *pthis, int i1)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
int ret=0;
|
|
|
|
int origret=0;
|
|
|
|
PUSH_INT()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
MAKE_VECTOR()
|
2007-05-04 12:51:13 +00:00
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
P_INT(i1)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
,i1
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (__fastcall*)(void*, int, int)>(hook->func)(pthis, 0, i1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (*)(void*, int)>(hook->func)(pthis, i1);
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
,i1
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
|
|
|
CHECK_RETURN()
|
|
|
|
return ret;
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Hook_Int_Entvar(Hook *hook, void *pthis, entvars_t *ev1)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
int ret=0;
|
|
|
|
int origret=0;
|
|
|
|
|
|
|
|
PUSH_INT()
|
2007-05-04 12:51:13 +00:00
|
|
|
int iOther=EntvarToIndex(ev1);
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
MAKE_VECTOR()
|
|
|
|
P_ENTVAR(ev1, iOther)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
,iOther
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (__fastcall*)(void*, int, entvars_t *)>(hook->func)(pthis, 0, ev1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (*)(void*, entvars_t *)>(hook->func)(pthis, ev1);
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
, iOther
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
|
|
|
CHECK_RETURN()
|
|
|
|
return ret;
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Hook_Int_Entvar_Entvar_Float_Int(Hook *hook, void *pthis, entvars_t *inflictor, entvars_t *attacker, float damage, int damagebits)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
int ret=0;
|
|
|
|
int origret=0;
|
|
|
|
PUSH_INT()
|
2007-05-04 12:51:13 +00:00
|
|
|
int iInflictor=EntvarToIndex(inflictor);
|
|
|
|
int iAttacker=EntvarToIndex(attacker);
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
MAKE_VECTOR()
|
|
|
|
P_ENTVAR(inflictor, iInflictor)
|
|
|
|
P_ENTVAR(attacker, iAttacker)
|
|
|
|
P_FLOAT(damage)
|
|
|
|
P_INT(damagebits)
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
PRE_START()
|
|
|
|
,iInflictor, iAttacker, damage, damagebits
|
|
|
|
PRE_END()
|
|
|
|
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (__fastcall*)(void*, int, entvars_t *, entvars_t *, float, int)>(hook->func)(pthis, 0, inflictor, attacker, damage, damagebits);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (*)(void*, entvars_t *, entvars_t *, float, int)>(hook->func)(pthis, inflictor, attacker, damage, damagebits);
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
,iInflictor, iAttacker, damage, damagebits
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
|
|
|
CHECK_RETURN()
|
|
|
|
return ret;
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
2007-05-12 17:33:58 +00:00
|
|
|
int Hook_Int_Entvar_Entvar_Float_Float_Int(Hook *hook, void *pthis, entvars_t *inflictor, entvars_t *attacker, float damage, float unknown, int damagebits)
|
|
|
|
{
|
|
|
|
int ret=0;
|
|
|
|
int origret=0;
|
|
|
|
PUSH_INT()
|
|
|
|
int iInflictor=EntvarToIndex(inflictor);
|
|
|
|
int iAttacker=EntvarToIndex(attacker);
|
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
P_ENTVAR(inflictor, iInflictor)
|
|
|
|
P_ENTVAR(attacker, iAttacker)
|
|
|
|
P_FLOAT(damage)
|
|
|
|
P_FLOAT(unknown)
|
|
|
|
P_INT(damagebits)
|
|
|
|
|
|
|
|
PRE_START()
|
|
|
|
,iInflictor, iAttacker, damage, unknown, damagebits
|
|
|
|
PRE_END()
|
|
|
|
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-12 17:33:58 +00:00
|
|
|
origret=reinterpret_cast<int (__fastcall*)(void*, int, entvars_t *, entvars_t *, float, float, int)>(hook->func)(pthis, 0, inflictor, attacker, damage, unknown, damagebits);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-12 17:33:58 +00:00
|
|
|
origret=reinterpret_cast<int (*)(void*, entvars_t *, entvars_t *, float, float, int)>(hook->func)(pthis, inflictor, attacker, damage, unknown, damagebits);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
,iInflictor, iAttacker, damage, unknown, damagebits
|
|
|
|
POST_END()
|
|
|
|
|
|
|
|
KILL_VECTOR()
|
|
|
|
POP()
|
|
|
|
CHECK_RETURN()
|
|
|
|
return ret;
|
|
|
|
}
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
void Hook_Void_Int(Hook *hook, void *pthis, int i1)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_VOID()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
P_INT(i1)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
, i1
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, int)>(hook->func)(pthis, 0, i1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (*)(void*, int)>(hook->func)(pthis, i1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
,i1
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hook_Void_Cbase_Cbase_Int_Float(Hook *hook, void *pthis, void *cb1, void *cb2, int i1, float f1)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_VOID()
|
2007-05-04 12:51:13 +00:00
|
|
|
int iCaller=PrivateToIndex(cb1);
|
|
|
|
int iActivator=PrivateToIndex(cb2);
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
MAKE_VECTOR()
|
|
|
|
P_CBASE(cb1, iCaller)
|
|
|
|
P_CBASE(cb2, iActivator)
|
|
|
|
P_INT(i1)
|
|
|
|
P_FLOAT(f1)
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
PRE_START()
|
|
|
|
,iCaller, iActivator, i1, f1
|
|
|
|
PRE_END()
|
|
|
|
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, void *, void *, int, float)>(hook->func)(pthis, 0, cb1, cb2, i1, f1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (*)(void*, void *, void *, int, float)>(hook->func)(pthis, cb1, cb2, i1, f1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
,iCaller, iActivator, i1, f1
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Hook_Void_Entvar_Float_Vector_Trace_Int(Hook *hook, void *pthis, entvars_t *ev1, float f1, Vector v1, TraceResult *tr1, int i1)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_VOID()
|
2007-05-04 12:51:13 +00:00
|
|
|
int iev1=EntvarToIndex(ev1);
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
P_ENTVAR(ev1, iev1)
|
|
|
|
P_FLOAT(f1)
|
|
|
|
P_VECTOR(v1)
|
|
|
|
P_TRACE(tr1)
|
|
|
|
P_INT(i1)
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
PRE_START()
|
2007-05-09 14:58:55 +00:00
|
|
|
,iev1, f1, MF_PrepareCellArrayA(reinterpret_cast<cell *>(&v1), 3, false), tr1, i1
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, entvars_t *, float, Vector, TraceResult *, int)>(hook->func)(pthis, 0, ev1, f1, v1, tr1, i1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (*)(void*, entvars_t *, float, Vector, TraceResult *, int)>(hook->func)(pthis, ev1, f1, v1, tr1, i1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
2007-05-09 14:58:55 +00:00
|
|
|
, iev1, f1, MF_PrepareCellArrayA(reinterpret_cast<cell *>(&v1), 3, false), tr1, i1
|
2007-05-04 12:51:13 +00:00
|
|
|
POST_END()
|
2007-05-08 17:26:51 +00:00
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
2007-05-10 16:08:02 +00:00
|
|
|
void Hook_Void_Float_Vector_Trace_Int(Hook *hook, void *pthis, float f1, Vector v1, TraceResult *tr1, int i1)
|
2007-05-04 12:51:13 +00:00
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_VOID()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
P_FLOAT(f1)
|
|
|
|
P_VECTOR(v1)
|
|
|
|
P_TRACE(tr1)
|
|
|
|
P_INT(i1)
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
PRE_START()
|
2007-05-09 14:58:55 +00:00
|
|
|
, f1, MF_PrepareCellArrayA(reinterpret_cast<cell *>(&v1), 3, false), tr1, i1
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, float, Vector, TraceResult *, int)>(hook->func)(pthis, 0, f1, v1, tr1, i1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (*)(void*, float, Vector, TraceResult *, int)>(hook->func)(pthis, f1, v1, tr1, i1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
2007-05-09 14:58:55 +00:00
|
|
|
, f1, MF_PrepareCellArrayA(reinterpret_cast<cell *>(&v1), 3, false), tr1, i1
|
2007-05-04 12:51:13 +00:00
|
|
|
POST_END()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
const char *Hook_Str_Void(Hook *hook, void *pthis)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
String ret;
|
|
|
|
String origret;
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_STRING()
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret.assign(reinterpret_cast<const char *(__fastcall*)(void*, int)>(hook->func)(pthis, 0));
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret.assign(reinterpret_cast<const char *(*)(void*)>(hook->func)(pthis));
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
|
|
|
CHECK_RETURN_STR();
|
|
|
|
return ret.c_str();
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void *Hook_Cbase_Void(Hook *hook, void *pthis)
|
|
|
|
{
|
|
|
|
void *ret=NULL;
|
2007-05-08 17:26:51 +00:00
|
|
|
void *origret=NULL;
|
|
|
|
PUSH_CBASE()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<void *(__fastcall*)(void*, int)>(hook->func)(pthis, 0);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<void *(*)(void*)>(hook->func)(pthis);
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
|
|
|
CHECK_RETURN()
|
2007-05-04 12:51:13 +00:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-05-12 13:16:05 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
void Hook_Vector_Void(Hook *hook, void *pthis, Vector *out)
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-09 14:58:55 +00:00
|
|
|
void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis)
|
2007-05-12 13:16:05 +00:00
|
|
|
#endif
|
2007-05-04 12:51:13 +00:00
|
|
|
{
|
|
|
|
Vector ret;
|
2007-05-08 17:26:51 +00:00
|
|
|
Vector origret;
|
|
|
|
|
|
|
|
PUSH_VECTOR()
|
2007-05-04 12:51:13 +00:00
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
MAKE_VECTOR()
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
memset(&ret, 0x0, sizeof(Vector));
|
2007-05-08 17:26:51 +00:00
|
|
|
memset(&origret, 0x0, sizeof(Vector));
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
PRE_START()
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-09 14:58:55 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, Vector *)>(hook->func)(pthis, 0, &origret);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-12 17:33:58 +00:00
|
|
|
origret=reinterpret_cast<Vector (*)(void *)>(hook->func)(pthis);
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-09 14:58:55 +00:00
|
|
|
CHECK_RETURN_VEC()
|
|
|
|
memcpy(out, &ret, sizeof(Vector));
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
}
|
2007-05-12 13:16:05 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
void Hook_Vector_pVector(Hook *hook, void *pthis, Vector *out, Vector *v1)
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-09 14:58:55 +00:00
|
|
|
void Hook_Vector_pVector(Hook *hook, Vector *out, void *pthis, Vector *v1)
|
2007-05-12 13:16:05 +00:00
|
|
|
#endif
|
2007-05-04 12:51:13 +00:00
|
|
|
{
|
|
|
|
Vector ret;
|
2007-05-08 17:26:51 +00:00
|
|
|
Vector origret;
|
|
|
|
|
|
|
|
PUSH_VECTOR()
|
2007-05-04 12:51:13 +00:00
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
MAKE_VECTOR()
|
|
|
|
P_PTRVECTOR(v1)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
memset(&ret, 0x0, sizeof(Vector));
|
2007-05-08 17:26:51 +00:00
|
|
|
memset(&origret, 0x0, sizeof(Vector));
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
PRE_START()
|
2007-05-09 14:58:55 +00:00
|
|
|
, MF_PrepareCellArrayA(reinterpret_cast<cell *>(v1), 3, false)
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-09 14:58:55 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, Vector *, Vector *)>(hook->func)(pthis, 0, &origret, v1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-12 17:33:58 +00:00
|
|
|
origret=reinterpret_cast<Vector (*)(void*, Vector *)>(hook->func)(pthis, v1);
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
2007-05-09 14:58:55 +00:00
|
|
|
, MF_PrepareCellArrayA(reinterpret_cast<cell *>(v1), 3, false)
|
2007-05-04 12:51:13 +00:00
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-09 14:58:55 +00:00
|
|
|
CHECK_RETURN_VEC()
|
|
|
|
memcpy(out, &ret, sizeof(Vector));
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int Hook_Int_pVector(Hook *hook, void *pthis, Vector *v1)
|
|
|
|
{
|
|
|
|
int ret=0;
|
2007-05-08 17:26:51 +00:00
|
|
|
int origret=0;
|
|
|
|
PUSH_INT()
|
2007-05-04 12:51:13 +00:00
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
MAKE_VECTOR()
|
|
|
|
P_PTRVECTOR(v1)
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
PRE_START()
|
2007-05-09 14:58:55 +00:00
|
|
|
, MF_PrepareCellArrayA(reinterpret_cast<cell *>(v1), 3, false)
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (__fastcall*)(void*, int, Vector *)>(hook->func)(pthis, 0, v1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (*)(void*, Vector *)>(hook->func)(pthis, v1);
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
2007-05-09 14:58:55 +00:00
|
|
|
, MF_PrepareCellArrayA(reinterpret_cast<cell *>(v1), 3, false)
|
2007-05-04 12:51:13 +00:00
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
|
|
|
CHECK_RETURN()
|
2007-05-04 12:51:13 +00:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hook_Void_Entvar_Float_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1, float f2)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_VOID()
|
2007-05-04 12:51:13 +00:00
|
|
|
cell cev1=EntvarToIndex(ev1);
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
MAKE_VECTOR()
|
|
|
|
P_ENTVAR(ev1, cev1)
|
|
|
|
P_FLOAT(f1)
|
|
|
|
P_FLOAT(f2)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
, cev1, f1, f2
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void *, int, entvars_t *, float, float)>(hook->func)(pthis, 0, ev1, f1, f2);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (*)(void *, entvars_t *, float, float)>(hook->func)(pthis, ev1, f1, f2);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
, cev1, f1, f2
|
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int Hook_Int_pFloat_pFloat(Hook *hook, void *pthis, float *f1, float *f2)
|
|
|
|
{
|
|
|
|
int ret=0;
|
2007-05-08 17:26:51 +00:00
|
|
|
int origret=0;
|
|
|
|
PUSH_INT()
|
2007-05-04 12:51:13 +00:00
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
P_PTRFLOAT(f1)
|
|
|
|
P_PTRFLOAT(f2)
|
2007-05-04 12:51:13 +00:00
|
|
|
|
|
|
|
PRE_START()
|
2007-05-09 14:58:55 +00:00
|
|
|
, f1 != NULL ? *f1 : 0, f2 != NULL ? *f2 : 0
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (__fastcall*)(void *, int, float *, float *)>(hook->func)(pthis, 0, f1, f2);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-08 17:26:51 +00:00
|
|
|
origret=reinterpret_cast<int (*)(void *, float *, float *)>(hook->func)(pthis, f1, f2);
|
2007-05-04 12:51:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
2007-05-09 14:58:55 +00:00
|
|
|
, f1 != NULL ? *f1 : 0, f2 != NULL ? *f2 : 0
|
2007-05-04 12:51:13 +00:00
|
|
|
POST_END()
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
|
|
|
CHECK_RETURN()
|
2007-05-04 12:51:13 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Hook_Void_Entvar_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1)
|
|
|
|
{
|
2007-05-08 17:26:51 +00:00
|
|
|
PUSH_VOID()
|
2007-05-04 12:51:13 +00:00
|
|
|
cell cev1=EntvarToIndex(ev1);
|
|
|
|
|
2007-05-09 14:58:55 +00:00
|
|
|
MAKE_VECTOR()
|
|
|
|
P_ENTVAR(ev1, cev1)
|
|
|
|
P_FLOAT(f1)
|
|
|
|
|
2007-05-04 12:51:13 +00:00
|
|
|
PRE_START()
|
|
|
|
, cev1, f1
|
|
|
|
PRE_END()
|
|
|
|
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void *, int, entvars_t *, float)>(hook->func)(pthis, 0, ev1, f1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-04 12:51:13 +00:00
|
|
|
reinterpret_cast<void (*)(void *, entvars_t *, float)>(hook->func)(pthis, ev1, f1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
, cev1, f1
|
|
|
|
POST_END()
|
2007-05-09 14:58:55 +00:00
|
|
|
|
|
|
|
KILL_VECTOR()
|
2007-05-08 17:26:51 +00:00
|
|
|
POP()
|
2007-05-04 12:51:13 +00:00
|
|
|
}
|
|
|
|
|
2007-05-10 16:08:02 +00:00
|
|
|
void Hook_Void_Int_Int_Int(Hook *hook, void *pthis, int i1, int i2, int i3)
|
|
|
|
{
|
|
|
|
PUSH_VOID()
|
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
|
|
|
|
P_INT(i1)
|
|
|
|
P_INT(i2)
|
|
|
|
P_INT(i3)
|
|
|
|
|
|
|
|
PRE_START()
|
|
|
|
,i1, i2, i3
|
|
|
|
PRE_END()
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-10 16:08:02 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, int, int, int)>(hook->func)(pthis, 0, i1, i2, i3);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-10 16:08:02 +00:00
|
|
|
reinterpret_cast<void (*)(void*, int, int, int)>(hook->func)(pthis, i1, i2, i3);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
,i1, i2, i3
|
|
|
|
POST_END()
|
|
|
|
|
|
|
|
KILL_VECTOR()
|
|
|
|
POP()
|
|
|
|
}
|
|
|
|
void Hook_Void_ItemInfo(Hook *hook, void *pthis, void *iteminfo)
|
|
|
|
{
|
|
|
|
PUSH_VOID()
|
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
|
|
|
|
P_ITEMINFO(iteminfo)
|
|
|
|
|
|
|
|
PRE_START()
|
|
|
|
,iteminfo
|
|
|
|
PRE_END()
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-10 16:08:02 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, void *)>(hook->func)(pthis, 0, iteminfo);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-10 16:08:02 +00:00
|
|
|
reinterpret_cast<void (*)(void*, void *)>(hook->func)(pthis, iteminfo);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
,iteminfo
|
|
|
|
POST_END()
|
|
|
|
|
|
|
|
KILL_VECTOR()
|
|
|
|
POP()
|
|
|
|
}
|
2007-05-16 03:57:18 +00:00
|
|
|
|
|
|
|
float Hook_Float_Void(Hook *hook, void *pthis)
|
|
|
|
{
|
|
|
|
float ret=0.0;
|
|
|
|
float origret=0.0;
|
|
|
|
PUSH_FLOAT()
|
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
|
|
|
|
PRE_START()
|
|
|
|
PRE_END()
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-05-16 03:57:18 +00:00
|
|
|
origret=reinterpret_cast<float (__fastcall*)(void*, int)>(hook->func)(pthis, 0);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-05-16 03:57:18 +00:00
|
|
|
origret=reinterpret_cast<float (*)(void*)>(hook->func)(pthis);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
POST_END()
|
|
|
|
|
|
|
|
KILL_VECTOR()
|
|
|
|
POP()
|
|
|
|
|
|
|
|
CHECK_RETURN()
|
|
|
|
return ret;
|
|
|
|
}
|
2007-07-19 18:43:27 +00:00
|
|
|
void Hook_Void_Float_Int(Hook* hook, void* pthis, float f1, int i1)
|
|
|
|
{
|
|
|
|
PUSH_VOID()
|
|
|
|
|
|
|
|
MAKE_VECTOR()
|
|
|
|
P_FLOAT(f1)
|
|
|
|
P_INT(i1)
|
|
|
|
|
|
|
|
PRE_START()
|
|
|
|
, f1, i1
|
|
|
|
PRE_END()
|
2013-02-13 07:14:37 +00:00
|
|
|
#if defined(_WIN32)
|
2007-07-19 18:43:27 +00:00
|
|
|
reinterpret_cast<void (__fastcall*)(void*, int, float, int)>(hook->func)(pthis, 0, f1, i1);
|
2013-02-13 07:14:37 +00:00
|
|
|
#elif defined(__linux__) || defined(__APPLE__)
|
2007-07-19 18:43:27 +00:00
|
|
|
reinterpret_cast<void (*)(void*, float, int)>(hook->func)(pthis, f1, i1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
POST_START()
|
|
|
|
, f1, i1
|
|
|
|
POST_END()
|
|
|
|
|
|
|
|
KILL_VECTOR()
|
|
|
|
POP()
|
|
|
|
}
|
|
|
|
void Hook_Deprecated(Hook* hook)
|
|
|
|
{
|
|
|
|
}
|