ID:109218
 
BYOND Version:479
Operating System:Windows 7 Ultimate 64-bit
Web Browser:Firefox 4.0
Applies to:Dream Seeker
Status: Deferred

This issue may be low priority or very difficult to fix, and has been put on the back burner for the time being.
Descriptive Problem Summary:
If you attempt to remove null, "", or 0 from a /savefile's dir, it'll wipe the savefile.

Numbered Steps to Reproduce Problem:
1.) Create or load a savefile.
2.) IF created, populate the savefile.
3.) F.dir -= null
4.) Observe F.dir.len drop from whatever it was to 0.

Code Snippet (if applicable) to Reproduce Problem:
mob/Login()
..()
var/savefile/F = new
F["hi"] << 6
F["s"] << 53
F["lol"] << "LOL"
world << F.dir.len
F.dir -= 0
world << F.dir.len


Expected Results:
Output "3" then "3"

Actual Results:
Outputs "3" then "0"

Does the problem occur:
Every time? Or how often? Every time I remove any of the abovementioned entries.
In other games? I reckon so.
In other user accounts? I reckon so.
On other computers? I reckon so.

When does the problem NOT occur? When you're not removing 0, "", or null.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
I'm pretty sure it's been around for a while.

Workarounds: Proper sanity checks.

I think that was intended behavior maybe? When you look inside a savefile and look at the top, it's blank which means the root of everything is just null, well I wouldn't take my word for it but what possible reason could you have to remove null?
..........
Hey.
What happens if you subtract 0(aka nothing) from A?
Oh hey.
You still get A.
hi5 for logic, ExPixel.
It's blank because it's an empty node. The way savefiles are structured, every entry is given an index, a parent index ("directory index"), a name (key), and data (value). For the root node, the index is 0, the directory index is 0xFFFFFFFF, the key is non-existant and the data is non-existant. That is why the directory structure works. When you 'cd' to a directory in a /savefile, DS (should, really) look strictly at that directory and its children. The root node, having no associated key or value, should not be removed in the process. That being said, having a zero-length name is possible. The following works in DM:

mob/Login()
..()
var/savefile/F = new
F[""] << "Hi There"
F["Hi"] << 5


Removing "" still results in the savefile being cleared. Odds are, it is stopping at the root because it has a zero-length name, but this should not work like that, really. If I wanted to remove the root node, I would delete the savefile.
Super Saiyan X wrote:
What happens if you subtract 0 from A?

You get a type mismatch runtime error.
I did a test myself and have found trying to subtract the directory using any integer or floating point value will kill the savefile (since it removes based on the entry name and not by any numerical value). Basically, it resets the whole file.

However, removing an entry based on string (even if it no longer remains, just as long it has at least 1 character) will not reset the whole file.