From 8fa677c27c547faf368ac5daf8fb9bc7acf950ac Mon Sep 17 00:00:00 2001 From: "ALLEN-PC\\acj30" Date: Mon, 24 Feb 2025 19:10:11 -0600 Subject: [PATCH] Mapbase TF2 compatibility --- src/game/client/c_basecombatcharacter.h | 3 +- src/game/client/c_baseviewmodel.cpp | 4 +- src/game/client/c_particle_system.cpp | 11 +++++- src/game/client/client_mapbase.vpc | 8 ++-- src/game/client/hud_locator_target.cpp | 31 +++++++-------- src/game/client/vgui_video.cpp | 2 +- .../NextBot/NextBotComponentInterface.cpp | 5 +++ src/game/server/ai_basenpc.cpp | 4 ++ src/game/server/basecombatcharacter.cpp | 2 + src/game/server/baseflex.h | 3 +- src/game/server/entitylist.cpp | 5 ++- src/game/server/fire.cpp | 4 ++ src/game/server/hltvdirector.h | 2 +- src/game/server/particle_system.cpp | 7 ++++ src/game/server/particle_system.h | 3 ++ src/game/server/player.cpp | 5 ++- src/game/server/server_mapbase.vpc | 12 +++--- src/game/server/tf/nav_mesh/tf_nav_area.cpp | 5 +++ src/game/server/vscript_server.cpp | 2 +- src/game/server/vscript_server.nut | 3 -- src/game/shared/func_ladder.cpp | 12 +++++- src/game/shared/mapbase/mapbase_shared.cpp | 4 ++ src/game/shared/teamplay_round_timer.cpp | 4 +- src/game/shared/util_shared.cpp | 2 +- src/game/shared/util_shared.h | 2 +- src/public/vscript/ivscript.h | 4 ++ src/vscript/vscript_squirrel.cpp | 38 +++++++------------ 27 files changed, 119 insertions(+), 68 deletions(-) diff --git a/src/game/client/c_basecombatcharacter.h b/src/game/client/c_basecombatcharacter.h index c5784c63..ce9db6ae 100644 --- a/src/game/client/c_basecombatcharacter.h +++ b/src/game/client/c_basecombatcharacter.h @@ -99,7 +99,8 @@ public: #ifdef GLOWS_ENABLE CGlowObject *GetGlowObject( void ){ return m_pGlowEffect; } - virtual void GetGlowEffectColor( float *r, float *g, float *b, float *a = NULL ); + virtual void GetGlowEffectColor( float *r, float *g, float *b, float *a ); + virtual void GetGlowEffectColor( float *r, float *g, float *b ) { GetGlowEffectColor( r, g, b, NULL ); } // void EnableGlowEffect( float r, float g, float b ); void SetClientSideGlowEnabled( bool bEnabled ){ m_bClientSideGlowEnabled = bEnabled; UpdateGlowEffect(); } diff --git a/src/game/client/c_baseviewmodel.cpp b/src/game/client/c_baseviewmodel.cpp index 4b3c22bb..bcf609c5 100644 --- a/src/game/client/c_baseviewmodel.cpp +++ b/src/game/client/c_baseviewmodel.cpp @@ -35,7 +35,7 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -#if defined(CSTRIKE_DLL) || defined (MAPBASE) +#if defined(CSTRIKE_DLL) || (defined(MAPBASE) && !defined(TF_CLIENT_DLL)) ConVar cl_righthand( "cl_righthand", "1", FCVAR_ARCHIVE, "Use right-handed view models." ); #endif @@ -197,7 +197,7 @@ bool C_BaseViewModel::Interpolate( float currentTime ) bool C_BaseViewModel::ShouldFlipViewModel() { -#if defined(CSTRIKE_DLL) || defined (MAPBASE) +#if defined(CSTRIKE_DLL) || (defined(MAPBASE) && !defined(TF_CLIENT_DLL)) // If cl_righthand is set, then we want them all right-handed. CBaseCombatWeapon *pWeapon = m_hWeapon.Get(); if ( pWeapon ) diff --git a/src/game/client/c_particle_system.cpp b/src/game/client/c_particle_system.cpp index 74ac224f..fa9704bf 100644 --- a/src/game/client/c_particle_system.cpp +++ b/src/game/client/c_particle_system.cpp @@ -47,6 +47,9 @@ protected: unsigned char m_iControlPointParents[kMAXCONTROLPOINTS]; bool m_bWeatherEffect; +#ifdef MAPBASE + bool m_bUsesCoordinates; +#endif }; IMPLEMENT_CLIENTCLASS(C_ParticleSystem, DT_ParticleSystem, CParticleSystem); @@ -69,6 +72,9 @@ BEGIN_RECV_TABLE_NOBASE( C_ParticleSystem, DT_ParticleSystem ) RecvPropArray3( RECVINFO_ARRAY(m_vControlPointVecs), RecvPropVector( RECVINFO( m_vControlPointVecs[0] ) ) ), RecvPropArray3( RECVINFO_ARRAY(m_iControlPointParents), RecvPropInt( RECVINFO(m_iControlPointParents[0]))), RecvPropBool( RECVINFO( m_bWeatherEffect ) ), +#ifdef MAPBASE + RecvPropBool( RECVINFO( m_bUsesCoordinates ) ), +#endif END_RECV_TABLE(); //----------------------------------------------------------------------------- @@ -77,6 +83,9 @@ END_RECV_TABLE(); C_ParticleSystem::C_ParticleSystem() { m_bWeatherEffect = false; +#ifdef MAPBASE + m_bDestroyImmediately = false; +#endif } //----------------------------------------------------------------------------- @@ -152,7 +161,7 @@ void C_ParticleSystem::ClientThink( void ) AssertMsg1( pEffect, "Particle system couldn't make %s", pszName ); if (pEffect) { - if (m_vControlPointVecs[0] != GetAbsOrigin() && m_hControlPointEnts[0] == NULL) + if ( m_bUsesCoordinates ) { // we are using info_particle_system_coordinate for (int i = 0; i < kMAXCONTROLPOINTS; ++i) diff --git a/src/game/client/client_mapbase.vpc b/src/game/client/client_mapbase.vpc index 7b3b28f3..774d2d9d 100644 --- a/src/game/client/client_mapbase.vpc +++ b/src/game/client/client_mapbase.vpc @@ -53,7 +53,7 @@ $Project $File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.h" [$MAPBASE_VSCRIPT] $File "$SRCDIR\game\shared\mapbase\vscript_singletons.cpp" [$MAPBASE_VSCRIPT] $File "$SRCDIR\game\shared\mapbase\vscript_singletons.h" [$MAPBASE_VSCRIPT] - $File "$SRCDIR\game\shared\mapbase\vscript_funcs_hl2.cpp" [$MAPBASE_VSCRIPT] + $File "$SRCDIR\game\shared\mapbase\vscript_funcs_hl2.cpp" [$MAPBASE_VSCRIPT&&($HL2||$EPISODIC)] $File "$SRCDIR\game\shared\mapbase\vscript_consts_shared.cpp" [$MAPBASE_VSCRIPT] $File "$SRCDIR\game\shared\mapbase\vscript_consts_weapons.cpp" [$MAPBASE_VSCRIPT] $File "$SRCDIR\game\shared\mapbase\weapon_custom_scripted.cpp" [$MAPBASE_VSCRIPT] @@ -69,18 +69,18 @@ $Project $File "mapbase\c_func_fake_worldportal.h" $File "mapbase\c_point_glow.cpp" $File "mapbase\c_vgui_text_display.cpp" - $File "mapbase\c_weapon_custom_hl2.cpp" + $File "mapbase\c_weapon_custom_hl2.cpp" [$HL2||$EPISODIC] $File "mapbase\mapbase_autocubemap.cpp" } - $Folder "HL2 DLL" + $Folder "HL2 DLL" [$HL2||$EPISODIC] { // Original stunstick files are conditional'd out in the HL2 VPCs $File "$SRCDIR\game\shared\hl2mp\weapon_stunstick.cpp" $File "$SRCDIR\game\shared\hl2mp\weapon_stunstick.h" } - $Folder "HL2MP" + $Folder "HL2MP" [$HL2||$EPISODIC] { $Folder "Weapons" { diff --git a/src/game/client/hud_locator_target.cpp b/src/game/client/hud_locator_target.cpp index 2a8af109..dead20ed 100644 --- a/src/game/client/hud_locator_target.cpp +++ b/src/game/client/hud_locator_target.cpp @@ -50,11 +50,12 @@ ConVar locator_icon_max_size_non_ss( "locator_icon_max_size_non_ss", "1.5", FCVA enum { - DRAW_ARROW_NO = 0, - DRAW_ARROW_UP, - DRAW_ARROW_DOWN, - DRAW_ARROW_LEFT, - DRAW_ARROW_RIGHT + // "LOCATOR_" prefix added for TF2 compatibility (collision in tf_shareddefs.h) + LOCATOR_DRAW_ARROW_NO = 0, + LOCATOR_DRAW_ARROW_UP, + LOCATOR_DRAW_ARROW_DOWN, + LOCATOR_DRAW_ARROW_LEFT, + LOCATOR_DRAW_ARROW_RIGHT }; ConVar locator_fade_time( "locator_fade_time", "0.3", FCVAR_NONE, "Number of seconds it takes for a lesson to fully fade in/out." ); @@ -126,7 +127,7 @@ void CLocatorTarget::Activate( int serialNumber ) m_lastXPos = iStartX; m_lastYPos = iStartY; - m_drawArrowDirection = DRAW_ARROW_NO; + m_drawArrowDirection = LOCATOR_DRAW_ARROW_NO; m_lerpStart = gpGlobals->curtime; m_pulseStart = gpGlobals->curtime; m_declutterIndex = 0; @@ -1369,7 +1370,7 @@ void CLocatorPanel::ComputeTargetIconPosition( CLocatorTarget *pTarget, bool bSe } } - pTarget->m_drawArrowDirection = DRAW_ARROW_NO; + pTarget->m_drawArrowDirection = LOCATOR_DRAW_ARROW_NO; float fTitleSafeInset = ScreenWidth() * 0.075f; @@ -1392,9 +1393,9 @@ void CLocatorPanel::ComputeTargetIconPosition( CLocatorTarget *pTarget, bool bSe Vector vCenter = pTarget->m_vecOrigin; if( MainViewRight().Dot( vCenter - MainViewOrigin() ) > 0 ) - pTarget->m_drawArrowDirection = DRAW_ARROW_RIGHT; + pTarget->m_drawArrowDirection = LOCATOR_DRAW_ARROW_RIGHT; else - pTarget->m_drawArrowDirection = DRAW_ARROW_LEFT; + pTarget->m_drawArrowDirection = LOCATOR_DRAW_ARROW_LEFT; } else if( iconY < fTitleSafeInset || iconY > ScreenHeight() - fTitleSafeInset ) { @@ -1415,9 +1416,9 @@ void CLocatorPanel::ComputeTargetIconPosition( CLocatorTarget *pTarget, bool bSe Vector vCenter = pTarget->m_vecOrigin; if( MainViewUp().Dot( vCenter - MainViewOrigin() ) > 0 ) - pTarget->m_drawArrowDirection = DRAW_ARROW_UP; + pTarget->m_drawArrowDirection = LOCATOR_DRAW_ARROW_UP; else - pTarget->m_drawArrowDirection = DRAW_ARROW_DOWN; + pTarget->m_drawArrowDirection = LOCATOR_DRAW_ARROW_DOWN; } else { @@ -2093,28 +2094,28 @@ void CLocatorPanel::DrawIndicatorArrow( int x, int y, int iconWide, int iconTall switch( direction ) { - case DRAW_ARROW_LEFT: + case LOCATOR_DRAW_ARROW_LEFT: vgui::surface()->DrawSetTexture( m_textureID_ArrowLeft ); x -= wide; y += iconTall / 2 - tall / 2; vgui::surface()->DrawTexturedRect( x, y, x + wide, y + tall ); break; - case DRAW_ARROW_RIGHT: + case LOCATOR_DRAW_ARROW_RIGHT: vgui::surface()->DrawSetTexture( m_textureID_ArrowRight ); x += iconWide + textWidth; y += iconTall / 2 - tall / 2; vgui::surface()->DrawTexturedRect( x, y, x + wide, y + tall ); break; - case DRAW_ARROW_UP: + case LOCATOR_DRAW_ARROW_UP: vgui::surface()->DrawSetTexture( m_textureID_ArrowUp ); x += iconWide / 2 - wide / 2; y -= tall; vgui::surface()->DrawTexturedRect( x, y, x + wide, y + tall ); break; - case DRAW_ARROW_DOWN: + case LOCATOR_DRAW_ARROW_DOWN: vgui::surface()->DrawSetTexture( m_textureID_ArrowDown ); x += iconWide / 2 - wide / 2; y += iconTall; diff --git a/src/game/client/vgui_video.cpp b/src/game/client/vgui_video.cpp index 13b16bd9..21fb328d 100644 --- a/src/game/client/vgui_video.cpp +++ b/src/game/client/vgui_video.cpp @@ -400,7 +400,7 @@ void VideoPanel::Paint( void ) // Draw the polys to draw this out CMatRenderContextPtr pRenderContext( materials ); -#ifdef MAPBASE +#if defined(MAPBASE) && !defined(TF_CLIENT_DLL) // TODO: Figure out actual purpose of this pRenderContext->ClearColor4ub( 255, 255, 255, alpha * 255.0f ); #endif diff --git a/src/game/server/NextBot/NextBotComponentInterface.cpp b/src/game/server/NextBot/NextBotComponentInterface.cpp index 11d6bc2b..05473064 100644 --- a/src/game/server/NextBot/NextBotComponentInterface.cpp +++ b/src/game/server/NextBot/NextBotComponentInterface.cpp @@ -43,9 +43,14 @@ HSCRIPT INextBotComponent::GetScriptInstance() //-------------------------------------------------------------------------------------------------------------- #ifdef TF_DLL +#ifndef MAPBASE_VSCRIPT // TODO: Need better way of supporting this DEFINE_SCRIPT_INSTANCE_HELPER( INextBotComponent, &g_NextBotComponentScriptInstanceHelper ) +#endif #endif BEGIN_ENT_SCRIPTDESC_ROOT( INextBotComponent, "Next bot component" ) +#ifdef MAPBASE_VSCRIPT + DEFINE_SCRIPT_INSTANCE_HELPER( &g_NextBotComponentScriptInstanceHelper ) +#endif DEFINE_SCRIPTFUNC( Reset, "Resets the internal update state" ) DEFINE_SCRIPTFUNC( ComputeUpdateInterval, "Recomputes the component update interval" ) DEFINE_SCRIPTFUNC( GetUpdateInterval, "Returns the component update interval" ) diff --git a/src/game/server/ai_basenpc.cpp b/src/game/server/ai_basenpc.cpp index a1e94432..1becbe7a 100644 --- a/src/game/server/ai_basenpc.cpp +++ b/src/game/server/ai_basenpc.cpp @@ -709,8 +709,10 @@ bool CAI_BaseNPC::FriendlyFireEnabled() if (m_FriendlyFireOverride != TRS_NONE) return m_FriendlyFireOverride == TRS_TRUE; +#ifdef HL2_DLL if (HL2GameRules()->GlobalFriendlyFire() != TRS_NONE) return HL2GameRules()->GlobalFriendlyFire() == TRS_TRUE; +#endif return !(CapabilitiesGet() & bits_CAP_FRIENDLY_DMG_IMMUNE); } @@ -15922,6 +15924,7 @@ bool CanNPCsTradePlaces( CAI_BaseNPC *pNPC1, CAI_BaseNPC *pNPC2, bool bDebug ) #ifdef MAPBASE bool CAI_BaseNPC::InteractionIsAllowed( CAI_BaseNPC *pOtherNPC, ScriptedNPCInteraction_t *pInteraction ) { +#ifdef HL2_DLL // Now that female citizens have hunter interactions, Alyx is vulnerable to being murdered by hunters *dynamically*! // Citizens also have antlion interaction kill animations, so antlions could potentially murder her as well. // @@ -15929,6 +15932,7 @@ bool CAI_BaseNPC::InteractionIsAllowed( CAI_BaseNPC *pOtherNPC, ScriptedNPCInter // Hopefully there aren't any maps that already have hunters murder Barneys. if (pOtherNPC->Classify() == CLASS_PLAYER_ALLY_VITAL) return false; +#endif if (m_iDynamicInteractionsAllowed == TRS_FALSE) return false; diff --git a/src/game/server/basecombatcharacter.cpp b/src/game/server/basecombatcharacter.cpp index 8e9400f4..b706fd3f 100644 --- a/src/game/server/basecombatcharacter.cpp +++ b/src/game/server/basecombatcharacter.cpp @@ -4239,11 +4239,13 @@ void CBaseCombatCharacter::InputGiveWeapon( inputdata_t &inputdata ) { if (IsNPC()) { +#ifdef HL2_DLL if( Classify() == CLASS_PLAYER_ALLY_VITAL ) { MyNPCPointer()->m_iszPendingWeapon = iszWeaponName; } else +#endif { MyNPCPointer()->GiveWeapon( iszWeaponName ); } diff --git a/src/game/server/baseflex.h b/src/game/server/baseflex.h index 3e2f88af..ef4262ab 100644 --- a/src/game/server/baseflex.h +++ b/src/game/server/baseflex.h @@ -76,7 +76,8 @@ public: // Start the specifics of an scene event #ifdef MAPBASE - virtual bool StartSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event, CChoreoActor *actor, CBaseEntity *pTarget, CSceneEntity *pSceneEnt = NULL ); + virtual bool StartSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event, CChoreoActor *actor, CBaseEntity *pTarget, CSceneEntity *pSceneEnt ); + virtual bool StartSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event, CChoreoActor *actor, CBaseEntity *pTarget ) { return StartSceneEvent( info, scene, event, actor, pTarget, NULL ); } #else virtual bool StartSceneEvent( CSceneEventInfo *info, CChoreoScene *scene, CChoreoEvent *event, CChoreoActor *actor, CBaseEntity *pTarget ); #endif diff --git a/src/game/server/entitylist.cpp b/src/game/server/entitylist.cpp index cd8a8326..61f1b4dc 100644 --- a/src/game/server/entitylist.cpp +++ b/src/game/server/entitylist.cpp @@ -22,10 +22,13 @@ #include "npc_playercompanion.h" #ifdef MAPBASE #include "hl2_player.h" -#include "mapbase_matchers_base.h" #endif #endif // HL2_DLL +#ifdef MAPBASE +#include "mapbase_matchers_base.h" +#endif + // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" diff --git a/src/game/server/fire.cpp b/src/game/server/fire.cpp index 878d6e64..941819c9 100644 --- a/src/game/server/fire.cpp +++ b/src/game/server/fire.cpp @@ -18,7 +18,9 @@ #include "collisionutils.h" #include "tier0/vprof.h" #ifdef MAPBASE +#ifdef HL2_DLL #include "weapon_flaregun.h" +#endif #include "mapbase/GlobalStrings.h" #endif @@ -1417,6 +1419,7 @@ void CEnvFireSensor::Think() #ifdef MAPBASE if (HasSpawnFlags(SF_FIRESENSOR_ACCEPT_FLARES)) { +#ifdef HL2_DLL // Also look for nearby flares CBaseEntity *pEntity = gEntList.FindEntityByClassnameWithin( NULL, "env_flare", GetAbsOrigin(), m_radius ); while (pEntity) @@ -1429,6 +1432,7 @@ void CEnvFireSensor::Think() pEntity = gEntList.FindEntityByClassnameWithin( pEntity, "env_flare", GetAbsOrigin(), m_radius ); } +#endif } #endif diff --git a/src/game/server/hltvdirector.h b/src/game/server/hltvdirector.h index 24891c80..9fe60c7a 100644 --- a/src/game/server/hltvdirector.h +++ b/src/game/server/hltvdirector.h @@ -67,7 +67,7 @@ public: // CBaseGameSystem overrides virtual void Shutdown(); virtual void FrameUpdatePostEntityThink(); virtual void LevelInitPostEntity(); - virtual const char *GetFixedCameraEntityName( void ) { return "point_viewcontrol"; } + virtual char *GetFixedCameraEntityName( void ) { return "point_viewcontrol"; } bool SetCameraMan( int iPlayerIndex ); int GetCameraMan() { return m_iCameraManIndex; } diff --git a/src/game/server/particle_system.cpp b/src/game/server/particle_system.cpp index 23e98eaf..5680cc67 100644 --- a/src/game/server/particle_system.cpp +++ b/src/game/server/particle_system.cpp @@ -34,6 +34,9 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE(CParticleSystem, DT_ParticleSystem) SendPropArray3( SENDINFO_ARRAY3(m_vControlPointVecs), SendPropVector( SENDINFO_ARRAY(m_vControlPointVecs) ) ), SendPropArray3( SENDINFO_ARRAY3(m_iControlPointParents), SendPropInt( SENDINFO_ARRAY(m_iControlPointParents), 3, SPROP_UNSIGNED ) ), SendPropBool( SENDINFO(m_bWeatherEffect) ), +#ifdef MAPBASE + SendPropBool( SENDINFO(m_bUsesCoordinates) ), +#endif END_SEND_TABLE() BEGIN_DATADESC( CParticleSystem ) @@ -140,6 +143,9 @@ LINK_ENTITY_TO_CLASS( info_particle_system_coordinate, CParticleSystemCoordinate CParticleSystem::CParticleSystem() { m_bWeatherEffect = false; +#ifdef MAPBASE + m_bDestroyImmediately = false; +#endif } //----------------------------------------------------------------------------- @@ -284,6 +290,7 @@ void CParticleSystem::ReadControlPointEnts( void ) } m_hControlPointEnts.Set( i, pPointEnt ); + m_bUsesCoordinates = true; } } } diff --git a/src/game/server/particle_system.h b/src/game/server/particle_system.h index 42e213f5..d9e375ff 100644 --- a/src/game/server/particle_system.h +++ b/src/game/server/particle_system.h @@ -63,6 +63,9 @@ protected: CNetworkArray( Vector, m_vControlPointVecs, kMAXCONTROLPOINTS ); CNetworkArray( unsigned char, m_iControlPointParents, kMAXCONTROLPOINTS ); CNetworkVar( bool, m_bWeatherEffect ); +#ifdef MAPBASE + CNetworkVar( bool, m_bUsesCoordinates ); +#endif }; //----------------------------------------------------------------------------- diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 179c5892..0079b7dc 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -86,10 +86,13 @@ #include "weapon_physcannon.h" #ifdef MAPBASE #include "mapbase/GlobalStrings.h" -#include "mapbase/matchers.h" #endif #endif +#ifdef MAPBASE +#include "mapbase/matchers.h" +#endif + #ifdef MAPBASE_VSCRIPT #include "mapbase/vscript_funcs_shared.h" #endif diff --git a/src/game/server/server_mapbase.vpc b/src/game/server/server_mapbase.vpc index 7d74847e..7f751868 100644 --- a/src/game/server/server_mapbase.vpc +++ b/src/game/server/server_mapbase.vpc @@ -52,15 +52,15 @@ $Project $File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.h" [$MAPBASE_VSCRIPT] $File "$SRCDIR\game\shared\mapbase\vscript_singletons.cpp" [$MAPBASE_VSCRIPT] $File "$SRCDIR\game\shared\mapbase\vscript_singletons.h" [$MAPBASE_VSCRIPT] - $File "$SRCDIR\game\shared\mapbase\vscript_funcs_hl2.cpp" [$MAPBASE_VSCRIPT] + $File "$SRCDIR\game\shared\mapbase\vscript_funcs_hl2.cpp" [$MAPBASE_VSCRIPT&&($HL2||$EPISODIC)] $File "$SRCDIR\game\shared\mapbase\vscript_consts_shared.cpp" [$MAPBASE_VSCRIPT] $File "$SRCDIR\game\shared\mapbase\vscript_consts_weapons.cpp" [$MAPBASE_VSCRIPT] $File "$SRCDIR\game\shared\mapbase\weapon_custom_scripted.cpp" [$MAPBASE_VSCRIPT] $File "$SRCDIR\game\shared\mapbase\weapon_custom_scripted.h" [$MAPBASE_VSCRIPT] $File "$SRCDIR\game\shared\mapbase\logic_script_client.cpp" [$MAPBASE_VSCRIPT] - $File "mapbase\ai_grenade.cpp" - $File "mapbase\ai_grenade.h" + $File "mapbase\ai_grenade.cpp" [$HL2||$EPISODIC] + $File "mapbase\ai_grenade.h" [$HL2||$EPISODIC] $File "mapbase\ai_monitor.cpp" $File "mapbase\ai_weaponmodifier.cpp" $File "mapbase\custom_weapon_factory.cpp" @@ -88,20 +88,20 @@ $Project $File "mapbase\SystemConvarMod.h" $File "mapbase\variant_tools.h" $File "mapbase\vgui_text_display.cpp" - $File "mapbase\weapon_custom_hl2.cpp" + $File "mapbase\weapon_custom_hl2.cpp" [$HL2||$EPISODIC] $File "mapbase\logic_eventlistener.cpp" $File "mapbase\logic_register_activator.cpp" } - $Folder "HL2 DLL" + $Folder "HL2 DLL" [$HL2||$EPISODIC] { // Original stunstick files are conditional'd out in the HL2 VPCs $File "$SRCDIR\game\shared\hl2mp\weapon_stunstick.cpp" $File "$SRCDIR\game\shared\hl2mp\weapon_stunstick.h" } - $Folder "HL2MP" + $Folder "HL2MP" [$HL2||$EPISODIC] { $Folder "Weapons" { diff --git a/src/game/server/tf/nav_mesh/tf_nav_area.cpp b/src/game/server/tf/nav_mesh/tf_nav_area.cpp index a5bbc0a5..4601582f 100644 --- a/src/game/server/tf/nav_mesh/tf_nav_area.cpp +++ b/src/game/server/tf/nav_mesh/tf_nav_area.cpp @@ -31,9 +31,14 @@ ConVar tf_show_incursion_range_max( "tf_show_incursion_range_max", "0", FCVAR_CH // Script access to manipulate the nav //-------------------------------------------------------------------------------------------------------------- +#ifndef MAPBASE_VSCRIPT // TODO: Need better way of supporting this DEFINE_SCRIPT_INSTANCE_HELPER( CTFNavArea, &g_NavAreaScriptInstanceHelper ) +#endif BEGIN_ENT_SCRIPTDESC_ROOT( CTFNavArea, "Navigation areas class" ) +#ifdef MAPBASE_VSCRIPT + DEFINE_SCRIPT_INSTANCE_HELPER( &g_NavAreaScriptInstanceHelper ) +#endif DEFINE_SCRIPTFUNC_NAMED( ScriptGetID, "GetID", "Get area ID." ) DEFINE_SCRIPTFUNC( GetAttributes, "Get area attribute bits" ) DEFINE_SCRIPTFUNC( SetAttributes, "Set area attribute bits" ) diff --git a/src/game/server/vscript_server.cpp b/src/game/server/vscript_server.cpp index d06f928a..44611893 100644 --- a/src/game/server/vscript_server.cpp +++ b/src/game/server/vscript_server.cpp @@ -1420,7 +1420,6 @@ static CBaseEntity *VScript_ParseEntity( const char *pszClassname, HSCRIPT hSpaw return pEntity; } -#ifndef MAPBASE_VSCRIPT // See vscript_funcs_shared.cpp //----------------------------------------------------------------------------- CBaseEntity *ScriptCreateEntityFromTable( const char *pszClassname, HSCRIPT hSpawnTable ) { @@ -1436,6 +1435,7 @@ CBaseEntity *ScriptCreateEntityFromTable( const char *pszClassname, HSCRIPT hSpa return pEntity; } +#ifndef MAPBASE_VSCRIPT // See vscript_funcs_shared.cpp //----------------------------------------------------------------------------- static HSCRIPT Script_SpawnEntityFromTable( const char *pszName, HSCRIPT spawn_table ) { diff --git a/src/game/server/vscript_server.nut b/src/game/server/vscript_server.nut index 12b54a93..0309a702 100644 --- a/src/game/server/vscript_server.nut +++ b/src/game/server/vscript_server.nut @@ -1,4 +1,3 @@ -static char g_Script_vscript_client[] = R"vscript( //========== Copyright © 2008, Valve Corporation, All rights reserved. ======== // // Purpose: @@ -296,7 +295,6 @@ function FireScriptEvent( event, params ) __RunEventCallbacks( event, params, "OnScriptEvent_", "ScriptEventCallbacks", false ) } - //----------------------------------------------------------------------------- // Debug watches & trace //----------------------------------------------------------------------------- @@ -778,4 +776,3 @@ function EndScriptDebug() } //----------------------------------------------------------------------------- -)vscript"; diff --git a/src/game/shared/func_ladder.cpp b/src/game/shared/func_ladder.cpp index f3852cc5..bcdab526 100644 --- a/src/game/shared/func_ladder.cpp +++ b/src/game/shared/func_ladder.cpp @@ -5,7 +5,7 @@ //=============================================================================// #include "cbase.h" #include "func_ladder.h" -#ifdef MAPBASE +#if defined(MAPBASE) && (defined(HL2_DLL) || defined(HL2_CLIENT_DLL)) #include "hl_gamemovement.h" #endif @@ -16,7 +16,7 @@ /*static*/ ConVar sv_showladders( "sv_showladders", "0", 0, "Show bbox and dismount points for all ladders (must be set before level load.)\n" ); #endif -#if MAPBASE +#if defined(MAPBASE) && (defined(HL2_DLL) || defined(HL2_CLIENT_DLL)) extern IGameMovement *g_pGameMovement; #endif @@ -415,7 +415,11 @@ void CFuncLadder::InputDisable( inputdata_t &inputdata ) //----------------------------------------------------------------------------- void CFuncLadder::InputForcePlayerOn( inputdata_t &inputdata ) { +#if (defined(HL2_DLL) || defined(HL2_CLIENT_DLL)) static_cast(g_pGameMovement)->ForcePlayerOntoLadder(this); +#else + Warning( "This game does not support ForcePlayerOn\n" ); +#endif } //----------------------------------------------------------------------------- @@ -424,7 +428,11 @@ void CFuncLadder::InputForcePlayerOn( inputdata_t &inputdata ) //----------------------------------------------------------------------------- void CFuncLadder::InputCheckPlayerOn( inputdata_t &inputdata ) { +#if (defined(HL2_DLL) || defined(HL2_CLIENT_DLL)) static_cast(g_pGameMovement)->MountPlayerOntoLadder(this); +#else + Warning( "This game does not support CheckPlayerOn\n" ); +#endif } #endif diff --git a/src/game/shared/mapbase/mapbase_shared.cpp b/src/game/shared/mapbase/mapbase_shared.cpp index 85e8dee3..eeb31e3f 100644 --- a/src/game/shared/mapbase/mapbase_shared.cpp +++ b/src/game/shared/mapbase/mapbase_shared.cpp @@ -56,7 +56,9 @@ ConVar mapbase_flush_talker("mapbase_flush_talker", "1", FCVAR_NONE, "Normally, extern void MapbaseGameLog_Init(); +#ifdef HL2_DLL extern void ParseCustomActbusyFile(const char *file); +#endif extern bool LoadResponseSystemFile(const char *scriptfile); extern void ReloadResponseSystem(); @@ -466,8 +468,10 @@ public: } break; //case MANIFEST_SOUNDSCAPES: { g_SoundscapeSystem.AddSoundscapeFile(value); } break; //case MANIFEST_SENTENCES: { engine->PrecacheSentenceFile(value); } break; +#ifdef HL2_DLL case MANIFEST_ACTBUSY: { ParseCustomActbusyFile(value); } break; #endif +#endif #ifdef MAPBASE_VSCRIPT case MANIFEST_VSCRIPT: { VScriptRunScript(value, false); } break; #endif diff --git a/src/game/shared/teamplay_round_timer.cpp b/src/game/shared/teamplay_round_timer.cpp index 74d67249..fd555362 100644 --- a/src/game/shared/teamplay_round_timer.cpp +++ b/src/game/shared/teamplay_round_timer.cpp @@ -1398,14 +1398,14 @@ void CTeamRoundTimer::InputAddTeamTime( inputdata_t &input ) int nSeconds = 0; // get the team - p = nexttoken( token, p, ' ', sizeof(token) ); + p = nexttoken( token, p, ' ' ); if ( token[0] ) { nTeam = Q_atoi( token ); } // get the time - p = nexttoken( token, p, ' ', sizeof(token) ); + p = nexttoken( token, p, ' ' ); if ( token[0] ) { nSeconds = Q_atoi( token ); diff --git a/src/game/shared/util_shared.cpp b/src/game/shared/util_shared.cpp index 6aee3582..b348ec66 100644 --- a/src/game/shared/util_shared.cpp +++ b/src/game/shared/util_shared.cpp @@ -1359,7 +1359,7 @@ char *UTIL_GetFilteredChatText( int iPlayerIndex, char *pszText, int nTextBuffer } #endif // CLIENT_DLL -const char* ReadAndAllocStringValue( KeyValues *pSub, const char *pName, const char *pFilename ) +char* ReadAndAllocStringValue( KeyValues *pSub, const char *pName, const char *pFilename ) { const char *pValue = pSub->GetString( pName, NULL ); if ( !pValue ) diff --git a/src/game/shared/util_shared.h b/src/game/shared/util_shared.h index 5add18c5..4e350390 100644 --- a/src/game/shared/util_shared.h +++ b/src/game/shared/util_shared.h @@ -663,7 +663,7 @@ class RealTimeCountdownTimer : public CountdownTimer } }; -const char* ReadAndAllocStringValue( KeyValues *pSub, const char *pName, const char *pFilename = NULL ); +char* ReadAndAllocStringValue( KeyValues *pSub, const char *pName, const char *pFilename = NULL ); int UTIL_StringFieldToInt( const char *szValue, const char **pValueStrings, int iNumStrings ); diff --git a/src/public/vscript/ivscript.h b/src/public/vscript/ivscript.h index b5db780c..ab1071e2 100644 --- a/src/public/vscript/ivscript.h +++ b/src/public/vscript/ivscript.h @@ -582,7 +582,11 @@ inline IScriptInstanceHelper *GetScriptInstanceHelper_ScriptNoBase_t() #define DEFINE_SCRIPTFUNC_WRAPPED( func, description ) DEFINE_SCRIPTFUNC_NAMED( SCRIPTFUNC_CONCAT( Script, func ), #func, description ) #define DEFINE_SCRIPTFUNC_NAMED( func, scriptName, description ) ScriptAddFunctionToClassDescNamed( pDesc, _className, func, scriptName, description ); #define DEFINE_SCRIPT_CONSTRUCTOR() ScriptAddConstructorToClassDesc( pDesc, _className ); +#ifdef MAPBASE_VSCRIPT #define DEFINE_SCRIPT_INSTANCE_HELPER( p ) pDesc->pHelper = (p); +#else +#define DEFINE_SCRIPT_INSTANCE_HELPER( className, p ) template <> IScriptInstanceHelper *GetScriptInstanceHelperOverride< className >( IScriptInstanceHelper * ) { return p; } +#endif #ifdef MAPBASE_VSCRIPT // Use this for hooks which have no parameters diff --git a/src/vscript/vscript_squirrel.cpp b/src/vscript/vscript_squirrel.cpp index 880fb8dd..e5afcbe8 100644 --- a/src/vscript/vscript_squirrel.cpp +++ b/src/vscript/vscript_squirrel.cpp @@ -1090,13 +1090,17 @@ bool CreateParamCheck(const ScriptFunctionBinding_t& func, char* output) switch (func.m_desc.m_Parameters[i]) { case FIELD_FLOAT: + case FIELD_FLOAT64: case FIELD_INTEGER: + case FIELD_UINT: + case FIELD_UINT64: *output++ = 'n'; break; case FIELD_CSTRING: *output++ = 's'; break; case FIELD_VECTOR: + case FIELD_QANGLE: *output++ = 'x'; // Generic instance, we validate on arrival break; case FIELD_BOOLEAN: @@ -1137,6 +1141,7 @@ void PushVariant(HSQUIRRELVM vm, const ScriptVariant_t& value) sq_pushnull(vm); break; case FIELD_VECTOR: + case FIELD_QANGLE: { SquirrelVM* pSquirrelVM = (SquirrelVM*)sq_getforeignptr(vm); assert(pSquirrelVM); @@ -1196,6 +1201,7 @@ void GetVariantScriptString(const ScriptVariant_t& value, char *szValue, int iSi V_snprintf( szValue, iSize, "\"%s\"", value.m_pszString ); break; case FIELD_VECTOR: + case FIELD_QANGLE: // Could show "QAngle" instead, but Mapbase VScript never did that V_snprintf( szValue, iSize, "Vector( %f, %f, %f )", value.m_pVector->x, value.m_pVector->y, value.m_pVector->z ); break; case FIELD_INTEGER: @@ -1343,6 +1349,7 @@ SQInteger function_stub(HSQUIRRELVM vm) break; } case FIELD_VECTOR: + case FIELD_QANGLE: { Vector* val; if (SQ_FAILED(sq_getinstanceup(vm, i + 2, (SQUserPointer*)&val, TYPETAG_VECTOR))) @@ -1433,7 +1440,7 @@ SQInteger function_stub(HSQUIRRELVM vm) PushVariant(vm, retval); - if (retval.m_type == FIELD_VECTOR) + if (retval.m_type == FIELD_VECTOR || retval.m_type == FIELD_QANGLE) delete retval.m_pVector; return pFunc->m_desc.m_ReturnType != FIELD_VOID; @@ -1753,23 +1760,6 @@ void errorfunc(HSQUIRRELVM SQ_UNUSED_ARG(v), const SQChar* format, ...) Warning("%s", buffer); } -const char * ScriptDataTypeToName(ScriptDataType_t datatype) -{ - switch (datatype) - { - case FIELD_VOID: return "void"; - case FIELD_FLOAT: return "float"; - case FIELD_CSTRING: return "string"; - case FIELD_VECTOR: return "Vector"; - case FIELD_INTEGER: return "int"; - case FIELD_BOOLEAN: return "bool"; - case FIELD_CHARACTER: return "char"; - case FIELD_HSCRIPT: return "handle"; - case FIELD_VARIANT: return "variant"; - default: return ""; - } -} - #define PushDocumentationRegisterFunction( szName ) \ sq_pushroottable(vm); \ @@ -1805,14 +1795,14 @@ void RegisterDocumentation(HSQUIRRELVM vm, const ScriptFuncDescriptor_t& pFuncDe char signature[256] = ""; - V_snprintf(signature, sizeof(signature), "%s %s(", ScriptDataTypeToName(pFuncDesc.m_ReturnType), name); + V_snprintf(signature, sizeof(signature), "%s %s(", VariantFieldTypeName(pFuncDesc.m_ReturnType), name); for (int i = 0; i < pFuncDesc.m_Parameters.Count(); ++i) { if (i != 0) V_strcat_safe(signature, ", "); - V_strcat_safe(signature, ScriptDataTypeToName(pFuncDesc.m_Parameters[i])); + V_strcat_safe(signature, VariantFieldTypeName(pFuncDesc.m_Parameters[i])); } V_strcat_safe(signature, ")"); @@ -1901,7 +1891,7 @@ void RegisterConstantDocumentation( HSQUIRRELVM vm, const ScriptConstantBinding_ V_strcat_safe(name, pConstDesc->m_pszScriptName); char signature[256] = ""; - V_snprintf(signature, sizeof(signature), "%s (%s)", pszAsString, ScriptDataTypeToName(pConstDesc->m_data.m_type)); + V_snprintf(signature, sizeof(signature), "%s (%s)", pszAsString, VariantFieldTypeName(pConstDesc->m_data.m_type)); // RegisterConstHelp(name, signature, description) PushDocumentationRegisterFunction( "RegisterConstHelp" ); @@ -1933,14 +1923,14 @@ void RegisterHookDocumentation(HSQUIRRELVM vm, const ScriptHook_t* pHook, const char signature[256] = ""; - V_snprintf(signature, sizeof(signature), "%s %s(", ScriptDataTypeToName(pFuncDesc.m_ReturnType), name); + V_snprintf(signature, sizeof(signature), "%s %s(", VariantFieldTypeName(pFuncDesc.m_ReturnType), name); for (int i = 0; i < pFuncDesc.m_Parameters.Count(); ++i) { if (i != 0) V_strcat_safe(signature, ", "); - V_strcat_safe(signature, ScriptDataTypeToName(pFuncDesc.m_Parameters[i])); + V_strcat_safe(signature, VariantFieldTypeName(pFuncDesc.m_Parameters[i])); V_strcat_safe(signature, " ["); V_strcat_safe(signature, pHook->m_pszParameterNames[i]); V_strcat_safe(signature, "]"); @@ -1978,7 +1968,7 @@ void RegisterMemberDocumentation(HSQUIRRELVM vm, const ScriptMemberDesc_t& pDesc V_strcat_safe(name, pDesc.m_pszScriptName); char signature[256] = ""; - V_snprintf(signature, sizeof(signature), "%s %s", ScriptDataTypeToName(pDesc.m_ReturnType), name); + V_snprintf(signature, sizeof(signature), "%s %s", VariantFieldTypeName(pDesc.m_ReturnType), name); // RegisterMemberHelp(name, signature, description) PushDocumentationRegisterFunction( "RegisterMemberHelp" );