2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-03-13 14:00:19 +03:00

Add pr_dlls.h & fix GetEntityInit() return type (#228)

* Add pr_dlls.h

* fix GetEntityInit hook return type

* add getApiType(ENTITYINIT) type cast

* remove extra cast from callNext()

* indent fix
This commit is contained in:
Sergey Shorokhov 2021-10-23 12:54:44 +03:00 committed by GitHub
parent a16dfd08fa
commit de26345d27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 16 deletions

View File

@ -0,0 +1,51 @@
/*
*
* 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.
*
*/
#pragma once
#include "maintypes.h"
#include "eiface.h"
const int MAX_EXTENSION_DLL = 50;
typedef struct functiontable_s
{
uint32 pFunction;
char *pFunctionName;
} functiontable_t;
typedef struct extensiondll_s
{
void *lDLLHandle;
functiontable_t *functionTable;
int functionCount;
} extensiondll_t;
typedef void(*ENTITYINIT)(struct entvars_s *);
typedef void(*DISPATCHFUNCTION)(struct entvars_s *, void *);
typedef void(*FIELDIOFUNCTION)(SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int);

View File

@ -33,6 +33,7 @@
#include "FlightRecorder.h" #include "FlightRecorder.h"
#include "interface.h" #include "interface.h"
#include "model.h" #include "model.h"
#include "pr_dlls.h"
#define REHLDS_API_VERSION_MAJOR 3 #define REHLDS_API_VERSION_MAJOR 3
#define REHLDS_API_VERSION_MINOR 11 #define REHLDS_API_VERSION_MINOR 11
@ -206,8 +207,8 @@ typedef IHookChain<bool, IGameClient*, bool> IRehldsHook_SV_ShouldSendConsistenc
typedef IHookChainRegistry<bool, IGameClient*, bool> IRehldsHookRegistry_SV_ShouldSendConsistencyList; typedef IHookChainRegistry<bool, IGameClient*, bool> IRehldsHookRegistry_SV_ShouldSendConsistencyList;
//GetEntityInit hook //GetEntityInit hook
typedef IHookChain<struct entvars_s *, char *> IRehldsHook_GetEntityInit; typedef IHookChain<ENTITYINIT, char *> IRehldsHook_GetEntityInit;
typedef IHookChainRegistry<struct entvars_s *, char *> IRehldsHookRegistry_GetEntityInit; typedef IHookChainRegistry<ENTITYINIT, char *> IRehldsHookRegistry_GetEntityInit;
//SV_EmitPings hook //SV_EmitPings hook
typedef IHookChain<void, IGameClient *, sizebuf_t *> IRehldsHook_SV_EmitPings; typedef IHookChain<void, IGameClient *, sizebuf_t *> IRehldsHook_SV_EmitPings;

View File

@ -63,14 +63,14 @@ void SV_WriteFullClientUpdate(IRehldsHook_SV_WriteFullClientUpdate *chain, IGame
SV_WriteFullClientUpdate_AMXX(&data, client, (size_t)buffer, receiver); SV_WriteFullClientUpdate_AMXX(&data, client, (size_t)buffer, receiver);
} }
entvars_t *GetEntityInit(IRehldsHook_GetEntityInit *chain, char *classname) ENTITYINIT GetEntityInit(IRehldsHook_GetEntityInit *chain, char *classname)
{ {
auto original = [chain](char *_classname) auto original = [chain](char *_classname)
{ {
return (entvars_t *)chain->callNext(_classname); return chain->callNext(_classname);
}; };
return callForward<entvars_t *>(RH_GetEntityInit, original, classname); return callForward<ENTITYINIT>(RH_GetEntityInit, original, classname);
} }
void ClientConnected(IRehldsHook_ClientConnected* chain, IGameClient* cl) void ClientConnected(IRehldsHook_ClientConnected* chain, IGameClient* cl)

View File

@ -41,17 +41,18 @@ struct retval_t
}; };
}; };
inline AType getApiType(int) { return ATYPE_INTEGER; } inline AType getApiType(int) { return ATYPE_INTEGER; }
inline AType getApiType(unsigned) { return ATYPE_INTEGER; } inline AType getApiType(unsigned) { return ATYPE_INTEGER; }
inline AType getApiType(ULONG) { return ATYPE_INTEGER; } inline AType getApiType(ULONG) { return ATYPE_INTEGER; }
inline AType getApiType(float) { return ATYPE_FLOAT; } inline AType getApiType(float) { return ATYPE_FLOAT; }
inline AType getApiType(const char *) { return ATYPE_STRING; } inline AType getApiType(const char *) { return ATYPE_STRING; }
inline AType getApiType(char[]) { return ATYPE_STRING; } inline AType getApiType(char[]) { return ATYPE_STRING; }
inline AType getApiType(CBaseEntity *) { return ATYPE_CLASSPTR; } inline AType getApiType(CBaseEntity *) { return ATYPE_CLASSPTR; }
inline AType getApiType(edict_t *) { return ATYPE_EDICT; } inline AType getApiType(edict_t *) { return ATYPE_EDICT; }
inline AType getApiType(entvars_t *) { return ATYPE_EVARS; } inline AType getApiType(entvars_t *) { return ATYPE_EVARS; }
inline AType getApiType(bool) { return ATYPE_BOOL; } inline AType getApiType(bool) { return ATYPE_BOOL; }
inline AType getApiType(Vector) { return ATYPE_VECTOR; } inline AType getApiType(Vector) { return ATYPE_VECTOR; }
inline AType getApiType(ENTITYINIT) { return ATYPE_INTEGER; }
template<typename T> template<typename T>
inline AType getApiType(T *) { return ATYPE_INTEGER; } inline AType getApiType(T *) { return ATYPE_INTEGER; }
@ -344,7 +345,7 @@ struct SV_WriteFullClientUpdate_args_t
using SV_WriteFullClientUpdate_t = hookdata_t<IRehldsHook_SV_WriteFullClientUpdate *, SV_WriteFullClientUpdate_args_t &>; using SV_WriteFullClientUpdate_t = hookdata_t<IRehldsHook_SV_WriteFullClientUpdate *, SV_WriteFullClientUpdate_args_t &>;
void SV_WriteFullClientUpdate_AMXX(SV_WriteFullClientUpdate_t *data, IGameClient *client, size_t buffer, IGameClient *receiver); void SV_WriteFullClientUpdate_AMXX(SV_WriteFullClientUpdate_t *data, IGameClient *client, size_t buffer, IGameClient *receiver);
void SV_WriteFullClientUpdate(IRehldsHook_SV_WriteFullClientUpdate *chain, IGameClient *client, char *buffer, size_t maxlen, sizebuf_t *sb, IGameClient *receiver); void SV_WriteFullClientUpdate(IRehldsHook_SV_WriteFullClientUpdate *chain, IGameClient *client, char *buffer, size_t maxlen, sizebuf_t *sb, IGameClient *receiver);
entvars_s *GetEntityInit(IRehldsHook_GetEntityInit *chain, char *classname); ENTITYINIT GetEntityInit(IRehldsHook_GetEntityInit *chain, char *classname);
struct SV_EmitPings_args_t struct SV_EmitPings_args_t
{ {