• Hi Guest!

    We are extremely excited to announce the release of our first Beta for VaM2, the next generation of Virt-A-Mate which is currently in development.
    To participate in the Beta, a subscription to the Entertainer or Creator Tier is required. Once subscribed, download instructions can be found here.

    Click here for information and guides regarding the VaM2 beta. Join our Discord server for more announcements and community discussion about VaM2.

Fixed (1.20.1.6) GetAtomUIDs weirdness

MacGruber

Invaluable member
Developer
Wiki Contributor
Featured Contributor
Joined
May 11, 2020
Messages
1,689
Solutions
93
Reactions
3,332
I stumbled across an issue with SuperController.GetAtomUIDs(). The implementation currently looks like this:
C#:
public List<string> GetAtomUIDs()
{
    if (showHiddenAtoms)
    {
        return sortedAtomUIDs;
    }
    if (sortAtomUIDs)
    {
        return visibleAtomUIDs;
    }
    return atomUIDs;
}
Since sortAtomUIDs seems to be always true, you might only get the visible atoms. However, this is called in cases where you would want ALL atoms. For example SuperController.RenameAtom() is calling this, which can result in sending the OLD list of atoms out to anyone listening to OnAtomUIDsChanged, because visibleAtomUIDs was not yet updated at that point.

Currently, in my plugin I came up with a workaround:
C#:
private List<string> GetAllAtomUIDs()
{
    // working around VaM weirdness not returning hidden atoms
    SuperController sc = SuperController.singleton;
    bool wasSorted = sc.sortAtomUIDs;
    sc.sortAtomUIDs = false;
    List<string> atomUIDs = sc.GetAtomUIDs();
    sc.sortAtomUIDs = wasSorted;           
    return atomUIDs;
}

However, to allow us coders to keep our sanity, my suggestion would be to have GetAtomUIDs() just always return ALL atoms, either sortedAtomUIDs or atomUIDs. And then have a second method GetVisibleAtomUIDs() to make clear what you get.

@Acid Bubbles I think this is what is causing the issue with atom cloning in your Keybindings plugin :)
 
Yeah you are right - in general this function should return all atom uids sorted. I need to make another function for the few places I actually use this and need it to return only visible atom uids. And you are right there are several internal bugs caused by this internally.
 
@meshedvr Great! Can give a vague ETA for the release containing this fix? Days, weeks or months?
I want to release a new version of Life today or tomorrow and need to know whether or not to use above workaround. Can I assume the workaround will keep working with the new version?
 
Release will likely be sometime next week. Almost finished it before the holiday break, but decided not to rush it.
 
Oh and yes your workaround will still work.

This is the new code for the function:

Code:
    public List<string> GetAtomUIDs() {
        if (sortAtomUIDs) {
            return sortedAtomUIDs;
        } else {
            return atomUIDs;
        }
    }
 
Back
Top Bottom