Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to RT v195.0.1 and .NET 8 #1562

Merged
merged 7 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.101
dotnet-version: 8.0.100
- name: Install dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/compiler-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.101
dotnet-version: 8.0.100
- name: Install dependencies
run: dotnet restore main/OpenDream.sln
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-tgs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
cancel-in-progress: true

env:
OD_DOTNET_VERSION: 7
OD_DOTNET_VERSION: 8
TGS_DOTNET_VERSION: 8
TGS_REFERENCE: V6 # This will break after the V6 branch gets deleted during the TGS6 release cycle. When it does, change this to `dev`

Expand Down
2 changes: 1 addition & 1 deletion Content.IntegrationTests/Content.IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<OutputPath>..\bin\Content.IntegrationTests\</OutputPath>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<LangVersion>11</LangVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.2" />
Expand Down
2 changes: 1 addition & 1 deletion Content.Tests/Content.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
<TargetFramework>$(TargetFramework)</TargetFramework>
<LangVersion>11</LangVersion>
<LangVersion>12</LangVersion>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>..\bin\Content.Tests\</OutputPath>
Expand Down
2 changes: 1 addition & 1 deletion DMCompiler/DMCompiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<Configurations>Debug;Release;Tools</Configurations>
<Platforms>AnyCPU</Platforms>
Expand Down
8 changes: 4 additions & 4 deletions DMCompiler/copy_standard.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
if not exist bin\Debug\net7.0\DMStandard mkdir bin\Debug\net7.0\DMStandard
xcopy DMStandard bin\Debug\net7.0\DMStandard /y /s /e
if not exist bin\Release\net7.0\DMStandard mkdir bin\Release\net7.0\DMStandard
xcopy DMStandard bin\Release\net7.0\DMStandard /y /s /e
if not exist bin\Debug\net8.0\DMStandard mkdir bin\Debug\net8.0\DMStandard
xcopy DMStandard bin\Debug\net8.0\DMStandard /y /s /e
if not exist bin\Release\net8.0\DMStandard mkdir bin\Release\net8.0\DMStandard
xcopy DMStandard bin\Release\net8.0\DMStandard /y /s /e
16 changes: 8 additions & 8 deletions DMCompiler/copy_standard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ set -xe
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")

if [ -d "$SCRIPTPATH/bin/Debug/net7.0/DMStandard" ]; then
cp -r $SCRIPTPATH/DMStandard $SCRIPTPATH/bin/Debug/net7.0/DMStandard
if [ -d "$SCRIPTPATH/bin/Debug/net8.0/DMStandard" ]; then
cp -r $SCRIPTPATH/DMStandard $SCRIPTPATH/bin/Debug/net8.0/DMStandard
else
mkdir -p $SCRIPTPATH/bin/Debug/net7.0/DMStandard
cp -r $SCRIPTPATH/DMStandard $SCRIPTPATH/bin/Debug/net7.0/DMStandard
mkdir -p $SCRIPTPATH/bin/Debug/net8.0/DMStandard
cp -r $SCRIPTPATH/DMStandard $SCRIPTPATH/bin/Debug/net8.0/DMStandard
fi

if [ -d "$SCRIPTPATH/bin/Release/net7.0/DMStandard" ]; then
cp -r $SCRIPTPATH/DMStandard $SCRIPTPATH/bin/Release/net7.0/DMStandard
if [ -d "$SCRIPTPATH/bin/Release/net8.0/DMStandard" ]; then
cp -r $SCRIPTPATH/DMStandard $SCRIPTPATH/bin/Release/net8.0/DMStandard
else
mkdir -p $SCRIPTPATH/bin/Release/net7.0/DMStandard
cp -r $SCRIPTPATH/DMStandard $SCRIPTPATH/bin/Release/net7.0/DMStandard
mkdir -p $SCRIPTPATH/bin/Release/net8.0/DMStandard
cp -r $SCRIPTPATH/DMStandard $SCRIPTPATH/bin/Release/net8.0/DMStandard
fi
2 changes: 1 addition & 1 deletion DMDisassembler/DMDisassembler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Configurations>Debug;Release;Tools</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
Expand Down
18 changes: 5 additions & 13 deletions OpenDreamClient/Audio/DreamSoundChannel.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
using Robust.Client.Graphics;
using Robust.Client.Audio;
using Robust.Shared.Audio.Components;

namespace OpenDreamClient.Audio;

public sealed class DreamSoundChannel : IDisposable {
public IClydeAudioSource Source { get; }

public DreamSoundChannel(IClydeAudioSource source) {
Source = source;
}
public sealed class DreamSoundChannel(AudioSystem audioSystem, (EntityUid Entity, AudioComponent Component) source) {
public readonly (EntityUid Entity, AudioComponent Component) Source = source;

public void Stop() {
Source.StopPlaying();
}

public void Dispose() {
Stop();
Source.Dispose();
audioSystem.Stop(Source.Entity, Source.Component);
}
}
128 changes: 71 additions & 57 deletions OpenDreamClient/Audio/DreamSoundEngine.cs
Original file line number Diff line number Diff line change
@@ -1,89 +1,103 @@
using OpenDreamClient.Resources;
using OpenDreamClient.Resources.ResourceTypes;
using OpenDreamShared.Network.Messages;
using Robust.Client.Graphics;
using Robust.Client.Audio;
using Robust.Shared.Audio;
using Robust.Shared.Network;

namespace OpenDreamClient.Audio {
public sealed class DreamSoundEngine : IDreamSoundEngine {
private const int SoundChannelLimit = 1024;
namespace OpenDreamClient.Audio;

[Dependency] private readonly IDreamResourceManager _resourceManager = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly INetManager _netManager = default!;
public sealed class DreamSoundEngine : IDreamSoundEngine {
private const int SoundChannelLimit = 1024;

private ISawmill _sawmill = default!;
[Dependency] private readonly IDreamResourceManager _resourceManager = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly INetManager _netManager = default!;
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
[Dependency] private readonly IAudioManager _audioManager = default!;
private AudioSystem? _audioSystem;

private readonly DreamSoundChannel?[] _channels = new DreamSoundChannel[SoundChannelLimit];
private ISawmill _sawmill = default!;

public void Initialize() {
_sawmill = _logManager.GetSawmill("opendream.audio");
private readonly DreamSoundChannel?[] _channels = new DreamSoundChannel[SoundChannelLimit];

_netManager.RegisterNetMessage<MsgSound>(RxSound);
public void Initialize() {
_sawmill = _logManager.GetSawmill("opendream.audio");

_netManager.Disconnect += DisconnectedFromServer;
}
_netManager.RegisterNetMessage<MsgSound>(RxSound);

public void StopFinishedChannels() {
for (int i = 0; i < SoundChannelLimit; i++) {
if (_channels[i]?.Source.IsPlaying is false or null)
StopChannel(i + 1);
}
_netManager.Disconnect += DisconnectedFromServer;
}

public void StopFinishedChannels() {
for (int i = 0; i < SoundChannelLimit; i++) {
if (_channels[i]?.Source.Component.Playing is false or null)
StopChannel(i + 1);
}
}

public void PlaySound(int channel, MsgSound.FormatType format, ResourceSound sound, float volume) {
if (channel == 0) {
//First available channel
for (int i = 0; i < _channels.Length; i++) {
if (_channels[i] == null) {
channel = i + 1;
break;
}
}
public void PlaySound(int channel, MsgSound.FormatType format, ResourceSound sound, float volume) {
if (_audioSystem == null)
_entitySystemManager.Resolve(ref _audioSystem);

if (channel == 0) {
_sawmill.Error("Failed to find a free audio channel to play a sound on");
return;
if (channel == 0) {
//First available channel
for (int i = 0; i < _channels.Length; i++) {
if (_channels[i] == null) {
channel = i + 1;
break;
}
}

StopChannel(channel);

// convert from DM volume (0-100) to OpenAL volume (db)
IClydeAudioSource? source = sound.Play(format, AudioParams.Default.WithVolume(20 * MathF.Log10(volume)));
if (source == null)
if (channel == 0) {
_sawmill.Error("Failed to find a free audio channel to play a sound on");
return;

_channels[channel - 1] = new DreamSoundChannel(source);
}
}

StopChannel(channel);

public void StopChannel(int channel) {
ref DreamSoundChannel? ch = ref _channels[channel - 1];

ch?.Dispose();
// This will null the corresponding index in the array.
ch = null;
var stream = sound.GetStream(format, _audioManager);
if (stream == null) {
_sawmill.Error($"Failed to load audio ${sound}");
return;
}

public void StopAllChannels() {
for (int i = 0; i < SoundChannelLimit; i++) {
StopChannel(i + 1);
}
var db = 20 * MathF.Log10(volume); // convert from DM volume (0-100) to OpenAL volume (db)
var source = _audioSystem.PlayGlobal(stream, AudioParams.Default.WithVolume(db)); // TODO: Positional audio.
if (source == null) {
_sawmill.Error($"Failed to play audio ${sound}");
return;
}

private void RxSound(MsgSound msg) {
if (msg.ResourceId.HasValue) {
_resourceManager.LoadResourceAsync<ResourceSound>(msg.ResourceId.Value,
sound => PlaySound(msg.Channel, msg.Format!.Value, sound, msg.Volume / 100.0f));
} else {
StopChannel(msg.Channel);
}
_channels[channel - 1] = new DreamSoundChannel(_audioSystem, source.Value);
}


public void StopChannel(int channel) {
ref DreamSoundChannel? ch = ref _channels[channel - 1];

ch?.Stop();
// This will null the corresponding index in the array.
ch = null;
}

public void StopAllChannels() {
for (int i = 0; i < SoundChannelLimit; i++) {
StopChannel(i + 1);
}
}

private void DisconnectedFromServer(object? sender, NetDisconnectedArgs e) {
StopAllChannels();
private void RxSound(MsgSound msg) {
if (msg.ResourceId.HasValue) {
_resourceManager.LoadResourceAsync<ResourceSound>(msg.ResourceId.Value,
sound => PlaySound(msg.Channel, msg.Format!.Value, sound, msg.Volume / 100.0f));
} else {
StopChannel(msg.Channel);
}
}

private void DisconnectedFromServer(object? sender, NetDisconnectedArgs e) {
StopAllChannels();
}
}
2 changes: 1 addition & 1 deletion OpenDreamClient/DreamClientSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using OpenDreamClient.Rendering;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;

namespace OpenDreamClient;

Expand Down
2 changes: 1 addition & 1 deletion OpenDreamClient/OpenDreamClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<!-- Work around https://github.com/dotnet/project-system/issues/4314 -->
<TargetFramework>$(TargetFramework)</TargetFramework>
<LangVersion>11</LangVersion>
<LangVersion>12</LangVersion>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>..\bin\Content.Client\</OutputPath>
Expand Down
8 changes: 4 additions & 4 deletions OpenDreamClient/Rendering/DreamViewOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ internal sealed class DreamViewOverlay : Overlay {

// Defined here so it isn't recreated every frame
private ViewAlgorithm.Tile?[,]? _tileInfo;
private readonly HashSet<EntityUid> _entities = new();

public DreamViewOverlay(TransformSystem transformSystem, EntityLookupSystem lookupSystem,
ClientAppearanceSystem appearanceSystem, ClientScreenOverlaySystem screenOverlaySystem, ClientImagesSystem clientImagesSystem) {
Expand Down Expand Up @@ -140,19 +141,18 @@ private void DrawAll(OverlayDrawArgs args, EntityUid eye, Vector2i viewportSize)

var worldHandle = args.WorldHandle;

HashSet<EntityUid> entities;
using (_prof.Group("lookup")) {
//TODO use a sprite tree.
//the scaling is to attempt to prevent pop-in, by rendering sprites that are *just* offscreen
entities = _lookupSystem.GetEntitiesIntersecting(args.MapId, args.WorldAABB.Scale(1.2f), MapLookupFlags);
_lookupSystem.GetEntitiesIntersecting(args.MapId, args.WorldAABB.Scale(1.2f), _entities, MapLookupFlags);
}

var eyeTile = grid.GetTileRef(eyeTransform.MapPosition);
var tiles = CalculateTileVisibility(grid, entities, eyeTile, seeVis);
var tiles = CalculateTileVisibility(grid, _entities, eyeTile, seeVis);

RefreshRenderTargets(args.WorldHandle, viewportSize);

CollectVisibleSprites(tiles, grid, eyeTile, entities, seeVis, sight, args.WorldAABB);
CollectVisibleSprites(tiles, grid, eyeTile, _entities, seeVis, sight, args.WorldAABB);
ClearPlanes();
ProcessSprites(worldHandle, viewportSize, args.WorldAABB);

Expand Down
44 changes: 10 additions & 34 deletions OpenDreamClient/Resources/ResourceTypes/ResourceSound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,28 @@
using JetBrains.Annotations;
using OpenDreamShared.Network.Messages;
using Robust.Client.Audio;
using Robust.Client.Graphics;
using Robust.Shared.Audio;

namespace OpenDreamClient.Resources.ResourceTypes {
[UsedImplicitly]
public sealed class ResourceSound : DreamResource {
private AudioStream? _stream;
namespace OpenDreamClient.Resources.ResourceTypes;

public ResourceSound(int id, byte[] data) : base(id, data) { }

public IClydeAudioSource? Play(MsgSound.FormatType format, AudioParams audioParams) {
LoadStream(format);
if (_stream == null)
return null;

// TODO: Positional audio.
var source = IoCManager.Resolve<IClydeAudio>().CreateAudioSource(_stream);

if (source != null) {
source.SetGlobal();
source.SetPitch(audioParams.PitchScale);
source.SetVolume(audioParams.Volume);
source.SetPlaybackPosition(audioParams.PlayOffsetSeconds);
source.IsLooping = audioParams.Loop;

source.StartPlaying();
}

return source;
}

private void LoadStream(MsgSound.FormatType format) {
if (_stream != null)
return;
[UsedImplicitly]
public sealed class ResourceSound(int id, byte[] data) : DreamResource(id, data) {
private AudioStream? _stream;

public AudioStream? GetStream(MsgSound.FormatType format, IAudioManager audioManager) {
if (_stream == null) {
switch (format) {
case MsgSound.FormatType.Ogg:
_stream = IoCManager.Resolve<IClydeAudio>().LoadAudioOggVorbis(new MemoryStream(Data));
_stream = audioManager.LoadAudioOggVorbis(new MemoryStream(Data));
break;
case MsgSound.FormatType.Wav:
_stream = IoCManager.Resolve<IClydeAudio>().LoadAudioWav(new MemoryStream(Data));
_stream = audioManager.LoadAudioWav(new MemoryStream(Data));
break;
default:
Logger.GetSawmill("opendream.audio").Fatal("Only *.ogg and *.wav audio files are supported.");
break;
}
}

return _stream;
}
}
Loading
Loading