Skip to content

Commit 79d02ee

Browse files
authored
Merge pull request #216 from ZehMatt/remove-platform-macros
Remove PlatformMacros and cleanup some code
2 parents e5014c5 + 78ea7bd commit 79d02ee

37 files changed

Lines changed: 357 additions & 402 deletions

‎.github/workflows/build.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
os: [windows-latest, ubuntu-latest]
13+
os: [windows-latest, ubuntu-latest, macos-15-intel, macos-latest]
1414
configuration: [Debug, Release]
1515
include:
1616
- os: ubuntu-latest

‎Dependencies/Steamworks/Steamworks.csproj‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<RootNamespace>Steamworks</RootNamespace>
66
<AssemblyName>Steamworks.NET</AssemblyName>
77
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
8-
<PlatformTarget>x64</PlatformTarget>
98
<Configurations>Debug;Release;Debug (Dedicated);Release (Dedicated)</Configurations>
109
<DefineConstants>$(DefineConstants);STEAMWORKS_X64</DefineConstants>
1110
</PropertyGroup>

‎Directory.Build.props‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,24 @@
4040
<DefineConstants>$(DefineConstants);LINUX</DefineConstants>
4141
</PropertyGroup>
4242

43+
<PropertyGroup Condition="'$(IsOSX)'=='true' Or '$(IsLinux)'=='true'">
44+
<DefineConstants>$(DefineConstants);POSIX</DefineConstants>
45+
</PropertyGroup>
46+
4347
<PropertyGroup Condition="$(Configuration.Contains('(Dedicated)'))">
4448
<DefineConstants>$(DefineConstants);SWDS;DEDICATED</DefineConstants>
4549
</PropertyGroup>
4650

4751
<PropertyGroup>
48-
<Platforms>x64</Platforms>
49-
<PlatformTarget>x64</PlatformTarget>
52+
<HostArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)</HostArchitecture>
53+
<Platforms Condition="'$(HostArchitecture)' == 'Arm64'">x64;arm64</Platforms>
54+
<Platforms Condition="'$(HostArchitecture)' != 'Arm64'">x64</Platforms>
55+
<PlatformTarget Condition="'$(PlatformTarget)' == '' And '$(HostArchitecture)' == 'Arm64'">arm64</PlatformTarget>
56+
<PlatformTarget Condition="'$(PlatformTarget)' == ''">x64</PlatformTarget>
57+
</PropertyGroup>
58+
59+
<PropertyGroup Condition="$(MSBuildProjectName.StartsWith('Source.CodeAnalysis'))">
60+
<PlatformTarget>AnyCPU</PlatformTarget>
5061
</PropertyGroup>
5162

5263
<PropertyGroup Condition="!$(MSBuildProjectName.StartsWith('Source.CodeAnalysis'))">

‎Directory.Build.targets‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,19 @@
44
<ItemGroup Condition="'@(Compile->WithMetadataValue('Identity', '..\Usings\GlobalUsings.cs'))' != ''">
55
<ProjectReference Include="$(MSBuildThisFileDirectory)Source.CodeAnalysis.ConVars\Source.CodeAnalysis.ConVars.csproj" PrivateAssets="all" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
66
</ItemGroup>
7+
8+
<ItemGroup Condition="'$(IsWindows)' != 'true'">
9+
<Compile Remove="**\*.Win32.cs" />
10+
<None Include="**\*.Win32.cs" />
11+
</ItemGroup>
12+
13+
<ItemGroup Condition="'$(IsOSX)' != 'true'">
14+
<Compile Remove="**\*.OSX.cs" />
15+
<None Include="**\*.OSX.cs" />
16+
</ItemGroup>
17+
18+
<ItemGroup Condition="'$(IsLinux)' != 'true'">
19+
<Compile Remove="**\*.Linux.cs" />
20+
<None Include="**\*.Linux.cs" />
21+
</ItemGroup>
722
</Project>

‎Game.Assets/Game.Assets.csproj‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<TargetFramework>net10.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
<PlatformTarget>x64</PlatformTarget>
87
<Configurations>Debug;Release;Debug (Dedicated);Release (Dedicated)</Configurations>
98
</PropertyGroup>
109

‎Game.Client/HL2/HudCredits.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private void DrawOutroCreditsName() {
219219
LastOneInPlace = true;
220220

221221
// 360 certification requires that we not hold a static image too long.
222-
FadeTime = gpGlobals.CurTime + (IsConsole() ? 2.0f : 10.0f);
222+
FadeTime = gpGlobals.CurTime + 10.0f;
223223
}
224224
}
225225
else {

‎Game.Client/RenderTexture.cs‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ static void AddReleaseFunc() {
2626

2727
static readonly TextureReference PowerOfTwoFrameBufferTexture = new();
2828
public static ITexture? GetPowerOfTwoFrameBufferTexture() {
29-
if (IsX360())
30-
return GetFullFrameFrameBufferTexture(1);
31-
3229
if (!PowerOfTwoFrameBufferTexture.IsValid()) {
3330
PowerOfTwoFrameBufferTexture.Init(materials.FindTexture("_rt_PowerOfTwoFB", MaterialDefines.TEXTURE_GROUP_RENDER_TARGET));
3431
Assert(!ITexture.IsError(PowerOfTwoFrameBufferTexture.Get()));
@@ -169,11 +166,6 @@ static void AddReleaseFunc() {
169166
/// tiny 32x32 texture, always 8888
170167
/// </summary>
171168
public static ITexture? GetTeenyTexture(int which) {
172-
if (IsX360()) {
173-
Assert(false);
174-
return null;
175-
}
176-
177169
Assert(which < MAX_TEENY_TEXTURES);
178170

179171
if (!TeenyTextures[which].IsValid()) {

‎Game.Client/ViewScene.cs‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,16 @@ public static class ViewScene
2626
public static void UpdateRefractTexture(int x, int y, int w, int h, bool forceUpdate = false) {
2727
Assert(!DrawingShadowDepthView());
2828

29-
if (!IsRetail() && !r_updaterefracttexture.GetBool())
29+
if (!r_updaterefracttexture.GetBool())
3030
return;
3131

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

39-
g_viewscene_refractUpdateFrame = gpGlobals.FrameCount;
40-
}
38+
g_viewscene_refractUpdateFrame = gpGlobals.FrameCount;
4139
renderContext.SetFrameBufferCopyTexture(texture);
4240
}
4341

‎Game.Server/BaseEntity.cs‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3015,25 +3015,23 @@ public static void PrecacheModelComponents(int modelIndex) {
30153015
return;
30163016

30173017
// sounds
3018-
if (IsPC()) {
3019-
ReadOnlySpan<char> name = modelinfo.GetModelName(model);
3020-
if (!g_ModelSoundsCache.TryGetValue(name.Hash(), out _)) {
3021-
ReadOnlySpan<char> extension = Path.GetExtension(name);
3018+
ReadOnlySpan<char> name = modelinfo.GetModelName(model);
3019+
if (!g_ModelSoundsCache.TryGetValue(name.Hash(), out _)) {
3020+
ReadOnlySpan<char> extension = Path.GetExtension(name);
30223021

3023-
if (!stristr(extension, "mdl").IsEmpty)
3024-
DevMsg(2, $"Late precache of {name}, need to rebuild modelsounds.cache\n");
3025-
else {
3026-
if (extension[0] == '\0')
3027-
Warning($"Precache of {name} ambigious (no extension specified)\n");
3028-
else
3029-
Warning($"Late precache of {name} (file missing?)\n");
3030-
return;
3031-
}
3022+
if (!stristr(extension, "mdl").IsEmpty)
3023+
DevMsg(2, $"Late precache of {name}, need to rebuild modelsounds.cache\n");
3024+
else {
3025+
if (extension[0] == '\0')
3026+
Warning($"Precache of {name} ambigious (no extension specified)\n");
3027+
else
3028+
Warning($"Late precache of {name} (file missing?)\n");
3029+
return;
30323030
}
3033-
3034-
if (g_ModelSoundsCache.TryGetValue(name.Hash(), out ModelSoundsCache? entry))
3035-
entry.PrecacheSoundList();
30363031
}
3032+
3033+
if (g_ModelSoundsCache.TryGetValue(name.Hash(), out ModelSoundsCache? entry))
3034+
entry.PrecacheSoundList();
30373035
}
30383036

30393037
static readonly Dictionary<UtlSymId_t, ModelSoundsCache> g_ModelSoundsCache = [];

‎Game.Server/World.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ public override void Spawn() {
171171
g_EventQueue.Init();
172172
Precache();
173173

174-
GlobalEntity.Add("is_console", gpGlobals.MapName, (IsConsole()) ? GlobalEState.On : GlobalEState.Off);
175-
GlobalEntity.Add("is_pc", gpGlobals.MapName, (!IsConsole()) ? GlobalEState.On : GlobalEState.Off);
174+
GlobalEntity.Add("is_console", gpGlobals.MapName, GlobalEState.Off);
175+
GlobalEntity.Add("is_pc", gpGlobals.MapName, GlobalEState.On);
176176
}
177177

178178
public static readonly new ServerClass ServerClass = new ServerClass(DT_WORLD);

0 commit comments

Comments
 (0)