2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-27 23:25:30 +03:00

Update regamedll API sdk

Update cssdk & minor refactoring
Added safe checks CGameRules/CCSEntity version interface (for future safe migrate)
This commit is contained in:
s1lent 2019-08-30 02:20:31 +07:00
parent abd47009fb
commit 80b9f6f1bc
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
12 changed files with 597 additions and 442 deletions

View File

@ -122,14 +122,17 @@
/**
* get_entvar(entity, var_effects) values
*/
#define EF_BRIGHTFIELD 1 // Swirling cloud of particles
#define EF_MUZZLEFLASH 2 // Single frame ELIGHT on entity attachment 0
#define EF_BRIGHTLIGHT 4 // DLIGHT centered at entity origin
#define EF_DIMLIGHT 8 // Player flashlight
#define EF_INVLIGHT 16 // Get lighting from ceiling
#define EF_NOINTERP 32 // Don't interpolate the next frame
#define EF_LIGHT 64 // Rocket flare glow sprite
#define EF_NODRAW 128 // Don't draw entity
#define EF_BRIGHTFIELD 1 // Swirling cloud of particles
#define EF_MUZZLEFLASH 2 // Single frame ELIGHT on entity attachment 0
#define EF_BRIGHTLIGHT 4 // DLIGHT centered at entity origin
#define EF_DIMLIGHT 8 // Player flashlight
#define EF_INVLIGHT 16 // Get lighting from ceiling
#define EF_NOINTERP 32 // Don't interpolate the next frame
#define EF_LIGHT 64 // Rocket flare glow sprite
#define EF_NODRAW 128 // Don't draw entity
#define EF_FORCEVISIBILITY 2048 // force visibility
#define EF_OWNER_VISIBILITY 4096 // visibility for owner
#define EF_OWNER_NO_VISIBILITY 8192 // no visibility for owner
/**
* Break Model Defines

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,11 @@ class CBaseEntity;
class CCSEntity
{
public:
CCSEntity() :
m_pContainingEntity(nullptr)
{
}
virtual ~CCSEntity() {}
virtual void FireBullets(int iShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker);
virtual Vector FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand);
@ -63,3 +68,5 @@ class CCSMonster: public CCSToggle
public:
};
#define CSENTITY_API_INTERFACE_VERSION "CSENTITY_API_INTERFACE_VERSION001"

View File

@ -39,7 +39,7 @@
#include "strtools.h"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define NOWINRES
#define NOSERVICE
#define NOMCX
@ -66,16 +66,20 @@ typedef float vec_t; // needed before including progdefs.h
// Vector class
#include "vector.h"
//#include "vector.h"
// Defining it as a (bogus) struct helps enforce type-checking
#define vec3_t Vector
// Shared engine/DLL constants
// QString class
#include "qstring.h"
// Shared engine/DLL constants
#include "const.h"
#include "edict.h"
// Shared header describing protocol between engine and DLLs
#include "eiface.h"
// Shared header between the client DLL and the game DLLs
#include "cdll_dll.h"
#include "extdef.h"

View File

@ -332,6 +332,8 @@ public:
bool m_bGameOver; // intermission or finale (deprecated name g_fGameOver)
};
#define GAMERULES_API_INTERFACE_VERSION "GAMERULES_API_INTERFACE_VERSION001"
// CHalfLifeRules - rules for the single player Half-Life game.
class CHalfLifeRules: public CGameRules {
protected:

View File

@ -0,0 +1,121 @@
/*
*
* 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
#define QSTRING_DEFINE
constexpr unsigned int iStringNull = {0};
// Quake string (helper class)
class QString final
{
public:
using qstring_t = unsigned int;
QString(): m_string(iStringNull) {};
QString(qstring_t string): m_string(string) {};
bool IsNull() const;
bool IsNullOrEmpty() const;
// Copy the array
QString &operator=(const QString &other);
bool operator==(qstring_t string) const;
bool operator==(const QString &s) const;
bool operator==(const char *pszString) const;
operator const char *() const;
operator unsigned int() const;
const char *str() const;
private:
qstring_t m_string;
};
#ifdef USE_QSTRING
#define string_t QString
#endif
#include "const.h"
#include "edict.h"
#include "eiface.h"
#include "enginecallback.h"
extern globalvars_t *gpGlobals;
#define STRING(offset) ((const char *)(gpGlobals->pStringBase + (unsigned int)(offset)))
#define MAKE_STRING(str) ((unsigned int)(str) - (unsigned int)(STRING(0)))
// Inlines
inline bool QString::IsNull() const
{
return m_string == iStringNull;
}
inline bool QString::IsNullOrEmpty() const
{
return IsNull() || (&gpGlobals->pStringBase[m_string])[0] == '\0';
}
inline QString &QString::operator=(const QString &other)
{
m_string = other.m_string;
return (*this);
}
inline bool QString::operator==(qstring_t string) const
{
return m_string == string;
}
inline bool QString::operator==(const QString &s) const
{
return m_string == s.m_string;
}
inline bool QString::operator==(const char *pszString) const
{
return Q_strcmp(&gpGlobals->pStringBase[m_string], pszString) == 0;
}
inline const char *QString::str() const
{
return &gpGlobals->pStringBase[m_string];
}
inline QString::operator const char *() const
{
return str();
}
inline QString::operator unsigned int() const
{
return m_string;
}

View File

@ -38,7 +38,7 @@
#include <API/CSInterfaces.h>
#define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 10
#define REGAMEDLL_API_VERSION_MINOR 11
// CBasePlayer::Spawn hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
@ -589,6 +589,8 @@ public:
virtual struct AmmoInfo *GetAmmoInfo(AmmoType ammoID) = 0;
virtual struct AmmoInfoStruct *GetAmmoInfoEx(AmmoType ammoID) = 0;
virtual struct AmmoInfoStruct *GetAmmoInfoEx(const char *ammoName) = 0;
virtual bool BGetICSEntity(const char *pchVersion) const = 0;
virtual bool BGetIGameRules(const char *pchVersion) const = 0;
};
#define VRE_GAMEDLL_API_VERSION "VRE_GAMEDLL_API_VERSION001"

View File

@ -57,6 +57,26 @@
#define BIT(n) (1<<(n))
#ifdef HAVE_STRONG_TYPEDEF
enum class string_t: unsigned int {};
#else
typedef unsigned int string_t;
#endif
typedef int EOFFSET;
typedef int BOOL;
typedef unsigned char byte;
typedef unsigned short word;
#define _DEF_BYTE_
#ifndef __cplusplus
#undef true
#undef false
typedef enum {false, true} qboolean;
#else
typedef int qboolean;
#endif // #ifndef __cplusplus
// From engine/server.h
typedef enum sv_delta_s
{

View File

@ -7,6 +7,11 @@ CAPI_Config::CAPI_Config() : m_api_rehlds(false), m_api_regame(false), m_api_vtc
}
void CAPI_Config::FailedReGameDllAPI()
{
m_api_regame = false;
}
void CAPI_Config::Init()
{
m_api_rehlds = RehldsApi_Init();

View File

@ -7,6 +7,7 @@ class CAPI_Config {
public:
CAPI_Config();
void Init();
void FailedReGameDllAPI();
bool hasReHLDS() const { return m_api_rehlds; }
bool hasReGameDLL() const { return m_api_regame; }

View File

@ -95,7 +95,20 @@ void KeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd)
CGameRules *InstallGameRules(IReGameHook_InstallGameRules *chain)
{
return g_pGameRules = chain->callNext();
auto gamerules = chain->callNext();
// Safe check CGameRules API interface version
if (!g_ReGameApi->BGetIGameRules(GAMERULES_API_INTERFACE_VERSION))
{
api_cfg.FailedReGameDllAPI();
UTIL_ServerPrint("[%s]: Interface CGameRules API version '%s' not found.\n", Plugin_info.logtag, GAMERULES_API_INTERFACE_VERSION);
}
else
{
g_pGameRules = gamerules;
}
return gamerules;
}
int DispatchSpawn(edict_t *pEntity)

View File

@ -58,5 +58,12 @@ bool RegamedllApi_Init()
g_ReGameFuncs = g_ReGameApi->GetFuncs();
g_ReGameHookchains = g_ReGameApi->GetHookchains();
// Safe check CCSEntity API interface version
if (!g_ReGameApi->BGetICSEntity(CSENTITY_API_INTERFACE_VERSION))
{
UTIL_ServerPrint("[%s]: Interface CCSEntity API version '%s' not found.\n", Plugin_info.logtag, CSENTITY_API_INTERFACE_VERSION);
return false;
}
return true;
}
}