From 2265047bfe21b1bdc8620f91b5388ffdf0db38eb Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Wed, 16 Nov 2022 14:04:10 -0800 Subject: [PATCH] Fix a bunch of nonvirtual/virtual mismatching going on that's been caught by the new compiler. --- .../shared/prop_vehicle_driveable.qc | 89 +- src/shared/NSEntity.h | 8 +- src/shared/NSEntity.qc | 961 +++++++----------- src/shared/NSIO.h | 41 +- src/shared/NSMonster.h | 2 +- src/shared/NSMonster.qc | 2 + src/shared/NSRenderableEntity.h | 8 +- src/shared/NSTalkMonster.h | 2 +- src/shared/NSTalkMonster.qc | 2 + src/shared/NSTrigger.h | 17 +- src/shared/NSWeapon.h | 3 +- src/shared/NSWeapon.qc | 6 - 12 files changed, 473 insertions(+), 668 deletions(-) diff --git a/src/gs-entbase/shared/prop_vehicle_driveable.qc b/src/gs-entbase/shared/prop_vehicle_driveable.qc index bbdff41a..04f30f96 100644 --- a/src/gs-entbase/shared/prop_vehicle_driveable.qc +++ b/src/gs-entbase/shared/prop_vehicle_driveable.qc @@ -48,6 +48,7 @@ enumflags class prop_vehicle_driveable_wheel { void() prop_vehicle_driveable_wheel; + float m_flSuspension; float m_flSuspensionForce; @@ -122,6 +123,50 @@ class prop_vehicle_driveable:NSVehicle virtual float(entity, float) SendEntity; #endif }; + +void +prop_vehicle_driveable::prop_vehicle_driveable(void) +{ + m_eDriver = __NULL__; + m_flBounceFactor = 1.25f; + m_flAcceleration = 600.0f; + m_flSkidSpeed = 256.0f; + m_flTraction = 5.0f; + m_flBreakFactor = 2.0f; + m_flSteerFactor = 1.0f; + m_flStraightenFactor = 1.0f; + m_vecGravityDir = [0,0,-1]; + m_iVehicleFlags |= VHF_FROZEN; + hitcontentsmaski = CONTENTBIT_BODY | CONTENTBITS_POINTSOLID | CONTENTBIT_VEHICLECLIP; + + if (!m_eCollBox1) + m_eCollBox1 = spawn(NSEntity); + if (!m_eCollBox2) + m_eCollBox2 = spawn(NSEntity); + + { + m_eCollBox1.SetSize([-32,-32,0], [32,32,32]); + m_eCollBox2.SetSize([-32,-32,0], [32,32,32]); + } + + m_eCollBox1.hitcontentsmaski = hitcontentsmaski; + m_eCollBox2.hitcontentsmaski = hitcontentsmaski; + + if (!m_wlFL) + m_wlFL = spawn(prop_vehicle_driveable_wheel); + if (!m_wlFR) + m_wlFR = spawn(prop_vehicle_driveable_wheel); + if (!m_wlBL) + m_wlBL = spawn(prop_vehicle_driveable_wheel); + if (!m_wlBR) + m_wlBR = spawn(prop_vehicle_driveable_wheel); + + m_eCollBox1.owner = m_eCollBox2.owner = \ + m_wlFL.owner = m_wlFR.owner = \ + m_wlBL.owner = m_wlBR.owner = this; + + customphysics = Physics; +} #ifdef CLIENT bool @@ -853,50 +898,6 @@ prop_vehicle_driveable::Spawned(void) #endif } -void -prop_vehicle_driveable::prop_vehicle_driveable(void) -{ - m_eDriver = __NULL__; - m_flBounceFactor = 1.25f; - m_flAcceleration = 600.0f; - m_flSkidSpeed = 256.0f; - m_flTraction = 5.0f; - m_flBreakFactor = 2.0f; - m_flSteerFactor = 1.0f; - m_flStraightenFactor = 1.0f; - m_vecGravityDir = [0,0,-1]; - m_iVehicleFlags |= VHF_FROZEN; - hitcontentsmaski = CONTENTBIT_BODY | CONTENTBITS_POINTSOLID | CONTENTBIT_VEHICLECLIP; - - if (!m_eCollBox1) - m_eCollBox1 = spawn(NSEntity); - if (!m_eCollBox2) - m_eCollBox2 = spawn(NSEntity); - - { - m_eCollBox1.SetSize([-32,-32,0], [32,32,32]); - m_eCollBox2.SetSize([-32,-32,0], [32,32,32]); - } - - m_eCollBox1.hitcontentsmaski = hitcontentsmaski; - m_eCollBox2.hitcontentsmaski = hitcontentsmaski; - - if (!m_wlFL) - m_wlFL = spawn(prop_vehicle_driveable_wheel); - if (!m_wlFR) - m_wlFR = spawn(prop_vehicle_driveable_wheel); - if (!m_wlBL) - m_wlBL = spawn(prop_vehicle_driveable_wheel); - if (!m_wlBR) - m_wlBR = spawn(prop_vehicle_driveable_wheel); - - m_eCollBox1.owner = m_eCollBox2.owner = \ - m_wlFL.owner = m_wlFR.owner = \ - m_wlBL.owner = m_wlBR.owner = this; - - customphysics = Physics; -} - #ifdef CLIENT void prop_vehicle_driveable_readentity(float isnew) diff --git a/src/shared/NSEntity.h b/src/shared/NSEntity.h index 7b9f75d6..dc798cc3 100644 --- a/src/shared/NSEntity.h +++ b/src/shared/NSEntity.h @@ -115,6 +115,9 @@ public: virtual void Save(float); virtual void Restore(string,string); + /** Called when we need to re-align the entity to our parent entity. */ + virtual void ParentUpdate(void); + /** Called when the entity has been successfully restored from a savegame file. */ virtual void RestoreComplete(void); @@ -136,9 +139,6 @@ public: /** Call this on an entity to remove the connection to its parent. */ nonvirtual void ClearParent(void); - /** Called when we need to re-align the entity to our parent entity. */ - virtual void ParentUpdate(void); - /** Restore the entity's angles to the value they spawned with. */ nonvirtual void RestoreAngles(void); @@ -172,7 +172,7 @@ public: /** Sets the collision type of the entity. Check the solid_t enum for available types. */ nonvirtual void SetSolid(float); /** Sets the 3D model representation of the entity from a file path and name. */ - nonvirtual void SetModel(string); + virtual void SetModel(string); /** Sets the 3D model representation of the entity from an already precached resource id. */ nonvirtual void SetModelindex(float); /** Sets the movement type of the entity. Check the movetype_t enum for available types. */ diff --git a/src/shared/NSEntity.qc b/src/shared/NSEntity.qc index 3a9c51d3..7c1a5648 100644 --- a/src/shared/NSEntity.qc +++ b/src/shared/NSEntity.qc @@ -21,77 +21,63 @@ NSEntity::NSEntity client doesn't have to do a whole lot here ============ */ -void -NSEntity::NSEntity(void) -{ +void NSEntity::NSEntity( void ) { #ifdef SERVER identity = 1; #endif } -void -NSEntity::Spawned(void) -{ +void NSEntity::Spawned( void ) { super::Spawned(); m_oldAngle = angles; m_oldOrigin = origin; - m_oldModel = Util_FixModel(model); + m_oldModel = Util_FixModel( model ); m_oldSolid = solid; #ifdef SERVER m_oldstrTarget = target; - if (m_oldModel) { - precache_model(GetSpawnModel()); + if ( m_oldModel ) { + precache_model( GetSpawnModel() ); } - if (m_strOnTrigger) - m_strOnTrigger = CreateOutput(m_strOnTrigger); + if ( m_strOnTrigger ) { + m_strOnTrigger = CreateOutput( m_strOnTrigger ); + } #endif } -float -NSEntity::EntIndex(void) -{ - return (num_for_edict(this)); +float NSEntity::EntIndex( void ) { + return ( num_for_edict( this ) ); } -void -droptofloorwrapper(entity foo) -{ +void droptofloorwrapper( entity foo ) { entity old_self = self; + self = foo; droptofloor(); self = old_self; } -void -NSEntity::DropToFloor(void) -{ - droptofloorwrapper(this); +void NSEntity::DropToFloor( void ) { + droptofloorwrapper( this ); } -vector -NSEntity::GetForward(void) -{ - makevectors(angles); - return (v_forward); +vector NSEntity::GetForward( void ) { + makevectors( angles ); + return ( v_forward ); } -vector -NSEntity::GetRight(void) -{ - makevectors(angles); - return (v_right); +vector NSEntity::GetRight( void ) { + makevectors( angles ); + return ( v_right ); } -vector -NSEntity::GetUp(void) -{ - makevectors(angles); - return (v_up); +vector NSEntity::GetUp( void ) { + makevectors( angles ); + return ( v_up ); } /* @@ -102,10 +88,8 @@ Returns the center of an entity's bounding boxes. Useful on brush entities that have no real 'origin' defined. ============ */ -vector -NSEntity::WorldSpaceCenter(void) -{ - return (absmin + (0.5 * (absmax - absmin))); +vector NSEntity::WorldSpaceCenter( void ) { + return ( absmin + ( 0.5 * ( absmax - absmin ) ) ); } /* @@ -115,10 +99,8 @@ NSEntity::WaterLevel Returns whether or not the entity is able to see a given position ============ */ -float -NSEntity::WaterLevel(void) -{ - return (waterlevel); +float NSEntity::WaterLevel( void ) { + return ( waterlevel ); } /* @@ -128,23 +110,21 @@ NSEntity::VisibleVec Returns whether or not the entity is able to see a given position ============ */ -bool -NSEntity::VisibleVec(vector org) -{ +bool NSEntity::VisibleVec( vector org ) { vector flDelta; float flFoV; - makevectors(angles); - flDelta = normalize (org - origin); + makevectors( angles ); + flDelta = normalize( org - origin ); flFoV = flDelta * v_forward; - if (flFoV > 0.3f) { - traceline(origin, org, TRUE, this); - if (trace_fraction == 1.0f) { - return (true); + if ( flFoV > 0.3f ) { + traceline( origin, org, TRUE, this ); + if ( trace_fraction == 1.0f ) { + return ( true ); } } - return (false); + return ( false ); } /* @@ -154,56 +134,44 @@ NSEntity::Visible Returns whether or not the entity is able to see a given entity ============ */ -bool -NSEntity::Visible(entity ent) -{ +bool NSEntity::Visible( entity ent ) { vector flDelta; float flFoV; - makevectors(angles); - flDelta = normalize(ent.origin - origin); + makevectors( angles ); + flDelta = normalize( ent.origin - origin ); flFoV = flDelta * v_forward; /* is it in our field of view? */ - if (flFoV > 0.3f) { - traceline(origin, ent.origin, MOVE_NORMAL, this); - if (trace_fraction == 1.0f || trace_ent == ent) { - print(sprintf("%s can see %s\n", classname, ent.classname)); - return (true); + if ( flFoV > 0.3f ) { + traceline( origin, ent.origin, MOVE_NORMAL, this ); + if ( trace_fraction == 1.0f || trace_ent == ent ) { + print( sprintf( "%s can see %s\n", classname, ent.classname ) ); + return ( true ); } } - print(sprintf("%s can not see %s\n", classname, ent.classname)); - return (false); + print( sprintf( "%s can not see %s\n", classname, ent.classname ) ); + return ( false ); } -bool -NSEntity::HasSpawnFlags(float sf) -{ - return (spawnflags & sf) ? true : false; +bool NSEntity::HasSpawnFlags( float sf ) { + return ( spawnflags & sf ) ? true : false; } -bool -NSEntity::IsOnGround(void) -{ - return (flags & FL_ONGROUND) ? true : false; +bool NSEntity::IsOnGround( void ) { + return ( flags & FL_ONGROUND ) ? true : false; } -bool -NSEntity::IsSolid(void) -{ - return (solid != SOLID_NOT) ? true : false; +bool NSEntity::IsSolid( void ) { + return ( solid != SOLID_NOT ) ? true : false; } -entity -NSEntity::GetGroundEntity(void) -{ - return (groundentity); +entity NSEntity::GetGroundEntity( void ) { + return ( groundentity ); } -bool -NSEntity::CreatedByMap(void) -{ - return (_mapspawned); +bool NSEntity::CreatedByMap( void ) { + return ( _mapspawned ); } @@ -217,10 +185,8 @@ make sure any child-classes precache their assets in here for vid_reload calls or other sudden deaths (driver restarts) ============ */ -void -NSEntity::RendererRestarted(void) -{ - +void NSEntity::RendererRestarted( void ) { + } /* @@ -228,49 +194,46 @@ NSEntity::RendererRestarted(void) NSEntity::ReceiveEntity ============ */ -void -NSEntity::ReceiveEntity(float flNew, float flChanged) -{ - READENTITY_COORD(origin[0], BASEFL_CHANGED_ORIGIN_X) - READENTITY_COORD(origin[1], BASEFL_CHANGED_ORIGIN_Y) - READENTITY_COORD(origin[2], BASEFL_CHANGED_ORIGIN_Z) - READENTITY_ANGLE(angles[0], BASEFL_CHANGED_ANGLES_X) - READENTITY_ANGLE(angles[1], BASEFL_CHANGED_ANGLES_Y) - READENTITY_ANGLE(angles[2], BASEFL_CHANGED_ANGLES_Z) - READENTITY_SHORT(modelindex, BASEFL_CHANGED_MODELINDEX) - READENTITY_BYTE(solid, BASEFL_CHANGED_SOLID) - READENTITY_BYTE(movetype, BASEFL_CHANGED_FLAGS) - READENTITY_INT(flags, BASEFL_CHANGED_FLAGS) - READENTITY_COORD(mins[0], BASEFL_CHANGED_SIZE) - READENTITY_COORD(mins[1], BASEFL_CHANGED_SIZE) - READENTITY_COORD(mins[2], BASEFL_CHANGED_SIZE) - READENTITY_COORD(maxs[0], BASEFL_CHANGED_SIZE) - READENTITY_COORD(maxs[1], BASEFL_CHANGED_SIZE) - READENTITY_COORD(maxs[2], BASEFL_CHANGED_SIZE) - READENTITY_BYTE(frame, BASEFL_CHANGED_FRAME) - READENTITY_FLOAT(skin, BASEFL_CHANGED_SKIN) - READENTITY_FLOAT(effects, BASEFL_CHANGED_EFFECTS) - READENTITY_FLOAT(scale, BASEFL_CHANGED_SCALE) - READENTITY_COORD(velocity[0], BASEFL_CHANGED_VELOCITY_X) - READENTITY_COORD(velocity[1], BASEFL_CHANGED_VELOCITY_Y) - READENTITY_COORD(velocity[2], BASEFL_CHANGED_VELOCITY_Z) - READENTITY_COORD(avelocity[0], BASEFL_CHANGED_ANGULARVELOCITY) - READENTITY_COORD(avelocity[1], BASEFL_CHANGED_ANGULARVELOCITY) - READENTITY_COORD(avelocity[2], BASEFL_CHANGED_ANGULARVELOCITY) - - if (modelindex) { +void NSEntity::ReceiveEntity( float flNew, float flChanged ) { + READENTITY_COORD( origin[0], BASEFL_CHANGED_ORIGIN_X ) + READENTITY_COORD( origin[1], BASEFL_CHANGED_ORIGIN_Y ) + READENTITY_COORD( origin[2], BASEFL_CHANGED_ORIGIN_Z ) + READENTITY_ANGLE( angles[0], BASEFL_CHANGED_ANGLES_X ) + READENTITY_ANGLE( angles[1], BASEFL_CHANGED_ANGLES_Y ) + READENTITY_ANGLE( angles[2], BASEFL_CHANGED_ANGLES_Z ) + READENTITY_SHORT( modelindex, BASEFL_CHANGED_MODELINDEX ) + READENTITY_BYTE( solid, BASEFL_CHANGED_SOLID ) + READENTITY_BYTE( movetype, BASEFL_CHANGED_FLAGS ) + READENTITY_INT( flags, BASEFL_CHANGED_FLAGS ) + READENTITY_COORD( mins[0], BASEFL_CHANGED_SIZE ) + READENTITY_COORD( mins[1], BASEFL_CHANGED_SIZE ) + READENTITY_COORD( mins[2], BASEFL_CHANGED_SIZE ) + READENTITY_COORD( maxs[0], BASEFL_CHANGED_SIZE ) + READENTITY_COORD( maxs[1], BASEFL_CHANGED_SIZE ) + READENTITY_COORD( maxs[2], BASEFL_CHANGED_SIZE ) + READENTITY_BYTE( frame, BASEFL_CHANGED_FRAME ) + READENTITY_FLOAT( skin, BASEFL_CHANGED_SKIN ) + READENTITY_FLOAT( effects, BASEFL_CHANGED_EFFECTS ) + READENTITY_FLOAT( scale, BASEFL_CHANGED_SCALE ) + READENTITY_COORD( velocity[0], BASEFL_CHANGED_VELOCITY_X ) + READENTITY_COORD( velocity[1], BASEFL_CHANGED_VELOCITY_Y ) + READENTITY_COORD( velocity[2], BASEFL_CHANGED_VELOCITY_Z ) + READENTITY_COORD( avelocity[0], BASEFL_CHANGED_ANGULARVELOCITY ) + READENTITY_COORD( avelocity[1], BASEFL_CHANGED_ANGULARVELOCITY ) + READENTITY_COORD( avelocity[2], BASEFL_CHANGED_ANGULARVELOCITY ) + if ( modelindex ) { drawmask = MASK_ENGINE; } else { drawmask = 0; } - if (scale == 0.0f) + if ( scale == 0.0f ) scale = 1.0f; - if (flChanged & BASEFL_CHANGED_SIZE) - setsize(this, mins, maxs); + if ( flChanged & BASEFL_CHANGED_SIZE ) + setsize( this, mins, maxs ); - setorigin(this, origin); + setorigin( this, origin ); } /* @@ -278,243 +241,199 @@ NSEntity::ReceiveEntity(float flNew, float flChanged) NSEntity::postdraw ============ */ -void -NSEntity::postdraw(void) -{ +void NSEntity::postdraw( void ) { } #else /* Make sure StartFrame calls this */ -float -NSEntity::SendEntity(entity ePEnt, float flChanged) -{ - if (!modelindex) - return (0); +float NSEntity::SendEntity( entity ePEnt, float flChanged ) { + if ( !modelindex ) + return ( 0 ); - if (clienttype(ePEnt) != CLIENTTYPE_REAL) - return (0); + if ( clienttype( ePEnt ) != CLIENTTYPE_REAL ) + return ( 0 ); - if (alpha == 0.0f) - return (0); + if ( alpha == 0.0f ) + return ( 0 ); - WriteByte(MSG_ENTITY, ENT_ENTITY); + WriteByte( MSG_ENTITY, ENT_ENTITY ); /* broadcast how much data is expected to be read */ - WriteFloat(MSG_ENTITY, flChanged); + WriteFloat( MSG_ENTITY, flChanged ); - SENDENTITY_COORD(origin[0], BASEFL_CHANGED_ORIGIN_X) - SENDENTITY_COORD(origin[1], BASEFL_CHANGED_ORIGIN_Y) - SENDENTITY_COORD(origin[2], BASEFL_CHANGED_ORIGIN_Z) - SENDENTITY_ANGLE(angles[0], BASEFL_CHANGED_ANGLES_X) - SENDENTITY_ANGLE(angles[1], BASEFL_CHANGED_ANGLES_Y) - SENDENTITY_ANGLE(angles[2], BASEFL_CHANGED_ANGLES_Z) - SENDENTITY_SHORT(modelindex, BASEFL_CHANGED_MODELINDEX) - SENDENTITY_BYTE(solid, BASEFL_CHANGED_SOLID) - SENDENTITY_BYTE(movetype, BASEFL_CHANGED_FLAGS) - SENDENTITY_INT(flags, BASEFL_CHANGED_FLAGS) - SENDENTITY_COORD(mins[0], BASEFL_CHANGED_SIZE) - SENDENTITY_COORD(mins[1], BASEFL_CHANGED_SIZE) - SENDENTITY_COORD(mins[2], BASEFL_CHANGED_SIZE) - SENDENTITY_COORD(maxs[0], BASEFL_CHANGED_SIZE) - SENDENTITY_COORD(maxs[1], BASEFL_CHANGED_SIZE) - SENDENTITY_COORD(maxs[2], BASEFL_CHANGED_SIZE) - SENDENTITY_BYTE(frame, BASEFL_CHANGED_FRAME) - SENDENTITY_FLOAT(skin, BASEFL_CHANGED_SKIN) - SENDENTITY_FLOAT(effects, BASEFL_CHANGED_EFFECTS) - SENDENTITY_FLOAT(scale, BASEFL_CHANGED_SCALE) - SENDENTITY_COORD(velocity[0], BASEFL_CHANGED_VELOCITY_X) - SENDENTITY_COORD(velocity[1], BASEFL_CHANGED_VELOCITY_Y) - SENDENTITY_COORD(velocity[2], BASEFL_CHANGED_VELOCITY_Z) - SENDENTITY_COORD(avelocity[0], BASEFL_CHANGED_ANGULARVELOCITY) - SENDENTITY_COORD(avelocity[1], BASEFL_CHANGED_ANGULARVELOCITY) - SENDENTITY_COORD(avelocity[2], BASEFL_CHANGED_ANGULARVELOCITY) - - return (1); + SENDENTITY_COORD( origin[0], BASEFL_CHANGED_ORIGIN_X ) + SENDENTITY_COORD( origin[1], BASEFL_CHANGED_ORIGIN_Y ) + SENDENTITY_COORD( origin[2], BASEFL_CHANGED_ORIGIN_Z ) + SENDENTITY_ANGLE( angles[0], BASEFL_CHANGED_ANGLES_X ) + SENDENTITY_ANGLE( angles[1], BASEFL_CHANGED_ANGLES_Y ) + SENDENTITY_ANGLE( angles[2], BASEFL_CHANGED_ANGLES_Z ) + SENDENTITY_SHORT( modelindex, BASEFL_CHANGED_MODELINDEX ) + SENDENTITY_BYTE( solid, BASEFL_CHANGED_SOLID ) + SENDENTITY_BYTE( movetype, BASEFL_CHANGED_FLAGS ) + SENDENTITY_INT( flags, BASEFL_CHANGED_FLAGS ) + SENDENTITY_COORD( mins[0], BASEFL_CHANGED_SIZE ) + SENDENTITY_COORD( mins[1], BASEFL_CHANGED_SIZE ) + SENDENTITY_COORD( mins[2], BASEFL_CHANGED_SIZE ) + SENDENTITY_COORD( maxs[0], BASEFL_CHANGED_SIZE ) + SENDENTITY_COORD( maxs[1], BASEFL_CHANGED_SIZE ) + SENDENTITY_COORD( maxs[2], BASEFL_CHANGED_SIZE ) + SENDENTITY_BYTE( frame, BASEFL_CHANGED_FRAME ) + SENDENTITY_FLOAT( skin, BASEFL_CHANGED_SKIN ) + SENDENTITY_FLOAT( effects, BASEFL_CHANGED_EFFECTS ) + SENDENTITY_FLOAT( scale, BASEFL_CHANGED_SCALE ) + SENDENTITY_COORD( velocity[0], BASEFL_CHANGED_VELOCITY_X ) + SENDENTITY_COORD( velocity[1], BASEFL_CHANGED_VELOCITY_Y ) + SENDENTITY_COORD( velocity[2], BASEFL_CHANGED_VELOCITY_Z ) + SENDENTITY_COORD( avelocity[0], BASEFL_CHANGED_ANGULARVELOCITY ) + SENDENTITY_COORD( avelocity[1], BASEFL_CHANGED_ANGULARVELOCITY ) + SENDENTITY_COORD( avelocity[2], BASEFL_CHANGED_ANGULARVELOCITY ) + return ( 1 ); } -void -NSEntity::EvaluateEntity(void) -{ - EVALUATE_VECTOR(origin, 0, BASEFL_CHANGED_ORIGIN_X) - EVALUATE_VECTOR(origin, 1, BASEFL_CHANGED_ORIGIN_Y) - EVALUATE_VECTOR(origin, 2, BASEFL_CHANGED_ORIGIN_Z) - EVALUATE_VECTOR(angles, 0, BASEFL_CHANGED_ANGLES_X) - EVALUATE_VECTOR(angles, 1, BASEFL_CHANGED_ANGLES_Y) - EVALUATE_VECTOR(angles, 2, BASEFL_CHANGED_ANGLES_Z) - EVALUATE_FIELD(modelindex, BASEFL_CHANGED_MODELINDEX) - EVALUATE_FIELD(solid, BASEFL_CHANGED_SOLID) - EVALUATE_FIELD(movetype, BASEFL_CHANGED_FLAGS) - EVALUATE_FIELD(flags, BASEFL_CHANGED_FLAGS) - EVALUATE_VECTOR(mins, 0, BASEFL_CHANGED_SIZE) - EVALUATE_VECTOR(mins, 1, BASEFL_CHANGED_SIZE) - EVALUATE_VECTOR(mins, 2, BASEFL_CHANGED_SIZE) - EVALUATE_VECTOR(maxs, 0, BASEFL_CHANGED_SIZE) - EVALUATE_VECTOR(maxs, 1, BASEFL_CHANGED_SIZE) - EVALUATE_VECTOR(maxs, 2, BASEFL_CHANGED_SIZE) - EVALUATE_FIELD(frame, BASEFL_CHANGED_FRAME) - EVALUATE_FIELD(skin, BASEFL_CHANGED_SKIN) - EVALUATE_FIELD(effects, BASEFL_CHANGED_EFFECTS) - EVALUATE_FIELD(scale, BASEFL_CHANGED_SCALE) - EVALUATE_VECTOR(velocity, 0, BASEFL_CHANGED_VELOCITY_X) - EVALUATE_VECTOR(velocity, 1, BASEFL_CHANGED_VELOCITY_Y) - EVALUATE_VECTOR(velocity, 2, BASEFL_CHANGED_VELOCITY_Z) - EVALUATE_VECTOR(avelocity, 0, BASEFL_CHANGED_ANGULARVELOCITY) - EVALUATE_VECTOR(avelocity, 1, BASEFL_CHANGED_ANGULARVELOCITY) - EVALUATE_VECTOR(avelocity, 2, BASEFL_CHANGED_ANGULARVELOCITY) +void NSEntity::EvaluateEntity( void ) { + EVALUATE_VECTOR( origin, 0, BASEFL_CHANGED_ORIGIN_X ) + EVALUATE_VECTOR( origin, 1, BASEFL_CHANGED_ORIGIN_Y ) + EVALUATE_VECTOR( origin, 2, BASEFL_CHANGED_ORIGIN_Z ) + EVALUATE_VECTOR( angles, 0, BASEFL_CHANGED_ANGLES_X ) + EVALUATE_VECTOR( angles, 1, BASEFL_CHANGED_ANGLES_Y ) + EVALUATE_VECTOR( angles, 2, BASEFL_CHANGED_ANGLES_Z ) + EVALUATE_FIELD( modelindex, BASEFL_CHANGED_MODELINDEX ) + EVALUATE_FIELD( solid, BASEFL_CHANGED_SOLID ) + EVALUATE_FIELD( movetype, BASEFL_CHANGED_FLAGS ) + EVALUATE_FIELD( flags, BASEFL_CHANGED_FLAGS ) + EVALUATE_VECTOR( mins, 0, BASEFL_CHANGED_SIZE ) + EVALUATE_VECTOR( mins, 1, BASEFL_CHANGED_SIZE ) + EVALUATE_VECTOR( mins, 2, BASEFL_CHANGED_SIZE ) + EVALUATE_VECTOR( maxs, 0, BASEFL_CHANGED_SIZE ) + EVALUATE_VECTOR( maxs, 1, BASEFL_CHANGED_SIZE ) + EVALUATE_VECTOR( maxs, 2, BASEFL_CHANGED_SIZE ) + EVALUATE_FIELD( frame, BASEFL_CHANGED_FRAME ) + EVALUATE_FIELD( skin, BASEFL_CHANGED_SKIN ) + EVALUATE_FIELD( effects, BASEFL_CHANGED_EFFECTS ) + EVALUATE_FIELD( scale, BASEFL_CHANGED_SCALE ) + EVALUATE_VECTOR( velocity, 0, BASEFL_CHANGED_VELOCITY_X ) + EVALUATE_VECTOR( velocity, 1, BASEFL_CHANGED_VELOCITY_Y ) + EVALUATE_VECTOR( velocity, 2, BASEFL_CHANGED_VELOCITY_Z ) + EVALUATE_VECTOR( avelocity, 0, BASEFL_CHANGED_ANGULARVELOCITY ) + EVALUATE_VECTOR( avelocity, 1, BASEFL_CHANGED_ANGULARVELOCITY ) + EVALUATE_VECTOR( avelocity, 2, BASEFL_CHANGED_ANGULARVELOCITY ) } /* Make sure StartFrame calls this */ -void -NSEntity::ParentUpdate(void) -{ +void NSEntity::ParentUpdate( void ) { EvaluateEntity(); frame1time += frametime; - if (m_parent) { + if ( m_parent ) { NSEntity parent; - entity p = find(world, ::targetname, m_parent); + entity p = find( world, ::targetname, m_parent ); - if (p) { - if (!m_parent_attachment) { - parent = (NSEntity)p; + if ( p ) { + if ( !m_parent_attachment ) { + parent = ( NSEntity ) p; vector ofs = parent.origin - parent.GetSpawnOrigin(); - SetOrigin(GetSpawnOrigin() + ofs); - } else if (m_parent_attachment == "origin") { - SetOrigin(p.origin); + + SetOrigin( GetSpawnOrigin() + ofs ); + } else if ( m_parent_attachment == "origin" ) { + SetOrigin( p.origin ); } } } /* handle end-touch */ - if (m_beingTouched == true) - if (m_flTouchTime < GetTime()) { - EndTouch(m_eTouchLast); - m_beingTouched = false; - m_eTouchLast = __NULL__; + if ( m_beingTouched == true ) + if ( m_flTouchTime < GetTime() ) { + EndTouch( m_eTouchLast ); + m_beingTouched = false; + m_eTouchLast = __NULL__; } } -entity -NSEntity::GetParent(void) -{ - return (find(world, ::targetname, m_parent)); +entity NSEntity::GetParent( void ) { + return ( find( world, ::targetname, m_parent ) ); } -void -NSEntity::SetParent(string name) -{ +void NSEntity::SetParent( string name ) { m_parent = name; } -void -NSEntity::SetParentAttachment(string name) -{ +void NSEntity::SetParentAttachment( string name ) { m_parent_attachment = name; } -void -NSEntity::ClearParent(void) -{ +void NSEntity::ClearParent( void ) { m_parent = __NULL__; m_parent_attachment = __NULL__; } -void -NSEntity::RestoreAngles(void) -{ +void NSEntity::RestoreAngles( void ) { angles = GetSpawnAngles(); } -void -NSEntity::ClearAngles(void) -{ - angles = [0,0,0]; +void NSEntity::ClearAngles( void ) { + angles =[0, 0, 0]; } #endif -void -NSEntity::SetEffects(float newEffects) -{ +void NSEntity::SetEffects( float newEffects ) { effects = newEffects; } -void -NSEntity::SetFrame(float newFrame) -{ - if (newFrame == frame) +void NSEntity::SetFrame( float newFrame ) { + if ( newFrame == frame ) return; frame = newFrame; frame1time = 0.0f; } -void -NSEntity::SetSkin(float newSkin) -{ +void NSEntity::SetSkin( float newSkin ) { skin = newSkin; } -void -NSEntity::SetOwner(entity newOwner) -{ +void NSEntity::SetOwner( entity newOwner ) { owner = newOwner; } -void -NSEntity::SetVelocity(vector vecNew) -{ +void NSEntity::SetVelocity( vector vecNew ) { velocity = vecNew; } -void -NSEntity::SetTouch(void() newTouch) -{ +void NSEntity::SetTouch( void ()newTouch ) { touch = newTouch; } /* we want to really use those set functions because they'll notify of any * networking related changes. otherwise we'll have to keep track of copies * that get updated every frame */ -void -NSEntity::SetSendFlags(float flSendFlags) -{ +void NSEntity::SetSendFlags( float flSendFlags ) { #ifdef SERVER SendFlags |= flSendFlags; #endif } -void -NSEntity::SetMovetype(float newMovetype) -{ +void NSEntity::SetMovetype( float newMovetype ) { movetype = newMovetype; } -void -NSEntity::SetGravity(float newGrav) -{ +void NSEntity::SetGravity( float newGrav ) { gravity = newGrav; } -void -NSEntity::SetSolid(float newSolid) -{ +void NSEntity::SetSolid( float newSolid ) { solid = newSolid; } -void -NSEntity::SetScale(float newScale) -{ - if (newScale == scale) +void NSEntity::SetScale( float newScale ) { + if ( newScale == scale ) return; scale = newScale; - setsize(this, m_vecMins * scale, m_vecMaxs * scale); + setsize( this, m_vecMins * scale, m_vecMaxs * scale ); } -void -NSEntity::UpdateBounds(void) -{ +void NSEntity::UpdateBounds( void ) { vector newMins, newMaxs; float flScale = 1.0f; @@ -522,426 +441,336 @@ NSEntity::UpdateBounds(void) newMaxs = m_vecMaxs; /* avoid useless computation */ - if (angles != [0,0,0]) { + if ( angles !=[0, 0, 0] ) { /* adjust bbox according to rotation */ vector vecCorner[8]; - newMins = newMaxs = [0,0,0]; - for (int i = 0; i < 8; i++) { - vecCorner[i][0] = (i & 1) ? m_vecMins[0] : m_vecMaxs[0]; - vecCorner[i][1] = (i & 2) ? m_vecMins[1] : m_vecMaxs[1]; - vecCorner[i][2] = (i & 4) ? m_vecMins[2] : m_vecMaxs[2]; + + newMins = newMaxs =[0, 0, 0]; + for ( int i = 0; i < 8; i++ ) { + vecCorner[i][0] = ( i & 1 ) ? m_vecMins[0] : m_vecMaxs[0]; + vecCorner[i][1] = ( i & 2 ) ? m_vecMins[1] : m_vecMaxs[1]; + vecCorner[i][2] = ( i & 4 ) ? m_vecMins[2] : m_vecMaxs[2]; vecCorner[i] += origin; - vecCorner[i] = Math_RotateAroundPivot(vecCorner[i], origin, angles[1]); + vecCorner[i] = Math_RotateAroundPivot( vecCorner[i], origin, angles[1] ); vecCorner[i] -= origin; - if (!(vecCorner[i][0] <= newMaxs[0])) + if ( !( vecCorner[i][0] <= newMaxs[0] ) ) newMaxs[0] = vecCorner[i][0]; - if (!(vecCorner[i][1] <= newMaxs[1])) + if ( !( vecCorner[i][1] <= newMaxs[1] ) ) newMaxs[1] = vecCorner[i][1]; - if (!(vecCorner[i][2] <= newMaxs[2])) + if ( !( vecCorner[i][2] <= newMaxs[2] ) ) newMaxs[2] = vecCorner[i][2]; - if (!(vecCorner[i][0] >= newMins[0])) + if ( !( vecCorner[i][0] >= newMins[0] ) ) newMins[0] = vecCorner[i][0]; - if (!(vecCorner[i][1] >= newMins[1])) + if ( !( vecCorner[i][1] >= newMins[1] ) ) newMins[1] = vecCorner[i][1]; - if (!(vecCorner[i][2] >= newMins[2])) + if ( !( vecCorner[i][2] >= newMins[2] ) ) newMins[2] = vecCorner[i][2]; } } /* 0.0 is never valid, if you want it to disappear do something else */ - if (scale != 0.0) + if ( scale != 0.0 ) flScale = scale; - setsize(this, newMins * flScale, newMaxs * flScale); + setsize( this, newMins * flScale, newMaxs * flScale ); } -void -NSEntity::SetAngles(vector newAngles) -{ +void NSEntity::SetAngles( vector newAngles ) { angles = newAngles; } -void -NSEntity::SetAngularVelocity(vector newAvel) -{ +void NSEntity::SetAngularVelocity( vector newAvel ) { avelocity = newAvel; } -void -NSEntity::SetSize(vector newMins, vector newMaxs) -{ +void NSEntity::SetSize( vector newMins, vector newMaxs ) { float flScale = 1.0f; m_vecMins = newMins; m_vecMaxs = newMaxs; /* 0.0 is never valid, if you want it to disappear do something else */ - if (scale != 0.0f) + if ( scale != 0.0f ) flScale = scale; - setsize(this, newMins * flScale, newMaxs * flScale); + setsize( this, newMins * flScale, newMaxs * flScale ); } -void -NSEntity::SetOrigin(vector newOrigin) -{ - setorigin(this, newOrigin); +void NSEntity::SetOrigin( vector newOrigin ) { + setorigin( this, newOrigin ); } -void -NSEntity::SetModel(string newModel) -{ +void NSEntity::SetModel( string newModel ) { model = newModel; - setmodel(this, newModel); + setmodel( this, newModel ); /* mins/maxs have been updated by setmodel */ - SetSize(mins, maxs); + SetSize( mins, maxs ); } -void -NSEntity::SetModelindex(float newModelIndex) -{ - if (newModelIndex == modelindex) +void NSEntity::SetModelindex( float newModelIndex ) { + if ( newModelIndex == modelindex ) return; modelindex = newModelIndex; - SetSize(mins, maxs); + SetSize( mins, maxs ); } -void -NSEntity::AddEffects(float fl) -{ +void NSEntity::AddEffects( float fl ) { effects |= fl; } -void -NSEntity::RemoveEffects(float fl) -{ +void NSEntity::RemoveEffects( float fl ) { effects &= ~fl; } -void -NSEntity::AddFlags(float fl) -{ +void NSEntity::AddFlags( float fl ) { flags |= fl; } -void -NSEntity::RemoveFlags(float fl) -{ +void NSEntity::RemoveFlags( float fl ) { flags &= ~fl; } -void -NSEntity::SetThink(void(void) func) -{ +void NSEntity::SetThink( void ( void ) func ) { think = func; } -void -NSEntity::SetNextThink(float fl) -{ +void NSEntity::SetNextThink( float fl ) { float flTime = GetTime(); /* HACK: to make sure things happen post-spawn */ - if (flTime <= 0.0f) + if ( flTime <= 0.0f ) flTime = 0.1f; - if (fl >= 0) + if ( fl >= 0 ) nextthink = flTime + fl; else - NSLog("%s sets bogus nextthink value %f\n", classname, fl); + NSLog( "%s sets bogus nextthink value %f\n", classname, fl ); } -void -NSEntity::ScheduleThink(void(void) func, float fl) -{ - SetThink(func); - SetNextThink(fl); +void NSEntity::ScheduleThink( void ( void ) func, float fl ) { + SetThink( func ); + SetNextThink( fl ); } -vector -NSEntity::GetSpawnOrigin(void) -{ - return (m_oldOrigin); +vector NSEntity::GetSpawnOrigin( void ) { + return ( m_oldOrigin ); } -vector -NSEntity::GetSpawnAngles(void) -{ - return (m_oldAngle); +vector NSEntity::GetSpawnAngles( void ) { + return ( m_oldAngle ); } -string -NSEntity::GetSpawnModel(void) -{ - return (m_oldModel); +string NSEntity::GetSpawnModel( void ) { + return ( m_oldModel ); } -float -NSEntity::GetEffects(void) -{ - return (effects); +float NSEntity::GetEffects( void ) { + return ( effects ); } -float -NSEntity::GetFrame(void) -{ - return (frame); +float NSEntity::GetFrame( void ) { + return ( frame ); } -float -NSEntity::GetSkin(void) -{ - return (skin); +float NSEntity::GetSkin( void ) { + return ( skin ); } -float -NSEntity::GetScale(void) -{ - return (scale); +float NSEntity::GetScale( void ) { + return ( scale ); } -entity -NSEntity::GetOwner(void) -{ - return (owner); +entity NSEntity::GetOwner( void ) { + return ( owner ); } -vector -NSEntity::GetVelocity(void) -{ - return (velocity); +vector NSEntity::GetVelocity( void ) { + return ( velocity ); } -float -NSEntity::GetSolid(void) -{ - return (solid); +float NSEntity::GetSolid( void ) { + return ( solid ); } -string -NSEntity::GetModel(void) -{ - return (model); +string NSEntity::GetModel( void ) { + return ( model ); } -float -NSEntity::GetModelindex(void) -{ - return (modelindex); +float NSEntity::GetModelindex( void ) { + return ( modelindex ); } -float -NSEntity::GetMovetype(void) -{ - return (movetype); +float NSEntity::GetMovetype( void ) { + return ( movetype ); } -float -NSEntity::GetGravity(void) -{ - return (gravity); +float NSEntity::GetGravity( void ) { + return ( gravity ); } -vector -NSEntity::GetAngles(void) -{ - return (angles); +vector NSEntity::GetAngles( void ) { + return ( angles ); } -vector -NSEntity::GetAngularVelocity(void) -{ - return (avelocity); +vector NSEntity::GetAngularVelocity( void ) { + return ( avelocity ); } -vector -NSEntity::GetOrigin(void) -{ - return (origin); +vector NSEntity::GetOrigin( void ) { + return ( origin ); } -vector -NSEntity::GetMins(void) -{ - return (mins); +vector NSEntity::GetMins( void ) { + return ( mins ); } -vector -NSEntity::GetMaxs(void) -{ - return (maxs); +vector NSEntity::GetMaxs( void ) { + return ( maxs ); } -vector -NSEntity::GetRealMins(void) -{ - return (m_vecMins); +vector NSEntity::GetRealMins( void ) { + return ( m_vecMins ); } -vector -NSEntity::GetRealMaxs(void) -{ - return (m_vecMaxs); +vector NSEntity::GetRealMaxs( void ) { + return ( m_vecMaxs ); } -vector -NSEntity::GetAbsoluteMins(void) -{ - return (absmin); +vector NSEntity::GetAbsoluteMins( void ) { + return ( absmin ); } -vector -NSEntity::GetAbsoluteMaxs(void) -{ - return (absmax); +vector NSEntity::GetAbsoluteMaxs( void ) { + return ( absmax ); } -float -NSEntity::GetFlags(void) -{ - return (flags); +float NSEntity::GetFlags( void ) { + return ( flags ); } -float -NSEntity::GetNextThinkTime(void) -{ - return (nextthink); +float NSEntity::GetNextThinkTime( void ) { + return ( nextthink ); } -bool -NSEntity::IsThinking(void) -{ - return (nextthink > GetTime()) ? true : false; +bool NSEntity::IsThinking( void ) { + return ( nextthink > GetTime() )? true : false; } -void -NSEntity::ReleaseThink(void) -{ +void NSEntity::ReleaseThink( void ) { think = __NULL__; nextthink = 0.0f; } -void -NSEntity::ClearVelocity(void) -{ - velocity = avelocity = [0.0f, 0.0f, 0.0f]; +void NSEntity::ClearVelocity( void ) { + velocity = avelocity =[0.0f, 0.0f, 0.0f]; } #ifdef SERVER -void -NSEntity::Respawn(void) -{ +void NSEntity::Respawn( void ) { NSTrigger::Respawn(); - SetSolid(m_oldSolid); - SetAngles(GetSpawnAngles()); - SetOrigin(GetSpawnOrigin()); - SetModel(GetSpawnModel()); - SetTriggerTarget(m_oldstrTarget); /* FIXME: Move into NSTrigger::Respawn */ + SetSolid( m_oldSolid ); + SetAngles( GetSpawnAngles() ); + SetOrigin( GetSpawnOrigin() ); + SetModel( GetSpawnModel() ); + SetTriggerTarget( m_oldstrTarget ); /* FIXME: Move into NSTrigger::Respawn */ } -void -NSEntity::Save(float handle) -{ - super::Save(handle); - SaveFloat(handle, "pvsflags", pvsflags); - SaveFloat(handle, "_mapspawned", _mapspawned); - SaveFloat(handle, "scale", scale); - SaveVector(handle, "m_vecMins", m_vecMins); - SaveVector(handle, "m_vecMaxs", m_vecMaxs); - SaveVector(handle, "m_oldOrigin", m_oldOrigin); - SaveVector(handle, "m_oldAngle", m_oldAngle); - SaveString(handle, "m_oldModel", m_oldModel); - SaveFloat(handle, "m_oldSolid", m_oldSolid); - SaveFloat(handle, "m_flTouchTime", m_flTouchTime); - SaveBool(handle, "m_beingTouched", m_beingTouched); - SaveEntity(handle, "m_eTouchLast", m_eTouchLast); - SaveString(handle, "m_parent", m_parent); - SaveString(handle, "m_parent_attachment", m_parent_attachment); +void NSEntity::Save( float handle ) { + super::Save( handle ); + SaveFloat( handle, "pvsflags", pvsflags ); + SaveFloat( handle, "_mapspawned", _mapspawned ); + SaveFloat( handle, "scale", scale ); + SaveVector( handle, "m_vecMins", m_vecMins ); + SaveVector( handle, "m_vecMaxs", m_vecMaxs ); + SaveVector( handle, "m_oldOrigin", m_oldOrigin ); + SaveVector( handle, "m_oldAngle", m_oldAngle ); + SaveString( handle, "m_oldModel", m_oldModel ); + SaveFloat( handle, "m_oldSolid", m_oldSolid ); + SaveFloat( handle, "m_flTouchTime", m_flTouchTime ); + SaveBool( handle, "m_beingTouched", m_beingTouched ); + SaveEntity( handle, "m_eTouchLast", m_eTouchLast ); + SaveString( handle, "m_parent", m_parent ); + SaveString( handle, "m_parent_attachment", m_parent_attachment ); } -void -NSEntity::Restore(string strKey, string strValue) -{ - switch (strKey) { +void NSEntity::Restore( string strKey, string strValue ) { + switch ( strKey ) { case "pvsflags": - pvsflags = stof(strValue); + pvsflags = stof( strValue ); break; case "_mapspawned": - _mapspawned = stof(strValue); + _mapspawned = stof( strValue ); break; case "scale": - scale = ReadFloat(strValue); + scale = ReadFloat( strValue ); break; case "m_vecMins": - m_vecMins = ReadVector(strValue); + m_vecMins = ReadVector( strValue ); break; case "m_vecMaxs": - m_vecMaxs = ReadVector(strValue); + m_vecMaxs = ReadVector( strValue ); break; case "m_oldOrigin": - m_oldOrigin = ReadVector(strValue); + m_oldOrigin = ReadVector( strValue ); break; case "m_oldAngle": - m_oldAngle = ReadVector(strValue); + m_oldAngle = ReadVector( strValue ); break; case "m_oldModel": - m_oldModel = ReadString(strValue); + m_oldModel = ReadString( strValue ); break; case "m_oldSolid": - m_oldSolid = ReadFloat(strValue); + m_oldSolid = ReadFloat( strValue ); break; case "m_flTouchTime": - m_flTouchTime = ReadFloat(strValue); + m_flTouchTime = ReadFloat( strValue ); break; case "m_beingTouched": - m_beingTouched = ReadBool(strValue); + m_beingTouched = ReadBool( strValue ); break; case "m_eTouchLast": - m_eTouchLast = ReadEntity(strValue); + m_eTouchLast = ReadEntity( strValue ); break; case "m_parent": - m_parent = ReadString(strValue); + m_parent = ReadString( strValue ); break; case "m_parent_attachment": - m_parent_attachment = ReadString(strValue); + m_parent_attachment = ReadString( strValue ); break; default: - super::Restore(strKey, strValue); + super::Restore( strKey, strValue ); break; } } -void -NSEntity::RestoreComplete(void) -{ +void NSEntity::RestoreComplete( void ) { /* this is where we can handle anything post-loading */ } -void -NSEntity::Input(entity eAct, string strInput, string strData) -{ - switch (strInput) { +void NSEntity::Input( entity eAct, string strInput, string strData ) { + switch ( strInput ) { case "Kill": Destroy(); break; case "KillHierarchy": /* this works because ents are basically just entnums */ - for (entity e = world; (e=findfloat(e, ::owner, this));) { - NSEntity ent = (NSEntity)e; + for ( entity e = world; ( e = findfloat( e, ::owner, this ) ); ) { + NSEntity ent = ( NSEntity ) e; + ent.Destroy(); } Destroy(); break; case "SetParent": - SetParent(strData); + SetParent( strData ); break; case "SetParentAttachment": - SetParentAttachment(strData); + SetParentAttachment( strData ); break; case "ClearParent": ClearParent(); @@ -949,11 +778,11 @@ NSEntity::Input(entity eAct, string strInput, string strData) case "Use": eActivator = eAct; - if (PlayerUse) + if ( PlayerUse ) PlayerUse(); break; default: - NSTrigger::Input(eAct, strInput, strData); + NSTrigger::Input( eAct, strInput, strData ); } } #endif @@ -967,43 +796,41 @@ pairs on its own, but we can at least undo some of that in here if needed ============ */ -void -NSEntity::SpawnKey(string strKey, string strValue) -{ +void NSEntity::SpawnKey( string strKey, string strValue ) { /* we do re-read a lot of the builtin fields in case we want to set defaults. just in case anybody is wondering. */ - switch (strKey) { + switch ( strKey ) { case "spawnflags": - spawnflags = stof(strValue); + spawnflags = stof( strValue ); break; case "origin": - origin = stov(strValue); + origin = stov( strValue ); break; case "model": model = strValue; break; case "angles": - angles = stov(strValue); + angles = stov( strValue ); break; case "angle": - angles[1] = stof(strValue); + angles[1] = stof( strValue ); break; case "solid": - solid = stof(strValue); + solid = stof( strValue ); break; #ifdef SERVER case "health": - health = stof(strValue); + health = stof( strValue ); break; case "parentname": - SetParent(strValue); + SetParent( strValue ); break; case "ignorepvs": pvsflags = PVSF_IGNOREPVS; break; #endif default: - NSTrigger::SpawnKey(strKey, strValue); + NSTrigger::SpawnKey( strKey, strValue ); break; } } @@ -1016,9 +843,7 @@ OnRemoveEntity Empty method, meant for sub-classes to clean up their contents ============ */ -void -NSEntity::OnRemoveEntity(void) -{ +void NSEntity::OnRemoveEntity( void ) { } /* @@ -1030,97 +855,75 @@ If you want an entity to be purged immediately, you'll have to jump through your own hoops. This however will be sufficient 99,99% of the time. ============ */ -void -NSEntity::Destroy(void) -{ +void NSEntity::Destroy( void ) { OnRemoveEntity(); - ScheduleThink(Util_Destroy, 0.0f); + ScheduleThink( Util_Destroy, 0.0f ); } -void -NSEntity::Show(void) -{ +void NSEntity::Show( void ) { effects &= ~EF_NODRAW; } -void -NSEntity::Hide(void) -{ +void NSEntity::Hide( void ) { effects |= EF_NODRAW; } -bool -NSEntity::IsHidden(void) -{ - return (effects & EF_NODRAW) ? true : false; +bool NSEntity::IsHidden( void ) { + return ( effects & EF_NODRAW ) ? true : false; } -void -NSEntity::Disappear(void) -{ +void NSEntity::Disappear( void ) { modelindex = 0; solid = SOLID_NOT; } -void -NSEntity::MakeStatic(void) -{ - makestatic(this); +void NSEntity::MakeStatic( void ) { + makestatic( this ); } -bool -NSEntity::WithinBounds(entity check) -{ - if not (check.absmin[0] >= absmin[0] && check.absmax[0] <= absmax[0]) - return (false); - if not (check.absmin[1] >= absmin[1] && check.absmax[1] <= absmax[1]) - return (false); - if not (check.absmin[2] >= absmin[2] && check.absmax[2] <= absmax[2]) - return (false); +bool NSEntity::WithinBounds( entity check ) { + if not ( check.absmin[0] >= absmin[0] && check.absmax[0] <= absmax[0] ) + return ( false ); + if not ( check.absmin[1] >= absmin[1] && check.absmax[1] <= absmax[1] ) + return ( false ); + if not ( check.absmin[2] >= absmin[2] && check.absmax[2] <= absmax[2] ) + return ( false ); - return (true); + return ( true ); } -bool -NSEntity::StartSound(string strSample, float channel, float flags, bool broadcast) -{ - if not (whichpack(strcat("sound/", strSample))) - return (false); +bool NSEntity::StartSound( string strSample, float channel, float flags, bool broadcast ) { + if not ( whichpack( strcat( "sound/", strSample ) ) ) + return ( false ); - if (broadcast) - sound(this, channel, strSample, 1.0, ATTN_NORM); - else { + if ( broadcast ) { + sound( this, channel, strSample, 1.0, ATTN_NORM ); + } else { #ifdef SERVER msg_entity = this; - sound(this, channel, strSample, 1.0, ATTN_NORM, 0, SOUNDFLAG_UNICAST); + sound( this, channel, strSample, 1.0, ATTN_NORM, 0, SOUNDFLAG_UNICAST ); msg_entity = __NULL__; #else - sound(this, channel, strSample, 1.0, ATTN_NORM); + sound( this, channel, strSample, 1.0, ATTN_NORM ); #endif } - return (true); + return ( true ); } -bool -NSEntity::StartSoundDef(string strSample, float channel, bool broadcast) -{ - NSLog("StartSoundDef: %s %d %d", strSample, channel, broadcast); - Sound_Play(this, channel, strSample); - return (true); +bool NSEntity::StartSoundDef( string strSample, float channel, bool broadcast ) { + NSLog( "StartSoundDef: %s %d %d", strSample, channel, broadcast ); + Sound_Play( this, channel, strSample ); + return ( true ); } -void -NSEntity::StopSound(float channel, bool broadcast) -{ - sound(this, channel, "common/null.wav", 0.1f, ATTN_NORM); +void NSEntity::StopSound( float channel, bool broadcast ) { + sound( this, channel, "common/null.wav", 0.1f, ATTN_NORM ); } -void -NSEntity::HandleThink(void) -{ +void NSEntity::HandleThink( void ) { /* support for think/nextthink */ - if (think && nextthink > 0.0f) { - if (nextthink < time) { + if ( think && nextthink > 0.0f ) { + if ( nextthink < time ) { nextthink = 0.0f; think(); } diff --git a/src/shared/NSIO.h b/src/shared/NSIO.h index 2da0f031..d4b7a4b7 100644 --- a/src/shared/NSIO.h +++ b/src/shared/NSIO.h @@ -55,14 +55,21 @@ public: that are part of NSIO. */ virtual void SpawnKey(string,string); - /** Get the level time the entity finds itself in. - Always use this instead of the `time` global. The `time` global may not - be valid on every type of entity. Specifically, MOVETYPE_PUSH entities only - update upon movement (so that any think timers the entity may have are not triggered - when it is at rest. */ - nonvirtual float GetTime(void); - #ifdef SERVER + + /** Handles saving a copy of this entity to a given filehandle. + Within you want to use the ::SaveFloat() etc. methods to write + the internal member attributes to the specified file handle. */ + virtual void Save(float); + + /** Similar to `::SpawnKey` but for save-game fields. + Whatever you write into file handles within your `::Save()` method + needs to be read back in here. */ + virtual void Restore(string,string); + + /** Called when we are being prompted by another object/function with an input message. */ + virtual void Input(entity,string,string); + /* helper functions to allocate outputs */ /** Triggers an output field that has been created beforehand */ nonvirtual void UseOutput(entity,string); @@ -80,16 +87,6 @@ public: Input/Output specification. */ nonvirtual string CreateOutput(string); - /** Handles saving a copy of this entity to a given filehandle. - Within you want to use the ::SaveFloat() etc. methods to write - the internal member attributes to the specified file handle. */ - virtual void Save(float); - - /** Similar to `::SpawnKey` but for save-game fields. - Whatever you write into file handles within your `::Save()` method - needs to be read back in here. */ - virtual void Restore(string,string); - /* save game related methods */ /** Saves a floating point key/value pair to a filehandle. */ nonvirtual void SaveFloat(float,string,float); @@ -117,10 +114,14 @@ public: nonvirtual bool ReadBool(string); /** read an entity id, converted to entity, from a string */ nonvirtual entity ReadEntity(string); - - /** Called when we are being prompted by another object/function with an input message. */ - virtual void Input(entity,string,string); #endif + + /** Get the level time the entity finds itself in. + Always use this instead of the `time` global. The `time` global may not + be valid on every type of entity. Specifically, MOVETYPE_PUSH entities only + update upon movement (so that any think timers the entity may have are not triggered + when it is at rest. */ + nonvirtual float GetTime(void); }; .bool _mapspawned; diff --git a/src/shared/NSMonster.h b/src/shared/NSMonster.h index 25451314..0cf5cf63 100644 --- a/src/shared/NSMonster.h +++ b/src/shared/NSMonster.h @@ -272,7 +272,7 @@ public: virtual void EvaluateEntity(void); virtual float SendEntity(entity,float); virtual void Touch(entity); - virtual void Hide(void); + //virtual void Hide(void); virtual void Respawn(void); virtual void Pain(void); virtual void Death(void); diff --git a/src/shared/NSMonster.qc b/src/shared/NSMonster.qc index 23b43acf..958151cc 100644 --- a/src/shared/NSMonster.qc +++ b/src/shared/NSMonster.qc @@ -815,6 +815,7 @@ NSMonster::Death(void) TriggerTargets(); } +#if 0 void NSMonster::Hide(void) { @@ -823,6 +824,7 @@ NSMonster::Hide(void) SetMovetype(MOVETYPE_NONE); customphysics = __NULL__; } +#endif void NSMonster::Respawn(void) diff --git a/src/shared/NSRenderableEntity.h b/src/shared/NSRenderableEntity.h index 24b7b478..78a23c92 100644 --- a/src/shared/NSRenderableEntity.h +++ b/src/shared/NSRenderableEntity.h @@ -139,6 +139,10 @@ public: virtual void MakeStatic(void); + /* model events */ + /** Callback for any model event that gets triggered while playing a framegroup. */ + virtual void HandleAnimEvent(float, int,string); + /* set */ /** Sets the bodygroup of the entity. */ nonvirtual void SetBody(int); @@ -181,10 +185,6 @@ public: /** Returns the value of the entity's bone controller #5. */ nonvirtual float GetBoneControl5(void); - /* model events */ - /** Callback for any model event that gets triggered while playing a framegroup. */ - virtual void HandleAnimEvent(float, int,string); - #ifdef CLIENT /** Called by predraw(); and will set the appropriate rendering specific fields. */ nonvirtual void RenderFXPass(void); diff --git a/src/shared/NSTalkMonster.h b/src/shared/NSTalkMonster.h index ad958a23..b19070da 100644 --- a/src/shared/NSTalkMonster.h +++ b/src/shared/NSTalkMonster.h @@ -109,7 +109,7 @@ public: virtual void PanicFrame(void); virtual void OnPlayerUse(void); - virtual void Hide(void); + //virtual void Hide(void); virtual void Respawn(void); virtual void SpawnKey(string,string); virtual float SendEntity(entity,float); diff --git a/src/shared/NSTalkMonster.qc b/src/shared/NSTalkMonster.qc index 43e77688..5e53f537 100644 --- a/src/shared/NSTalkMonster.qc +++ b/src/shared/NSTalkMonster.qc @@ -644,12 +644,14 @@ NSTalkMonster::SpawnKey(string strKey, string strValue) } } +#if 0 void NSTalkMonster::Hide(void) { m_eFollowing = world; NSMonster::Hide(); } +#endif float NSTalkMonster::SendEntity(entity ePEnt, float flChanged) diff --git a/src/shared/NSTrigger.h b/src/shared/NSTrigger.h index 3786093e..368cb6e4 100644 --- a/src/shared/NSTrigger.h +++ b/src/shared/NSTrigger.h @@ -77,7 +77,15 @@ public: /** Called when we stopped touching the last touched entity. */ virtual void EndTouch(entity); + /* override */ + virtual void SpawnKey(string,string); + #ifdef SERVER + /* overrides */ + virtual void Save(float); + virtual void Restore(string,string); + virtual void Input(entity,string,string); + /** Called whenever we're legacy triggered by another object or function. */ virtual void Trigger(entity,int); @@ -89,7 +97,8 @@ public: /* master feature */ /** Returns what we will pass onto other's `::GetMaster()` calls if we're their master. */ - nonvirtual int GetValue(void); + /* multisource overrides this, so keep virtual */ + virtual int GetValue(void); /** Returns whether our master allows us to be triggered. */ nonvirtual int GetMaster(void); @@ -112,13 +121,7 @@ public: /** Retrives the team value of a given entity. */ nonvirtual float GetTeam(void); - /* overrides */ - virtual void Save(float); - virtual void Restore(string,string); - virtual void Input(entity,string,string); - #endif - virtual void SpawnKey(string,string); }; enum diff --git a/src/shared/NSWeapon.h b/src/shared/NSWeapon.h index 52899651..f61a6e9e 100644 --- a/src/shared/NSWeapon.h +++ b/src/shared/NSWeapon.h @@ -41,8 +41,7 @@ public: virtual string GetObituaryMessage(void); /** Returns the weapon type. Check weapontype_t for details. */ virtual int GetType(void); - /** Returns the owner/wielder of the weapon. */ - virtual entity GetOwner(void); + /** Returns primary attack clip */ virtual int GetClip1(void); /** Returns secondary attack clip */ diff --git a/src/shared/NSWeapon.qc b/src/shared/NSWeapon.qc index 756286c8..ff4908e4 100644 --- a/src/shared/NSWeapon.qc +++ b/src/shared/NSWeapon.qc @@ -117,12 +117,6 @@ NSWeapon::GetType(void) return 0; } -entity -NSWeapon::GetOwner(void) -{ - return m_owner; -} - int NSWeapon::GetClip1(void) {