From cdce5c0a8b92357b1e0e97d8436f033fb83a5e9e Mon Sep 17 00:00:00 2001
From: biwa <6475593+biwa@users.noreply.github.com>
Date: Sat, 2 Jul 2022 23:28:07 +0200
Subject: [PATCH] Sound Environment Mode: fixed an issue that caused building
 sound environments to fail when the arguments of the Sound Environment thing
 had unexpected values.

---
 Source/Plugins/SoundPropagationMode/BuilderPlug.cs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Source/Plugins/SoundPropagationMode/BuilderPlug.cs b/Source/Plugins/SoundPropagationMode/BuilderPlug.cs
index 08ca5f57b..2acfb699d 100755
--- a/Source/Plugins/SoundPropagationMode/BuilderPlug.cs
+++ b/Source/Plugins/SoundPropagationMode/BuilderPlug.cs
@@ -245,7 +245,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
 			for(int i = 0; i < soundenvironmenthings.Count; i++)
 			{
 				//mxd. Make sure same environments use the same color
-				int seid = (soundenvironmenthings[i].Args[0] << 8) + soundenvironmenthings[i].Args[1];
+				int seid = (Math.Abs(soundenvironmenthings[i].Args[0])%256 << 8) + Math.Abs(soundenvironmenthings[i].Args[1])%256;
 				secolor[soundenvironmenthings[i]] = distinctcolors[seid % distinctcolors.Count];
 				senumber.Add(soundenvironmenthings[i], i + 1);
 			}
-- 
GitLab