Skip to content

Commit

Permalink
Update to RT v194.1.0 and .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
wixoaGit committed Dec 22, 2023
1 parent a3dcd59 commit a5b6695
Show file tree
Hide file tree
Showing 22 changed files with 72 additions and 104 deletions.
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);
}
}
28 changes: 21 additions & 7 deletions OpenDreamClient/Audio/DreamSoundEngine.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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;

Expand All @@ -12,6 +12,9 @@ public sealed class DreamSoundEngine : IDreamSoundEngine {
[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 ISawmill _sawmill = default!;

Expand All @@ -27,12 +30,15 @@ public void Initialize() {

public void StopFinishedChannels() {
for (int i = 0; i < SoundChannelLimit; i++) {
if (_channels[i]?.Source.IsPlaying is false or null)
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 (_audioSystem == null)
_entitySystemManager.Resolve(ref _audioSystem);

if (channel == 0) {
//First available channel
for (int i = 0; i < _channels.Length; i++) {
Expand All @@ -50,19 +56,27 @@ public void PlaySound(int channel, MsgSound.FormatType format, ResourceSound sou

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)
var stream = sound.GetStream(format, _audioManager);
if (stream == null) {
_sawmill.Error($"Failed to load audio ${sound}");
return;
}

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;
}

_channels[channel - 1] = new DreamSoundChannel(source);
_channels[channel - 1] = new DreamSoundChannel(_audioSystem, source.Value);
}


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

ch?.Dispose();
ch?.Stop();
// This will null the corresponding index in the array.
ch = null;
}
Expand Down
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
54 changes: 15 additions & 39 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 {
public sealed class ResourceSound(int id, byte[] data) : DreamResource(id, data) {
private AudioStream? _stream;

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

return source;
}

private void LoadStream(MsgSound.FormatType format) {
if (_stream != null)
return;

switch (format) {
case MsgSound.FormatType.Ogg:
_stream = IoCManager.Resolve<IClydeAudio>().LoadAudioOggVorbis(new MemoryStream(Data));
break;
case MsgSound.FormatType.Wav:
_stream = IoCManager.Resolve<IClydeAudio>().LoadAudioWav(new MemoryStream(Data));
break;
default:
Logger.GetSawmill("opendream.audio").Fatal("Only *.ogg and *.wav audio files are supported.");
break;
}
return _stream;
}
}
}
2 changes: 1 addition & 1 deletion OpenDreamPackageTool/OpenDreamPackageTool.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>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
6 changes: 2 additions & 4 deletions OpenDreamPackaging/DreamPackaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ public static async Task WriteResources(

var inputPass = graph.Input;

await RobustClientPackaging.WriteContentAssemblies(
inputPass,
await RobustClientPackaging.WriteClientResources(
contentDir,
"Content.Client",
new[] { "OpenDreamClient", "OpenDreamShared" },
inputPass,
cancel);

await RobustClientPackaging.WriteClientResources(contentDir, inputPass, cancel);
Expand Down
2 changes: 1 addition & 1 deletion OpenDreamPackaging/OpenDreamPackaging.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>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
10 changes: 2 additions & 8 deletions OpenDreamRuntime/DreamConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public sealed class DreamConnection {
[Dependency] private readonly DreamResourceManager _resourceManager = default!;
[Dependency] private readonly WalkManager _walkManager = default!;
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;

private readonly ServerScreenOverlaySystem? _screenOverlaySystem;
private readonly ServerClientImagesSystem? _clientImagesSystem;
private readonly ActorSystem? _actorSystem;

[ViewVariables] private readonly Dictionary<string, (DreamObject Src, DreamProc Verb)> _availableVerbs = new();
[ViewVariables] private readonly Dictionary<string, List<(string, string, string?)>> _statPanels = new();
Expand Down Expand Up @@ -68,12 +68,7 @@ public DreamObjectMovable? Eye {
get => _eye;
set {
_eye = value;

if (_eye != null) {
_actorSystem?.Attach(_eye.Entity, Session!);
} else {
_actorSystem?.Detach(Session!);
}
_playerManager.SetAttachedEntity(Session!, _eye?.Entity);
}
}

Expand Down Expand Up @@ -105,7 +100,6 @@ public DreamConnection() {

_entitySystemManager.TryGetEntitySystem(out _screenOverlaySystem);
_entitySystemManager.TryGetEntitySystem(out _clientImagesSystem);
_entitySystemManager.TryGetEntitySystem(out _actorSystem);
}

public void HandleConnection(ICommonSession session) {
Expand Down
2 changes: 1 addition & 1 deletion OpenDreamRuntime/Objects/Types/DreamList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ public override void AddValue(DreamValue value) {

// TODO: Only override the entity's visibility if its parent atom is visible
if (entity != EntityUid.Invalid)
_pvsOverrideSystem?.AddGlobalOverride(entity);
_pvsOverrideSystem?.AddGlobalOverride(_entityManager.GetNetEntity(entity));

_atomManager.UpdateAppearance(_atom, appearance => {
// Add even an invalid UID to keep this and _visContents in sync
Expand Down
4 changes: 2 additions & 2 deletions OpenDreamRuntime/Objects/Types/DreamObjectMovable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ protected override bool TryGetVar(string varName, out DreamValue value) {
DreamList contents = ObjectTree.CreateList();

using (var childEnumerator = _transformComponent.ChildEnumerator) {
while (childEnumerator.MoveNext(out EntityUid? child)) {
if (!AtomManager.TryGetMovableFromEntity(child.Value, out var childAtom))
while (childEnumerator.MoveNext(out EntityUid child)) {
if (!AtomManager.TryGetMovableFromEntity(child, out var childAtom))
continue;

contents.AddValue(new DreamValue(childAtom));
Expand Down
2 changes: 1 addition & 1 deletion OpenDreamRuntime/OpenDreamRuntime.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Configurations>Debug;Release;Tools</Configurations>
Expand Down
2 changes: 1 addition & 1 deletion OpenDreamServer/OpenDreamServer.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.Server\</OutputPath>
Expand Down
2 changes: 1 addition & 1 deletion OpenDreamShared/OpenDreamShared.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.Shared</OutputPath>
Expand Down
2 changes: 1 addition & 1 deletion RobustToolbox
Submodule RobustToolbox updated 355 files
6 changes: 0 additions & 6 deletions global.json

This file was deleted.

0 comments on commit a5b6695

Please sign in to comment.