Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
os: [windows-latest, ubuntu-latest, macos-15-intel, macos-latest]
configuration: [Debug, Release]
include:
- os: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion Dependencies/Steamworks/Steamworks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<RootNamespace>Steamworks</RootNamespace>
<AssemblyName>Steamworks.NET</AssemblyName>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PlatformTarget>x64</PlatformTarget>
<Configurations>Debug;Release;Debug (Dedicated);Release (Dedicated)</Configurations>
<DefineConstants>$(DefineConstants);STEAMWORKS_X64</DefineConstants>
</PropertyGroup>
Expand Down
15 changes: 13 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,24 @@
<DefineConstants>$(DefineConstants);LINUX</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(IsOSX)'=='true' Or '$(IsLinux)'=='true'">
<DefineConstants>$(DefineConstants);POSIX</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="$(Configuration.Contains('(Dedicated)'))">
<DefineConstants>$(DefineConstants);SWDS;DEDICATED</DefineConstants>
</PropertyGroup>

<PropertyGroup>
<Platforms>x64</Platforms>
<PlatformTarget>x64</PlatformTarget>
<HostArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)</HostArchitecture>
<Platforms Condition="'$(HostArchitecture)' == 'Arm64'">x64;arm64</Platforms>
<Platforms Condition="'$(HostArchitecture)' != 'Arm64'">x64</Platforms>
<PlatformTarget Condition="'$(PlatformTarget)' == '' And '$(HostArchitecture)' == 'Arm64'">arm64</PlatformTarget>
<PlatformTarget Condition="'$(PlatformTarget)' == ''">x64</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="$(MSBuildProjectName.StartsWith('Source.CodeAnalysis'))">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="!$(MSBuildProjectName.StartsWith('Source.CodeAnalysis'))">
Expand Down
15 changes: 15 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,19 @@
<ItemGroup Condition="'@(Compile->WithMetadataValue('Identity', '..\Usings\GlobalUsings.cs'))' != ''">
<ProjectReference Include="$(MSBuildThisFileDirectory)Source.CodeAnalysis.ConVars\Source.CodeAnalysis.ConVars.csproj" PrivateAssets="all" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
</ItemGroup>

<ItemGroup Condition="'$(IsWindows)' != 'true'">
<Compile Remove="**\*.Win32.cs" />
<None Include="**\*.Win32.cs" />
</ItemGroup>

<ItemGroup Condition="'$(IsOSX)' != 'true'">
<Compile Remove="**\*.OSX.cs" />
<None Include="**\*.OSX.cs" />
</ItemGroup>

<ItemGroup Condition="'$(IsLinux)' != 'true'">
<Compile Remove="**\*.Linux.cs" />
<None Include="**\*.Linux.cs" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion Game.Assets/Game.Assets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
<Configurations>Debug;Release;Debug (Dedicated);Release (Dedicated)</Configurations>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion Game.Client/HL2/HudCredits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private void DrawOutroCreditsName() {
LastOneInPlace = true;

// 360 certification requires that we not hold a static image too long.
FadeTime = gpGlobals.CurTime + (IsConsole() ? 2.0f : 10.0f);
FadeTime = gpGlobals.CurTime + 10.0f;
}
}
else {
Expand Down
8 changes: 0 additions & 8 deletions Game.Client/RenderTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ static void AddReleaseFunc() {

static readonly TextureReference PowerOfTwoFrameBufferTexture = new();
public static ITexture? GetPowerOfTwoFrameBufferTexture() {
if (IsX360())
return GetFullFrameFrameBufferTexture(1);

if (!PowerOfTwoFrameBufferTexture.IsValid()) {
PowerOfTwoFrameBufferTexture.Init(materials.FindTexture("_rt_PowerOfTwoFB", MaterialDefines.TEXTURE_GROUP_RENDER_TARGET));
Assert(!ITexture.IsError(PowerOfTwoFrameBufferTexture.Get()));
Expand Down Expand Up @@ -169,11 +166,6 @@ static void AddReleaseFunc() {
/// tiny 32x32 texture, always 8888
/// </summary>
public static ITexture? GetTeenyTexture(int which) {
if (IsX360()) {
Assert(false);
return null;
}

Assert(which < MAX_TEENY_TEXTURES);

if (!TeenyTextures[which].IsValid()) {
Expand Down
12 changes: 5 additions & 7 deletions Game.Client/ViewScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,16 @@ public static class ViewScene
public static void UpdateRefractTexture(int x, int y, int w, int h, bool forceUpdate = false) {
Assert(!DrawingShadowDepthView());

if (!IsRetail() && !r_updaterefracttexture.GetBool())
if (!r_updaterefracttexture.GetBool())
return;

using MatRenderContextPtr renderContext = new(materials);
ITexture? texture = RenderTexture.GetPowerOfTwoFrameBufferTexture();
if (IsPC() || forceUpdate || g_bAllowMultipleRefractUpdatesPerScenePerFrame || (gpGlobals.FrameCount != g_viewscene_refractUpdateFrame)) {
// forced or only once per frame
System.Drawing.Rectangle rect = new(x, y, w, h);
renderContext.CopyRenderTargetToTextureEx(texture!, 0, ref rect, ref Unsafe.NullRef<System.Drawing.Rectangle>());
// forced or only once per frame
System.Drawing.Rectangle rect = new(x, y, w, h);
renderContext.CopyRenderTargetToTextureEx(texture!, 0, ref rect, ref Unsafe.NullRef<System.Drawing.Rectangle>());

g_viewscene_refractUpdateFrame = gpGlobals.FrameCount;
}
g_viewscene_refractUpdateFrame = gpGlobals.FrameCount;
renderContext.SetFrameBufferCopyTexture(texture);
}

Expand Down
30 changes: 14 additions & 16 deletions Game.Server/BaseEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3015,25 +3015,23 @@ public static void PrecacheModelComponents(int modelIndex) {
return;

// sounds
if (IsPC()) {
ReadOnlySpan<char> name = modelinfo.GetModelName(model);
if (!g_ModelSoundsCache.TryGetValue(name.Hash(), out _)) {
ReadOnlySpan<char> extension = Path.GetExtension(name);
ReadOnlySpan<char> name = modelinfo.GetModelName(model);
if (!g_ModelSoundsCache.TryGetValue(name.Hash(), out _)) {
ReadOnlySpan<char> extension = Path.GetExtension(name);

if (!stristr(extension, "mdl").IsEmpty)
DevMsg(2, $"Late precache of {name}, need to rebuild modelsounds.cache\n");
else {
if (extension[0] == '\0')
Warning($"Precache of {name} ambigious (no extension specified)\n");
else
Warning($"Late precache of {name} (file missing?)\n");
return;
}
if (!stristr(extension, "mdl").IsEmpty)
DevMsg(2, $"Late precache of {name}, need to rebuild modelsounds.cache\n");
else {
if (extension[0] == '\0')
Warning($"Precache of {name} ambigious (no extension specified)\n");
else
Warning($"Late precache of {name} (file missing?)\n");
return;
}

if (g_ModelSoundsCache.TryGetValue(name.Hash(), out ModelSoundsCache? entry))
entry.PrecacheSoundList();
}

if (g_ModelSoundsCache.TryGetValue(name.Hash(), out ModelSoundsCache? entry))
entry.PrecacheSoundList();
}

static readonly Dictionary<UtlSymId_t, ModelSoundsCache> g_ModelSoundsCache = [];
Expand Down
4 changes: 2 additions & 2 deletions Game.Server/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ public override void Spawn() {
g_EventQueue.Init();
Precache();

GlobalEntity.Add("is_console", gpGlobals.MapName, (IsConsole()) ? GlobalEState.On : GlobalEState.Off);
GlobalEntity.Add("is_pc", gpGlobals.MapName, (!IsConsole()) ? GlobalEState.On : GlobalEState.Off);
GlobalEntity.Add("is_console", gpGlobals.MapName, GlobalEState.Off);
GlobalEntity.Add("is_pc", gpGlobals.MapName, GlobalEState.On);
}

public static readonly new ServerClass ServerClass = new ServerClass(DT_WORLD);
Expand Down
2 changes: 1 addition & 1 deletion Game.Shared/AchievementMgr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ public void ResetAchievement(int achievementID) {
}

public void PrintAchievementStatus() {
if (IsPC() && !LoggedIntoSteam()) {
if (!LoggedIntoSteam()) {
Msg("Steam not running, achievements disabled. Cannot view or unlock achievements.\n");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Game.Shared/HL2/HL_GameMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ protected override void FullLadderMove() {
if (!wouldleaveladder && !neardismountnode) {
// Otherwise, if the move would leave the ladder, disallow it.
if (pressed_use) {
if (ExitLadderViaDismountNode(ladder, false, IsX360())) {
if (ExitLadderViaDismountNode(ladder, false)) {
// See if they +used a dismount point mid-span..
return;
}
Expand Down
33 changes: 11 additions & 22 deletions Game.UI/GameUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,24 +158,15 @@ private bool FindPlatformDirectory(out ReadOnlySpan<char> platformDir) {
platformDir = string.Empty;

#if WIN32
var location = System.Reflection.Assembly.GetExecutingAssembly().Location;
if (string.IsNullOrEmpty(location))
return false;

var dir = Path.GetDirectoryName(location);
if (dir == null)
return false;

platformDir = Path.Combine(dir, "platform") + Path.DirectorySeparatorChar;
return true;
string? dir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
#else
string dir = Directory.GetCurrentDirectory();
string? dir = Directory.GetCurrentDirectory();
#endif
if (string.IsNullOrEmpty(dir))
return false;

platformDir = Path.Combine(dir, "platform") + Path.DirectorySeparatorChar;
return true;
#endif
}

public void Shutdown() {
Expand All @@ -186,20 +177,18 @@ public void Start() {
if (!FindPlatformDirectory(out ReadOnlySpan<char> platformDir))
return;

if (IsPC()) {
Span<char> configDir = stackalloc char[512];
strcpy(configDir, platformDir);
strcat(configDir, "config");
Span<char> configDir = stackalloc char[512];
strcpy(configDir, platformDir);
strcat(configDir, "config");

Msg($"Steam config directory: {configDir.SliceNullTerminatedString()}\n");
Msg($"Steam config directory: {configDir.SliceNullTerminatedString()}\n");

fileSystem.AddSearchPath(configDir.SliceNullTerminatedString(), "CONFIG");
fileSystem.CreateDirHierarchy("", "CONFIG");
fileSystem.AddSearchPath(configDir.SliceNullTerminatedString(), "CONFIG");
fileSystem.CreateDirHierarchy("", "CONFIG");

// todo SetUserConfigFile
// todo SetUserConfigFile

fileSystem.AddSearchPath("platform", "PLATFORM");
}
fileSystem.AddSearchPath("platform", "PLATFORM");

localize.AddFile("Resource/platform_%language%.txt");
localize.AddFile("Resource/vgui_%language%.txt");
Expand Down
12 changes: 6 additions & 6 deletions Game.UI/OptionsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public OptionsDialog(Panel? parent) : base(parent, "OptionsDialog") {
AddPage(new OptionsSubVoice(this, null), "#GameUI_Voice");
// AddPage(new OptionsSubLegal(this, null), "#GameUI_Legal");
#else
#if WIN32
ConVarRef hap_HasDevice = new("hap_HasDevice");
hap_HasDevice.Init("hap_HasDevice", true);
// if (hap_HasDevice.GetBool())
// AddPage(new OptionsSubHaptics(this), "#GameUI_Haptics_TabTitle");
#endif
if (IsWindows) {
ConVarRef hap_HasDevice = new("hap_HasDevice");
hap_HasDevice.Init("hap_HasDevice", true);
// if (hap_HasDevice.GetBool())
// AddPage(new OptionsSubHaptics(this), "#GameUI_Haptics_TabTitle");
}

// if (ModInfo.IsSinglePlayerOnly() && !ModInfo.NoDifficulty())
// AddPage(new OptionsSubDifficulty(this), "#GameUI_Difficulty");
Expand Down
19 changes: 8 additions & 11 deletions Game.UI/OptionsSubAudio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ public OptionsSubAudio(Panel? parent, ReadOnlySpan<char> name) : base(parent, na
SoundQualityCombo.AddItem("#GameUI_Low", null);

SpeakerSetupCombo = new(this, "SpeakerSetup", 6, false);
#if !POSIX
SpeakerSetupCombo.AddItem("#GameUI_Headphones", null);
#endif
if (!IsPosix)
SpeakerSetupCombo.AddItem("#GameUI_Headphones", null);
SpeakerSetupCombo.AddItem("#GameUI_2Speakers", null);
#if !POSIX
SpeakerSetupCombo.AddItem("#GameUI_4Speakers", null);
SpeakerSetupCombo.AddItem("#GameUI_5Speakers", null);
SpeakerSetupCombo.AddItem("#GameUI_7Speakers", null);
#endif
if (!IsPosix) {
SpeakerSetupCombo.AddItem("#GameUI_4Speakers", null);
SpeakerSetupCombo.AddItem("#GameUI_5Speakers", null);
SpeakerSetupCombo.AddItem("#GameUI_7Speakers", null);
}
SpokenLanguageCombo = new(this, "AudioSpokenLanguage", 6, false);

SoundMuteLoseFocusCheckButton = new(this, "snd_mute_losefocus", "#GameUI_SndMuteLoseFocus", "snd_mute_losefocus");
Expand Down Expand Up @@ -77,10 +76,8 @@ public override void OnResetData() {
ConVarRef snd_surround_speakers = new("snd_surround_speakers");
int speakers = snd_surround_speakers.GetInt();

#if POSIX
if (speakers == 0)
if (IsPosix && speakers == 0)
speakers = 2;
#endif

if (speakers < 0)
speakers = 2;
Expand Down
20 changes: 4 additions & 16 deletions Source.Common/Formats/Keyvalues/KeyValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,32 +271,20 @@ public static bool EvaluateConditional(Span<char> str) {
bNot = true;

if (str.Contains("$WIN32", StringComparison.OrdinalIgnoreCase))
return IsPC() ^ bNot;
return !bNot;

if (str.Contains("$WINDOWS", StringComparison.OrdinalIgnoreCase))
#if WIN32
return !bNot;
#else
return bNot;
#endif
return IsWindows ? !bNot : bNot;
if (str.Contains("$OSX", StringComparison.OrdinalIgnoreCase))
#if OSX
return !bNot;
#else
return bNot;
#endif
return IsOSX ? !bNot : bNot;
if (str.Contains("$LINUX", StringComparison.OrdinalIgnoreCase))
#if LINUX
return !bNot;
#else
return bNot;
#endif
if (str.Contains("$POSIX", StringComparison.OrdinalIgnoreCase))
#if OSX || LINUX
return !bNot;
#else
return bNot;
#endif
return IsPosix ? !bNot : bNot;

return false;
}
Expand Down
35 changes: 20 additions & 15 deletions Source.Common/Platform.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
using Source.Common;

using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Source;

public static class PlatformMacros
public delegate bool MessageBoxFn(ReadOnlySpan<char> title, ReadOnlySpan<char> info, bool showOkAndCancel);

public static class Platform
{
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsPC() => true;
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsConsole() => false;
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsX360() => false;
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsRetail() => false;
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSX()
public const bool IsWindows
#if WIN32
= true;
#else
= false;
#endif

public const bool IsOSX
#if OSX
=> true;
= true;
#else
=> false;
= false;
#endif

public const bool IsPosix
#if POSIX
= true;
#else
= false;
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsPlatform64Bits() => IntPtr.Size == 8;

public const int MAX_PATH = 260;
public const int MAX_OSPATH = 260;
}

public delegate bool MessageBoxFn(ReadOnlySpan<char> title, ReadOnlySpan<char> info, bool showOkAndCancel);

public static class Platform
{
readonly static Lazy<Stopwatch> __timer = new(() => {
Stopwatch stopwatch = new();
stopwatch.Start();
Expand Down
Loading
Loading