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

Fully implement /savefile (except ImportText() because fuck it) #1554

Merged
merged 86 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
f498253
datum savin
LetterN Dec 5, 2023
1d09fd2
no tmp savefiles yet sadly
LetterN Dec 5, 2023
d990d69
Merge remote-tracking branch 'upstream/master' into issaved
LetterN Dec 6, 2023
92df5d9
some intermediary setter thing
LetterN Dec 6, 2023
deffd2e
datum write only writes `type` not it's constituent vars
LetterN Dec 6, 2023
3d2a2b8
implement the key nuking thing
LetterN Dec 6, 2023
9e3df94
Write!
LetterN Dec 6, 2023
b62ade5
revert DreamPath.cs change wait for pr #1528 instead
LetterN Dec 6, 2023
1038c2b
add or assign value
LetterN Dec 11, 2023
b9f82b3
start
amylizzle Dec 13, 2023
7afdffb
premerge
amylizzle Dec 14, 2023
bd85b82
Merge remote-tracking branch 'upstream/master' into exporttext
amylizzle Dec 14, 2023
15b0923
todo a bunch of recursive bullshit
amylizzle Dec 14, 2023
a3014f1
stub import
amylizzle Dec 14, 2023
6eb23ec
broken test plus some stuff, todo: lots
amylizzle Dec 15, 2023
0756351
Merge remote-tracking branch 'upstream/master' into exporttext
amylizzle Dec 18, 2023
4e36d84
Merge remote-tracking branch 'upstream/master' into issaved
LetterN Dec 19, 2023
5cfa866
dreampath changed
LetterN Dec 19, 2023
e9dd0a1
savefile rewrit
LetterN Dec 23, 2023
08a79e7
currpath it
LetterN Dec 23, 2023
c0ef28e
reimplement this .0 thingy
LetterN Dec 23, 2023
bae0f8e
yeah how the FUCK do i save objs
LetterN Dec 26, 2023
007b900
check list
LetterN Dec 26, 2023
ffd6699
Merge remote-tracking branch 'upstream/master' into issaved
LetterN Dec 26, 2023
6a5a79b
Merge remote-tracking branch 'upstream/master' into exporttext
amylizzle Jan 13, 2024
0839c0b
fix test
amylizzle Jan 13, 2024
7e7bd0e
pathing is wrong but it's closer. Also I stole DreamObjectSavefile fr…
amylizzle Jan 13, 2024
4b0cdb5
stuff
amylizzle Jan 14, 2024
deaaa54
Merge remote-tracking branch 'upstream/master' into issaved
LetterN Jan 14, 2024
0662395
Merge branch 'issaved' into exporttext
amylizzle Jan 14, 2024
735789a
fix seekto
amylizzle Jan 20, 2024
5681a91
make serialisation work
amylizzle Jan 20, 2024
c7ca9db
clarify comment
amylizzle Jan 20, 2024
a4f0b03
exporttext working, just minor formatting issues
amylizzle Jan 20, 2024
8e4962f
add save/load test
amylizzle Jan 20, 2024
f6e124b
paths working, plus codestyle
amylizzle Jan 21, 2024
47311f8
recursive lists, wow
amylizzle Jan 21, 2024
28adcfb
lol whoops
amylizzle Jan 21, 2024
1a53f2f
fix fcopy and tests
amylizzle Jan 21, 2024
d5a7331
clean up after test
amylizzle Jan 21, 2024
b87a0e6
start on object saving, tired now
amylizzle Jan 21, 2024
a53423b
Merge branch 'master' into exporttext
amylizzle Jan 21, 2024
a40a08a
clean up tests
amylizzle Jan 22, 2024
7c0a53c
add tmp to some stuff that needed it
amylizzle Jan 22, 2024
6810735
partial object and list
amylizzle Jan 22, 2024
59ebd35
lists can contain multiple objects
amylizzle Jan 22, 2024
dad2603
better formatting
amylizzle Jan 22, 2024
999cbca
almost done list, just gotta fix the whole assoc keys thing
amylizzle Jan 22, 2024
fbbc855
fix associative lists
amylizzle Jan 22, 2024
fbea079
ExportText formatting final
amylizzle Jan 24, 2024
709e021
now icon2base64 works again
amylizzle Jan 24, 2024
e6ef3c8
crc formatting
amylizzle Jan 24, 2024
e959a3d
savefiles too
amylizzle Jan 24, 2024
f588f94
object loading kinda?
amylizzle Jan 24, 2024
1e5122f
haha fuck you I am done
amylizzle Jan 25, 2024
9274c5b
Merge branch 'master' into exporttext
amylizzle Jan 25, 2024
844afb6
Merge branch 'master' into exporttext
amylizzle Jan 28, 2024
6ee5cf0
basic .dir implementation, delete first pass of importtext, add missi…
amylizzle Jan 28, 2024
f3efcb7
CRC32
amylizzle Jan 28, 2024
baecb4b
handle null index writes
amylizzle Jan 28, 2024
f617161
?
amylizzle Jan 28, 2024
5ccf7bb
fix text on windows
amylizzle Jan 28, 2024
9788f3c
Merge branch 'master' into exporttext
amylizzle Jan 29, 2024
f5a6ff6
eof
amylizzle Feb 2, 2024
e77bcd2
Merge branch 'master' into exporttext
amylizzle Feb 2, 2024
b4193f5
dir
amylizzle Feb 2, 2024
3afa639
failsafe
amylizzle Feb 2, 2024
9a59b79
cleanup
amylizzle Feb 2, 2024
2b1d404
broken sequence test
amylizzle Feb 2, 2024
a7755bd
feex
amylizzle Feb 3, 2024
a469949
Merge branch 'master' into exporttext
amylizzle Feb 3, 2024
ebe7ebf
fix overwriting subdirs
amylizzle Feb 4, 2024
3011651
Merge branch 'master' into exporttext
amylizzle Feb 6, 2024
a24dd88
oh hey this was actually failing the test for real, that's novel
amylizzle Feb 7, 2024
9aa26ac
Merge branch 'master' into exporttext
amylizzle Feb 9, 2024
d63202d
Merge branch 'master' into exporttext
amylizzle Feb 9, 2024
8cc4f56
Merge remote-tracking branch 'upstream/master' into exporttext
amylizzle Feb 18, 2024
2ec0fc6
Merge branch 'master' into exporttext
amylizzle Feb 20, 2024
b0339b5
Merge branch 'master' into exporttext
amylizzle Feb 21, 2024
a179002
Apply suggestions from code review
amylizzle Mar 1, 2024
5c983fe
Apply more suggestions from code review
amylizzle Mar 1, 2024
45d988e
more codestyle
amylizzle Mar 1, 2024
5a59284
Accessing a key creates it
amylizzle Mar 1, 2024
a74c6c6
throw an explicit orderby on there
amylizzle Mar 1, 2024
2bd4895
Merge branch 'OpenDreamProject:master' into exporttext
amylizzle Mar 1, 2024
6bc9d2b
Apply suggestions from code review
wixoaGit Mar 1, 2024
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
60 changes: 60 additions & 0 deletions Content.Tests/DMProject/Tests/Savefile/BasicReadAndWrite.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/datum/foobar

/proc/RunTest()
var/savefile/S = new("savefile.sav")
Expand All @@ -7,15 +8,74 @@
// Indexing the object to write/read the savefile
S["ABC"] = 5
ASSERT(V == null)
ASSERT(S["ABC"] == 5)
V = S["ABC"]
ASSERT(V == 5)

// << and >> can do the same thing
S["DEF"] << 10
S["DEF"] >> V
ASSERT(S["DEF"] == 10)
ASSERT(V == 10)
S["notakey"] >> V
ASSERT(V == null)

// test path
S["pathymcpathface"] << /datum/foobar
ASSERT(S["pathymcpathface"] == /datum/foobar)

// test list()
var/list/array = list("3.14159", "pizza")
S["pie"] << array
ASSERT(S["pie"] ~= array)
var/list/assoc = list("6.28" = "pizza", "aaaaa" = "bbbbbbb")
S["pie2"] << assoc
ASSERT(S["pie2"] ~= assoc)

// Shouldn't evaluate CRASH
S2?["ABC"] << CRASH("rhs should not evaluate due to null-conditional")

// Test EOF
S.cd = "DEF"
var/out
ASSERT(S.eof == 0)
S >> out
ASSERT(out == 10)
ASSERT(S.eof == 1)
S.eof = -1
S.cd = "/"
ASSERT(S["DEF"] == null)

//Test dir
S.cd = "/"
var/dir = S.dir
ASSERT(dir ~= list("ABC", "DEF", "notakey", "pathymcpathface", "pie", "pie2"))

//test add
dir += "test/beep"
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", "pathymcpathface", "pie", "pie2"))

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

fdel("savefile.sav")

file("badsavefile.sav") << "hey wait, this isn't json! oh well, better fail miserably and die"

var/savefile/fail
try
fail = new("badsavefile.sav")
catch(var/exception/e)
ASSERT(isnull(fail))
ASSERT(fail == null)
fdel("badsavefile.sav")
52 changes: 52 additions & 0 deletions Content.Tests/DMProject/Tests/Savefile/DatumSaving.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/datum/foo
var/best_map = "pl_upward" // mutated by RunTest(), should save
var/worst_map = "pl_badwater" // same as, should not be saved
var/null_me = "ok" // should save as null

var/tmp/current_map = "yeah" // tmp, should not save
var/const/default_cube = "delete it" // const, should not save

New(args)
proc_call_order_check += list("New")
..()

Read(savefile/F)
proc_call_order_check += list("Read")
..()

Write(savefile/F)
proc_call_order_check += list("Write")
..()

/var/static/proc_call_order_check = list()


/proc/RunTest()
var/savefile/S = new()

var/datum/foo/F = new()
F.best_map = "pl_pier"
F.null_me = null

S["mapdata"] << F

// test the savefile's contents
ASSERT(S["mapdata/.0/type"] == /datum/foo)
ASSERT(S["mapdata/.0/best_map"] == "pl_pier")
ASSERT(S["mapdata/.0/null_me"] == null)
ASSERT(S["mapdata/.0/worst_map"] == null)
ASSERT(S["mapdata/.0/current_map"] == null)
ASSERT(S["mapdata/.0/default_cube"] == null)

var/datum/foo/W
S["mapdata"] >> W

// load test
ASSERT(istype(W))
ASSERT(W != F) //they are equivalent, but not the same datum
ASSERT(W.best_map == "pl_pier")
ASSERT(W.worst_map == "pl_badwater")
ASSERT(W.null_me == null)

ASSERT(proc_call_order_check ~= list("New","Write","New","Read"))

37 changes: 37 additions & 0 deletions Content.Tests/DMProject/Tests/Savefile/ExportText.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/obj/savetest
var/obj/savetest/recurse = null

/proc/RunTest()
var/obj/savetest/O = new() //create a test object
O.name = "test"
//O.recurse = O //TODO

var/savefile/F = new() //create a temporary savefile

F["dir"] = O
F["dir2"] = "object(\".0\")"
F["dir3"] = 1080
F["dir4"] = "the afternoon of the 3rd"
var/savefile/P = new() //nested savefile
P["subsavedir1"] = O
P["subsavedir2"] = "butts"
P["subsavedir3"] = 123

F["dir5"] = P
F["dir6/subdir6"] = 321
F["dir7"] = null
F["dirIcon"] = new /icon()
F["list"] << list("1",2,"three"=3,4, new /datum(), new /datum(), list(1,2,3, new /datum()))

ASSERT(F.dir ~= list("dir","dir2","dir3","dir4","dir5","dir6","dir7","dirIcon","list"))
amylizzle marked this conversation as resolved.
Show resolved Hide resolved
ASSERT(F.ExportText("dir6/subdir6") == ". = 321\n")
ASSERT(F.ExportText("dir6/subdir6/") == ". = 321\n")
ASSERT(F.ExportText("dir6") == "\nsubdir6 = 321\n")
var/list_match = {". = list("1",2,"three" = 3,4,object(".0"),object(".1"),list(1,2,3,object(".2")))\n.0\n\ttype = /datum\n.1\n\ttype = /datum\n.2\n\ttype = /datum\n"}
ASSERT(F.ExportText("list") == list_match)

F.cd = "dir6"
F << "test"
F.cd = "/"
ASSERT(F.ExportText("dir6") == ". = \"test\"\nsubdir6 = 321\n")
ASSERT(F.ExportText("dir6/subdir6/") == ". = 321\n")
44 changes: 44 additions & 0 deletions Content.Tests/DMProject/Tests/Savefile/SaveAndLoad.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/datum/foobar

/proc/RunTest()
var/savefile/S = new("savefile.sav")
var/savefile/S2 = null


// Indexing the object to write/read the savefile
S["ABC"] = 5
ASSERT(S["ABC"] == 5)

S["DEF"] = 10
ASSERT(S["DEF"] == 10)

// test path
S["pathymcpathface"] << /datum/foobar
ASSERT(S["pathymcpathface"] == /datum/foobar)

// test list()
var/list/array = list("3.14159", "pizza")
S["pie"] << array
ASSERT(S["pie"] ~= array)

// test assoc list()
var/list/assoc = list("6.28" = "pizza", "aaaaa" = "bbbbbbb")
S["pie2"] << assoc
ASSERT(S["pie2"] ~= assoc)

S.Flush()

// test loading
//gotta copy it because otherwise we're accessing the cache
fcopy("savefile.sav", "savefile2.sav")
ASSERT(fexists("savefile2.sav"))
S2 = new("savefile2.sav")
ASSERT(S2["ABC"] == 5)
ASSERT(S2["DEF"] == 10)
ASSERT(S2["pathymcpathface"] == /datum/foobar)
ASSERT(S2["pie"] ~= array)
ASSERT(S2["pie2"] ~= assoc)


fdel("savefile.sav")
fdel("savefile2.sav")
30 changes: 30 additions & 0 deletions Content.Tests/DMProject/Tests/Savefile/SequenceRead.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/datum/test_holder
var/test1
var/test2
var/test3
var/test4

/proc/RunTest()
var/savefile/F = new("savtest.sav")
F["savtest1"] = "beep"
F["savtest2"] = "boop"
F["savtest3"] = "berp"
F["savtest4"] = "borp"
del(F)
fcopy("savtest.sav", "savtest2.sav")
var/savefile/F2 = new("savtest2.sav")
var/datum/test_holder/T = new()
T.test1 = F2["savtest1"]
T.test2 = F2["savtest2"]

F2["savtest1"] >> T.test1
F2["savtest2"] >> T.test2
F2["savtest3"] >> T.test3
F2["savtest4"] >> T.test4

ASSERT(T.test1 == "beep")
ASSERT(T.test2 == "boop")
ASSERT(T.test3 == "berp")
ASSERT(T.test4 == "borp")
fdel("savtest.sav")
fdel("savtest2.sav")
10 changes: 0 additions & 10 deletions Content.Tests/DMProject/Tests/Savefile/override_datum.dm

This file was deleted.

1 change: 0 additions & 1 deletion DMCompiler/DM/Builders/DMProcBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,6 @@ public void ProcessStatementInput(DMASTProcStatementInput statementInput) {
_proc.Input(leftRef, rightRef);

_proc.AddLabel(leftEndLabel);
_proc.PopReference(rightRef);
_proc.AddLabel(rightEndLabel);
}

Expand Down
4 changes: 2 additions & 2 deletions DMCompiler/DMStandard/Types/Atoms/Mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

var/client/client
var/key
var/ckey
var/tmp/ckey

var/list/group as opendream_unimplemented
var/tmp/list/group as opendream_unimplemented

var/see_invisible = 0
var/see_infrared = 0 as opendream_unimplemented
Expand Down
10 changes: 5 additions & 5 deletions DMCompiler/DMStandard/Types/Atoms/Movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

var/animate_movement = FORWARD_STEPS as opendream_unimplemented
var/list/locs = null as opendream_unimplemented
var/glide_size
var/glide_size = 0
var/step_size as opendream_unimplemented
var/bound_x as opendream_unimplemented
var/bound_y as opendream_unimplemented
var/bound_width as opendream_unimplemented
var/bound_height as opendream_unimplemented
var/tmp/bound_x as opendream_unimplemented
var/tmp/bound_y as opendream_unimplemented
var/tmp/bound_width as opendream_unimplemented
var/tmp/bound_height as opendream_unimplemented

//Undocumented var. "[x],[y]" or "[x],[y] to [x2],[y2]" based on bound_* vars
var/bounds as opendream_unimplemented
Expand Down
18 changes: 9 additions & 9 deletions DMCompiler/DMStandard/Types/Atoms/_Atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
var/suffix = null as opendream_unimplemented

// The initialization/usage of these lists is handled internally by the runtime
var/list/verbs = null
var/tmp/list/verbs = null
var/list/contents = null
var/list/overlays = null
var/list/underlays = null
var/list/vis_locs = null as opendream_unimplemented
var/tmp/list/vis_locs = null as opendream_unimplemented
var/list/vis_contents = null

var/atom/loc
var/tmp/atom/loc
var/dir = SOUTH
var/x = 0
var/y = 0
var/z = 0
var/tmp/x = 0
var/tmp/y = 0
var/tmp/z = 0
var/pixel_x = 0
var/pixel_y = 0
var/pixel_z = 0 as opendream_unimplemented
Expand Down Expand Up @@ -53,9 +53,9 @@
var/step_x as opendream_unimplemented
var/step_y as opendream_unimplemented
var/render_source
var/mouse_drag_pointer as opendream_unimplemented
var/mouse_drop_pointer as opendream_unimplemented
var/mouse_over_pointer as opendream_unimplemented
var/tmp/mouse_drag_pointer as opendream_unimplemented
var/tmp/mouse_drop_pointer as opendream_unimplemented
var/tmp/mouse_over_pointer as opendream_unimplemented
var/render_target
var/vis_flags as opendream_unimplemented

Expand Down
2 changes: 0 additions & 2 deletions DMCompiler/DMStandard/Types/Datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@
proc/Topic(href, href_list)

proc/Read(savefile/F)
set opendream_unimplemented = TRUE

proc/Write(savefile/F)
set opendream_unimplemented = TRUE
Loading
Loading