diff --git a/Installer/Changes.txt b/Installer/Changes.txt index 837bf0913..b5c8f99e2 100644 --- a/Installer/Changes.txt +++ b/Installer/Changes.txt @@ -7,6 +7,7 @@ Tomb Editor: * Added Flyby Timeline control to edit and preview flyby sequences. * Added "Preview flyby sequence" and "Preview camera" context menus for cameras. * Added On Pickup, On Vehicle Enter and On Vehicle Exit global events in the global event set editor. + * Added support for room reverb in TRX. WadTool: * Added missing TR2 henchman death sound (ID 838) and appropriate TR2 -> TEN conversion. diff --git a/TombLib/TombLib/LevelData/Compilers/Trx.cs b/TombLib/TombLib/LevelData/Compilers/Trx.cs index 11a367ee3..fd2185845 100644 --- a/TombLib/TombLib/LevelData/Compilers/Trx.cs +++ b/TombLib/TombLib/LevelData/Compilers/Trx.cs @@ -44,6 +44,11 @@ private IEnumerable GenerateTrxSectorEdits() { foreach (var (teRoom, trRoom) in _tempRooms) { + if (GetRoomPropertyEntry(teRoom, trRoom) is TRXRoomPropertyEntry roomEntry) + { + yield return roomEntry; + } + for (ushort x = 1; x < teRoom.NumXSectors - 1; x++) { for (ushort z = 1; z < teRoom.NumZSectors - 1; z++) @@ -65,6 +70,21 @@ private IEnumerable GenerateTrxSectorEdits() } } + private TRXRoomPropertyEntry GetRoomPropertyEntry(Room teRoom, tr_room trRoom) + { + if (teRoom.Properties.Reverberation == 0) + { + return null; + } + + return new() + { + RoomIndex = (short)_roomRemapping[teRoom], + Flags = trRoom.Flags, + ReverbInfo = teRoom.Properties.Reverberation, + }; + } + private TrxSectorOverwrite GetSectorOverwrite(Room teRoom, tr_room trRoom, ushort x, ushort z) { var teSector = teRoom.Sectors[x, z]; diff --git a/TombLib/TombLib/LevelData/Compilers/Util/TrxInjector.cs b/TombLib/TombLib/LevelData/Compilers/Util/TrxInjector.cs index 7a27a0eb2..1cbf9921d 100644 --- a/TombLib/TombLib/LevelData/Compilers/Util/TrxInjector.cs +++ b/TombLib/TombLib/LevelData/Compilers/Util/TrxInjector.cs @@ -10,7 +10,7 @@ namespace TombLib.LevelData.Compilers.Util; public static class TrxInjector { private const uint _magic = 'T' | 'R' << 8 | 'X' << 16 | 'J' << 24; - private const uint _version = 6; + private const uint _version = 8; private const uint _injectionType = 0; // Implies no link to a TRX config option public static void Serialize(TrxInjectionData data, BinaryWriterEx outWriter) @@ -239,6 +239,20 @@ protected override void SerializeImpl(BinaryWriterEx writer) } } +public class TRXRoomPropertyEntry : TrxSectorEdit +{ + public override int Command => 5; + + public short Flags { get; set; } + public byte ReverbInfo { get; set; } + + protected override void SerializeImpl(BinaryWriterEx writer) + { + writer.Write(Flags); + writer.Write(ReverbInfo); + } +} + public class TrxTextureOverwrite { public ushort Page { get; set; } diff --git a/TombLib/TombLib/LevelData/Enumerations.cs b/TombLib/TombLib/LevelData/Enumerations.cs index ad76035c3..e0a709bc4 100644 --- a/TombLib/TombLib/LevelData/Enumerations.cs +++ b/TombLib/TombLib/LevelData/Enumerations.cs @@ -56,7 +56,7 @@ public static bool SupportsFontAndSkySettings(this Game ver) => ver.Native() >= Game.TR4; public static bool SupportsReverberation(this Game ver) - => ver.Native() >= Game.TR3; + => ver >= Game.TR3; public static bool SupportsLensflare(this Game ver) => ver.Native() >= Game.TR4;