From cb04a1e4510c5444fa4600d38184c7c42ad53f3c Mon Sep 17 00:00:00 2001 From: nillerusr Date: Wed, 13 Oct 2021 20:01:24 +0300 Subject: [PATCH] Replace 1e24 with 1e16 to avoid float overflow --- engine/cmodel.cpp | 2 +- engine/disp.cpp | 4 ++-- engine/disp_mapload.cpp | 4 ++-- engine/r_areaportal.cpp | 4 ++-- game/client/c_steamjet.cpp | 4 ++-- game/client/particle_iterators.h | 4 ++-- game/client/tf2/c_obj_mcv_selection_panel.cpp | 2 +- game/client/tf2/c_ragdoll_shadow.cpp | 2 +- game/server/player.cpp | 2 +- game/server/tf2/order_heal.cpp | 2 +- game/server/tf2/order_helpers.cpp | 2 +- game/server/tf2/order_killmortarguy.cpp | 2 +- game/server/tf2/order_mortar_attack.cpp | 2 +- game/server/tf2/order_repair.cpp | 4 ++-- game/server/tf2/tf_obj_barbed_wire.cpp | 2 +- game/server/tf2/tf_playerclass.cpp | 2 +- game/server/tf2/tf_team.h | 2 +- game/shared/physics_shared.cpp | 2 +- public/disp_common.cpp | 4 ++-- public/keyframe/keyframe.cpp | 2 +- vphysics/ledgewriter.cpp | 2 +- vphysics/trace.cpp | 6 +++--- 22 files changed, 31 insertions(+), 31 deletions(-) diff --git a/engine/cmodel.cpp b/engine/cmodel.cpp index 466d4451..4b031bf7 100644 --- a/engine/cmodel.cpp +++ b/engine/cmodel.cpp @@ -2788,7 +2788,7 @@ int CFastPointLeafNum::GetLeaf( const Vector &vPos ) m_vCachedPos = vPos; CCollisionBSPData *pBSPData = GetCollisionBSPData(); - m_flDistToExitLeafSqr = 1e24; + m_flDistToExitLeafSqr = 1e16; m_iCachedLeaf = CM_PointLeafnumMinDistSqr_r( pBSPData, vPos, 0, m_flDistToExitLeafSqr ); } diff --git a/engine/disp.cpp b/engine/disp.cpp index 6c9781c1..adfdbd41 100644 --- a/engine/disp.cpp +++ b/engine/disp.cpp @@ -102,8 +102,8 @@ inline CVertIndex CDispInfo::IndexToVert( int index ) const void CDispInfo::UpdateBoundingBox() { - m_BBoxMin.Init( 1e24, 1e24, 1e24 ); - m_BBoxMax.Init( -1e24, -1e24, -1e24 ); + m_BBoxMin.Init( 1e16, 1e16, 1e16 ); + m_BBoxMax.Init( -1e16, -1e16, -1e16 ); for( int i=0; i < NumVerts(); i++ ) { diff --git a/engine/disp_mapload.cpp b/engine/disp_mapload.cpp index 11b75e96..744a68b6 100644 --- a/engine/disp_mapload.cpp +++ b/engine/disp_mapload.cpp @@ -793,7 +793,7 @@ CDispInfo::CDispInfo() m_pPowerInfo = NULL; - m_ViewerSphereCenter.Init( 1e24, 1e24, 1e24 ); + m_ViewerSphereCenter.Init( 1e16, 1e16, 1e16 ); m_bInUse = false; @@ -995,7 +995,7 @@ int FindNeighborCornerVert( CCoreDispInfo *pDisp, const Vector &vecPoint ) CDispUtilsHelper *pDispHelper = pDisp; int iClosest = 0; - float flClosest = 1e24; + float flClosest = 1e16; for ( int iCorner = 0; iCorner < 4; ++iCorner ) { diff --git a/engine/r_areaportal.cpp b/engine/r_areaportal.cpp index 4773fc1e..2c596b11 100644 --- a/engine/r_areaportal.cpp +++ b/engine/r_areaportal.cpp @@ -122,8 +122,8 @@ struct portalclip_t static inline bool GetPortalScreenExtents( dareaportal_t *pPortal, portalclip_t * RESTRICT clip, CPortalRect &portalRect , float *pReflectionWaterHeight ) { - portalRect.left = portalRect.bottom = 1e24; - portalRect.right = portalRect.top = -1e24; + portalRect.left = portalRect.bottom = 1e16; + portalRect.right = portalRect.top = -1e16; bool bValidExtents = false; worldbrushdata_t *pBrushData = host_state.worldbrush; diff --git a/game/client/c_steamjet.cpp b/game/client/c_steamjet.cpp index f36ccc63..9608ceda 100644 --- a/game/client/c_steamjet.cpp +++ b/game/client/c_steamjet.cpp @@ -150,8 +150,8 @@ C_SteamJet::C_SteamJet() m_bFaceLeft = false; m_ParticleEffect.SetAlwaysSimulate( false ); // Don't simulate outside the PVS or frustum. - m_vLastRampUpdatePos.Init( 1e24, 1e24, 1e24 ); - m_vLastRampUpdateAngles.Init( 1e24, 1e24, 1e24 ); + m_vLastRampUpdatePos.Init( 1e16, 1e16, 1e16 ); + m_vLastRampUpdateAngles.Init( 1e16, 1e16, 1e16 ); } diff --git a/game/client/particle_iterators.h b/game/client/particle_iterators.h index f38e4c49..ba9ebae1 100644 --- a/game/client/particle_iterators.h +++ b/game/client/particle_iterators.h @@ -125,8 +125,8 @@ inline CParticleRenderIterator::CParticleRenderIterator() m_bGotFirst = false; m_flPrevZ = 0; m_nParticlesInCurrentBatch = 0; - m_MinZ = 1e24; - m_MaxZ = -1e24; + m_MinZ = 1e16; + m_MaxZ = -1e16; m_nZCoords = 0; } diff --git a/game/client/tf2/c_obj_mcv_selection_panel.cpp b/game/client/tf2/c_obj_mcv_selection_panel.cpp index 1e57f0ba..e5315bc8 100644 --- a/game/client/tf2/c_obj_mcv_selection_panel.cpp +++ b/game/client/tf2/c_obj_mcv_selection_panel.cpp @@ -173,7 +173,7 @@ void CMCVMinimapPanel::OnMousePressed( vgui::MouseCode code ) // Find the closest MCV to their mouse press. int iClosest = -1; - float flClosest = 1e24; + float flClosest = 1e16; Vector2D curMousePos( m_LastX, m_LastY ); for ( int i=0; i < pPanel->m_DeployedTeleportStations.Count(); i++ ) diff --git a/game/client/tf2/c_ragdoll_shadow.cpp b/game/client/tf2/c_ragdoll_shadow.cpp index efb705b4..4e9487bc 100644 --- a/game/client/tf2/c_ragdoll_shadow.cpp +++ b/game/client/tf2/c_ragdoll_shadow.cpp @@ -79,7 +79,7 @@ IPhysicsObject *PhysModelCreateCustom( C_BaseEntity *pEntity, const CPhysCollide solid_t solid; solid.params = g_PhysDefaultObjectParams; solid.params.mass = 85.0f; - solid.params.inertia = 1e24f; + solid.params.inertia = 1e16f; int surfaceProp = -1; if ( props && props[0] ) { diff --git a/game/server/player.cpp b/game/server/player.cpp index 7dea1f50..745a8242 100644 --- a/game/server/player.cpp +++ b/game/server/player.cpp @@ -8014,7 +8014,7 @@ void CBasePlayer::SetupVPhysicsShadow( const Vector &vecAbsOrigin, const Vector Q_strncpy( solid.surfaceprop, "player", sizeof(solid.surfaceprop) ); solid.params = g_PhysDefaultObjectParams; solid.params.mass = 85.0f; - solid.params.inertia = 1e24f; + solid.params.inertia = 1e16f; solid.params.enableCollisions = false; //disable drag solid.params.dragCoefficient = 0; diff --git a/game/server/tf2/order_heal.cpp b/game/server/tf2/order_heal.cpp index 2e6631b9..768911d5 100644 --- a/game/server/tf2/order_heal.cpp +++ b/game/server/tf2/order_heal.cpp @@ -74,7 +74,7 @@ bool COrderHeal::CreateOrder( CPlayerClass *pClass ) ORDER_HEAL, pTeam->GetPlayer( sorted[0] ), pClass->GetPlayer(), - 1e24, + 1e16, 60, pOrder ); diff --git a/game/server/tf2/order_helpers.cpp b/game/server/tf2/order_helpers.cpp index 56274ce1..20764a3c 100644 --- a/game/server/tf2/order_helpers.cpp +++ b/game/server/tf2/order_helpers.cpp @@ -157,7 +157,7 @@ bool OrderCreator_ResourceZoneObject( ORDER_BUILD, pClosest, pPlayer, - 1e24, + 1e16, 60, pOrder ); diff --git a/game/server/tf2/order_killmortarguy.cpp b/game/server/tf2/order_killmortarguy.cpp index ff2bdffe..88c729ff 100644 --- a/game/server/tf2/order_killmortarguy.cpp +++ b/game/server/tf2/order_killmortarguy.cpp @@ -95,7 +95,7 @@ bool COrderKillMortarGuy::CreateOrder( CPlayerClass *pClass ) ORDER_KILL, pBrian, pClass->GetPlayer(), - 1e24, + 1e16, 60, pOrder ); diff --git a/game/server/tf2/order_mortar_attack.cpp b/game/server/tf2/order_mortar_attack.cpp index 1f98da36..db0888f0 100644 --- a/game/server/tf2/order_mortar_attack.cpp +++ b/game/server/tf2/order_mortar_attack.cpp @@ -61,7 +61,7 @@ bool COrderMortarAttack::CreateOrder( CPlayerClass *pClass ) ORDER_MORTAR_ATTACK, pEnt, pPlayer, - 1e24, + 1e16, 40, pOrder ); diff --git a/game/server/tf2/order_repair.cpp b/game/server/tf2/order_repair.cpp index a75f75da..65153dcb 100644 --- a/game/server/tf2/order_repair.cpp +++ b/game/server/tf2/order_repair.cpp @@ -91,7 +91,7 @@ bool COrderRepair::CreateOrder_RepairFriendlyObjects( CPlayerClassDefender *pCla ORDER_REPAIR, pObjToHeal, pPlayer, - 1e24, + 1e16, 60, pOrder ); @@ -130,7 +130,7 @@ bool COrderRepair::CreateOrder_RepairOwnObjects( CPlayerClass *pClass ) ORDER_REPAIR, pObj, info.m_pPlayer, - 1e24, + 1e16, 60, pOrder ); diff --git a/game/server/tf2/tf_obj_barbed_wire.cpp b/game/server/tf2/tf_obj_barbed_wire.cpp index 5666d362..341338a2 100644 --- a/game/server/tf2/tf_obj_barbed_wire.cpp +++ b/game/server/tf2/tf_obj_barbed_wire.cpp @@ -177,7 +177,7 @@ void CObjectBarbedWire::StartPlacement( CBaseTFPlayer *pPlayer ) if ( pPlayer && !m_hConnectedTo ) { // Automatically connect to the nearest barbed wire on our team. - float flClosest = 1e24; + float flClosest = 1e16; CObjectBarbedWire *pClosest = NULL; CBaseEntity *pCur = gEntList.FirstEnt(); diff --git a/game/server/tf2/tf_playerclass.cpp b/game/server/tf2/tf_playerclass.cpp index 51134354..675f259a 100644 --- a/game/server/tf2/tf_playerclass.cpp +++ b/game/server/tf2/tf_playerclass.cpp @@ -1041,7 +1041,7 @@ void CPlayerClass::InitVCollision( void ) solid_t solid; solid.params = g_PhysDefaultObjectParams; solid.params.mass = 85.0f; - solid.params.inertia = 1e24f; + solid.params.inertia = 1e16f; solid.params.enableCollisions = false; //disable drag solid.params.dragCoefficient = 0; diff --git a/game/server/tf2/tf_team.h b/game/server/tf2/tf_team.h index 1f90b656..e1e7f48c 100644 --- a/game/server/tf2/tf_team.h +++ b/game/server/tf2/tf_team.h @@ -145,7 +145,7 @@ public: int iOrderType, CBaseEntity *pTarget, CBaseTFPlayer *pPlayer = NULL, - float flDistanceToRemove = 1e24, + float flDistanceToRemove = 1e16, float flLifetime = 60, COrder *pDefaultOrder = NULL // If this is specified, then it is used instead of // asking COrder to allocate an order. diff --git a/game/shared/physics_shared.cpp b/game/shared/physics_shared.cpp index 53ede911..07851584 100644 --- a/game/shared/physics_shared.cpp +++ b/game/shared/physics_shared.cpp @@ -478,7 +478,7 @@ void PhysGetDefaultAABBSolid( solid_t &solid ) { solid.params = g_PhysDefaultObjectParams; solid.params.mass = 85.0f; - solid.params.inertia = 1e24f; + solid.params.inertia = 1e16f; Q_strncpy( solid.surfaceprop, "default", sizeof( solid.surfaceprop ) ); } diff --git a/public/disp_common.cpp b/public/disp_common.cpp index 0c2ac51b..3072e742 100644 --- a/public/disp_common.cpp +++ b/public/disp_common.cpp @@ -770,8 +770,8 @@ void ClearNeighborData( CCoreDispInfo *pDisp ) void GetDispBox( CCoreDispInfo *pDisp, CDispBox &box ) { // Calculate the bbox for this displacement. - Vector vMin( 1e24, 1e24, 1e24 ); - Vector vMax( -1e24, -1e24, -1e24 ); + Vector vMin( 1e16, 1e16, 1e16 ); + Vector vMax( -1e16, -1e16, -1e16 ); for ( int iVert = 0; iVert < 4; ++iVert ) { diff --git a/public/keyframe/keyframe.cpp b/public/keyframe/keyframe.cpp index 1e08b0a3..3c12971e 100644 --- a/public/keyframe/keyframe.cpp +++ b/public/keyframe/keyframe.cpp @@ -311,7 +311,7 @@ CPositionInterpolator_Rope::CPositionInterpolator_Rope() m_nSegments = 5; for( int i=0; i < 2; i++ ) - m_Delegate.m_CurEndPoints[i] = Vector( 1e24, 1e24, 1e24 ); + m_Delegate.m_CurEndPoints[i] = Vector( 1e16, 1e16, 1e16 ); } void CPositionInterpolator_Rope::Release() diff --git a/vphysics/ledgewriter.cpp b/vphysics/ledgewriter.cpp index 6b6b1865..3c930bef 100644 --- a/vphysics/ledgewriter.cpp +++ b/vphysics/ledgewriter.cpp @@ -65,7 +65,7 @@ static void BuildVertMap( vertmap_t &out, const Vector *pVerts, int vertexCount, int index = -1; Vector tmp; ConvertPositionToHL( &pVertList[ivpIndex], tmp); - float minDist = 1e24; + float minDist = 1e16; for ( int k = 0; k < vertexCount; k++ ) { float dist = (tmp-pVerts[k]).Length(); diff --git a/vphysics/trace.cpp b/vphysics/trace.cpp index c05bc5ed..18474522 100644 --- a/vphysics/trace.cpp +++ b/vphysics/trace.cpp @@ -1231,7 +1231,7 @@ loop_without_store: const IVP_Compact_Ledgetree_Node *node0 = node->left_son(); center.set(node0->center.k); // if we don't insert, this is larger than any quad distance - float lastDist = 1e24f; + float lastDist = 1e16f; if ( SweepHitsSphereOS( ¢er, node0->radius ) ) { lastDist = m_rayStartOS.quad_distance_to(¢er); @@ -2073,7 +2073,7 @@ inline float Clip( const Vector &dir, const Vector &pos, const Vector &normal ) return dist / cosTheta; // parallel or not facing the plane - return 1e24f; + return 1e16f; } // This is the first iteration of solving time of intersection. @@ -2258,7 +2258,7 @@ float simplex_t::ClipRayToTriangle( const Vector &dir, float epsilon ) } float dot = DotProduct( dir, *normals[best] ); if ( dot <= 0 ) - return 1e24f; + return 1e16f; dmin += epsilon/dot; return dmin;