From 3bf9df6b2785fa6d951086978a3e66f49427166a Mon Sep 17 00:00:00 2001 From: FluorescentCIAAfricanAmerican <0934gj3049fk@protonmail.com> Date: Wed, 22 Apr 2020 12:56:21 -0400 Subject: 1 --- game/server/tf2/mapdata_server.cpp | 115 +++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 game/server/tf2/mapdata_server.cpp (limited to 'game/server/tf2/mapdata_server.cpp') diff --git a/game/server/tf2/mapdata_server.cpp b/game/server/tf2/mapdata_server.cpp new file mode 100644 index 0000000..258f580 --- /dev/null +++ b/game/server/tf2/mapdata_server.cpp @@ -0,0 +1,115 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" + +#include "mapdata_shared.h" +#include "sharedinterface.h" +#include "baseentity.h" +#include "world.h" +#include "player.h" + +class CMapData_Server : public IMapData +{ +public: + + // World data queries. + void GetMapBounds( Vector &vecMins, Vector &vecMaxs ); + void GetMapOrigin( Vector &vecOrigin ); + void GetMapSize( Vector &vecSize ); + + // 3D Skybox data queries. + void Get3DSkyboxOrigin( Vector &vecOrigin ); + float Get3DSkyboxScale( void ); +}; + +static CMapData_Server g_MapData; +IMapData *g_pMapData = &g_MapData; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMapData_Server::GetMapBounds( Vector &vecMins, Vector &vecMaxs ) +{ + CWorld *pWorld = static_cast( GetWorldEntity() ); + if ( pWorld ) + { + // Get the world bounds. + pWorld->GetWorldBounds( vecMins, vecMaxs ); + + // Backward compatability... + if ( ( vecMins.LengthSqr() == 0.0f ) && ( vecMaxs.LengthSqr() == 0.0f ) ) + { + vecMins.Init( -6500.0f, -6500.0f, -6500.0f ); + vecMaxs.Init( 6500.0f, 6500.0f, 6500.0f ); + } + } + else + { + Assert( 0 ); + vecMins.Init( 0.0f, 0.0f, 0.0f ); + vecMaxs.Init( 1.0f, 1.0f, 1.0f ); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMapData_Server::GetMapOrigin( Vector &vecOrigin ) +{ + Vector vecMins, vecMaxs; + GetMapBounds( vecMins, vecMaxs ); + VectorAdd( vecMins, vecMaxs, vecOrigin ); + VectorMultiply( vecOrigin, 0.5f, vecOrigin ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMapData_Server::GetMapSize( Vector &vecSize ) +{ + Vector vecMins, vecMaxs; + GetMapBounds( vecMins, vecMaxs ); + VectorSubtract( vecMaxs, vecMins, vecSize ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void CMapData_Server::Get3DSkyboxOrigin( Vector &vecOrigin ) +{ + // NOTE: If the player hasn't been created yet -- this doesn't work!!! + // We need to pass the data along in the map - requires a tool change. + CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); + if ( pPlayer ) + { + CPlayerLocalData *pLocalData = &pPlayer->m_Local; + VectorCopy( pLocalData->m_skybox3d.origin, vecOrigin ); + } + else + { + // Debugging! + Assert( 0 ); + vecOrigin.Init(); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +float CMapData_Server::Get3DSkyboxScale( void ) +{ + // NOTE: If the player hasn't been created yet -- this doesn't work!!! + // We need to pass the data along in the map - requires a tool change. + CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); + if ( pPlayer ) + { + CPlayerLocalData *pLocalData = &pPlayer->m_Local; + return pLocalData->m_skybox3d.scale; + } + else + { + // Debugging! + Assert( 0 ); + return 1.0f; + } +} -- cgit v1.2.3