Skip to content

Commit

Permalink
Revert "Converts empty strings to null in savefile serialization" (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
amylizzle authored Mar 29, 2024
1 parent 82694ac commit 7bfee41
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
12 changes: 4 additions & 8 deletions Content.Tests/DMProject/Tests/Savefile/BasicReadAndWrite.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
ASSERT(V == 10)
S["notakey"] >> V
ASSERT(V == null)

// "" is converted into null if entered into a savefile
S["nullcheck"] = ""
ASSERT(S["nullcheck"] == null)

// test path
S["pathymcpathface"] << /datum/foobar
Expand Down Expand Up @@ -53,23 +49,23 @@
//Test dir
S.cd = "/"
var/dir = S.dir
ASSERT(dir ~= list("ABC", "DEF", "notakey", "nullcheck", "pathymcpathface", "pie", "pie2"))
ASSERT(dir ~= list("ABC", "DEF", "notakey", "pathymcpathface", "pie", "pie2"))

//test add
dir += "test/beep"
ASSERT(dir ~= list("ABC", "DEF", "notakey", "nullcheck", "pathymcpathface", "pie", "pie2", "test"))
ASSERT(dir ~= list("ABC", "DEF", "notakey", "pathymcpathface", "pie", "pie2", "test"))
ASSERT(S["test"] == null)
S.cd = "test"
ASSERT(dir ~= list("beep"))

//test del
S.cd = "/"
dir -= "test"
ASSERT(dir ~= list("ABC", "DEF", "notakey", "nullcheck", "pathymcpathface", "pie", "pie2"))
ASSERT(dir ~= list("ABC", "DEF", "notakey", "pathymcpathface", "pie", "pie2"))

//test rename and null
dir[1] = "CBA"
ASSERT(dir ~= list("CBA", "DEF", "notakey", "nullcheck", "pathymcpathface", "pie", "pie2"))
ASSERT(dir ~= list("CBA", "DEF", "notakey", "pathymcpathface", "pie", "pie2"))
ASSERT(S["CBA"] == null)

fdel("savefile.sav")
Expand Down
3 changes: 0 additions & 3 deletions OpenDreamRuntime/Objects/Types/DreamObjectSavefile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,6 @@ public DreamValue DeserializeJsonValue(SFDreamJsonValue value) {
public SFDreamJsonValue SerializeDreamValue(DreamValue val, int objectCount = 0) {
switch (val.Type) {
case DreamValue.DreamValueType.String:
if(val.TryGetValueAsString(out var valString) && string.IsNullOrEmpty(valString))
val = DreamValue.Null;
return new SFDreamPrimitive { Value = val };
case DreamValue.DreamValueType.Float:
return new SFDreamPrimitive { Value = val };
case DreamValue.DreamValueType.DreamType:
Expand Down

0 comments on commit 7bfee41

Please sign in to comment.