Fix: now nades not drop if throws a grenade player.

Rollback: remove virtual destructor in class CBaseEntity
Add: Using info about item from table weaponInfo (yet only for hegrenade, flashbang, smokegrenade)
This commit is contained in:
s1lentq 2016-07-15 20:52:38 +07:00
parent 552a1d1bb4
commit 183a9f674c
12 changed files with 30 additions and 28 deletions

View File

@ -1089,7 +1089,8 @@ void OnFreeEntPrivateData(edict_t *pEnt)
pEntity->m_pEntity = nullptr; pEntity->m_pEntity = nullptr;
} }
// entities can have a own destructor if (g_pMapInfo == pEntity)
pEntity->~CBaseEntity(); g_pMapInfo = nullptr;
#endif #endif
} }

View File

@ -275,13 +275,8 @@ public:
virtual void Blocked(CBaseEntity *pOther) { if (m_pfnBlocked) (this->*m_pfnBlocked)(pOther); } virtual void Blocked(CBaseEntity *pOther) { if (m_pfnBlocked) (this->*m_pfnBlocked)(pOther); }
virtual CBaseEntity *Respawn() { return NULL; } virtual CBaseEntity *Respawn() { return NULL; }
#ifndef REGAMEDLL_ADD
// used by monsters that are created by the MonsterMaker // used by monsters that are created by the MonsterMaker
virtual void UpdateOwner() {} virtual void UpdateOwner() {}
#else
virtual ~CBaseEntity() {}
#endif
virtual BOOL FBecomeProne() { return FALSE; } virtual BOOL FBecomeProne() { return FALSE; }
virtual Vector Center() { return (pev->absmax + pev->absmin) * 0.5f; } virtual Vector Center() { return (pev->absmax + pev->absmin) * 0.5f; }
virtual Vector EyePosition() { return (pev->origin + pev->view_ofs); } virtual Vector EyePosition() { return (pev->origin + pev->view_ofs); }

View File

@ -20,12 +20,6 @@ CMapInfo::CMapInfo()
} }
} }
CMapInfo::~CMapInfo()
{
if (g_pMapInfo == this)
g_pMapInfo = nullptr;
}
void CMapInfo::CheckMapInfo() void CMapInfo::CheckMapInfo()
{ {
bool bCTCantBuy, bTCantBuy; bool bCTCantBuy, bTCantBuy;

View File

@ -32,7 +32,6 @@ class CMapInfo: public CPointEntity
{ {
public: public:
CMapInfo(); CMapInfo();
virtual ~CMapInfo();
virtual void Spawn(); virtual void Spawn();
virtual void KeyValue(KeyValueData *pkvd); virtual void KeyValue(KeyValueData *pkvd);
void CheckMapInfo(); void CheckMapInfo();

View File

@ -3588,7 +3588,6 @@ void CHalfLifeMultiplay::__API_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars
ClientPrint(killer->pev, HUD_PRINTCONSOLE, "#Banned_For_Killing_Teamates"); ClientPrint(killer->pev, HUD_PRINTCONSOLE, "#Banned_For_Killing_Teamates");
int iUserID = GETPLAYERUSERID(killer->edict()); int iUserID = GETPLAYERUSERID(killer->edict());
if (iUserID != -1) if (iUserID != -1)
{ {
SERVER_COMMAND(UTIL_VarArgs("kick # %d\n", iUserID)); SERVER_COMMAND(UTIL_VarArgs("kick # %d\n", iUserID));

View File

@ -1455,14 +1455,16 @@ void packPlayerNade(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo)
break; break;
} }
if (pItem->m_flStartThrow != 0.0f)
{
auto& ammoNades = pPlayer->m_rgAmmo[ pItem->PrimaryAmmoIndex() ]; auto& ammoNades = pPlayer->m_rgAmmo[ pItem->PrimaryAmmoIndex() ];
if (pItem->m_flStartThrow != 0)
{
if (ammoNades < 2) if (ammoNades < 2)
return; return;
ammoNades--; ammoNades--;
} }
else if (pItem->m_flReleaseThrow > 0 && ammoNades < 1)
return;
Vector vecAngles = pPlayer->pev->angles; Vector vecAngles = pPlayer->pev->angles;
Vector dir(Q_cos(vecAngles.y) * flOffset, Q_sin(vecAngles.y) * flOffset, 0.0f); Vector dir(Q_cos(vecAngles.y) * flOffset, Q_sin(vecAngles.y) * flOffset, 0.0f);

View File

@ -256,9 +256,9 @@ WeaponInfoStruct weaponInfo_default[] =
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
{ WEAPON_C4, 0, 0, 0, 0, 0, AMMO_NONE, "weapon_c4", nullptr }, { WEAPON_C4, 0, 0, 0, 0, 0, AMMO_NONE, "weapon_c4", nullptr },
{ WEAPON_KNIFE, 0, 0, 0, 0, 0, AMMO_NONE, "weapon_knife", nullptr }, { WEAPON_KNIFE, 0, 0, 0, 0, 0, AMMO_NONE, "weapon_knife", nullptr },
{ WEAPON_HEGRENADE, (WeaponCostType)HEGRENADE_PRICE, 0, 0, 0, 1, AMMO_NONE, "weapon_hegrenade", nullptr }, { WEAPON_HEGRENADE, (WeaponCostType)HEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_HEGRENADE, AMMO_NONE, "weapon_hegrenade", nullptr },
{ WEAPON_SMOKEGRENADE, (WeaponCostType)SMOKEGRENADE_PRICE, 0, 0, 0, 1, AMMO_NONE, "weapon_smokegrenade", nullptr }, { WEAPON_SMOKEGRENADE, (WeaponCostType)SMOKEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_SMOKEGRENADE, AMMO_NONE, "weapon_smokegrenade", nullptr },
{ WEAPON_FLASHBANG, (WeaponCostType)FLASHBANG_PRICE, 0, 0, 0, 2, AMMO_NONE, "weapon_flashbang", nullptr }, { WEAPON_FLASHBANG, (WeaponCostType)FLASHBANG_PRICE, 0, 0, 0, MAX_AMMO_FLASHBANG, AMMO_NONE, "weapon_flashbang", nullptr },
#endif #endif
{ WEAPON_SHIELDGUN, SHIELDGUN_PRICE, 0, 0, 0, 0, AMMO_NONE, "weapon_shield", nullptr }, { WEAPON_SHIELDGUN, SHIELDGUN_PRICE, 0, 0, 0, 0, AMMO_NONE, "weapon_shield", nullptr },
@ -436,6 +436,7 @@ WeaponInfoStruct* GetWeaponInfo(const char* weaponName)
return &info; return &info;
} }
} }
return nullptr; return nullptr;
} }

View File

@ -32,12 +32,16 @@ void CFlashbang::__MAKE_VHOOK(Precache)()
int CFlashbang::__MAKE_VHOOK(GetItemInfo)(ItemInfo *p) int CFlashbang::__MAKE_VHOOK(GetItemInfo)(ItemInfo *p)
{ {
auto info = GetWeaponInfo(WEAPON_FLASHBANG);
p->pszName = STRING(pev->classname); p->pszName = STRING(pev->classname);
p->pszAmmo1 = "Flashbang"; p->pszAmmo1 = "Flashbang";
p->iMaxAmmo1 = MAX_AMMO_FLASHBANG;
p->iMaxAmmo1 = info ? info->maxRounds : MAX_AMMO_FLASHBANG;
p->iMaxClip = info ? info->gunClipSize : WEAPON_NOCLIP;
p->pszAmmo2 = NULL; p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1; p->iMaxAmmo2 = -1;
p->iMaxClip = WEAPON_NOCLIP;
p->iSlot = 3; p->iSlot = 3;
p->iPosition = 2; p->iPosition = 2;
p->iId = m_iId = WEAPON_FLASHBANG; p->iId = m_iId = WEAPON_FLASHBANG;

View File

@ -35,12 +35,16 @@ void CHEGrenade::__MAKE_VHOOK(Precache)()
int CHEGrenade::__MAKE_VHOOK(GetItemInfo)(ItemInfo *p) int CHEGrenade::__MAKE_VHOOK(GetItemInfo)(ItemInfo *p)
{ {
auto info = GetWeaponInfo(WEAPON_HEGRENADE);
p->pszName = STRING(pev->classname); p->pszName = STRING(pev->classname);
p->pszAmmo1 = "HEGrenade"; p->pszAmmo1 = "HEGrenade";
p->iMaxAmmo1 = MAX_AMMO_HEGRENADE;
p->iMaxAmmo1 = info ? info->maxRounds : MAX_AMMO_HEGRENADE;
p->iMaxClip = info ? info->gunClipSize : WEAPON_NOCLIP;
p->pszAmmo2 = NULL; p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1; p->iMaxAmmo2 = -1;
p->iMaxClip = WEAPON_NOCLIP;
p->iSlot = 3; p->iSlot = 3;
p->iPosition = 1; p->iPosition = 1;
p->iId = m_iId = WEAPON_HEGRENADE; p->iId = m_iId = WEAPON_HEGRENADE;

View File

@ -33,12 +33,16 @@ void CSmokeGrenade::__MAKE_VHOOK(Precache)()
int CSmokeGrenade::__MAKE_VHOOK(GetItemInfo)(ItemInfo *p) int CSmokeGrenade::__MAKE_VHOOK(GetItemInfo)(ItemInfo *p)
{ {
auto info = GetWeaponInfo(WEAPON_SMOKEGRENADE);
p->pszName = STRING(pev->classname); p->pszName = STRING(pev->classname);
p->pszAmmo1 = "SmokeGrenade"; p->pszAmmo1 = "SmokeGrenade";
p->iMaxAmmo1 = MAX_AMMO_SMOKEGRENADE;
p->iMaxAmmo1 = info ? info->maxRounds : MAX_AMMO_SMOKEGRENADE;
p->iMaxClip = info ? info->gunClipSize : WEAPON_NOCLIP;
p->pszAmmo2 = NULL; p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1; p->iMaxAmmo2 = -1;
p->iMaxClip = WEAPON_NOCLIP;
p->iSlot = 3; p->iSlot = 3;
p->iPosition = 3; p->iPosition = 3;
p->iId = m_iId = WEAPON_SMOKEGRENADE; p->iId = m_iId = WEAPON_SMOKEGRENADE;

View File

@ -116,7 +116,7 @@ public:
virtual void Blocked(CBaseEntity *pOther) = 0; virtual void Blocked(CBaseEntity *pOther) = 0;
virtual CBaseEntity *Respawn() = 0; virtual CBaseEntity *Respawn() = 0;
virtual ~CBaseEntity() = 0; // NOTE: it was replaced on function "virtual void UpdateOwner() {}" which is not used. virtual void UpdateOwner() = 0;
virtual BOOL FBecomeProne() = 0; virtual BOOL FBecomeProne() = 0;
virtual Vector Center() = 0; // center point of entity virtual Vector Center() = 0; // center point of entity

View File

@ -31,7 +31,6 @@
class CMapInfo: public CPointEntity class CMapInfo: public CPointEntity
{ {
public: public:
virtual ~CMapInfo() = 0;
virtual void Spawn() = 0; virtual void Spawn() = 0;
virtual void KeyValue(KeyValueData *pkvd) = 0; virtual void KeyValue(KeyValueData *pkvd) = 0;