Skip to content

Commit

Permalink
reimplement this .0 thingy
Browse files Browse the repository at this point in the history
  • Loading branch information
LetterN committed Dec 23, 2023
1 parent 08a79e7 commit c0ef28e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions OpenDreamRuntime/Objects/Types/DreamObjectSavefile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,18 @@ public DreamValue RealizeJsonValue(IDreamJsonValue value) {
// TODO stub
break;
case DreamObjectValue dreamObjectValue:
if (dreamObjectValue.TryGetValue("type", out var unserialType) && unserialType is DreamPrimitive primtype) {
// todo DOV should store WHERE is the actual path for data (normaly its .0)
if (!dreamObjectValue.TryGetValue(".0", out var saveData))
break;

if (saveData.TryGetValue("type", out var unserialType) && unserialType is DreamPrimitive primtype) {
primtype.Value.MustGetValueAsType();
var newObj = GetProc("New").Spawn(this, new DreamProcArguments(primtype.Value));
var dObj = newObj.MustGetValueAsDreamObject()!;

foreach (var key in dObj.ObjectDefinition.Variables.Keys) {
DreamValue val = DreamValue.Null;
if (dreamObjectValue.TryGetValue(key, out var dreamObjVal)) {
if (saveData.TryGetValue(key, out var dreamObjVal)) {
val = (dreamObjVal is DreamPathValue) ? newObj : RealizeJsonValue(dreamObjVal);
}
dObj.SetVariable(key, val);
Expand Down Expand Up @@ -348,7 +352,9 @@ public IDreamJsonValue SerializeDreamValue(DreamValue val) {
};
}
return new DreamObjectValue {
["type"] = new DreamPrimitive { Value = val.MustGetValueAsDreamObject()!.GetVariable("type") }
[".0"] = new DreamJsonValue {
["type"] = new DreamPrimitive { Value = val.MustGetValueAsDreamObject()!.GetVariable("type") }
}
};

// noop
Expand Down

0 comments on commit c0ef28e

Please sign in to comment.