source-sdk-2013-mapbase/sp/src/game/client/c_world.cpp

201 lines
5.4 KiB
C++
Raw Normal View History

2013-12-03 07:31:46 +04:00
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "c_world.h"
#include "ivmodemanager.h"
#include "activitylist.h"
#include "decals.h"
#include "engine/ivmodelinfo.h"
#include "ivieweffects.h"
#include "shake.h"
#include "eventlist.h"
// NVNT haptic include for notification of world precache
#include "haptics/haptic_utils.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#ifdef CWorld
#undef CWorld
#endif
C_GameRules *g_pGameRules = NULL;
static C_World *g_pClientWorld;
void ClientWorldFactoryInit()
{
g_pClientWorld = new C_World;
}
void ClientWorldFactoryShutdown()
{
delete g_pClientWorld;
g_pClientWorld = NULL;
}
static IClientNetworkable* ClientWorldFactory( int entnum, int serialNum )
{
Assert( g_pClientWorld != NULL );
g_pClientWorld->Init( entnum, serialNum );
return g_pClientWorld;
}
IMPLEMENT_CLIENTCLASS_FACTORY( C_World, DT_World, CWorld, ClientWorldFactory );
BEGIN_RECV_TABLE( C_World, DT_World )
RecvPropFloat(RECVINFO(m_flWaveHeight)),
RecvPropVector(RECVINFO(m_WorldMins)),
RecvPropVector(RECVINFO(m_WorldMaxs)),
RecvPropInt(RECVINFO(m_bStartDark)),
RecvPropFloat(RECVINFO(m_flMaxOccludeeArea)),
RecvPropFloat(RECVINFO(m_flMinOccluderArea)),
RecvPropFloat(RECVINFO(m_flMaxPropScreenSpaceWidth)),
RecvPropFloat(RECVINFO(m_flMinPropScreenSpaceWidth)),
RecvPropString(RECVINFO(m_iszDetailSpriteMaterial)),
RecvPropInt(RECVINFO(m_bColdWorld)),
Mapbase v2.0; bulk commit - Added custom map compile tools (vbsp, vvis, vrad) - Changed blink fix (shouldn't change anything in-game) - Added auto-completion to ent_create, npc_create, and the main set of "npc_" debug commands - Added ent_create_aimed, an ent_create equivalent of npc_create_aimed - Made hunters start using the "vs. player" melee animation against smaller NPCs that look weird with the "stab" attack - Added "explosion_sparks" convar, which fixes broken code for giving explosions sparks (disabled by default because of how different it looks) - Made interaction code capable of being dispatched on any entity, not just combat characters - Added npc_barnacle_ignite convar, which lets barnacles be ignited by flares - Fixed certain NPCs getting out of the way for the player when they hate them - Fixed auto-generated "speak" scene responses not using parameters that work on real VCDs - Made "stop_on_nonidle" capable of being used in any mod, not just HL2 episodic mods - Selectable color for ragdoll boogie/point_ragdollboogie - Fixed PickupWeaponInstant not firing weapon pickup outputs - Introduced inputs and keyvalues for "lerping" to math_counter_advanced - Fixed ClearConsole on logic_console - logic_convar should now detect client convars correctly - New NormalizeAngles input on math_vector - logic_modelinfo LookupActivity input - math_generate fixed and expanded to be more like math_counter - Added a WIP game logging system for playtesting maps - Introduced logic_playerinfo, an entity that can read a player's name or ID - Fixed some new filters not working with filter_multi - Added radius pickup spawnflag to func_physbox - Added "Preserve name" spawnflag to weapons - Added cc_achievement_debug message for when an achievement doesn't exist - Made npc_combine_s not speak while in logic_choreographed_scenes - Fixed zombie torsos/legs/headcrabs not being serverside when zombie is forced to server ragdoll - Expanded and cleaned up npc_zombie_custom - Fixed func_commandredirects not cleaning up correctly and sometimes crashing the game - Allowed player squad commands to go through +USE-held objects - Added a bunch of I/O/KV to trigger_waterydeath for better configuration - Changed save comment system to use the chapter title from world properties, and the ability to suppress the title popup that normally results from it - Adjusted game_convar_mod for MP planning - Removed the func_precipitation custom particle/splash code for now, as it was causing problems - Fixed env_global_light not accepting lightcolor - Added "Additional Buttons" to player_speedmod - Added save comment to RPC - Added env_projectedtexture attenuation - Added scripted_sequence OnPreIdleSequence - Added OnCrab to zombies - Added skill_changed game event (may need further testing) - Added a fix for viewmodels flipping under extreme FOV values - Added code that allows mappers to change the skin on shotgunners without it usually flipping back randomly - Fixed a very, very, very major shader performance issue - New SetAbsOrigin/Angles inputs on all entities, analogous to SetLocalOrigin/Angles - Code improvements for I/O involving angles - logic_entity_position improvements/fixes, including a new OutAngles output that outputs the angles on position calls - Alternate collision/player avoidance spawnflag obsoletion enforcement disabled - Enable/DisableHazardLights inputs on the EP2 jalopy, equivalent to the keyvalue - Miscellaneous shader formatting adjustments and fixes - Fixed AlwaysDrawOff on env_projectedtexture not being a valid input
2019-12-14 07:20:02 +03:00
#ifdef MAPBASE
RecvPropString(RECVINFO(m_iszChapterTitle)),
#endif
#ifdef MAPBASE_VSCRIPT
RecvPropInt(RECVINFO(m_iScriptLanguage)),
#endif
2013-12-03 07:31:46 +04:00
END_RECV_TABLE()
C_World::C_World( void )
{
}
C_World::~C_World( void )
{
}
bool C_World::Init( int entnum, int iSerialNum )
{
m_flWaveHeight = 0.0f;
ActivityList_Init();
EventList_Init();
return BaseClass::Init( entnum, iSerialNum );
}
void C_World::Release()
{
ActivityList_Free();
Term();
}
void C_World::PreDataUpdate( DataUpdateType_t updateType )
{
BaseClass::PreDataUpdate( updateType );
}
void C_World::OnDataChanged( DataUpdateType_t updateType )
{
BaseClass::OnDataChanged( updateType );
// Always force reset to normal mode upon receipt of world in new map
if ( updateType == DATA_UPDATE_CREATED )
{
modemanager->SwitchMode( false, true );
if ( m_bStartDark )
{
ScreenFade_t sf;
memset( &sf, 0, sizeof( sf ) );
sf.a = 255;
sf.r = 0;
sf.g = 0;
sf.b = 0;
sf.duration = (float)(1<<SCREENFADE_FRACBITS) * 5.0f;
sf.holdTime = (float)(1<<SCREENFADE_FRACBITS) * 1.0f;
sf.fadeFlags = FFADE_IN | FFADE_PURGE;
vieweffects->Fade( sf );
}
OcclusionParams_t params;
params.m_flMaxOccludeeArea = m_flMaxOccludeeArea;
params.m_flMinOccluderArea = m_flMinOccluderArea;
engine->SetOcclusionParameters( params );
modelinfo->SetLevelScreenFadeRange( m_flMinPropScreenSpaceWidth, m_flMaxPropScreenSpaceWidth );
}
}
void C_World::RegisterSharedActivities( void )
{
ActivityList_RegisterSharedActivities();
EventList_RegisterSharedEvents();
}
// -----------------------------------------
// Sprite Index info
// -----------------------------------------
short g_sModelIndexLaser; // holds the index for the laser beam
const char *g_pModelNameLaser = "sprites/laserbeam.vmt";
short g_sModelIndexLaserDot; // holds the index for the laser beam dot
short g_sModelIndexFireball; // holds the index for the fireball
short g_sModelIndexSmoke; // holds the index for the smoke cloud
short g_sModelIndexWExplosion; // holds the index for the underwater explosion
short g_sModelIndexBubbles; // holds the index for the bubbles model
short g_sModelIndexBloodDrop; // holds the sprite index for the initial blood
short g_sModelIndexBloodSpray; // holds the sprite index for splattered blood
//-----------------------------------------------------------------------------
// Purpose: Precache global weapon sounds
//-----------------------------------------------------------------------------
void W_Precache(void)
{
PrecacheFileWeaponInfoDatabase( filesystem, g_pGameRules->GetEncryptionKey() );
g_sModelIndexFireball = modelinfo->GetModelIndex ("sprites/zerogxplode.vmt");// fireball
g_sModelIndexWExplosion = modelinfo->GetModelIndex ("sprites/WXplo1.vmt");// underwater fireball
g_sModelIndexSmoke = modelinfo->GetModelIndex ("sprites/steam1.vmt");// smoke
g_sModelIndexBubbles = modelinfo->GetModelIndex ("sprites/bubble.vmt");//bubbles
g_sModelIndexBloodSpray = modelinfo->GetModelIndex ("sprites/bloodspray.vmt"); // initial blood
g_sModelIndexBloodDrop = modelinfo->GetModelIndex ("sprites/blood.vmt"); // splattered blood
g_sModelIndexLaser = modelinfo->GetModelIndex( (char *)g_pModelNameLaser );
g_sModelIndexLaserDot = modelinfo->GetModelIndex("sprites/laserdot.vmt");
}
void C_World::Precache( void )
{
// UNDONE: Make most of these things server systems or precache_registers
// =================================================
// Activities
// =================================================
ActivityList_Free();
EventList_Free();
RegisterSharedActivities();
// Get weapon precaches
W_Precache();
// Call all registered precachers.
CPrecacheRegister::Precache();
// NVNT notify system of precache
if (haptics)
haptics->WorldPrecache();
}
void C_World::Spawn( void )
{
Precache();
}
C_World *GetClientWorldEntity()
{
Assert( g_pClientWorld != NULL );
return g_pClientWorld;
}