mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-01-27 14:08:00 +03:00
Implemented features of priority for hookchains
This commit is contained in:
parent
7238f215e2
commit
e50cfe32c6
@ -40,7 +40,7 @@ DLL_FUNCTIONS gFunctionTable =
|
||||
&SpectatorConnect,
|
||||
&SpectatorDisconnect,
|
||||
&SpectatorThink,
|
||||
&Sys_Error,
|
||||
&SysEngine_Error,
|
||||
&PM_Move,
|
||||
&PM_Init,
|
||||
&PM_FindTextureType,
|
||||
|
@ -3986,7 +3986,7 @@ const char *EXT_FUNC GetGameDescription()
|
||||
return "Counter-Strike";
|
||||
}
|
||||
|
||||
void EXT_FUNC Sys_Error(const char *error_string)
|
||||
void EXT_FUNC SysEngine_Error(const char *error_string)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ void ParmsChangeLevel();
|
||||
void StartFrame();
|
||||
void ClientPrecache();
|
||||
const char *GetGameDescription();
|
||||
void Sys_Error(const char *error_string);
|
||||
void SysEngine_Error(const char *error_string);
|
||||
void PlayerCustomization(edict_t *pEntity, customization_t *pCust);
|
||||
void SpectatorConnect(edict_t *pEntity);
|
||||
void SpectatorDisconnect(edict_t *pEntity);
|
||||
|
@ -2455,3 +2455,19 @@ void MAKE_STRING_CLASS(const char *str, entvars_t *pev)
|
||||
pev->classname = MAKE_STRING(str);
|
||||
AddEntityHashValue(pev, STRING(pev->classname), CLASSNAME);
|
||||
}
|
||||
|
||||
void NORETURN Sys_Error(const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char text[1024];
|
||||
|
||||
va_start(argptr, error);
|
||||
vsnprintf(text, sizeof(text), error, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
CONSOLE_ECHO("FATAL ERROR (shutting down): %s\n", text);
|
||||
|
||||
//TerminateProcess(GetCurrentProcess(), 1);
|
||||
*((int *)NULL) = 0;
|
||||
while (true);
|
||||
}
|
||||
|
@ -337,6 +337,7 @@ int UTIL_ReadFlags(const char *c);
|
||||
bool UTIL_AreBotsAllowed();
|
||||
bool UTIL_AreHostagesImprov();
|
||||
void MAKE_STRING_CLASS(const char *str, entvars_t *pev);
|
||||
void NORETURN Sys_Error(const char *error, ...);
|
||||
|
||||
extern int g_groupmask;
|
||||
extern int g_groupop;
|
||||
|
@ -103,6 +103,7 @@
|
||||
#define HIDDEN
|
||||
#define NOINLINE __declspec(noinline)
|
||||
#define ALIGN16 __declspec(align(16))
|
||||
#define NORETURN __declspec(noreturn)
|
||||
#define FORCE_STACK_ALIGN
|
||||
|
||||
//inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctlsocket(s, FIONBIO, (u_long*)&m) == 0); }
|
||||
@ -148,6 +149,7 @@
|
||||
#define HIDDEN __attribute__((visibility("hidden")))
|
||||
#define NOINLINE __attribute__((noinline))
|
||||
#define ALIGN16 __attribute__((aligned(16)))
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#define FORCE_STACK_ALIGN __attribute__((force_align_arg_pointer))
|
||||
|
||||
//inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctl(s, FIONBIO, (int*)&m) == 0); }
|
||||
@ -189,6 +191,4 @@
|
||||
|
||||
#define EXT_FUNC FORCE_STACK_ALIGN
|
||||
|
||||
extern void __declspec(noreturn) rehlds_syserror(const char* fmt, ...);
|
||||
|
||||
#endif // _OSCONFIG_H
|
||||
|
@ -69,13 +69,24 @@ public:
|
||||
virtual void callOriginal(t_class *, t_args... args) = 0;
|
||||
};
|
||||
|
||||
// Specifies priorities for hooks call order in the chain.
|
||||
// For equal priorities first registered hook will be called first.
|
||||
enum HookChainPriority
|
||||
{
|
||||
HC_PRIORITY_UNINTERRUPTABLE = 255, // Hook will be called before other hooks.
|
||||
HC_PRIORITY_HIGH = 192, // Hook will be called before hooks with default priority.
|
||||
HC_PRIORITY_DEFAULT = 128, // Default hook call priority.
|
||||
HC_PRIORITY_MEDIUM = 64, // Hook will be called after hooks with default priority.
|
||||
HC_PRIORITY_LOW = 0, // Hook will be called after all other hooks.
|
||||
};
|
||||
|
||||
// Hook chain registry(for hooks [un]registration)
|
||||
template<typename t_ret, typename ...t_args>
|
||||
class IHookChainRegistry {
|
||||
public:
|
||||
typedef t_ret(*hookfunc_t)(IHookChain<t_ret, t_args...>*, t_args...);
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) = 0;
|
||||
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
|
||||
virtual void unregisterHook(hookfunc_t hook) = 0;
|
||||
};
|
||||
|
||||
@ -85,7 +96,7 @@ class IHookChainRegistryClass {
|
||||
public:
|
||||
typedef t_ret(*hookfunc_t)(IHookChainClass<t_ret, t_class, t_args...>*, t_class *, t_args...);
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) = 0;
|
||||
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
|
||||
virtual void unregisterHook(hookfunc_t hook) = 0;
|
||||
};
|
||||
|
||||
@ -95,7 +106,7 @@ class IVoidHookChainRegistry {
|
||||
public:
|
||||
typedef void(*hookfunc_t)(IVoidHookChain<t_args...>*, t_args...);
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) = 0;
|
||||
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
|
||||
virtual void unregisterHook(hookfunc_t hook) = 0;
|
||||
};
|
||||
|
||||
@ -105,6 +116,6 @@ class IVoidHookChainRegistryClass {
|
||||
public:
|
||||
typedef void(*hookfunc_t)(IVoidHookChainClass<t_class, t_args...>*, t_class *, t_args...);
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) = 0;
|
||||
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
|
||||
virtual void unregisterHook(hookfunc_t hook) = 0;
|
||||
};
|
||||
|
@ -35,8 +35,8 @@
|
||||
#include "client.h"
|
||||
#include "items.h"
|
||||
|
||||
#define REGAMEDLL_API_VERSION_MAJOR 4
|
||||
#define REGAMEDLL_API_VERSION_MINOR 2
|
||||
#define REGAMEDLL_API_VERSION_MAJOR 5
|
||||
#define REGAMEDLL_API_VERSION_MINOR 0
|
||||
|
||||
// CBasePlayer::Spawn hook
|
||||
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
|
||||
|
@ -27,46 +27,47 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define BSPVERSION 30
|
||||
// header
|
||||
#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28)
|
||||
#define HLBSP_VERSION 30 // half-life regular version
|
||||
|
||||
#define MAX_MAP_HULLS 4
|
||||
|
||||
#define CONTENTS_ORIGIN -7 // removed at csg time
|
||||
#define CONTENTS_CLIP -8 // changed to contents_solid
|
||||
#define CONTENTS_CURRENT_0 -9
|
||||
#define CONTENTS_CURRENT_90 -10
|
||||
#define CONTENTS_CURRENT_0 -9
|
||||
#define CONTENTS_CURRENT_90 -10
|
||||
#define CONTENTS_CURRENT_180 -11
|
||||
#define CONTENTS_CURRENT_270 -12
|
||||
#define CONTENTS_CURRENT_UP -13
|
||||
#define CONTENTS_CURRENT_UP -13
|
||||
#define CONTENTS_CURRENT_DOWN -14
|
||||
|
||||
#define CONTENTS_TRANSLUCENT -15
|
||||
|
||||
#define LUMP_ENTITIES 0
|
||||
#define LUMP_ENTITIES 0
|
||||
#define LUMP_PLANES 1
|
||||
#define LUMP_TEXTURES 2
|
||||
#define LUMP_VERTEXES 3
|
||||
#define LUMP_VISIBILITY 4
|
||||
#define LUMP_TEXTURES 2
|
||||
#define LUMP_VERTEXES 3
|
||||
#define LUMP_VISIBILITY 4
|
||||
#define LUMP_NODES 5
|
||||
#define LUMP_TEXINFO 6
|
||||
#define LUMP_TEXINFO 6
|
||||
#define LUMP_FACES 7
|
||||
#define LUMP_LIGHTING 8
|
||||
#define LUMP_CLIPNODES 9
|
||||
#define LUMP_LIGHTING 8
|
||||
#define LUMP_CLIPNODES 9
|
||||
#define LUMP_LEAFS 10
|
||||
#define LUMP_MARKSURFACES 11
|
||||
#define LUMP_MARKSURFACES 11
|
||||
#define LUMP_EDGES 12
|
||||
#define LUMP_SURFEDGES 13
|
||||
#define LUMP_SURFEDGES 13
|
||||
#define LUMP_MODELS 14
|
||||
|
||||
#define HEADER_LUMPS 15
|
||||
#define HEADER_LUMPS 15
|
||||
|
||||
/* <a1fc> ../engine/bspfile.h:41 */
|
||||
typedef struct lump_s
|
||||
typedef struct lump_s
|
||||
{
|
||||
int fileofs;
|
||||
int filelen;
|
||||
} lump_t;
|
||||
|
||||
/* <a22c> ../engine/bspfile.h:64 */
|
||||
typedef struct dmodel_s
|
||||
{
|
||||
float mins[3], maxs[3];
|
||||
@ -76,21 +77,18 @@ typedef struct dmodel_s
|
||||
int firstface, numfaces;
|
||||
} dmodel_t;
|
||||
|
||||
/* <a2c2> ../engine/bspfile.h:73 */
|
||||
typedef struct dheader_s
|
||||
{
|
||||
int version;
|
||||
lump_t lumps[15];
|
||||
} dheader_t;
|
||||
|
||||
/* <485b2> ../engine/bspfile.h:79 */
|
||||
typedef struct dmiptexlump_s
|
||||
{
|
||||
int _nummiptex;
|
||||
int dataofs[4];
|
||||
} dmiptexlump_t;
|
||||
|
||||
/* <1ce18> ../engine/bspfile.h:86 */
|
||||
typedef struct miptex_s
|
||||
{
|
||||
char name[16];
|
||||
@ -99,13 +97,11 @@ typedef struct miptex_s
|
||||
unsigned offsets[4];
|
||||
} miptex_t;
|
||||
|
||||
/* <48652> ../engine/bspfile.h:94 */
|
||||
typedef struct dvertex_s
|
||||
{
|
||||
float point[3];
|
||||
} dvertex_t;
|
||||
|
||||
/* <48674> ../engine/bspfile.h:110 */
|
||||
typedef struct dplane_s
|
||||
{
|
||||
float normal[3];
|
||||
@ -113,7 +109,6 @@ typedef struct dplane_s
|
||||
int type;
|
||||
} dplane_t;
|
||||
|
||||
/* <486b2> ../engine/bspfile.h:132 */
|
||||
typedef struct dnode_s
|
||||
{
|
||||
int planenum;
|
||||
@ -124,14 +119,12 @@ typedef struct dnode_s
|
||||
unsigned short numfaces;
|
||||
} dnode_t;
|
||||
|
||||
/* <a332> ../engine/bspfile.h:142 */
|
||||
typedef struct dclipnode_s
|
||||
{
|
||||
int planenum;
|
||||
short children[2]; // negative numbers are contents
|
||||
} dclipnode_t;
|
||||
|
||||
/* <4876a> ../engine/bspfile.h:149 */
|
||||
typedef struct texinfo_s
|
||||
{
|
||||
float vecs[2][4];
|
||||
@ -139,13 +132,11 @@ typedef struct texinfo_s
|
||||
int flags;
|
||||
} texinfo_t;
|
||||
|
||||
/* <487c2> ../engine/bspfile.h:159 */
|
||||
typedef struct dedge_s
|
||||
{
|
||||
unsigned short v[2];
|
||||
} dedge_t;
|
||||
|
||||
/* <487f2> ../engine/bspfile.h:165 */
|
||||
typedef struct dface_s
|
||||
{
|
||||
short planenum;
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "archtypes.h"
|
||||
|
||||
typedef void(*xcommand_t)(void);
|
||||
|
||||
typedef struct cmd_function_s
|
||||
{
|
||||
struct cmd_function_s *next;
|
||||
|
@ -25,22 +25,27 @@
|
||||
* version.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "const.h"
|
||||
#include "qlimits.h"
|
||||
|
||||
#ifdef REHLDS_FIXES
|
||||
#define COM_TOKEN_LEN 2048
|
||||
#else
|
||||
#define COM_TOKEN_LEN 1024
|
||||
#endif
|
||||
|
||||
// Don't allow overflow
|
||||
#define SIZEBUF_CHECK_OVERFLOW 0
|
||||
#define SIZEBUF_ALLOW_OVERFLOW BIT(0)
|
||||
#define SIZEBUF_CHECK_OVERFLOW 0
|
||||
#define SIZEBUF_ALLOW_OVERFLOW BIT(0)
|
||||
#define SIZEBUF_OVERFLOWED BIT(1)
|
||||
|
||||
#define MAX_NUM_ARGVS 50
|
||||
#define NUM_SAFE_ARGVS 7
|
||||
#define MAX_NUM_ARGVS 50
|
||||
#define NUM_SAFE_ARGVS 7
|
||||
|
||||
#define COM_COPY_CHUNK_SIZE 1024
|
||||
#define COM_MAX_CMD_LINE 256
|
||||
#define COM_COPY_CHUNK_SIZE 1024
|
||||
#define COM_MAX_CMD_LINE 256
|
||||
|
||||
typedef struct sizebuf_s
|
||||
{
|
||||
|
@ -28,19 +28,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
/* <82286> ../engine/d_local.h:20 */
|
||||
typedef struct surfcache_s
|
||||
{
|
||||
struct surfcache_s *next;
|
||||
struct surfcache_s **owner;
|
||||
int lightadj[4];
|
||||
int dlight;
|
||||
int size;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
float mipscale;
|
||||
int lightadj[4];
|
||||
int dlight;
|
||||
int size;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
float mipscale;
|
||||
struct texture_s *texture;
|
||||
unsigned char data[4];
|
||||
unsigned char data[4];
|
||||
} surfcache_t;
|
||||
|
@ -94,7 +94,7 @@ typedef struct
|
||||
int fEnabled;
|
||||
int fPlayLooping;
|
||||
float cdvolume;
|
||||
//byte remap[100];
|
||||
//BYTE remap[100];
|
||||
int fCDRom;
|
||||
int fPlayTrack;
|
||||
} CDStatus;
|
||||
|
@ -33,14 +33,21 @@
|
||||
#include "bspfile.h"
|
||||
#include "crc.h"
|
||||
#include "com_model.h"
|
||||
#include "commonmacros.h"
|
||||
|
||||
#define SURF_PLANEBACK 2
|
||||
#define SURF_DRAWSKY 4
|
||||
// header
|
||||
#define ALIAS_MODEL_VERSION 0x006
|
||||
#define IDPOLYHEADER MAKEID('I', 'D', 'P', 'O') // little-endian "IDPO"
|
||||
|
||||
#define MAX_LBM_HEIGHT 480
|
||||
#define MAX_ALIAS_MODEL_VERTS 2000
|
||||
|
||||
#define SURF_PLANEBACK 2
|
||||
#define SURF_DRAWSKY 4
|
||||
#define SURF_DRAWSPRITE 8
|
||||
#define SURF_DRAWTURB 0x10
|
||||
#define SURF_DRAWTILED 0x20
|
||||
#define SURF_DRAWBACKGROUND 0x40
|
||||
#define ALIAS_MODEL_VERSION 0x006
|
||||
#define SURF_DRAWBACKGROUND 0x40
|
||||
|
||||
#define MAX_MODEL_NAME 64
|
||||
#define MIPLEVELS 4
|
||||
@ -48,13 +55,11 @@
|
||||
#define MAXLIGHTMAPS 4
|
||||
#define MAX_KNOWN_MODELS 1024
|
||||
|
||||
/* <6816> ../engine/model.h:27 */
|
||||
typedef struct mvertex_s
|
||||
{
|
||||
vec3_t position;
|
||||
} mvertex_t;
|
||||
|
||||
/* <6838> ../engine/model.h:39 */
|
||||
typedef struct mplane_s
|
||||
{
|
||||
vec3_t normal; // surface normal
|
||||
@ -64,30 +69,39 @@ typedef struct mplane_s
|
||||
byte pad[2];
|
||||
} mplane_t;
|
||||
|
||||
/* <68a6> ../engine/model.h:48 */
|
||||
typedef struct texture_s
|
||||
{
|
||||
char name[16];
|
||||
unsigned width, height;
|
||||
|
||||
#ifndef SWDS
|
||||
int gl_texturenum;
|
||||
struct msurface_s * texturechain;
|
||||
#endif
|
||||
|
||||
int anim_total; // total tenths in sequence ( 0 = no)
|
||||
int anim_min, anim_max; // time for this frame min <=time< max
|
||||
struct texture_s *anim_next; // in the animation sequence
|
||||
struct texture_s *alternate_anims; // bmodels in frame 1 use these
|
||||
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
||||
|
||||
#ifdef SWDS
|
||||
unsigned paloffset;
|
||||
#else
|
||||
byte *pPal;
|
||||
#endif
|
||||
|
||||
} texture_t;
|
||||
|
||||
/* <6950> ../engine/model.h:71 */
|
||||
typedef struct medge_s
|
||||
{
|
||||
unsigned short v[2];
|
||||
unsigned int cachededgeoffset;
|
||||
} medge_t;
|
||||
|
||||
/* <697e> ../engine/model.h:78 */
|
||||
typedef struct mtexinfo_s
|
||||
{
|
||||
float vecs[2][4]; // [s/t] unit vectors in world space.
|
||||
float vecs[2][4]; // [s/t] unit vectors in world space.
|
||||
// [i][3] is the s/t offset relative to the origin.
|
||||
// s or t = dot(3Dpoint,vecs[i])+vecs[i][3]
|
||||
float mipadjust; // ?? mipmap limits for very small surfaces
|
||||
@ -96,13 +110,10 @@ typedef struct mtexinfo_s
|
||||
} mtexinfo_t;
|
||||
#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision
|
||||
|
||||
/* <69d0> ../engine/model.h:91 */
|
||||
typedef struct msurface_s msurface_t;
|
||||
/* <1db66> ../engine/model.h:92 */
|
||||
typedef struct decal_s decal_t;
|
||||
|
||||
// JAY: Compress this as much as possible
|
||||
/* <1db71> ../engine/model.h:96 */
|
||||
struct decal_s
|
||||
{
|
||||
decal_t *pnext; // linked list for each surface
|
||||
@ -116,7 +127,6 @@ struct decal_s
|
||||
short entityIndex; // Entity this is attached to
|
||||
};
|
||||
|
||||
/* <69db> ../engine/model.h:118 */
|
||||
struct msurface_s
|
||||
{
|
||||
int visframe; // should be drawn when node is crossed
|
||||
@ -148,7 +158,6 @@ struct msurface_s
|
||||
decal_t *pdecals;
|
||||
};
|
||||
|
||||
/* <6b6c> ../engine/model.h:149 */
|
||||
typedef struct mnode_s
|
||||
{
|
||||
// common with leaf
|
||||
@ -167,7 +176,6 @@ typedef struct mnode_s
|
||||
unsigned short numsurfaces;
|
||||
} mnode_t;
|
||||
|
||||
/* <1dcd4> ../engine/model.h:169 */
|
||||
typedef struct mleaf_s
|
||||
{
|
||||
// common with node
|
||||
@ -188,7 +196,6 @@ typedef struct mleaf_s
|
||||
byte ambient_sound_level[NUM_AMBIENTS];
|
||||
} mleaf_t;
|
||||
|
||||
/* <1ddbe> ../engine/model.h:190 */
|
||||
typedef struct hull_s
|
||||
{
|
||||
dclipnode_t *clipnodes;
|
||||
@ -198,7 +205,6 @@ typedef struct hull_s
|
||||
vec3_t clip_mins, clip_maxs;
|
||||
} hull_t;
|
||||
|
||||
/* <4b3fe> ../engine/model.h:210 */
|
||||
typedef struct mspriteframe_t
|
||||
{
|
||||
int width;
|
||||
@ -208,7 +214,6 @@ typedef struct mspriteframe_t
|
||||
byte pixels[4];
|
||||
} mspriteframe_s;
|
||||
|
||||
/* <4b485> ../engine/model.h:219 */
|
||||
typedef struct mspritegroup_s
|
||||
{
|
||||
int numframes;
|
||||
@ -216,14 +221,12 @@ typedef struct mspritegroup_s
|
||||
mspriteframe_t *frames[1];
|
||||
} mspritegroup_t;
|
||||
|
||||
/* <4b4df> ../engine/model.h:226 */
|
||||
typedef struct mspriteframedesc_s
|
||||
{
|
||||
spriteframetype_t type;
|
||||
mspriteframe_t *frameptr;
|
||||
} mspriteframedesc_t;
|
||||
|
||||
/* <4b50f> ../engine/model.h:232 */
|
||||
typedef struct msprite_s
|
||||
{
|
||||
short int type;
|
||||
@ -236,7 +239,6 @@ typedef struct msprite_s
|
||||
mspriteframedesc_t frames[1];
|
||||
} msprite_t;
|
||||
|
||||
/* <4b5b5> ../engine/model.h:255 */
|
||||
typedef struct maliasframedesc_s
|
||||
{
|
||||
aliasframetype_t type;
|
||||
@ -245,7 +247,6 @@ typedef struct maliasframedesc_s
|
||||
char name[16];
|
||||
} maliasframedesc_t;
|
||||
|
||||
/* <4b615> ../engine/model.h:264 */
|
||||
typedef struct maliasskindesc_s
|
||||
{
|
||||
aliasskintype_t type;
|
||||
@ -253,14 +254,12 @@ typedef struct maliasskindesc_s
|
||||
int skin;
|
||||
} maliasskindesc_t;
|
||||
|
||||
/* <4b658> ../engine/model.h:271 */
|
||||
typedef struct maliasgroupframedesc_s
|
||||
{
|
||||
trivertx_t bboxmin, bboxmax;
|
||||
int frame;
|
||||
} maliasgroupframedesc_t;
|
||||
|
||||
/* <4b69b> ../engine/model.h:278 */
|
||||
typedef struct maliasgroup_s
|
||||
{
|
||||
int numframes;
|
||||
@ -268,7 +267,6 @@ typedef struct maliasgroup_s
|
||||
maliasgroupframedesc_t frames[1];
|
||||
} maliasgroup_t;
|
||||
|
||||
/* <4b6ee> ../engine/model.h:285 */
|
||||
typedef struct maliasskingroup_s
|
||||
{
|
||||
int numskins;
|
||||
@ -276,14 +274,12 @@ typedef struct maliasskingroup_s
|
||||
maliasskindesc_t skindescs[1];
|
||||
} maliasskingroup_t;
|
||||
|
||||
/* <4b741> ../engine/model.h:293 */
|
||||
typedef struct mtriangle_s
|
||||
{
|
||||
int facesfront;
|
||||
int vertindex[3];
|
||||
} mtriangle_t;
|
||||
|
||||
/* <4b779> ../engine/model.h:298 */
|
||||
typedef struct aliashdr_s
|
||||
{
|
||||
int model;
|
||||
@ -294,23 +290,21 @@ typedef struct aliashdr_s
|
||||
maliasframedesc_t frames[1];
|
||||
} aliashdr_t;
|
||||
|
||||
/* <1de30> ../engine/model.h:315 */
|
||||
typedef enum modtype_e
|
||||
{
|
||||
mod_bad = -1,
|
||||
mod_brush,
|
||||
mod_sprite,
|
||||
mod_alias,
|
||||
mod_studio,
|
||||
} modtype_t;
|
||||
|
||||
/* <1de5e> ../engine/model.h:331 */
|
||||
typedef struct model_s
|
||||
{
|
||||
char name[MAX_MODEL_NAME];
|
||||
|
||||
//TODO: qboolean? seriously?
|
||||
int needload; // bmodels and sprites don't cache normally
|
||||
|
||||
|
||||
modtype_t type;
|
||||
int numframes;
|
||||
synctype_t synctype;
|
||||
|
@ -32,30 +32,24 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
/* <67f6> ../engine/modelgen.h:37 */
|
||||
typedef enum synctype_e
|
||||
{
|
||||
ST_SYNC = 0,
|
||||
ST_RAND = 1,
|
||||
} synctype_t;
|
||||
|
||||
/* <4abae> ../engine/modelgen.h:40 */
|
||||
typedef enum aliasframetype_s
|
||||
{
|
||||
ALIAS_SINGLE = 0,
|
||||
ALIAS_GROUP = 1,
|
||||
} aliasframetype_t;
|
||||
|
||||
/* 203 */
|
||||
/* <4abce> ../engine/modelgen.h:42 */
|
||||
typedef enum aliasskintype_s
|
||||
{
|
||||
ALIAS_SKIN_SINGLE = 0,
|
||||
ALIAS_SKIN_GROUP = 1,
|
||||
} aliasskintype_t;
|
||||
|
||||
/* <4abee> ../engine/modelgen.h:44 */
|
||||
typedef struct mdl_s
|
||||
{
|
||||
int ident;
|
||||
@ -75,7 +69,6 @@ typedef struct mdl_s
|
||||
float size;
|
||||
} mdl_t;
|
||||
|
||||
/* <4acd4> ../engine/modelgen.h:64 */
|
||||
typedef struct stvert_s
|
||||
{
|
||||
int onseam;
|
||||
@ -83,59 +76,50 @@ typedef struct stvert_s
|
||||
int t;
|
||||
} stvert_t;
|
||||
|
||||
/* <4ad0e> ../engine/modelgen.h:70 */
|
||||
typedef struct dtriangle_s
|
||||
{
|
||||
int facesfront;
|
||||
int vertindex[3];
|
||||
} dtriangle_t;
|
||||
|
||||
/* <4ad42> ../engine/modelgen.h:80 */
|
||||
typedef struct trivertx_s
|
||||
{
|
||||
byte v[3];
|
||||
byte lightnormalindex;
|
||||
} trivertx_t;
|
||||
|
||||
/* <4ad80> ../engine/modelgen.h:85 */
|
||||
typedef struct daliasframe_s
|
||||
{
|
||||
trivertx_t bboxmin, bboxmax;
|
||||
char name[16];
|
||||
} daliasframe_t;
|
||||
|
||||
/* <4adbe> ../engine/modelgen.h:91 */
|
||||
typedef struct daliasgroup_s
|
||||
{
|
||||
int numframes;
|
||||
trivertx_t bboxmin, bboxmax;
|
||||
} daliasgroup_t;
|
||||
|
||||
/* <4adfc> ../engine/modelgen.h:97 */
|
||||
typedef struct daliasskingroup_s
|
||||
{
|
||||
int numskins;
|
||||
} daliasskingroup_t;
|
||||
|
||||
/* <4ae1e> ../engine/modelgen.h:101 */
|
||||
typedef struct daliasinterval_s
|
||||
{
|
||||
float interval;
|
||||
} daliasinterval_t;
|
||||
|
||||
/* <4ae40> ../engine/modelgen.h:105 */
|
||||
typedef struct daliasskininterval_s
|
||||
{
|
||||
float interval;
|
||||
} daliasskininterval_t;
|
||||
|
||||
/* <4ae62> ../engine/modelgen.h:109 */
|
||||
typedef struct daliasframetype_s
|
||||
{
|
||||
aliasframetype_t type;
|
||||
} daliasframetype_t;
|
||||
|
||||
/* <4ae84> ../engine/modelgen.h:113 */
|
||||
typedef struct daliasskintype_s
|
||||
{
|
||||
aliasskintype_t type;
|
||||
|
@ -103,6 +103,7 @@
|
||||
#define HIDDEN
|
||||
#define NOINLINE __declspec(noinline)
|
||||
#define ALIGN16 __declspec(align(16))
|
||||
#define NORETURN __declspec(noreturn)
|
||||
#define FORCE_STACK_ALIGN
|
||||
|
||||
//inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctlsocket(s, FIONBIO, (u_long*)&m) == 0); }
|
||||
@ -148,6 +149,7 @@
|
||||
#define HIDDEN __attribute__((visibility("hidden")))
|
||||
#define NOINLINE __attribute__((noinline))
|
||||
#define ALIGN16 __attribute__((aligned(16)))
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#define FORCE_STACK_ALIGN __attribute__((force_align_arg_pointer))
|
||||
|
||||
//inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctl(s, FIONBIO, (int*)&m) == 0); }
|
||||
@ -189,6 +191,4 @@
|
||||
|
||||
#define EXT_FUNC FORCE_STACK_ALIGN
|
||||
|
||||
extern void __declspec(noreturn) rehlds_syserror(const char* fmt, ...);
|
||||
|
||||
#endif // _OSCONFIG_H
|
||||
|
@ -34,8 +34,8 @@
|
||||
#include "interface.h"
|
||||
#include "model.h"
|
||||
|
||||
#define REHLDS_API_VERSION_MAJOR 2
|
||||
#define REHLDS_API_VERSION_MINOR 13
|
||||
#define REHLDS_API_VERSION_MAJOR 3
|
||||
#define REHLDS_API_VERSION_MINOR 0
|
||||
|
||||
//Steam_NotifyClientConnect hook
|
||||
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
|
||||
@ -122,8 +122,8 @@ typedef IVoidHookChain<IGameClient *, struct packet_entities_s *, sizebuf_t *> I
|
||||
typedef IVoidHookChainRegistry<IGameClient *, struct packet_entities_s *, sizebuf_t *> IRehldsHookRegistry_SV_EmitEvents;
|
||||
|
||||
//EV_PlayReliableEvent hook
|
||||
typedef IVoidHookChain<IGameClient *, int, short unsigned int, float, struct event_args_s *> IRehldsHook_EV_PlayReliableEvent;
|
||||
typedef IVoidHookChainRegistry<IGameClient *, int, short unsigned int, float, struct event_args_s *> IRehldsHookRegistry_EV_PlayReliableEvent;
|
||||
typedef IVoidHookChain<IGameClient *, int, unsigned short, float, struct event_args_s *> IRehldsHook_EV_PlayReliableEvent;
|
||||
typedef IVoidHookChainRegistry<IGameClient *, int, unsigned short, float, struct event_args_s *> IRehldsHookRegistry_EV_PlayReliableEvent;
|
||||
|
||||
//SV_StartSound hook
|
||||
typedef IVoidHookChain<int , edict_t *, int, const char *, int, float, int, int> IRehldsHook_SV_StartSound;
|
||||
@ -257,7 +257,7 @@ struct RehldsFuncs_t {
|
||||
cmd_source_t*(*GetCmdSource)();
|
||||
void(*Log)(const char* prefix, const char* msg);
|
||||
DLL_FUNCTIONS *(*GetEntityInterface)();
|
||||
void(*EV_PlayReliableEvent)(IGameClient *cl, int entindex, short unsigned int eventindex, float delay, struct event_args_s *pargs);
|
||||
void(*EV_PlayReliableEvent)(IGameClient *cl, int entindex, unsigned short eventindex, float delay, struct event_args_s *pargs);
|
||||
int(*SV_LookupSoundIndex)(const char *sample);
|
||||
void(*MSG_StartBitWriting)(sizebuf_t *buf);
|
||||
void(*MSG_WriteBits)(uint32 data, int numbits);
|
||||
@ -280,7 +280,8 @@ struct RehldsFuncs_t {
|
||||
void(*Steam_NotifyClientDisconnect)(IGameClient* cl);
|
||||
void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch);
|
||||
bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin);
|
||||
void (* SV_UpdateUserInfo)(IGameClient *pGameClient);
|
||||
void(*SV_UpdateUserInfo)(IGameClient *pGameClient);
|
||||
bool(*StripUnprintableAndSpace)(char *pch);
|
||||
};
|
||||
|
||||
class IRehldsApi {
|
||||
|
@ -33,11 +33,10 @@
|
||||
#endif
|
||||
|
||||
#include "modelgen.h"
|
||||
#include "commonmacros.h"
|
||||
|
||||
|
||||
#define IDSPRITEHEADER (('P'<<24)+('S'<<16)+('D'<<8)+'I')
|
||||
#define SPRITE_VERSION 2
|
||||
|
||||
#define SPRITE_VERSION 2 // Half-Life sprites
|
||||
#define IDSPRITEHEADER MAKEID('I', 'D', 'S', 'P') // little-endian "IDSP"
|
||||
|
||||
typedef enum spriteframetype_e
|
||||
{
|
||||
@ -46,7 +45,6 @@ typedef enum spriteframetype_e
|
||||
SPR_ANGLED
|
||||
} spriteframetype_t;
|
||||
|
||||
/* <4aea6> ../engine/spritegn.h:50 */
|
||||
typedef struct dsprite_s
|
||||
{
|
||||
int ident;
|
||||
@ -61,7 +59,6 @@ typedef struct dsprite_s
|
||||
synctype_t synctype;
|
||||
} dsprite_t;
|
||||
|
||||
/* <4af46> ../engine/spritegn.h:74 */
|
||||
typedef struct dspriteframe_s
|
||||
{
|
||||
int origin[2];
|
||||
@ -69,19 +66,16 @@ typedef struct dspriteframe_s
|
||||
int height;
|
||||
} dspriteframe_t;
|
||||
|
||||
/* <4af84> ../engine/spritegn.h:80 */
|
||||
typedef struct dspritegroup_s
|
||||
{
|
||||
int numframes;
|
||||
} dspritegroup_t;
|
||||
|
||||
/* <4afa6> ../engine/spritegn.h:84 */
|
||||
typedef struct dspriteinterval_s
|
||||
{
|
||||
float interval;
|
||||
} dspriteinterval_t;
|
||||
|
||||
/* <4afe8> ../engine/spritegn.h:90 */
|
||||
typedef struct dspriteframetype_s
|
||||
{
|
||||
spriteframetype_t type;
|
||||
|
@ -44,7 +44,7 @@ private:
|
||||
// this was a root node
|
||||
unsigned int rootId = GetRoodNodeId(node->key);
|
||||
if (m_RootNodes[rootId] != node) {
|
||||
util_syserror("%s: invlid root node", __FUNCTION__);
|
||||
Sys_Error(__FUNCTION__ ": invalid root node");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -310,10 +310,13 @@ typedef struct
|
||||
} mstudiotrivert_t;
|
||||
#endif
|
||||
|
||||
#define STUDIO_DYNAMIC_LIGHT 0x0100 // dynamically get lighting from floor or ceil (flying monsters)
|
||||
#define STUDIO_TRACE_HITBOX 0x0200 // always use hitbox trace instead of bbox
|
||||
|
||||
// lighting options
|
||||
#define STUDIO_NF_FLATSHADE 0x0001
|
||||
#define STUDIO_NF_CHROME 0x0002
|
||||
#define STUDIO_NF_FULLBRIGHT 0x0004
|
||||
#define STUDIO_NF_FULLBRIGHT 0x0004
|
||||
#define STUDIO_NF_NOMIPS 0x0008
|
||||
#define STUDIO_NF_ALPHA 0x0010
|
||||
#define STUDIO_NF_ADDITIVE 0x0020
|
||||
@ -321,7 +324,7 @@ typedef struct
|
||||
|
||||
// motion flags
|
||||
#define STUDIO_X 0x0001
|
||||
#define STUDIO_Y 0x0002
|
||||
#define STUDIO_Y 0x0002
|
||||
#define STUDIO_Z 0x0004
|
||||
#define STUDIO_XR 0x0008
|
||||
#define STUDIO_YR 0x0010
|
||||
|
@ -38,7 +38,6 @@ enum AUTH_IDTYPE
|
||||
AUTH_IDTYPE_LOCAL = 3
|
||||
};
|
||||
|
||||
/* <2e915> ../engine/userid.h:22 */
|
||||
typedef struct USERID_s
|
||||
{
|
||||
int idtype;
|
||||
|
@ -23,8 +23,8 @@
|
||||
#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0]))
|
||||
|
||||
// Keeps clutter down a bit, when using a float as a bit-vector
|
||||
#define SETBITS(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits))
|
||||
#define CLEARBITS(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits))
|
||||
#define FBitSet(flBitVector, bit) ((flBitVector) & (bit))
|
||||
#define SetBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits))
|
||||
#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits))
|
||||
#define FBitSet(flBitVector, bit) ((int)(flBitVector) & (bit))
|
||||
|
||||
#endif // COMMONMACROS_H
|
||||
|
@ -12,26 +12,15 @@
|
||||
//=============================================================================
|
||||
|
||||
#include "precompiled.h"
|
||||
#include <assert.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include "tier0/dbg.h"
|
||||
#include <math.h>
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// internal structures
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define MAX_GROUP_NAME_LENGTH 48
|
||||
//enum
|
||||
//{
|
||||
// MAX_GROUP_NAME_LENGTH = 48
|
||||
//};
|
||||
enum
|
||||
{
|
||||
MAX_GROUP_NAME_LENGTH = 48
|
||||
};
|
||||
|
||||
struct SpewGroup_t
|
||||
{
|
||||
@ -180,6 +169,8 @@ SpewRetval_t _SpewMessage(SpewType_t spewType, char const* pMsgFormat, va_list
|
||||
case SPEW_ABORT:
|
||||
// MessageBox(NULL,"Error in _SpewMessage","Error",MB_OK);
|
||||
exit(0);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// dll export stuff
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -441,6 +442,7 @@ private:
|
||||
//
|
||||
// Purpose: Embed debug info in each file.
|
||||
//
|
||||
|
||||
//#ifdef _WIN32
|
||||
//#ifdef _DEBUG
|
||||
//#pragma comment(compiler)
|
||||
|
@ -240,7 +240,7 @@ bool CBot::IsActiveWeaponClipEmpty() const
|
||||
{
|
||||
CBasePlayerWeapon *weapon = GetActiveWeapon();
|
||||
|
||||
if (weapon != NULL && weapon->m_iClip == 0)
|
||||
if (weapon && weapon->m_iClip == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -250,8 +250,7 @@ bool CBot::IsActiveWeaponClipEmpty() const
|
||||
bool CBot::IsActiveWeaponOutOfAmmo() const
|
||||
{
|
||||
CBasePlayerWeapon *weapon = GetActiveWeapon();
|
||||
|
||||
if (weapon == NULL)
|
||||
if (!weapon)
|
||||
return true;
|
||||
|
||||
if (weapon->m_iClip < 0)
|
||||
@ -362,8 +361,7 @@ int CBot::GetEnemiesRemaining() const
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBaseEntity *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == NULL)
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
if (FNullEnt(player->pev))
|
||||
@ -391,8 +389,7 @@ int CBot::GetFriendsRemaining() const
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CBaseEntity *player = UTIL_PlayerByIndex(i);
|
||||
|
||||
if (player == NULL)
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
if (FNullEnt(player->pev))
|
||||
@ -419,13 +416,13 @@ int CBot::GetFriendsRemaining() const
|
||||
bool CBot::IsLocalPlayerWatchingMe() const
|
||||
{
|
||||
// avoid crash during spawn
|
||||
if (pev == NULL)
|
||||
if (!pev)
|
||||
return false;
|
||||
|
||||
int myIndex = const_cast<CBot *>(this)->entindex();
|
||||
|
||||
CBasePlayer *player = UTIL_GetLocalPlayer();
|
||||
if (player == NULL)
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
if (((player->pev->flags & FL_SPECTATOR) || player->m_iTeam == SPECTATOR) && player->pev->iuser2 == myIndex)
|
||||
@ -470,13 +467,8 @@ void CBot::PrintIfWatched(char *format, ...) const
|
||||
char buffer[1024];
|
||||
|
||||
// prefix the message with the bot's name (this can be NULL if bot was just added)
|
||||
const char *name;
|
||||
if (pev == NULL)
|
||||
name = "(NULL pev)";
|
||||
else
|
||||
name = STRING(pev->netname);
|
||||
|
||||
Q_sprintf(buffer, "%s: ", (name != NULL) ? name : "(NULL netname)");
|
||||
const char *name = pev ? STRING(pev->netname) : "(NULL pev)";
|
||||
Q_sprintf(buffer, "%s: ", name ? name : "(NULL netname)");
|
||||
|
||||
SERVER_PRINT(buffer);
|
||||
|
||||
|
@ -309,7 +309,7 @@ FunctionHook g_FunctionHooks[] =
|
||||
{ 0x01D6B6A0, "_Z10StartFramev", (size_t)&StartFrame },
|
||||
{ 0x01D6B740, "_Z14ClientPrecachev", (size_t)&ClientPrecache },
|
||||
{ 0x01D6CCE0, "_Z18GetGameDescriptionv", (size_t)&GetGameDescription },
|
||||
{ 0x01D6CD00, "_Z9Sys_ErrorPKc", (size_t)&Sys_Error },
|
||||
{ 0x01D6CD00, "_Z9Sys_ErrorPKc", (size_t)&SysEngine_Error },
|
||||
{ 0x01D6CD10, "_Z19PlayerCustomizationP7edict_sP15customization_s", (size_t)&PlayerCustomization },
|
||||
{ 0x01D6CD90, "_Z16SpectatorConnectP7edict_s", (size_t)&SpectatorConnect },
|
||||
{ 0x01D6CDB0, "_Z19SpectatorDisconnectP7edict_s", (size_t)&SpectatorDisconnect },
|
||||
|
@ -69,13 +69,24 @@ public:
|
||||
virtual void callOriginal(t_class *, t_args... args) = 0;
|
||||
};
|
||||
|
||||
// Specifies priorities for hooks call order in the chain.
|
||||
// For equal priorities first registered hook will be called first.
|
||||
enum HookChainPriority
|
||||
{
|
||||
HC_PRIORITY_UNINTERRUPTABLE = 255, // Hook will be called before other hooks.
|
||||
HC_PRIORITY_HIGH = 192, // Hook will be called before hooks with default priority.
|
||||
HC_PRIORITY_DEFAULT = 128, // Default hook call priority.
|
||||
HC_PRIORITY_MEDIUM = 64, // Hook will be called after hooks with default priority.
|
||||
HC_PRIORITY_LOW = 0, // Hook will be called after all other hooks.
|
||||
};
|
||||
|
||||
// Hook chain registry(for hooks [un]registration)
|
||||
template<typename t_ret, typename ...t_args>
|
||||
class IHookChainRegistry {
|
||||
public:
|
||||
typedef t_ret(*hookfunc_t)(IHookChain<t_ret, t_args...>*, t_args...);
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) = 0;
|
||||
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
|
||||
virtual void unregisterHook(hookfunc_t hook) = 0;
|
||||
};
|
||||
|
||||
@ -85,7 +96,7 @@ class IHookChainRegistryClass {
|
||||
public:
|
||||
typedef t_ret(*hookfunc_t)(IHookChainClass<t_ret, t_class, t_args...>*, t_class *, t_args...);
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) = 0;
|
||||
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
|
||||
virtual void unregisterHook(hookfunc_t hook) = 0;
|
||||
};
|
||||
|
||||
@ -95,7 +106,7 @@ class IVoidHookChainRegistry {
|
||||
public:
|
||||
typedef void(*hookfunc_t)(IVoidHookChain<t_args...>*, t_args...);
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) = 0;
|
||||
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
|
||||
virtual void unregisterHook(hookfunc_t hook) = 0;
|
||||
};
|
||||
|
||||
@ -105,6 +116,6 @@ class IVoidHookChainRegistryClass {
|
||||
public:
|
||||
typedef void(*hookfunc_t)(IVoidHookChainClass<t_class, t_args...>*, t_class *, t_args...);
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) = 0;
|
||||
virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0;
|
||||
virtual void unregisterHook(hookfunc_t hook) = 0;
|
||||
};
|
||||
|
@ -22,25 +22,65 @@
|
||||
AbstractHookChainRegistry::AbstractHookChainRegistry()
|
||||
{
|
||||
Q_memset(m_Hooks, 0, sizeof(m_Hooks));
|
||||
Q_memset(m_Priorities, 0, sizeof(m_Priorities));
|
||||
|
||||
m_NumHooks = 0;
|
||||
}
|
||||
|
||||
void AbstractHookChainRegistry::addHook(void* hookFunc) {
|
||||
if (m_NumHooks >= MAX_HOOKS_IN_CHAIN) {
|
||||
regamedll_syserror("MAX_HOOKS_IN_CHAIN limit hit");
|
||||
bool AbstractHookChainRegistry::findHook(void* hookFunc) const
|
||||
{
|
||||
for (auto i = 0; i < m_NumHooks; i++) {
|
||||
if (m_Hooks[i] == hookFunc)
|
||||
return true;
|
||||
}
|
||||
|
||||
m_Hooks[m_NumHooks++] = hookFunc;
|
||||
return false;
|
||||
}
|
||||
|
||||
void AbstractHookChainRegistry::addHook(void* hookFunc, int priority)
|
||||
{
|
||||
if (!hookFunc) {
|
||||
Sys_Error(__FUNCTION__ " Parameter hookFunc can't be a nullptr");
|
||||
}
|
||||
|
||||
if (findHook(hookFunc)) {
|
||||
Sys_Error(__FUNCTION__ " The same handler can't be used twice on the hookchain.");
|
||||
}
|
||||
|
||||
for (auto i = 0; i < MAX_HOOKS_IN_CHAIN; i++)
|
||||
{
|
||||
if (m_Hooks[i] && priority <= m_Priorities[i])
|
||||
continue;
|
||||
|
||||
auto swapHookFunc = m_Hooks[i];
|
||||
auto swapPriority = m_Priorities[i];
|
||||
|
||||
m_Hooks[i] = hookFunc;
|
||||
m_Priorities[i] = priority;
|
||||
|
||||
hookFunc = swapHookFunc;
|
||||
priority = swapPriority;
|
||||
}
|
||||
|
||||
if (m_NumHooks >= MAX_HOOKS_IN_CHAIN) {
|
||||
Sys_Error(__FUNCTION__ " MAX_HOOKS_IN_CHAIN limit hit");
|
||||
}
|
||||
|
||||
m_NumHooks++;
|
||||
}
|
||||
|
||||
void AbstractHookChainRegistry::removeHook(void* hookFunc) {
|
||||
|
||||
// erase hook
|
||||
for (int i = 0; i < m_NumHooks; i++) {
|
||||
if (hookFunc == m_Hooks[i]) {
|
||||
if (--m_NumHooks != i)
|
||||
for (auto i = 0; i < m_NumHooks; i++)
|
||||
{
|
||||
if (hookFunc == m_Hooks[i])
|
||||
{
|
||||
--m_NumHooks;
|
||||
if (m_NumHooks != i)
|
||||
{
|
||||
Q_memmove(&m_Hooks[i], &m_Hooks[i + 1], (m_NumHooks - i) * sizeof(m_Hooks[0]));
|
||||
Q_memmove(&m_Priorities[i], &m_Priorities[i + 1], (m_NumHooks - i) * sizeof(m_Priorities[0]));
|
||||
m_Hooks[m_NumHooks] = NULL;
|
||||
}
|
||||
else
|
||||
|
@ -28,7 +28,7 @@
|
||||
#pragma once
|
||||
#include "hookchains.h"
|
||||
|
||||
#define MAX_HOOKS_IN_CHAIN 19
|
||||
#define MAX_HOOKS_IN_CHAIN 30
|
||||
|
||||
// Implementation for chains in modules
|
||||
template<typename t_ret, typename ...t_args>
|
||||
@ -40,7 +40,7 @@ public:
|
||||
IHookChainImpl(void** hooks, origfunc_t orig) : m_Hooks(hooks), m_OriginalFunc(orig)
|
||||
{
|
||||
if (orig == NULL)
|
||||
regamedll_syserror("Non-void HookChain without original function.");
|
||||
Sys_Error(__FUNCTION__ ": Non-void HookChain without original function.");
|
||||
}
|
||||
|
||||
virtual ~IHookChainImpl() {}
|
||||
@ -165,8 +165,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void callOriginal(t_args... args) {
|
||||
origfunc_t origfunc = (origfunc_t)m_OriginalFunc;
|
||||
origfunc(args...);
|
||||
if (m_OriginalFunc)
|
||||
m_OriginalFunc(args...);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -193,13 +193,14 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_OriginalFunc && m_Object)
|
||||
if (m_Object && m_OriginalFunc)
|
||||
(m_Object->*m_OriginalFunc)(args...);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void callOriginal(t_args... args) {
|
||||
(m_Object->*m_OriginalFunc)(args...);
|
||||
if (m_Object && m_OriginalFunc)
|
||||
(m_Object->*m_OriginalFunc)(args...);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -228,28 +229,30 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_OriginalFunc && object)
|
||||
if (object && m_OriginalFunc)
|
||||
(object->*m_OriginalFunc)(args...);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void callOriginal(t_class *object, t_args... args) {
|
||||
(m_Object->*m_OriginalFunc)(args...);
|
||||
if (object && m_OriginalFunc)
|
||||
(object->*m_OriginalFunc)(args...);
|
||||
}
|
||||
|
||||
private:
|
||||
void** m_Hooks;
|
||||
t_class *m_Object;
|
||||
origfunc_t m_OriginalFunc;
|
||||
};
|
||||
|
||||
class AbstractHookChainRegistry {
|
||||
protected:
|
||||
void* m_Hooks[MAX_HOOKS_IN_CHAIN + 1]; // +1 for null
|
||||
int m_Priorities[MAX_HOOKS_IN_CHAIN + 1];
|
||||
int m_NumHooks;
|
||||
|
||||
protected:
|
||||
void addHook(void* hookFunc);
|
||||
void addHook(void* hookFunc, int priority);
|
||||
bool findHook(void* hookFunc) const;
|
||||
void removeHook(void* hookFunc);
|
||||
|
||||
public:
|
||||
@ -269,8 +272,8 @@ public:
|
||||
return chain.callNext(args...);
|
||||
}
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) {
|
||||
addHook((void*)hook);
|
||||
virtual void registerHook(hookfunc_t hook, int priority) {
|
||||
addHook((void*)hook, priority);
|
||||
}
|
||||
virtual void unregisterHook(hookfunc_t hook) {
|
||||
removeHook((void*)hook);
|
||||
@ -290,8 +293,8 @@ public:
|
||||
return chain.callNext(object, args...);
|
||||
}
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) {
|
||||
addHook((void*)hook);
|
||||
virtual void registerHook(hookfunc_t hook, int priority) {
|
||||
addHook((void*)hook, priority);
|
||||
}
|
||||
virtual void unregisterHook(hookfunc_t hook) {
|
||||
removeHook((void*)hook);
|
||||
@ -311,8 +314,8 @@ public:
|
||||
return chain.callNext(args...);
|
||||
}
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) {
|
||||
addHook((void*)hook);
|
||||
virtual void registerHook(hookfunc_t hook, int priority) {
|
||||
addHook((void*)hook, priority);
|
||||
}
|
||||
virtual void unregisterHook(hookfunc_t hook) {
|
||||
removeHook((void*)hook);
|
||||
@ -332,8 +335,8 @@ public:
|
||||
chain.callNext(args...);
|
||||
}
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) {
|
||||
addHook((void*)hook);
|
||||
virtual void registerHook(hookfunc_t hook, int priority) {
|
||||
addHook((void*)hook, priority);
|
||||
}
|
||||
|
||||
virtual void unregisterHook(hookfunc_t hook) {
|
||||
@ -354,8 +357,8 @@ public:
|
||||
chain.callNext(args...);
|
||||
}
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) {
|
||||
addHook((void*)hook);
|
||||
virtual void registerHook(hookfunc_t hook, int priority) {
|
||||
addHook((void*)hook, priority);
|
||||
}
|
||||
|
||||
virtual void unregisterHook(hookfunc_t hook) {
|
||||
@ -376,8 +379,8 @@ public:
|
||||
chain.callNext(object, args...);
|
||||
}
|
||||
|
||||
virtual void registerHook(hookfunc_t hook) {
|
||||
addHook((void*)hook);
|
||||
virtual void registerHook(hookfunc_t hook, int priority) {
|
||||
addHook((void*)hook, priority);
|
||||
}
|
||||
|
||||
virtual void unregisterHook(hookfunc_t hook) {
|
||||
|
@ -27,19 +27,19 @@ void regamedll_log(const char *fmt, ...)
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
void __declspec(noreturn) regamedll_syserror(const char *fmt, ...)
|
||||
void NORETURN regamedll_syserror(const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char string[8192];
|
||||
static char text[2048];
|
||||
|
||||
va_start(argptr, fmt);
|
||||
vsnprintf(string, sizeof(string), fmt, argptr);
|
||||
va_start(argptr, error);
|
||||
vsnprintf(text, sizeof(text), error, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
printf("%s\n", string);
|
||||
printf("%s\n", text);
|
||||
|
||||
FILE *fl = fopen("regamedll_error.txt", "w");
|
||||
fprintf(fl, "%s\n", string);
|
||||
fprintf(fl, "%s\n", text);
|
||||
fclose(fl);
|
||||
|
||||
//TerminateProcess(GetCurrentProcess(), 1);
|
||||
|
@ -7,6 +7,6 @@
|
||||
#define _logf regamedll_log
|
||||
|
||||
extern void regamedll_log(const char *fmt, ...);
|
||||
extern void __declspec(noreturn) regamedll_syserror(const char *fmt, ...);
|
||||
extern void NORETURN regamedll_syserror(const char *error, ...);
|
||||
|
||||
#endif // PLATFORM_GAMEDLL_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user