From 1ea69570cb1124dad84406b06e5bb52e7151d68a Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Fri, 2 Aug 2019 05:40:59 +0500 Subject: [PATCH] Do not break Save/Restore(Think/Touch-functions must not virtual). --- dlls/hgrunt.cpp | 10 ++++++ dlls/hgrunt.h | 14 -------- dlls/osprey.cpp | 12 +++++-- dlls/osprey.h | 4 +-- dlls/rp/blkop_osprey.cpp | 73 ---------------------------------------- dlls/rp/fgrunt.cpp | 3 +- dlls/rp/massn.cpp | 12 ++++++- dlls/rp/ngrunt.cpp | 3 +- dlls/rp/zgrunt.cpp | 3 +- 9 files changed, 39 insertions(+), 95 deletions(-) diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index cf57f036..95ac5f77 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -2189,6 +2189,16 @@ Schedule_t *CHGrunt::GetScheduleOfType( int Type ) // CHGruntRepel - when triggered, spawns a monster_human_grunt // repelling down a line. //========================================================= + +class CHGruntRepel : public CBaseMonster +{ +public: + void Spawn(void); + void Precache(void); + void EXPORT RepelUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + int m_iSpriteTexture; // Don't save, precache +}; + LINK_ENTITY_TO_CLASS( monster_grunt_repel, CHGruntRepel ) void CHGruntRepel::Spawn( void ) diff --git a/dlls/hgrunt.h b/dlls/hgrunt.h index 153b2bbb..3b07480c 100644 --- a/dlls/hgrunt.h +++ b/dlls/hgrunt.h @@ -171,18 +171,4 @@ typedef enum HGRUNT_SENT_TAUNT } HGRUNT_SENTENCE_TYPES; -//========================================================= -// CHGruntRepel - when triggered, spawns a monster_human_grunt -// repelling down a line. -//========================================================= - -class CHGruntRepel : public CBaseMonster -{ -public: - virtual void Spawn(void); - virtual void Precache(void); - virtual void EXPORT RepelUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - int m_iSpriteTexture; // Don't save, precache -}; - #endif // HGRUNT_H diff --git a/dlls/osprey.cpp b/dlls/osprey.cpp index aeb8e959..ca60847a 100644 --- a/dlls/osprey.cpp +++ b/dlls/osprey.cpp @@ -135,9 +135,13 @@ void COsprey::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP void COsprey::FindAllThink( void ) { CBaseEntity *pEntity = NULL; + const char *pszName = "monster_human_grunt"; + + if( FClassnameIs( pev, "monster_blkop_osprey" ) ) + pszName = "monster_male_assassin"; m_iUnits = 0; - while( m_iUnits < OSPREY_MAX_CARRY && ( pEntity = UTIL_FindEntityByClassname( pEntity, "monster_human_grunt" ) ) != NULL ) + while( m_iUnits < OSPREY_MAX_CARRY && ( pEntity = UTIL_FindEntityByClassname( pEntity, pszName ) ) != NULL ) { if( pEntity->IsAlive() ) { @@ -208,6 +212,10 @@ CBaseMonster *COsprey::MakeGrunt( Vector vecSrc ) { CBaseEntity *pEntity; CBaseMonster *pGrunt; + const char *pszName = "monster_human_grunt"; + + if( FClassnameIs( pev, "monster_blkop_osprey" ) ) + pszName = "monster_male_assassin"; TraceResult tr; UTIL_TraceLine( vecSrc, vecSrc + Vector( 0, 0, -4096.0 ), dont_ignore_monsters, ENT( pev ), &tr ); @@ -222,7 +230,7 @@ CBaseMonster *COsprey::MakeGrunt( Vector vecSrc ) { m_hGrunt[i]->SUB_StartFadeOut(); } - pEntity = Create( "monster_human_grunt", vecSrc, pev->angles ); + pEntity = Create( pszName, vecSrc, pev->angles ); pGrunt = pEntity->MyMonsterPointer(); pGrunt->pev->movetype = MOVETYPE_FLY; pGrunt->pev->velocity = Vector( 0, 0, RANDOM_FLOAT( -196, -128 ) ); diff --git a/dlls/osprey.h b/dlls/osprey.h index 93d51a5c..90d77bab 100644 --- a/dlls/osprey.h +++ b/dlls/osprey.h @@ -37,9 +37,9 @@ public: void EXPORT DeployThink(void); void Flight(void); void EXPORT HitTouch(CBaseEntity *pOther); - virtual void EXPORT FindAllThink(void); + void EXPORT FindAllThink(void); void EXPORT HoverThink(void); - virtual CBaseMonster *MakeGrunt(Vector vecSrc); + CBaseMonster *MakeGrunt(Vector vecSrc); void EXPORT CrashTouch(CBaseEntity *pOther); void EXPORT DyingThink(void); void EXPORT CommandUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); diff --git a/dlls/rp/blkop_osprey.cpp b/dlls/rp/blkop_osprey.cpp index 367a1176..b7d76249 100644 --- a/dlls/rp/blkop_osprey.cpp +++ b/dlls/rp/blkop_osprey.cpp @@ -31,13 +31,8 @@ class CBlkopOsprey : public COsprey { public: - void Spawn( void ); void Precache( void ); - - void EXPORT FindAllThink(void); - - CBaseMonster *MakeGrunt(Vector vecSrc); }; LINK_ENTITY_TO_CLASS(monster_blkop_osprey, CBlkopOsprey); @@ -99,71 +94,3 @@ void CBlkopOsprey::Precache(void) m_iEngineGibs = PRECACHE_MODEL("models/blkop_enginegibs.mdl"); } - -void CBlkopOsprey::FindAllThink(void) -{ - CBaseEntity *pEntity = NULL; - - m_iUnits = 0; - while (m_iUnits < MAX_CARRY && (pEntity = UTIL_FindEntityByClassname(pEntity, "monster_male_assassin")) != NULL) - { - if (pEntity->IsAlive()) - { - m_hGrunt[m_iUnits] = pEntity; - m_vecOrigin[m_iUnits] = pEntity->pev->origin; - m_iUnits++; - } - } - - if (m_iUnits == 0) - { - ALERT(at_console, "osprey error: no assassins to resupply\n"); - UTIL_Remove(this); - return; - } - SetThink(&COsprey::FlyThink); - pev->nextthink = gpGlobals->time + 0.1; - m_startTime = gpGlobals->time; -} - - -CBaseMonster *CBlkopOsprey::MakeGrunt(Vector vecSrc) -{ - CBaseEntity *pEntity; - CBaseMonster *pGrunt; - - TraceResult tr; - UTIL_TraceLine(vecSrc, vecSrc + Vector(0, 0, -4096.0), dont_ignore_monsters, ENT(pev), &tr); - if (tr.pHit && Instance(tr.pHit)->pev->solid != SOLID_BSP) - return NULL; - - for (int i = 0; i < m_iUnits; i++) - { - if (m_hGrunt[i] == 0 || !m_hGrunt[i]->IsAlive()) - { - if (m_hGrunt[i] != 0 && m_hGrunt[i]->pev->rendermode == kRenderNormal) - { - m_hGrunt[i]->SUB_StartFadeOut(); - } - pEntity = Create("monster_male_assassin", vecSrc, pev->angles); - pGrunt = pEntity->MyMonsterPointer(); - pGrunt->pev->movetype = MOVETYPE_FLY; - pGrunt->pev->velocity = Vector(0, 0, RANDOM_FLOAT(-196, -128)); - pGrunt->SetActivity(ACT_GLIDE); - - CBeam *pBeam = CBeam::BeamCreate("sprites/rope.spr", 10); - pBeam->PointEntInit(vecSrc + Vector(0, 0, 112), pGrunt->entindex()); - pBeam->SetFlags(BEAM_FSOLID); - pBeam->SetColor(255, 255, 255); - pBeam->SetThink(&CBeam::SUB_Remove); - pBeam->pev->nextthink = gpGlobals->time + -4096.0 * tr.flFraction / pGrunt->pev->velocity.z + 0.5; - - // ALERT( at_console, "%d at %.0f %.0f %.0f\n", i, m_vecOrigin[i].x, m_vecOrigin[i].y, m_vecOrigin[i].z ); - pGrunt->m_vecLastPosition = m_vecOrigin[i]; - m_hGrunt[i] = pGrunt; - return pGrunt; - } - } - // ALERT( at_console, "none dead\n"); - return NULL; -} diff --git a/dlls/rp/fgrunt.cpp b/dlls/rp/fgrunt.cpp index 0abd6f66..bcb8ea03 100644 --- a/dlls/rp/fgrunt.cpp +++ b/dlls/rp/fgrunt.cpp @@ -915,12 +915,13 @@ Schedule_t *CFGrunt::GetScheduleOfType( int Type ) // CNGruntRepel - when triggered, spawns a monster_nari_grunt // repelling down a line. //========================================================= -class CFGruntRepel : public CHGruntRepel +class CFGruntRepel : public CBaseMonster { public: void Spawn(void); void Precache(void); void EXPORT RepelUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + int m_iSpriteTexture; // Don't save, precache }; LINK_ENTITY_TO_CLASS( monster_grunt_repel_ally, CFGruntRepel ) diff --git a/dlls/rp/massn.cpp b/dlls/rp/massn.cpp index 03f9ef2a..83be8899 100644 --- a/dlls/rp/massn.cpp +++ b/dlls/rp/massn.cpp @@ -349,11 +349,13 @@ void CMassn::DeathSound(void) // repelling down a line. //========================================================= -class CAssassinRepel : public CHGruntRepel +class CAssassinRepel : public CBaseMonster { public: void Precache(void); + void Spawn(); void EXPORT RepelUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + int m_iSpriteTexture; // Don't save, precache }; LINK_ENTITY_TO_CLASS(monster_assassin_repel, CAssassinRepel); @@ -364,6 +366,14 @@ void CAssassinRepel::Precache(void) m_iSpriteTexture = PRECACHE_MODEL("sprites/rope.spr"); } +void CAssassinRepel::Spawn( void ) +{ + Precache(); + pev->solid = SOLID_NOT; + + SetUse( &CAssassinRepel::RepelUse ); +} + void CAssassinRepel::RepelUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { TraceResult tr; diff --git a/dlls/rp/ngrunt.cpp b/dlls/rp/ngrunt.cpp index 95f2d0a5..1f4c5845 100644 --- a/dlls/rp/ngrunt.cpp +++ b/dlls/rp/ngrunt.cpp @@ -882,12 +882,13 @@ Schedule_t *CNGrunt::GetScheduleOfType( int Type ) // CNGruntRepel - when triggered, spawns a monster_nari_grunt // repelling down a line. //========================================================= -class CNGruntRepel : public CHGruntRepel +class CNGruntRepel : public CBaseMonster { public: void Spawn(void); void Precache(void); void EXPORT RepelUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + int m_iSpriteTexture; // Don't save, precache }; LINK_ENTITY_TO_CLASS( monster_ngrunt_repel, CNGruntRepel ) diff --git a/dlls/rp/zgrunt.cpp b/dlls/rp/zgrunt.cpp index 123a578a..997c9317 100644 --- a/dlls/rp/zgrunt.cpp +++ b/dlls/rp/zgrunt.cpp @@ -933,12 +933,13 @@ Schedule_t *CZGrunt::GetScheduleOfType( int Type ) // CZGruntRepel - when triggered, spawns a monster_nari_grunt // repelling down a line. //========================================================= -class CZGruntRepel : public CHGruntRepel +class CZGruntRepel : public CBaseMonster { public: void Spawn(void); void Precache(void); void EXPORT RepelUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + int m_iSpriteTexture; // Don't save, precache }; LINK_ENTITY_TO_CLASS( monster_zgrunt_repel, CZGruntRepel )