From d3b8c7cea3c76b561dd059bdd0441dd349d155e0 Mon Sep 17 00:00:00 2001 From: wixoaGit Date: Sun, 15 Oct 2023 13:47:43 -0400 Subject: [PATCH] make `world.Export()`'s returned CONTENT a resource value --- .../Procs/Native/DreamProcNativeWorld.cs | 3 ++- OpenDreamRuntime/Resources/DreamResourceManager.cs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/OpenDreamRuntime/Procs/Native/DreamProcNativeWorld.cs b/OpenDreamRuntime/Procs/Native/DreamProcNativeWorld.cs index 88453dc29f..c08d5fb8fd 100644 --- a/OpenDreamRuntime/Procs/Native/DreamProcNativeWorld.cs +++ b/OpenDreamRuntime/Procs/Native/DreamProcNativeWorld.cs @@ -61,8 +61,9 @@ public static async Task NativeProc_Export(AsyncNativeProc.State sta list.SetValue(new DreamValue(header.Key), new DreamValue(header.Value.First())); } + var content = state.ResourceManager.CreateResource(await response.Content.ReadAsByteArrayAsync()); list.SetValue(new DreamValue("STATUS"), new DreamValue(((int) response.StatusCode).ToString())); - list.SetValue(new DreamValue("CONTENT"), new DreamValue(await response.Content.ReadAsStringAsync())); + list.SetValue(new DreamValue("CONTENT"), new DreamValue(content)); return new DreamValue(list); } diff --git a/OpenDreamRuntime/Resources/DreamResourceManager.cs b/OpenDreamRuntime/Resources/DreamResourceManager.cs index 79925a5b74..d7fa2d72e2 100644 --- a/OpenDreamRuntime/Resources/DreamResourceManager.cs +++ b/OpenDreamRuntime/Resources/DreamResourceManager.cs @@ -133,6 +133,18 @@ public IconResource CreateIconResource(byte[] data, Image texture, DMIPa return resource; } + /// + /// Dynamically create a new generic resource that clients can use + /// + /// The resource's data + public DreamResource CreateResource(byte[] data) { + int resourceId = _resourceCache.Count; + DreamResource resource = new DreamResource(resourceId, data); + + _resourceCache.Add(resource); + return resource; + } + /// /// Dynamically create a new icon resource that clients can use ///