Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make world.Export()'s returned CONTENT a resource value #1498

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading