Skip to content

Commit

Permalink
make world.Export()'s returned CONTENT a resource value
Browse files Browse the repository at this point in the history
  • Loading branch information
wixoaGit committed Oct 15, 2023
1 parent 2698cab commit d3b8c7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion OpenDreamRuntime/Procs/Native/DreamProcNativeWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ public static async Task<DreamValue> 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);
}
Expand Down
12 changes: 12 additions & 0 deletions OpenDreamRuntime/Resources/DreamResourceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ public IconResource CreateIconResource(byte[] data, Image<Rgba32> texture, DMIPa
return resource;
}

/// <summary>
/// Dynamically create a new generic resource that clients can use
/// </summary>
/// <param name="data">The resource's data</param>
public DreamResource CreateResource(byte[] data) {
int resourceId = _resourceCache.Count;
DreamResource resource = new DreamResource(resourceId, data);

_resourceCache.Add(resource);
return resource;
}

/// <summary>
/// Dynamically create a new icon resource that clients can use
/// </summary>
Expand Down

0 comments on commit d3b8c7c

Please sign in to comment.