Skip to content

Commit

Permalink
Merge pull request #8 from Planimeter/feature/port
Browse files Browse the repository at this point in the history
Feature/port

Signed-off-by: Andrew McWatters <andrew@planimeter.org>
Co-authored-by: luttje <2738114+luttje@users.noreply.github.com>
Helped-by: @ItzVladik
Helped-by: @YourPixelMoon
Helped-by: @Jacobdeanr
  • Loading branch information
andrewmcwatters and luttje authored Dec 25, 2024
2 parents 31399de + eb0a258 commit 47da71a
Show file tree
Hide file tree
Showing 429 changed files with 131,572 additions and 180 deletions.
55,792 changes: 55,792 additions & 0 deletions mp/hl2sb-2007.diff

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions mp/src/game/client/c_baseanimating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3897,6 +3897,36 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int

// Eject brass
case CL_EVENT_EJECTBRASS1:
#if defined ( HL2SB )
{
// Check if we're a weapon, if we belong to the local player, and if the local player is in third person - if all are true, don't do a muzzleflash in this instance, because
// we're using the view models dispatch for smoothness.
if ( dynamic_cast< C_BaseCombatWeapon *>(this) != NULL )
{
C_BaseCombatWeapon *pWeapon = dynamic_cast< C_BaseCombatWeapon *>(this);
if ( pWeapon && pWeapon->GetOwner() == C_BasePlayer::GetLocalPlayer() && ::input->CAM_IsThirdPerson() )
break;
}

if ( ( prediction->InPrediction() && !prediction->IsFirstTimePredicted() ) )
break;

if ( m_Attachments.Count() > 0 )
{
if ( MainViewOrigin().DistToSqr( GetAbsOrigin() ) < (256 * 256) )
{
Vector attachOrigin;
QAngle attachAngles;

if( GetAttachment( 2, attachOrigin, attachAngles ) )
{
tempents->EjectBrass( attachOrigin, attachAngles, GetAbsAngles(), atoi( options ) );
}
}
}
break;
}
#else
if ( m_Attachments.Count() > 0 )
{
if ( MainViewOrigin().DistToSqr( GetAbsOrigin() ) < (256 * 256) )
Expand All @@ -3911,6 +3941,7 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
}
}
break;
#endif

case AE_MUZZLEFLASH:
{
Expand Down
6 changes: 6 additions & 0 deletions mp/src/game/client/c_baseanimating.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,16 @@ class C_BaseAnimating : public C_BaseEntity, private IModelLoadCallback
CInterpolatedVarArray< float, MAXSTUDIOBONECTRLS > m_iv_flEncodedController;
float m_flOldEncodedController[MAXSTUDIOBONECTRLS];

#ifdef HL2SB
public:
#endif
// Clientside animation
bool m_bClientSideAnimation;
bool m_bLastClientSideFrameReset;

#ifdef HL2SB
private:
#endif
int m_nNewSequenceParity;
int m_nResetEventsParity;

Expand Down
63 changes: 55 additions & 8 deletions mp/src/game/client/c_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#include "cdll_bounded_cvars.h"
#include "inetchannelinfo.h"
#include "proto_version.h"
#ifdef LUA_SDK
#include "luamanager.h"
#include "mathlib/lvector.h"
#endif

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
Expand Down Expand Up @@ -967,6 +971,10 @@ C_BaseEntity::C_BaseEntity() :
#endif

ParticleProp()->Init( this );

#if defined( LUA_SDK )
m_nTableReference = LUA_NOREF;
#endif
}


Expand All @@ -984,6 +992,9 @@ C_BaseEntity::~C_BaseEntity()
#endif
RemoveFromInterpolationList();
RemoveFromTeleportList();
#if defined( LUA_SDK )
lua_unref( L, m_nTableReference );
#endif
}

void C_BaseEntity::Clear( void )
Expand Down Expand Up @@ -1627,11 +1638,43 @@ int C_BaseEntity::GetSoundSourceIndex() const
//-----------------------------------------------------------------------------
const Vector& C_BaseEntity::GetRenderOrigin( void )
{
#ifdef LUA_SDK
if ( m_nTableReference != LUA_NOREF )
{
lua_getref( L, m_nTableReference );
lua_getfield( L, -1, "m_vecRenderOrigin" );
lua_remove( L, -2 );
if ( lua_isuserdata( L, -1 ) && luaL_checkudata( L, -1, "Vector" ) )
{
const Vector& res = luaL_checkvector( L, -1 );
lua_pop( L, 1 );
return res;
}
lua_pop( L, 1 );
}
#endif

return GetAbsOrigin();
}

const QAngle& C_BaseEntity::GetRenderAngles( void )
{
#ifdef LUA_SDK
if ( m_nTableReference != LUA_NOREF )
{
lua_getref( L, m_nTableReference );
lua_getfield( L, -1, "m_angRenderAngles" );
lua_remove( L, -2 );
if ( lua_isuserdata( L, -1 ) && luaL_checkudata( L, -1, "QAngle" ) )
{
const QAngle& res = luaL_checkangle( L, -1 );
lua_pop( L, 1 );
return res;
}
lua_pop( L, 1 );
}
#endif

return GetAbsAngles();
}

Expand Down Expand Up @@ -4764,6 +4807,13 @@ const char *C_BaseEntity::GetClassname( void )
static char outstr[ 256 ];
outstr[ 0 ] = 0;
bool gotname = false;
#if defined ( LUA_SDK )
if ( m_iClassname && m_iClassname[ 0 ] )
{
Q_snprintf( outstr, sizeof( outstr ), "%s", m_iClassname );
gotname = true;
}
#endif
#ifndef NO_ENTITY_PREDICTION
if ( GetPredDescMap() )
{
Expand Down Expand Up @@ -5899,14 +5949,11 @@ float C_BaseEntity::GetInterpolationAmount( int flags )
return TICK_INTERVAL * serverTickMultiple;
}

// Always fully interpolate during multi-player or during demo playback, if the recorded
// demo was recorded locally.
const bool bPlayingDemo = engine->IsPlayingDemo();
const bool bPlayingMultiplayer = !bPlayingDemo && ( gpGlobals->maxClients > 1 );
const bool bPlayingNonLocallyRecordedDemo = bPlayingDemo && !engine->IsPlayingDemoALocallyRecordedDemo();
if ( bPlayingMultiplayer || bPlayingNonLocallyRecordedDemo )
// Always fully interpolate during multi-player or during demo playback...
if ( ( gpGlobals->maxClients > 1 ) ||
engine->IsPlayingDemo() )
{
return AdjustInterpolationAmount( this, TICKS_TO_TIME( TIME_TO_TICKS( GetClientInterpAmount() ) + serverTickMultiple ) );
return AdjustInterpolationAmount( this, TICKS_TO_TIME ( TIME_TO_TICKS( GetClientInterpAmount() ) + serverTickMultiple ) );
}

int expandedServerTickMultiple = serverTickMultiple;
Expand All @@ -5929,7 +5976,7 @@ float C_BaseEntity::GetInterpolationAmount( int flags )
return TICK_INTERVAL * expandedServerTickMultiple;
}

return AdjustInterpolationAmount( this, TICKS_TO_TIME( TIME_TO_TICKS( GetClientInterpAmount() ) + serverTickMultiple ) );
return AdjustInterpolationAmount( this, TICK_INTERVAL * ( TIME_TO_TICKS( GetClientInterpAmount() ) + serverTickMultiple ) );
}


Expand Down
8 changes: 8 additions & 0 deletions mp/src/game/client/c_baseentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,14 @@ class C_BaseEntity : public IClientEntity
bool m_bEnableRenderingClipPlane; //true to use the custom clip plane when drawing
float * GetRenderClipPlane( void ); // Rendering clip plane, should be 4 floats, return value of NULL indicates a disabled render clip plane

#if defined( LUA_SDK )
// Andrew; This is used to determine an entity's reference in Lua's LUA_REGISTRYINDEX.
// I'd rather do this than create a struct and pass that to each bounded function, plus it'll save some perf for massive executions, like Think funcs.
int m_nTableReference;
// Henry; There's an IsPlayer and IsWorld and such, why not an IsWeapon?
virtual bool IsWeapon( void ) const { return false; }
#endif

protected:

void AddToInterpolationList();
Expand Down
35 changes: 35 additions & 0 deletions mp/src/game/client/c_baseplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
// NVNT haptics system interface
#include "haptics/ihaptics.h"

#ifdef LUA_SDK
#include "luamanager.h"
#endif

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

Expand Down Expand Up @@ -237,6 +241,13 @@ END_RECV_TABLE()

RecvPropVector ( RECVINFO( m_vecBaseVelocity ) ),

#ifdef ARGG
// adnan
// get the use angles
RecvPropVector ( RECVINFO( m_vecUseAngles ) ),
// end adnan
#endif

RecvPropEHandle ( RECVINFO( m_hConstraintEntity)),
RecvPropVector ( RECVINFO( m_vecConstraintCenter) ),
RecvPropFloat ( RECVINFO( m_flConstraintRadius )),
Expand Down Expand Up @@ -288,6 +299,13 @@ END_RECV_TABLE()
RecvPropFloat (RECVINFO(m_flMaxspeed)),
RecvPropInt (RECVINFO(m_fFlags)),

#ifdef ARGG
// adnan
// get the use angles
RecvPropVector ( RECVINFO( m_vecUseAngles ) ),
// end adnan
#endif


RecvPropInt (RECVINFO(m_iObserverMode), 0, RecvProxy_ObserverMode ),
RecvPropEHandle (RECVINFO(m_hObserverTarget), RecvProxy_ObserverTarget ),
Expand Down Expand Up @@ -1385,6 +1403,23 @@ void C_BasePlayer::CreateWaterEffects( void )
//-----------------------------------------------------------------------------
void C_BasePlayer::OverrideView( CViewSetup *pSetup )
{
#ifdef ARGG
// adnan
// OVERRIDING THE VIEW
// need to override the angles too
C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
if ( pWeapon )
{
// adnan
if(pWeapon->OverrideViewAngles()) {
// use the useAngles!
// override with the angles the server sends to us as useAngles
// use the useAngles only if we're holding and rotating with the grav gun
pSetup->angles = m_vecUseAngles;
}
}
// end adnan
#endif
}

bool C_BasePlayer::ShouldInterpolate()
Expand Down
12 changes: 12 additions & 0 deletions mp/src/game/client/c_baseplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,14 @@ class C_BasePlayer : public C_BaseCombatCharacter, public CGameEventListener

CUserCmd *m_pCurrentCommand;

#ifdef ARGG
// adnan
// store the use angles
// set when the player presses use
QAngle m_vecUseAngles;
// end adnan
#endif

// Movement constraints
EHANDLE m_hConstraintEntity;
Vector m_vecConstraintCenter;
Expand Down Expand Up @@ -618,7 +626,11 @@ class C_BasePlayer : public C_BaseCombatCharacter, public CGameEventListener
CUtlVector<CHandle<C_EconWearable > > m_hMyWearables;
#endif

#ifdef LUA_SDK
public:
#else
private:
#endif

struct StepSoundCache_t
{
Expand Down
3 changes: 3 additions & 0 deletions mp/src/game/client/c_basetempentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class C_BaseTempEntity : public IClientUnknown, public IClientNetworkable
void NetworkStateChanged() {}
void NetworkStateChanged( void *pVar ) {}

// Dummy for scripted weapons.
void SetClassname( const char *classname ) {}

virtual bool Init(int entnum, int iSerialNum);

virtual void Precache( void );
Expand Down
19 changes: 19 additions & 0 deletions mp/src/game/client/c_baseviewmodel.cpp.rej
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff a/mp/src/game/client/c_baseviewmodel.cpp b/mp/src/game/client/c_baseviewmodel.cpp (rejected hunks)
@@ -23,7 +23,7 @@
#include "tier0/memdbgon.h"

//Tony; modified so that the sdk view models are right handed out of the box.
-#if defined( CSTRIKE_DLL ) || defined( SDK_DLL )
+#if defined( CSTRIKE_DLL ) || defined( SDK_DLL ) || defined( LUA_SDK )
ConVar cl_righthand( "cl_righthand", "1", FCVAR_ARCHIVE, "Use right-handed view models." );
#endif

@@ -175,7 +175,7 @@ bool C_BaseViewModel::Interpolate( float currentTime )
inline bool C_BaseViewModel::ShouldFlipViewModel()
{
//Tony; changed for SDK so that the CSS models can be flipped out of the box.
-#if defined( CSTRIKE_DLL ) || defined ( SDK_DLL )
+#if defined( CSTRIKE_DLL ) || defined ( SDK_DLL ) || defined ( LUA_SDK )
//Tony; move this up here.
if (!cl_righthand.GetBool())
return false;
3 changes: 3 additions & 0 deletions mp/src/game/client/c_playerresource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ int C_PlayerResource::GetTeam(int iIndex )
{
if ( iIndex < 1 || iIndex > MAX_PLAYERS )
{
// Andrew; In HL2SB, we could be an NPC calling into this code
#ifndef HL2SB
Assert( false );
#endif
return 0;
}
else
Expand Down
12 changes: 12 additions & 0 deletions mp/src/game/client/c_playerresource.cpp.rej
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff a/mp/src/game/client/c_playerresource.cpp b/mp/src/game/client/c_playerresource.cpp (rejected hunks)
@@ -128,7 +128,10 @@ const char *C_PlayerResource::GetPlayerName( int iIndex )
{
if ( iIndex < 1 || iIndex > MAX_PLAYERS )
{
+ // Andrew; In HL2SB, we could be an NPC calling into this code
+#ifndef HL2SB
Assert( false );
+#endif
return "ERRORNAME";
}

Loading

0 comments on commit 47da71a

Please sign in to comment.