ReGameDLL API: Added calls func AddEntityHashValue, RemoveEntityHashValue, GetItemInfo, GetAmmoInfo

Fix: mp_refill_bpammo_weapons 2 - was not refill bpammo for shotguns.
This commit is contained in:
s1lentq 2016-08-05 17:43:13 +07:00
parent 5864d1ea34
commit b4fec27dc6
9 changed files with 62 additions and 36 deletions

View File

@ -127,7 +127,7 @@ void EmptyEntityHashTable()
}
}
void AddEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType)
void EXT_FUNC AddEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType)
{
int count;
hash_item_t *item, *next, *temp, *newp;
@ -200,7 +200,7 @@ void AddEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldTyp
}
}
void RemoveEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType)
void EXT_FUNC RemoveEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType)
{
int hash;
hash_item_t *item;
@ -296,11 +296,11 @@ NOINLINE edict_t *EXT_FUNC CREATE_NAMED_ENTITY(string_t iClass)
return named;
}
void REMOVE_ENTITY(edict_t *e)
void REMOVE_ENTITY(edict_t *pEntity)
{
if (e != NULL)
if (pEntity)
{
(*g_engfuncs.pfnRemoveEntity)(e);
(*g_engfuncs.pfnRemoveEntity)(pEntity);
}
}
@ -412,7 +412,7 @@ int EXT_FUNC DispatchSpawn(edict_t *pent)
{
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent);
if (pEntity != NULL)
if (pEntity)
{
// Initialize these or entities who don't link to the world won't have anything in here
pEntity->pev->absmin = pEntity->pev->origin - Vector(1, 1, 1);
@ -424,9 +424,9 @@ int EXT_FUNC DispatchSpawn(edict_t *pent)
// that would touch too much code for me to do that right now.
pEntity = (CBaseEntity *)GET_PRIVATE(pent);
if (pEntity != NULL)
if (pEntity)
{
if (g_pGameRules != NULL && !g_pGameRules->IsAllowedToSpawn(pEntity))
if (g_pGameRules && !g_pGameRules->IsAllowedToSpawn(pEntity))
{
// return that this entity should be deleted
return -1;
@ -439,7 +439,7 @@ int EXT_FUNC DispatchSpawn(edict_t *pent)
}
// Handle global stuff here
if (pEntity != NULL && pEntity->pev->globalname)
if (pEntity && pEntity->pev->globalname)
{
const globalentity_t *pGlobal = gGlobalState.EntityFromTable(pEntity->pev->globalname);
@ -508,17 +508,15 @@ void EXT_FUNC DispatchUse(edict_t *pentUsed, edict_t *pentOther)
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentUsed);
CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther);
if (pEntity != NULL && !(pEntity->pev->flags & FL_KILLME))
{
if (pEntity && !(pEntity->pev->flags & FL_KILLME))
pEntity->Use(pOther, pOther, USE_TOGGLE, 0);
}
}
void EXT_FUNC DispatchThink(edict_t *pent)
{
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent);
if (pEntity != NULL)
if (pEntity)
{
if (pEntity->pev->flags & FL_DORMANT)
{
@ -534,7 +532,7 @@ void EXT_FUNC DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther)
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentBlocked);
CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther);
if (pEntity != NULL)
if (pEntity)
{
pEntity->Blocked(pOther);
}
@ -544,7 +542,7 @@ void EXT_FUNC DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData)
{
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent);
if (pEntity != NULL && pSaveData != NULL)
if (pEntity && pSaveData)
{
ENTITYTABLE *pTable = &pSaveData->pTable[ pSaveData->currentIndex ];
@ -585,7 +583,7 @@ CBaseEntity *FindGlobalEntity(string_t classname, string_t globalname)
edict_t *pent = FIND_ENTITY_BY_STRING(NULL, "globalname", STRING(globalname));
CBaseEntity *pReturn = CBaseEntity::Instance(pent);
if (pReturn != NULL)
if (pReturn)
{
if (!FClassnameIs(pReturn->pev, STRING(classname)))
{
@ -632,7 +630,7 @@ int EXT_FUNC DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int glob
oldOffset = pSaveData->vecLandmarkOffset;
CBaseEntity *pNewEntity = FindGlobalEntity(tmpVars.classname, tmpVars.globalname);
if (pNewEntity != NULL)
if (pNewEntity)
{
// Tell the restore code we're overlaying a global entity from another level
// Don't overwrite global fields
@ -675,17 +673,17 @@ int EXT_FUNC DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int glob
{
pSaveData->vecLandmarkOffset = oldOffset;
if (pEntity != NULL)
if (pEntity)
{
UTIL_SetOrigin(pEntity->pev, pEntity->pev->origin);
pEntity->OverrideReset();
}
}
else if (pEntity != NULL && pEntity->pev->globalname)
else if (pEntity && pEntity->pev->globalname)
{
const globalentity_t *pGlobal = gGlobalState.EntityFromTable(pEntity->pev->globalname);
if (pGlobal != NULL)
if (pGlobal)
{
// Already dead? delete
if (pGlobal->state == GLOBAL_DEAD)
@ -760,7 +758,7 @@ EHANDLE::operator CBaseEntity *()
CBaseEntity *EHANDLE::operator=(CBaseEntity *pEntity)
{
if (pEntity != NULL)
if (pEntity)
{
m_pent = ENT(pEntity->pev);
if (m_pent)

View File

@ -715,7 +715,7 @@ void AddEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldTyp
void RemoveEntityHashValue(entvars_t *pev, const char *value, hash_types_e fieldType);
void printEntities();
edict_t *CREATE_NAMED_ENTITY(string_t iClass);
void REMOVE_ENTITY(edict_t *e);
void REMOVE_ENTITY(edict_t *pEntity);
void CONSOLE_ECHO_(char *pszMsg, ...);
void loopPerformance();
int DispatchSpawn(edict_t *pent);

View File

@ -166,8 +166,15 @@ void CM3::__MAKE_VHOOK(Reload)()
else
{
++m_iClip;
--m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType];
--m_pPlayer->ammo_buckshot;
#ifdef REGAMEDLL_ADD
if (refill_bpammo_weapons.value < 2.0f)
#endif
{
--m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType];
--m_pPlayer->ammo_buckshot;
}
m_fInSpecialReload = 1;
}
}

View File

@ -170,8 +170,15 @@ void CXM1014::__MAKE_VHOOK(Reload)()
else
{
++m_iClip;
--m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType];
--m_pPlayer->ammo_buckshot;
#ifdef REGAMEDLL_ADD
if (refill_bpammo_weapons.value < 2.0f)
#endif
{
--m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType];
--m_pPlayer->ammo_buckshot;
}
m_fInSpecialReload = 1;
}
}

View File

@ -135,6 +135,8 @@ public:
edict_t *edict() { return ENT(pev); }
EOFFSET eoffset() { return OFFSET(pev); }
int entindex() { return ENTINDEX(edict()); }
int IsDormant() { return (pev->flags & FL_DORMANT) == FL_DORMANT; }
public:
CCSEntity *m_pEntity; // NOTE: it was replaced on member "int *current_ammo" because it is useless.

View File

@ -36,7 +36,7 @@
#include "items.h"
#define REGAMEDLL_API_VERSION_MAJOR 4
#define REGAMEDLL_API_VERSION_MINOR 1
#define REGAMEDLL_API_VERSION_MINOR 2
// CBasePlayer::Spawn hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
@ -391,6 +391,8 @@ struct ReGameFuncs_t {
void (*ApplyMultiDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker);
void (*AddMultiDamage)(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);
class CBaseEntity *(*UTIL_FindEntityByString)(class CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue);
void (*AddEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType);
void (*RemoveEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType);
};
class IReGameApi {
@ -408,6 +410,8 @@ public:
virtual struct playermove_s* GetPlayerMove() = 0;
virtual struct WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID) = 0;
virtual struct WeaponSlotInfo* GetWeaponSlot(const char* weaponName) = 0;
virtual struct ItemInfo* GetItemInfo(WeaponIdType weaponID) = 0;
virtual struct AmmoInfo* GetAmmoInfo(AmmoType ammoID) = 0;
};
#define VRE_GAMEDLL_API_VERSION "VRE_GAMEDLL_API_VERSION001"

View File

@ -36,7 +36,7 @@
#include "items.h"
#define REGAMEDLL_API_VERSION_MAJOR 4
#define REGAMEDLL_API_VERSION_MINOR 1
#define REGAMEDLL_API_VERSION_MINOR 2
// CBasePlayer::Spawn hook
typedef IVoidHookChainClass<class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
@ -391,6 +391,8 @@ struct ReGameFuncs_t {
void (*ApplyMultiDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker);
void (*AddMultiDamage)(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);
class CBaseEntity *(*UTIL_FindEntityByString)(class CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue);
void (*AddEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType);
void (*RemoveEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType);
};
class IReGameApi {
@ -408,6 +410,8 @@ public:
virtual struct playermove_s* GetPlayerMove() = 0;
virtual struct WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID) = 0;
virtual struct WeaponSlotInfo* GetWeaponSlot(const char* weaponName) = 0;
virtual struct ItemInfo* GetItemInfo(WeaponIdType weaponID) = 0;
virtual struct AmmoInfo* GetAmmoInfo(AmmoType ammoID) = 0;
};
#define VRE_GAMEDLL_API_VERSION "VRE_GAMEDLL_API_VERSION001"

View File

@ -42,6 +42,9 @@ ReGameFuncs_t g_ReGameApiFuncs = {
&UTIL_FindEntityByString,
&AddEntityHashValue,
&RemoveEntityHashValue
};
IReGameHookRegistry_CBasePlayer_Spawn* CReGameHookchains::CBasePlayer_Spawn() { return &m_CBasePlayer_Spawn; }
@ -115,23 +118,19 @@ IReGameHookRegistry_CSGameRules_ChangeLevel* CReGameHookchains::CSGameRules_Chan
IReGameHookRegistry_CSGameRules_GoToIntermission* CReGameHookchains::CSGameRules_GoToIntermission() { return &m_CSGameRules_GoToIntermission; }
IReGameHookRegistry_CSGameRules_BalanceTeams* CReGameHookchains::CSGameRules_BalanceTeams() { return &m_CSGameRules_BalanceTeams; }
int CReGameApi::GetMajorVersion()
{
int EXT_FUNC CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR;
}
int CReGameApi::GetMinorVersion()
{
int EXT_FUNC CReGameApi::GetMinorVersion() {
return REGAMEDLL_API_VERSION_MINOR;
}
const ReGameFuncs_t *CReGameApi::GetFuncs()
{
const EXT_FUNC ReGameFuncs_t *CReGameApi::GetFuncs() {
return &g_ReGameApiFuncs;
}
IReGameHookchains *CReGameApi::GetHookchains()
{
IReGameHookchains* EXT_FUNC CReGameApi::GetHookchains() {
return &g_ReGameHookchains;
}
@ -154,6 +153,9 @@ playermove_t* EXT_FUNC CReGameApi::GetPlayerMove() {
WeaponSlotInfo* EXT_FUNC CReGameApi::GetWeaponSlot(WeaponIdType weaponID) { return ::GetWeaponSlot(weaponID); }
WeaponSlotInfo* EXT_FUNC CReGameApi::GetWeaponSlot(const char* weaponName) { return ::GetWeaponSlot(weaponName); }
ItemInfo* EXT_FUNC CReGameApi::GetItemInfo(WeaponIdType weaponID) { return &IMPL_CLASS(CBasePlayerItem, ItemInfoArray)[ weaponID ]; }
AmmoInfo* EXT_FUNC CReGameApi::GetAmmoInfo(AmmoType ammoID) { return &IMPL_CLASS(CBasePlayerItem, AmmoInfoArray)[ ammoID ]; }
void EXT_FUNC Regamedll_ChangeString_api(char *&dest, const char *source)
{
size_t len = Q_strlen(source);

View File

@ -463,6 +463,8 @@ public:
virtual playermove_t* GetPlayerMove();
virtual WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID);
virtual WeaponSlotInfo* GetWeaponSlot(const char* weaponName);
virtual ItemInfo* GetItemInfo(WeaponIdType weaponID);
virtual AmmoInfo* GetAmmoInfo(AmmoType ammoID);
};
void Regamedll_ChangeString_api(char *&dest, const char *source);