Skip to content

Commit c69afba

Browse files
committed
Merge branch 'master' into win64
2 parents bfb5b44 + f735e7a commit c69afba

File tree

24 files changed

+195
-185
lines changed

24 files changed

+195
-185
lines changed

README.md

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,49 @@
1-
# source-engine
2-
Welcome to source engine:)
1+
# Source Engine
2+
[![GitHub Actions Status](https://github.com/nillerusr/source-engine/actions/workflows/build.yml/badge.svg)](https://github.com/nillerusr/source-engine/actions/workflows/build.yml) [![GitHub Actions Status](https://github.com/nillerusr/source-engine/actions/workflows/tests.yml/badge.svg)](https://github.com/nillerusr/source-engine/actions/workflows/tests.yml)
3+
Discord: [![Discord Server](https://img.shields.io/discord/672055862608658432.svg)](https://discord.gg/hZRB7WMgGw)
4+
35

4-
Discord: https://discord.gg/hZRB7WMgGw
6+
Information from [wikipedia](https://wikipedia.org/wiki/Source_(game_engine)):
7+
8+
Source is a 3D game engine developed by Valve.
9+
It debuted as the successor to GoldSrc with Half-Life: Source in June 2004,
10+
followed by Counter-Strike: Source and Half-Life 2 later that year.
11+
Source does not have a concise version numbering scheme; instead, it was released in incremental versions
12+
13+
Source code is based on TF2 2018 leak. Don't use it for commercial purposes.
14+
15+
This project is using waf buildsystem. If you have waf-related questions look https://waf.io/book
16+
17+
# Features:
18+
- Android, OSX, FreeBSD, Windows support
19+
- Arm support( except windows )
20+
- 64bit support
21+
- Modern toolchains support
22+
- Fixed many undefined behaviours
23+
- Touch support( even on windows/linux/osx )
24+
- VTF 7.5 support
25+
- PBR support
26+
- bsp v19-v21 support( bsp v21 support is partial, portal 2 and csgo maps works fine )
27+
- mdl v46-49 support
28+
- Removed useless/unnecessary dependencies
29+
- Achivement system working without steam
30+
- Fixed many bugs
531

632
# Current tasks
7-
- [x] Windows build support for waf
8-
- [x] NEON support
9-
- [x] remove unnecessary dependencies
10-
- [x] Arm(android) port
11-
- [x] replace current buildsystem with waf
12-
- [x] rewrite achivement system( to work without steam )
13-
- [x] 64-bit support
14-
- [x] VTF 7.5 support
15-
- [x] PBR support
16-
- [ ] improve performance
17-
- [ ] fixing bugs
18-
- [ ] dxvk-native support
19-
- [ ] Elbrus port
20-
- [ ] rewrite serverbrowser to work without steam
21-
22-
23-
# [How to Build?](https://github.com/nillerusr/source-engine/wiki/How-to-build)
33+
- Rewrite materialsystem for OpenGL render
34+
- dxvk-native support
35+
- Elbrus port
36+
- Bink audio support( for video_bink )
37+
- Rewrite serverbrowser to work without steam
38+
39+
# How to Build?
40+
- [Windows](https://github.com/nillerusr/source-engine/wiki/How-to-build#on-windows)
41+
- [Linux](https://github.com/nillerusr/source-engine/wiki/How-to-build#on-linux)
42+
- [For Android under Linux](https://github.com/nillerusr/source-engine/wiki/How-to-build#on-linux-for-android)
43+
44+
# Support me
45+
BTC: `bc1qnjq92jj9uqjtafcx2zvnwd48q89hgtd6w8a6na`
46+
47+
ETH: `0x5d0D561146Ed758D266E59B56e85Af0b03ABAF46`
48+
49+
XMR: `48iXvX61MU24m5VGc77rXQYKmoww3dZh6hn7mEwDaLVTfGhyBKq2teoPpeBq6xvqj4itsGh6EzNTzBty6ZDDevApCFNpsJ`

common/sse2neon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ FORCE_INLINE uint32_t _mm_crc32_u8(uint32_t, uint8_t);
420420

421421
// Older gcc does not define vld1q_u8_x4 type
422422
#if defined(__GNUC__) && !defined(__clang__) && \
423-
((__GNUC__ <= 10 && defined(__arm__)) || \
423+
(defined(__arm__) || \
424424
(__GNUC__ == 10 && __GNUC_MINOR__ < 3 && defined(__aarch64__)) || \
425425
(__GNUC__ <= 9 && defined(__aarch64__)))
426426
FORCE_INLINE uint8x16x4_t _sse2neon_vld1q_u8_x4(const uint8_t *p)

datacache/mdlcache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ namespace {
8181
#if defined( _X360 )
8282
#define AsyncMdlCache() 0 // Explicitly OFF for 360 (incompatible)
8383
#else
84-
#define AsyncMdlCache() 0
84+
#define AsyncMdlCache() 1
8585
#endif
8686

8787
#define ERROR_MODEL "models/error.mdl"

engine/sys_getmodes.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -819,10 +819,13 @@ void CVideoMode_Common::SetupStartupGraphic()
819819

820820
// loading.vtf
821821
buf.Clear(); // added this Clear() because we saw cases where LoadVTF was not emptying the buf fully in the above section
822-
m_pLoadingTexture = LoadVTF( buf, "materials/console/startup_loading.vtf" );
822+
const char* loading = "materials/console/startup_loading.vtf";
823+
if ( IsSteamDeck() )
824+
loading = "materials/gamepadui/game_logo.vtf";
825+
m_pLoadingTexture = LoadVTF( buf, loading );
823826
if ( !m_pLoadingTexture )
824827
{
825-
Error( "Can't find background image materials/console/startup_loading.vtf\n" );
828+
Error( "Can't find background image '%s'\n", loading );
826829
return;
827830
}
828831
}
@@ -883,8 +886,12 @@ void CVideoMode_Common::DrawStartupGraphic()
883886
pVMTKeyValues->SetInt( "$nocull", 1 );
884887
IMaterial *pMaterial = g_pMaterialSystem->CreateMaterial( "__background", pVMTKeyValues );
885888

889+
const char* loading = "console/startup_loading.vtf";
890+
if ( IsSteamDeck() )
891+
loading = "gamepadui/game_logo.vtf";
892+
886893
pVMTKeyValues = new KeyValues( "UnlitGeneric" );
887-
pVMTKeyValues->SetString( "$basetexture", "Console/startup_loading.vtf" );
894+
pVMTKeyValues->SetString( "$basetexture", loading );
888895
pVMTKeyValues->SetInt( "$translucent", 1 );
889896
pVMTKeyValues->SetInt( "$ignorez", 1 );
890897
pVMTKeyValues->SetInt( "$nofog", 1 );
@@ -922,7 +929,11 @@ void CVideoMode_Common::DrawStartupGraphic()
922929
slide = 0;
923930

924931
DrawScreenSpaceRectangle( pMaterial, 0, 0+slide, w, h-50, 0, 0, tw-1, th-1, tw, th, NULL,1,1,depth );
925-
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
932+
if ( !IsSteamDeck() )
933+
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
934+
else
935+
// TODO: Steam Deck
936+
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
926937
}
927938

928939
if(0)

engine/vgui_baseui_interface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ void CEngineVGui::Init()
613613
return;
614614
}
615615

616-
if ( IsX360() )
616+
if ( IsX360() || IsSteamDeck() )
617617
{
618618
CCommand ccommand;
619619
if ( CL_ShouldLoadBackgroundLevel( ccommand ) )
@@ -1273,7 +1273,7 @@ void CEngineVGui::OnLevelLoadingStarted()
12731273
}
12741274
}
12751275

1276-
if ( IsX360() )
1276+
if ( IsX360() || IsSteamDeck() )
12771277
{
12781278
// TCR requirement, always!!!
12791279
m_bShowProgressDialog = true;

game/client/game_controls/vguitextwindow.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern INetworkStringTable *g_pStringTableInfoPanel;
3232

3333
#define TEMP_HTML_FILE "textwindow_temp.html"
3434

35-
ConVar cl_disablehtmlmotd( "cl_disablehtmlmotd", "0", FCVAR_ARCHIVE, "Disable HTML motds." );
35+
ConVar cl_disablehtmlmotd( "cl_disablehtmlmotd", "1", FCVAR_ARCHIVE, "Disable HTML motds." );
3636

3737
//=============================================================================
3838
// HPE_BEGIN:
@@ -129,7 +129,8 @@ void CTextWindow::ApplySchemeSettings( IScheme *pScheme )
129129
CTextWindow::~CTextWindow()
130130
{
131131
// remove temp file again
132-
g_pFullFileSystem->RemoveFile( TEMP_HTML_FILE, "DEFAULT_WRITE_PATH" );
132+
if (g_pFullFileSystem->FileExists(TEMP_HTML_FILE))
133+
g_pFullFileSystem->RemoveFile( TEMP_HTML_FILE, "DEFAULT_WRITE_PATH" );
133134
}
134135

135136
void CTextWindow::Reset( void )

game/client/hud_crosshair.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,15 @@ void CHudCrosshair::Paint( void )
258258
pWeapon->GetWeaponCrosshairScale( flWeaponScale );
259259
}
260260

261-
float flPlayerScale = 1.0f;
261+
int iScreenDiv = 1600;
262+
if ( IsSteamDeck() )
263+
iScreenDiv = 1440;
264+
265+
float flPlayerScale;
266+
if ( !m_pCrosshair->bRenderUsingFont )
267+
flPlayerScale = (ScreenHeight() / iScreenDiv) + 1;
268+
else
269+
flPlayerScale = 1.0f;
262270
#ifdef TF_CLIENT_DLL
263271
Color clr( cl_crosshair_red.GetInt(), cl_crosshair_green.GetInt(), cl_crosshair_blue.GetInt(), 255 );
264272
flPlayerScale = cl_crosshair_scale.GetFloat() / 32.0f; // the player can change the scale in the options/multiplayer tab

gameui/BasePanel.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,8 +1801,11 @@ void CBasePanel::ApplySchemeSettings(IScheme *pScheme)
18011801
// load the loading icon
18021802
if ( m_iLoadingImageID == -1 )
18031803
{
1804+
const char* loading = "console/startup_loading";
1805+
if ( IsSteamDeck() )
1806+
loading = "gamepadui/game_logo";
18041807
m_iLoadingImageID = surface()->CreateNewTextureID();
1805-
surface()->DrawSetTextureFile( m_iLoadingImageID, "Console/startup_loading", false, false );
1808+
surface()->DrawSetTextureFile( m_iLoadingImageID, loading, false, false );
18061809
}
18071810
}
18081811
}

launcher/android/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ char *LauncherArgv[512];
2727
char java_args[4096];
2828
int iLastArgs = 0;
2929

30+
extern void InitCrashHandler();
3031
DLL_EXPORT int LauncherMain( int argc, char **argv ); // from launcher.cpp
3132

3233
DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setenv(JNIEnv *jenv, jclass *jclass, jstring env, jstring value, jint over)
@@ -118,6 +119,8 @@ void android_property_print(const char *name)
118119

119120
DLL_EXPORT int LauncherMainAndroid( int argc, char **argv )
120121
{
122+
InitCrashHandler();
123+
121124
Msg("GetTotalMemory() = %.2f \n", GetTotalMemory());
122125

123126
android_property_print("ro.build.version.sdk");

materialsystem/cmaterialsystem.cpp

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ bool CMaterialSystem::AllowThreading( bool bAllow, int nServiceThread )
10291029

10301030
bool bOldAllow = m_bAllowQueuedRendering;
10311031

1032-
if ( GetCPUInformation()->m_nPhysicalProcessors >= 2 )
1032+
if ( GetCPUInformation()->m_nLogicalProcessors >= 2 )
10331033
{
10341034
m_bAllowQueuedRendering = bAllow;
10351035
bool bQueued = m_IdealThreadMode != MATERIAL_SINGLE_THREADED;
@@ -1806,11 +1806,7 @@ static ConVar mat_normalmaps( "mat_normalmaps", "0", FCVAR_CHEAT );
18061806
static ConVar mat_measurefillrate( "mat_measurefillrate", "0", FCVAR_CHEAT );
18071807
static ConVar mat_fillrate( "mat_fillrate", "0", FCVAR_CHEAT );
18081808
static ConVar mat_reversedepth( "mat_reversedepth", "0", FCVAR_CHEAT );
1809-
#ifdef DX_TO_GL_ABSTRACTION
1810-
static ConVar mat_bufferprimitives( "mat_bufferprimitives", "0" ); // I'm not seeing any benefit speed wise for buffered primitives on GLM/POSIX (checked via TF2 timedemo) - default to zero
1811-
#else
18121809
static ConVar mat_bufferprimitives( "mat_bufferprimitives", "1" );
1813-
#endif
18141810
static ConVar mat_drawflat( "mat_drawflat","0", FCVAR_CHEAT );
18151811
static ConVar mat_softwarelighting( "mat_softwarelighting", "0", FCVAR_ALLOWED_IN_COMPETITIVE );
18161812
static ConVar mat_proxy( "mat_proxy", "0", FCVAR_CHEAT, "", MatProxyCallback );
@@ -2780,8 +2776,8 @@ IMaterial* CMaterialSystem::FindMaterialEx( char const* pMaterialName, const cha
27802776
{
27812777
// We need lower-case symbols for this to work
27822778
int nLen = Q_strlen( pMaterialName ) + 1;
2783-
char *pFixedNameTemp = (char*)malloc( nLen );
2784-
char *pTemp = (char*)malloc( nLen );
2779+
char *pFixedNameTemp = (char*)stackalloc( nLen );
2780+
char *pTemp = (char*)stackalloc( nLen );
27852781
Q_strncpy( pFixedNameTemp, pMaterialName, nLen );
27862782
Q_strlower( pFixedNameTemp );
27872783
#ifdef POSIX
@@ -2883,9 +2879,6 @@ IMaterial* CMaterialSystem::FindMaterialEx( char const* pMaterialName, const cha
28832879
}
28842880
}
28852881

2886-
free(pTemp);
2887-
free(pFixedNameTemp);
2888-
28892882
return g_pErrorMaterial->GetRealTimeVersion();
28902883
}
28912884

@@ -3103,20 +3096,12 @@ void CMaterialSystem::ResetTempHWMemory( bool bExitingLevel )
31033096
//-----------------------------------------------------------------------------
31043097
void CMaterialSystem::CacheUsedMaterials( )
31053098
{
3099+
printf("Cache materials\n");
3100+
31063101
g_pShaderAPI->EvictManagedResources();
3107-
size_t count = 0;
3102+
31083103
for (MaterialHandle_t i = FirstMaterial(); i != InvalidMaterial(); i = NextMaterial(i) )
31093104
{
3110-
// Some (mac) drivers (amd) seem to keep extra resources around on uploads until the next frame swap. This
3111-
// injects pointless synthetic swaps (between already-static load frames)
3112-
if ( mat_texture_reload_frame_swap_workaround.GetBool() )
3113-
{
3114-
if ( count++ % 20 == 0 )
3115-
{
3116-
Flush(true);
3117-
SwapBuffers(); // Not the right thing to call
3118-
}
3119-
}
31203105
IMaterialInternal* pMat = GetMaterialInternal(i);
31213106
Assert( pMat->GetReferenceCount() >= 0 );
31223107
if( pMat->GetReferenceCount() > 0 )
@@ -3703,9 +3688,13 @@ void CMaterialSystem::EndFrame( void )
37033688
ThreadAcquire( true );
37043689
}
37053690

3691+
IThreadPool* pThreadPool = CreateMatQueueThreadPool();
3692+
37063693
if ( m_pActiveAsyncJob && !m_pActiveAsyncJob->IsFinished() )
37073694
{
3708-
m_pActiveAsyncJob->WaitForFinish();
3695+
m_pActiveAsyncJob->WaitForFinish(TT_INFINITE, pThreadPool);
3696+
3697+
// Sync with GPU if we had a job for it, even if it finished early on CPU!
37093698
if ( !IsPC() && g_config.ForceHWSync() )
37103699
{
37113700
g_pShaderAPI->ForceHardwareSync();
@@ -3730,7 +3719,6 @@ void CMaterialSystem::EndFrame( void )
37303719
}
37313720
}
37323721

3733-
IThreadPool *pThreadPool = CreateMatQueueThreadPool();
37343722
pThreadPool->AddJob( m_pActiveAsyncJob );
37353723
break;
37363724
}
@@ -4664,20 +4652,9 @@ void CMaterialSystem::BeginRenderTargetAllocation( void )
46644652

46654653
void CMaterialSystem::EndRenderTargetAllocation( void )
46664654
{
4667-
// Any GPU newer than 2005 doesn't need to do this, and it eats up ~40% of our level load time!
4668-
const bool cbRequiresRenderTargetAllocationFirst = mat_requires_rt_alloc_first.GetBool();
4669-
46704655
g_pShaderAPI->FlushBufferedPrimitives();
46714656
m_bAllocatingRenderTargets = false;
46724657

4673-
if ( IsPC() && cbRequiresRenderTargetAllocationFirst && g_pShaderAPI->CanDownloadTextures() )
4674-
{
4675-
// Simulate an Alt-Tab...will cause RTs to be allocated first
4676-
4677-
g_pShaderDevice->ReleaseResources();
4678-
g_pShaderDevice->ReacquireResources();
4679-
}
4680-
46814658
TextureManager()->CacheExternalStandardRenderTargets();
46824659
}
46834660

materialsystem/cmatqueuedrendercontext.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,14 +455,11 @@ class CMatQueuedMesh : public IMesh
455455
}
456456
else
457457
{
458-
ALIGN16 uint16 tempIndices[16];
458+
static ALIGN16 uint16 tempIndices[256];
459459

460+
// original method
460461
int i = 0;
461-
if ( (size_t)desc.m_pIndices % 4 == 2 )
462-
{
463-
desc.m_pIndices[i] = pIndexData[i] + desc.m_nFirstVertex;
464-
i++;
465-
}
462+
466463
while ( i < nIndices )
467464
{
468465
int nToCopy = min( (int)ARRAYSIZE(tempIndices), nIndices - i );

materialsystem/ctexture.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,15 +2458,8 @@ bool CTexture::AsyncReadTextureFromFile( IVTFTexture* pVTFTexture, unsigned int
24582458
return false;
24592459
}
24602460

2461-
if ( V_strstr( GetName(), "c_sniperrifle_scope" ) )
2462-
{
2463-
int i = 0;
2464-
i = 3;
2465-
}
2466-
2467-
24682461
tmZone( TELEMETRY_LEVEL0, TMZF_NONE, "%s - %s", __FUNCTION__, tmDynamicString( TELEMETRY_LEVEL0, pCacheFileName ) );
2469-
2462+
24702463
// OSX hackery
24712464
int nPreserveFlags = nAdditionalCreationFlags;
24722465
if ( m_nFlags & TEXTUREFLAGS_SRGB )
@@ -4189,12 +4182,6 @@ bool SLoadTextureBitsFromFile( IVTFTexture **ppOutVtfTexture, FileHandle_t hFile
41894182
// NOTE! NOTE! NOTE! or by the streaming texture code!
41904183
Assert( ppOutVtfTexture != NULL && *ppOutVtfTexture != NULL );
41914184

4192-
if ( V_strstr( pName, "c_rocketlauncher/c_rocketlauncher" ) )
4193-
{
4194-
int i = 0;
4195-
i = 3;
4196-
}
4197-
41984185
CUtlBuffer buf;
41994186

42004187
{

public/studio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ Studio models are position independent, so the cache manager can move them.
7979
#define MAXSTUDIOFLEXVERTS 5000
8080
#endif
8181
#define MAXSTUDIOSKINS 32 // total textures
82-
#define MAXSTUDIOBONES 256 // total bones actually used
82+
#define MAXSTUDIOBONES 128 // total bones actually used
8383
#define MAXSTUDIOFLEXDESC 1024 // maximum number of low level flexes (actual morph targets)
8484
#define MAXSTUDIOFLEXCTRL 96 // maximum number of flexcontrollers (input sliders)
8585
#define MAXSTUDIOPOSEPARAM 24
8686
#define MAXSTUDIOBONECTRLS 5
8787
#define MAXSTUDIOANIMBLOCKS 256
8888

89-
#define MAXSTUDIOBONEBITS 8 // NOTE: MUST MATCH MAXSTUDIOBONES
89+
#define MAXSTUDIOBONEBITS 7 // NOTE: MUST MATCH MAXSTUDIOBONES
9090

9191
// NOTE!!! : Changing this number also changes the vtx file format!!!!!
9292
#define MAX_NUM_BONES_PER_VERT 3

0 commit comments

Comments
 (0)