From c3e632eacce46a7ade35efbb8c320d0e87ef6e5c Mon Sep 17 00:00:00 2001 From: s1lentq Date: Tue, 2 Aug 2016 09:03:01 +0000 Subject: [PATCH] adjustment physics of amoury_entity (#51) --- regamedll/dlls/cbase.cpp | 6 +++--- regamedll/dlls/multiplay_gamerules.cpp | 12 ++++++------ regamedll/dlls/player.cpp | 2 +- regamedll/dlls/weapons.cpp | 25 ++++++++++++++++++++++++- 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/regamedll/dlls/cbase.cpp b/regamedll/dlls/cbase.cpp index d41c86e6..327537af 100644 --- a/regamedll/dlls/cbase.cpp +++ b/regamedll/dlls/cbase.cpp @@ -288,7 +288,7 @@ void printEntities() NOINLINE edict_t *EXT_FUNC CREATE_NAMED_ENTITY(string_t iClass) { edict_t *named = g_engfuncs.pfnCreateNamedEntity(iClass); - if (named != NULL) + if (named) { AddEntityHashValue(&named->v, STRING(iClass), CLASSNAME); } @@ -715,7 +715,7 @@ void EXT_FUNC DispatchObjectCollsionBox(edict_t *pent) { CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); - if (pEntity != NULL) + if (pEntity) { pEntity->SetObjectCollisionBox(); } @@ -918,7 +918,7 @@ int CBaseEntity::__MAKE_VHOOK(Restore)(CRestore &restore) // Initialize absmin & absmax to the appropriate box void SetObjectCollisionBox(entvars_t *pev) { - if ((pev->solid == SOLID_BSP) && (pev->angles.x || pev->angles.y || pev->angles.z)) + if (pev->solid == SOLID_BSP && (pev->angles.x || pev->angles.y || pev->angles.z)) { // expand for rotation float_precision max, v; diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index fce824ab..c96a6cc6 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -3169,7 +3169,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl) // FIXME: Probably don't need to cast this just to read m_iDeaths CBasePlayer *plr = UTIL_PlayerByIndex(i); - if (plr != NULL) + if (plr) { MESSAGE_BEGIN(MSG_ONE, gmsgScoreInfo, NULL, pl->edict()); WRITE_BYTE(i); // client number @@ -3211,7 +3211,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl) { CBasePlayer *plr = UTIL_PlayerByIndex(i); - if (plr != NULL) + if (plr) { MESSAGE_BEGIN(MSG_ONE, gmsgTeamInfo, NULL, pl->edict()); WRITE_BYTE(plr->entindex()); @@ -3242,7 +3242,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl) { CBaseEntity *pWeaponC4 = UTIL_FindEntityByClassname(NULL, "weapon_c4"); - if (pWeaponC4 != NULL) + if (pWeaponC4) { MESSAGE_BEGIN(MSG_ONE, gmsgBombDrop, NULL, pl->edict()); WRITE_COORD(pWeaponC4->pev->origin.x); @@ -3256,11 +3256,11 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(InitHUD)(CBasePlayer *pl) void CHalfLifeMultiplay::__MAKE_VHOOK(ClientDisconnected)(edict_t *pClient) { - if (pClient != NULL) + if (pClient) { CBasePlayer *pPlayer = static_cast(CBaseEntity::Instance(pClient)); - if (pPlayer != NULL) + if (pPlayer) { pPlayer->has_disconnected = true; pPlayer->pev->deadflag = DEAD_DEAD; @@ -3319,7 +3319,7 @@ void CHalfLifeMultiplay::__MAKE_VHOOK(ClientDisconnected)(edict_t *pClient) // destroy all of the players weapons and items pPlayer->RemoveAllItems(TRUE); - if (pPlayer->m_pObserver != NULL) + if (pPlayer->m_pObserver) { pPlayer->m_pObserver->SUB_Remove(); } diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index e83f95e1..0d971983 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -4224,7 +4224,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(PreThink)() // These buttons have changed this frame int buttonsChanged = (m_afButtonLast ^ pev->button); - //this means the player has pressed or released a key + // this means the player has pressed or released a key if (buttonsChanged) { m_fLastMovement = gpGlobals->time; diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index a0935f4a..a8b6423b 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -486,7 +486,7 @@ void CBasePlayerItem::FallInit() UTIL_SetOrigin(pev, pev->origin); - //pointsize until it lands on the ground. + // pointsize until it lands on the ground. UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); SetTouch(&CBasePlayerItem::DefaultTouch); @@ -1418,6 +1418,7 @@ void CBasePlayerAmmo::__MAKE_VHOOK(Spawn)() { pev->movetype = MOVETYPE_TOSS; pev->solid = SOLID_TRIGGER; + UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); UTIL_SetOrigin(pev, pev->origin); @@ -2107,6 +2108,12 @@ char *armouryItemModels[] = { void CArmoury::__MAKE_VHOOK(Spawn)() { Precache(); + +#ifdef REGAMEDLL_FIXES + // do it earlier than set UTIL_SetSize to avoid resetting mins/maxs. + SET_MODEL(ENT(pev), armouryItemModels[m_iItem]); +#endif + pev->movetype = MOVETYPE_TOSS; pev->solid = SOLID_TRIGGER; @@ -2114,13 +2121,21 @@ void CArmoury::__MAKE_VHOOK(Spawn)() UTIL_SetOrigin(pev, pev->origin); SetTouch(&CArmoury::ArmouryTouch); + +#ifndef REGAMEDLL_FIXES SET_MODEL(ENT(pev), armouryItemModels[m_iItem]); +#endif if (m_iCount <= 0) { m_iCount = 1; } +#ifdef REGAMEDLL_ADD + // Cache the placed origin of source point + pev->oldorigin = pev->origin; +#endif + m_bAlreadyCounted = false; m_iInitialCount = m_iCount; } @@ -2186,6 +2201,14 @@ void CArmoury::__MAKE_VHOOK(Restart)() if (m_iCount < 1) m_iCount = 1; +#ifdef REGAMEDLL_ADD + // Restored origin from the cache + UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); + UTIL_SetOrigin(pev, pev->oldorigin); + + DROP_TO_FLOOR(edict()); +#endif + Draw(); }