Skip to content

Commit

Permalink
Implement & port INS classic code (#1)
Browse files Browse the repository at this point in the history
Ported INS: Classic (1.2) from Source SDK 2006 to Source SDK 2013, with support for VS2022, easier shader building and more!
  • Loading branch information
BerntA authored Dec 13, 2024
1 parent e25d6b4 commit 73fba7d
Show file tree
Hide file tree
Showing 814 changed files with 89,993 additions and 68,374 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Insurgency Redeployed
# INSURGENCY: Classic

INSURGENCY: Modern Infantry Combat for SDK 2013!
88 changes: 72 additions & 16 deletions game/client/baseclientrendertargets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,38 @@
#include "materialsystem/imaterialsystemhardwareconfig.h" // Hardware config checks
#include "tier0/icommandline.h"

ITexture* CBaseClientRenderTargets::CreateWaterReflectionTexture( IMaterialSystem* pMaterialSystem, int iSize )
ITexture* CBaseClientRenderTargets::CreateWaterReflectionTexture(IMaterialSystem* pMaterialSystem, int iSize)
{
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
"_rt_WaterReflection",
iSize, iSize, RT_SIZE_PICMIP,
pMaterialSystem->GetBackBufferFormat(),
MATERIAL_RT_DEPTH_SHARED,
pMaterialSystem->GetBackBufferFormat(),
MATERIAL_RT_DEPTH_SHARED,
TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT,
CREATERENDERTARGETFLAGS_HDR );
CREATERENDERTARGETFLAGS_HDR);
}

ITexture* CBaseClientRenderTargets::CreateWaterRefractionTexture( IMaterialSystem* pMaterialSystem, int iSize )
ITexture* CBaseClientRenderTargets::CreateWaterRefractionTexture(IMaterialSystem* pMaterialSystem, int iSize)
{
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
"_rt_WaterRefraction",
iSize, iSize, RT_SIZE_PICMIP,
// This is different than reflection because it has to have alpha for fog factor.
IMAGE_FORMAT_RGBA8888,
MATERIAL_RT_DEPTH_SHARED,
IMAGE_FORMAT_RGBA8888,
MATERIAL_RT_DEPTH_SHARED,
TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT,
CREATERENDERTARGETFLAGS_HDR );
CREATERENDERTARGETFLAGS_HDR);
}

ITexture* CBaseClientRenderTargets::CreateCameraTexture( IMaterialSystem* pMaterialSystem, int iSize )
ITexture* CBaseClientRenderTargets::CreateCameraTexture(IMaterialSystem* pMaterialSystem, int iSize)
{
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
"_rt_Camera",
iSize, iSize, RT_SIZE_DEFAULT,
pMaterialSystem->GetBackBufferFormat(),
MATERIAL_RT_DEPTH_SHARED,
MATERIAL_RT_DEPTH_SHARED,
0,
CREATERENDERTARGETFLAGS_HDR );
CREATERENDERTARGETFLAGS_HDR);
}

//-----------------------------------------------------------------------------
Expand All @@ -52,14 +52,14 @@ ITexture* CBaseClientRenderTargets::CreateCameraTexture( IMaterialSystem* pMater
// Input : pMaterialSystem - the engine's material system (our singleton is not yet inited at the time this is called)
// pHardwareConfig - the user hardware config, useful for conditional render target setup
//-----------------------------------------------------------------------------
void CBaseClientRenderTargets::InitClientRenderTargets( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig, int iWaterTextureSize, int iCameraTextureSize )
void CBaseClientRenderTargets::InitClientRenderTargets(IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig, int iWaterTextureSize, int iCameraTextureSize)
{
// Water effects
m_WaterReflectionTexture.Init( CreateWaterReflectionTexture( pMaterialSystem, iWaterTextureSize ) );
m_WaterRefractionTexture.Init( CreateWaterRefractionTexture( pMaterialSystem, iWaterTextureSize ) );
m_WaterReflectionTexture.Init(CreateWaterReflectionTexture(pMaterialSystem, iWaterTextureSize));
m_WaterRefractionTexture.Init(CreateWaterRefractionTexture(pMaterialSystem, iWaterTextureSize));

// Monitors
m_CameraTexture.Init( CreateCameraTexture( pMaterialSystem, iCameraTextureSize ) );
m_CameraTexture.Init(CreateCameraTexture(pMaterialSystem, iCameraTextureSize));
}

//-----------------------------------------------------------------------------
Expand All @@ -75,4 +75,60 @@ void CBaseClientRenderTargets::ShutdownClientRenderTargets()

// Monitors
m_CameraTexture.Shutdown();
}
}

class CTNERenderTargets : public CBaseClientRenderTargets
{
DECLARE_CLASS_GAMEROOT(CTNERenderTargets, CBaseClientRenderTargets);

public:
virtual void InitClientRenderTargets(IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig);
virtual void ShutdownClientRenderTargets();

ITexture* CreateScopeTexture(IMaterialSystem* pMaterialSystem);

private:
CTextureReference m_ScopeTexture;
};

ITexture* CTNERenderTargets::CreateScopeTexture(IMaterialSystem* pMaterialSystem)
{
return pMaterialSystem->CreateNamedRenderTargetTextureEx2(
"_rt_Scope",
1024, 1024, RT_SIZE_OFFSCREEN,
pMaterialSystem->GetBackBufferFormat(),
MATERIAL_RT_DEPTH_SHARED,
TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT,
CREATERENDERTARGETFLAGS_HDR);
}

//-----------------------------------------------------------------------------
// Purpose: Called by the engine in material system init and shutdown.
// Clients should override this in their inherited version, but the base
// is to init all standard render targets for use.
// Input : pMaterialSystem - the engine's material system (our singleton is not yet inited at the time this is called)
// pHardwareConfig - the user hardware config, useful for conditional render target setup
//-----------------------------------------------------------------------------
void CTNERenderTargets::InitClientRenderTargets(IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig)
{
m_ScopeTexture.Init(CreateScopeTexture(pMaterialSystem));

// Water effects & camera from the base class (standard HL2 targets)
BaseClass::InitClientRenderTargets(pMaterialSystem, pHardwareConfig);
}

//-----------------------------------------------------------------------------
// Purpose: Shut down each CTextureReference we created in InitClientRenderTargets.
// Called by the engine in material system shutdown.
// Input : -
//-----------------------------------------------------------------------------
void CTNERenderTargets::ShutdownClientRenderTargets()
{
m_ScopeTexture.Shutdown();

// Clean up standard HL2 RTs (camera and water)
BaseClass::ShutdownClientRenderTargets();
}

static CTNERenderTargets g_TNERenderTargets;
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CTNERenderTargets, IClientRenderTargets, CLIENTRENDERTARGETS_INTERFACE_VERSION, g_TNERenderTargets);
16 changes: 7 additions & 9 deletions game/client/baseclientrendertargets.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,22 @@
#include "game/client/iclientrendertargets.h" // base class with interfaces called by the engine
#include "materialsystem/imaterialsystem.h" // for material system classes and interfaces


// Externs
class IMaterialSystem;
class IMaterialSystemHardwareConfig;

class CBaseClientRenderTargets : public IClientRenderTargets
{
// no networked vars
DECLARE_CLASS_GAMEROOT( CBaseClientRenderTargets, IClientRenderTargets );
DECLARE_CLASS_GAMEROOT(CBaseClientRenderTargets, IClientRenderTargets);
public:
// Interface called by engine during material system startup.
virtual void InitClientRenderTargets ( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig, int iWaterTextureSize = 1024, int iCameraTextureSize = 256 );
virtual void InitClientRenderTargets(IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig, int iWaterTextureSize = 1024, int iCameraTextureSize = 256);
// Shutdown all custom render targets here.
virtual void ShutdownClientRenderTargets ( void );
virtual void ShutdownClientRenderTargets(void);

protected:

// Standard render textures used by most mods-- Classes inheriting from
// this can choose to init these or not depending on their needs.

Expand All @@ -55,10 +54,9 @@ class CBaseClientRenderTargets : public IClientRenderTargets
CTextureReference m_UITexture;

// Init functions for the common render targets
ITexture* CreateWaterReflectionTexture( IMaterialSystem* pMaterialSystem, int iSize = 1024 );
ITexture* CreateWaterRefractionTexture( IMaterialSystem* pMaterialSystem, int iSize = 1024 );
ITexture* CreateCameraTexture( IMaterialSystem* pMaterialSystem, int iSize = 256 );

ITexture* CreateWaterReflectionTexture(IMaterialSystem* pMaterialSystem, int iSize = 1024);
ITexture* CreateWaterRefractionTexture(IMaterialSystem* pMaterialSystem, int iSize = 1024);
ITexture* CreateCameraTexture(IMaterialSystem* pMaterialSystem, int iSize = 256);
};

#endif // CLIENTRENDERTARTETS_H_
33 changes: 6 additions & 27 deletions game/client/c_baseanimating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2484,13 +2484,6 @@ void C_BaseAnimating::CalculateIKLocks( float currentTime )
}
}

#if defined( HL2_CLIENT_DLL )
if (minHeight < FLT_MAX)
{
input->AddIKGroundContactInfo( entindex(), minHeight, maxHeight );
}
#endif

CBaseEntity::PopEnableAbsRecomputations();
partition->SuppressLists( curSuppressed, true );
}
Expand Down Expand Up @@ -3599,7 +3592,7 @@ void MaterialFootstepSound( C_BaseAnimating *pEnt, bool bLeftFoot, float flVolum
//-----------------------------------------------------------------------------
void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options )
{
extern ConVar bb2_enable_particle_gunfx;
extern ConVar ins_enable_particle_gunfx;

Vector attachOrigin;
QAngle attachAngles;
Expand Down Expand Up @@ -3672,24 +3665,10 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
break;

case AE_WPN_MELEE_START:
{
C_BaseCombatWeapon *pLocalWeapon = GetActiveWeapon();
if (pLocalWeapon)
{
int type = atoi(options);
if (type)
pLocalWeapon->MeleeAttackStart(type);
}
}
break;
break;

case AE_WPN_MELEE_END:
{
C_BaseCombatWeapon *pLocalWeapon = GetActiveWeapon();
if (pLocalWeapon)
pLocalWeapon->MeleeAttackEnd();
}
break;
case AE_WPN_MELEE_END:
break;

case AE_CL_STOPSOUND:
{
Expand Down Expand Up @@ -3787,15 +3766,15 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
case AE_MUZZLEFLASH:
{
// Send out the effect for a player
if (!bb2_enable_particle_gunfx.GetBool())
if (!ins_enable_particle_gunfx.GetBool())
DispatchMuzzleEffect(options, true);
break;
}

case AE_NPC_MUZZLEFLASH:
{
// Send out the effect for an NPC
if (!bb2_enable_particle_gunfx.GetBool())
if (!ins_enable_particle_gunfx.GetBool())
DispatchMuzzleEffect(options, false);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion game/client/c_basecombatcharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ BEGIN_PREDICTION_DATA( C_BaseCombatCharacter )

DEFINE_PRED_FIELD( m_flNextAttack, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_hActiveWeapon, FIELD_EHANDLE, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_ARRAY( m_hMyWeapons, FIELD_EHANDLE, MAX_WEAPONS, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_ARRAY( m_hMyWeapons, FIELD_EHANDLE, MAX_PWEAPONS, FTYPEDESC_INSENDTABLE ),

END_PREDICTION_DATA()
23 changes: 12 additions & 11 deletions game/client/c_basecombatcharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,26 @@ class C_BaseCombatCharacter : public C_BaseFlex
virtual bool IsBaseCombatCharacter( void ) { return true; };
virtual C_BaseCombatCharacter *MyCombatCharacterPointer( void ) { return this; }

C_BaseCombatWeapon* Weapon_OwnsThisType( const char *pszWeapon ) const; // True if already owns a weapon of this class
C_BaseCombatWeapon* Weapon_GetBySlot(int slot) const;
virtual bool Weapon_Switch(C_BaseCombatWeapon *pWeapon, bool bWantDraw = false);
virtual C_BaseCombatWeapon* Weapon_OwnsThisType(int iWeaponID) const; // True if already owns a weapon of this class
virtual C_BaseCombatWeapon* Weapon_GetBySlot(int slot) const;
virtual bool Weapon_Switch(C_BaseCombatWeapon *pWeapon, bool bForce = false);
virtual bool Weapon_CanSwitchTo(C_BaseCombatWeapon *pWeapon);
virtual C_BaseCombatWeapon* GetNextBestWeapon(C_BaseCombatWeapon* pCurrentWeapon);

// I can't use my current weapon anymore. Switch me to the next best weapon.
bool SwitchToNextBestWeapon(C_BaseCombatWeapon *pCurrent);
virtual bool SwitchToNextBestWeapon(C_BaseCombatWeapon *pCurrent);

virtual C_BaseCombatWeapon *GetActiveWeapon( void ) const;
int WeaponCount() const;
C_BaseCombatWeapon *GetWeapon( int i ) const;
virtual int WeaponCount() const;
virtual C_BaseCombatWeapon *GetWeapon( int i ) const;

float GetNextAttack() const { return m_flNextAttack; }
void SetNextAttack( float flWait ) { m_flNextAttack = flWait; }

virtual int BloodColor();

// Blood color (see BLOOD_COLOR_* macros in baseentity.h)
void SetBloodColor( int nBloodColor );
virtual void SetBloodColor( int nBloodColor );

virtual void DoMuzzleFlash();

Expand All @@ -78,8 +79,8 @@ class C_BaseCombatCharacter : public C_BaseFlex

public:

CHandle<C_BaseCombatWeapon> m_hMyWeapons[MAX_WEAPONS];
CHandle< C_BaseCombatWeapon > m_hActiveWeapon;
CHandle<C_BaseCombatWeapon> m_hMyWeapons[MAX_PWEAPONS];
CHandle< C_BaseCombatWeapon > m_hActiveWeapon;

private:
C_BaseCombatCharacter( const C_BaseCombatCharacter & ); // not defined, not accessible
Expand All @@ -102,7 +103,7 @@ inline C_BaseCombatCharacter *ToBaseCombatCharacter( C_BaseEntity *pEntity )
//-----------------------------------------------------------------------------
inline int C_BaseCombatCharacter::WeaponCount() const
{
return MAX_WEAPONS;
return MAX_PWEAPONS;
}

//-----------------------------------------------------------------------------
Expand All @@ -111,7 +112,7 @@ inline int C_BaseCombatCharacter::WeaponCount() const
//-----------------------------------------------------------------------------
inline C_BaseCombatWeapon *C_BaseCombatCharacter::GetWeapon( int i ) const
{
Assert( (i >= 0) && (i < MAX_WEAPONS) );
Assert( (i >= 0) && (i < MAX_PWEAPONS) );
return m_hMyWeapons[i].Get();
}

Expand Down
Loading

0 comments on commit 73fba7d

Please sign in to comment.