Skip to content

Commit adfc7a7

Browse files
authored
prune formatting when outputting (#2491)
1 parent d9ccc2f commit adfc7a7

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

OpenDreamRuntime/DreamConnection.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Threading.Tasks;
22
using System.Web;
3+
using DMCompiler.Bytecode;
34
using OpenDreamRuntime.Objects;
45
using OpenDreamRuntime.Objects.Types;
56
using OpenDreamRuntime.Procs.Native;
@@ -282,7 +283,11 @@ public void OutputDreamValue(DreamValue value) {
282283
return;
283284
}
284285

285-
OutputControl(value.Stringify(), null);
286+
// Prune any remaining formatting
287+
var message = value.Stringify();
288+
message = StringFormatEncoder.RemoveFormatting(message);
289+
290+
OutputControl(message, null);
286291
}
287292

288293
public void OutputControl(string message, string? control) {

OpenDreamRuntime/Resources/ConsoleOutputResource.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using DMCompiler.Bytecode;
12
using OpenDreamRuntime.Procs.DebugAdapter;
23

34
namespace OpenDreamRuntime.Resources;
@@ -19,6 +20,10 @@ public void WriteConsole(LogLevel logLevel, string sawmill, string message) {
1920
}
2021

2122
public override void Output(DreamValue value) {
22-
WriteConsole(LogLevel.Info, "world.log", value.Stringify());
23+
// Prune any remaining formatting
24+
var message = value.Stringify();
25+
message = StringFormatEncoder.RemoveFormatting(message);
26+
27+
WriteConsole(LogLevel.Info, "world.log", message);
2328
}
2429
}

OpenDreamRuntime/Resources/DreamResource.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.IO;
2+
using DMCompiler.Bytecode;
23
using System.Runtime.CompilerServices;
34
using System.Text;
45

@@ -78,6 +79,9 @@ public virtual void Output(DreamValue value) {
7879
throw new Exception($"Invalid output operation '{ResourcePath}' << {value}");
7980
}
8081

82+
// Prune any remaining formatting
83+
text = StringFormatEncoder.RemoveFormatting(text);
84+
8185
CreateDirectory();
8286
File.AppendAllText(ResourcePath, text + "\r\n");
8387
_resourceDataBacking = null;

0 commit comments

Comments
 (0)