ID:1828389
 
(See the best response by Lummox JR.)
Problem description:

Okay, so my organization system works pretty well, but an issue I've been having involves the updating of the organization, and the list that comes along with the organizations.

mob/var/OrgID=0
var/list/allOrganizations=list()
Organization
New()
bankAccount=new()
orgbounties=new()
.=..()
var
list/orgbounties=list()
Name
ID
color
Description
Account/bankAccount
Rank1="Member"
Rank2="Recruiter"
Rank3="Co Leader"
Rank4="Leader"
proc
OLoad(ID)
var/savefile/F=new("Save/World/Organizations/[ID].sav")
F["name"]>>Name
F["desc"]>>Description
F["id"]>>ID
F["color"]>>color
F["rank1"]>>Rank1
F["rank2"]>>Rank2
F["rank3"]>>Rank3
F["rank4"]>>Rank4
F["bank"]>>bankAccount
OSave()
var/savefile/F = new("Save/World/Organizations/[ID].sav")
F["name"]<<Name
F["desc"]<<Description
F["id"]<<ID
F["color"]<<color
F["rank1"]<<Rank1
F["rank2"]<<Rank2
F["rank3"]<<Rank3
F["rank4"]<<Rank4
F["bank"]<<bankAccount

Here, it shows the variable created for a mobs Organization ID, as well as all the things that come with the organizations datums. The save proc seems to work, though I'm not too sure about the load proc tbh. BUT. I don't believe this is the issue.

When an Organization is created, it'll automatically be saved(OSave), and the organization ID will be added to the list, like this.
allOrganizations["[O.ID]"]=O

O, of course, being the variable used when creating an Organization, to refer to the organization being created.

Here's where I'm having the issue.

if(src.OrgID!=0)
if("[src.OrgID]" in allOrganizations)
src.aorganization=allOrganizations["[src.OrgID]"]
else
if(fexists("Save/World/Organizations/[src.OrgID].sav"))
var/Organization/O=new/Organization()
O.OLoad(src.OrgID)
allOrganizations["[O.ID]"]=O
src.aorganization=allOrganizations["[src.OrgID]"]


This is located in the loading proc. It's called whenever a mob loads their character. Basically, what it does here, is it first checks the allOrganizations list to see if the mobs Org ID has a match for the existing organizations(Only checks if they have an Organization ID that isn't 0).If they do, it'll update their organization with the latest version of their specific organization datum.

If their organization isn't on the list(In case of server shutdown, reboot, etc, anything that would delete the existing list), it's supposed to check and see if their Organization ID matches any of the Organization Datums in the saved folder. If it does, it'll add their organization to the list of allOrganizations, and update their organization with that latest version.

Everything was working fine, but we rebooted. After that reboot, it just stopped working, leading me to believe that once the list is gone, the part where it readds the Organizations to the list isn't working.

Any help is appreciated ;c

For starters,
if("[src.OrgID]" in allOrganizations)

is not the best way to check an associative list. Use
if(allOrganizations["[src.OrgID]"])


However, that is not your problem. Are you certain that src.OrgID is not 0 prior to attempting to load? Check to make certain the branch is being entered.
The code for the check originally was
if(allOrganizations("[src.OrgID]"))

and it said it wasn't a valid proc, so I changed it to that and it seemed to work fine.

src.OrgID is 0, because it doesn't save the clients. When your character is loaded, it returns to its saved value(based on the random organization ID given when creating an organization). After it loads the Org ID, it runs the check for organizations.
That's because it isn't. Note the brackets, not parentheses.
if(allOrganizations["[src.OrgID]"])


Even still, run a check to make certain that the loading branch is entered. Something like
world << "Entered."

or whatever, so that you know it is getting that far.
What exactly do you mean by the loading 'branch'?
Branch is often used as term to mean one of the code paths taken after an if statement. In this case the branch that I mean is under the fexists if statement, although it may be best to check inside the if(src.OrgID !=0) as well.
Ok, so first allow me to mention to you that doing:
Organization
    New()
        bankAccount=new()
        orgbounties=new()  <----
        .=..()
    var
        list/orgbounties=list()   <----- 
is somewhat redundant because you're already initialising the orgbounties var upon definition via '=list()' -it and new are interchangeable in a list's case- so as far as that goes i'd suggest changing it so only one of those assignments remains (you might prefer the init upon a New Org being created).

Anyway, moving onto your issue. I would echo -as per Mo's suggestion- that some well placed debug should enable you to figure out the issue for yourself. By 'branch', what is being referred to can be described as a specific pathway through the code from a specified root level -if you will, i.e:
mob   <---- example 'Tree'
    npc   <--- Npc 'Branch'
        proc/loadSkills()
            if skillfile present   <--- first if statement branch in loadSkills proc branch
                                     of npc branch of mob tree
Hopefully that example helps clarify.

But yeah... I have a question. You're saving and loading the org.ID vals of mobs upon logout/login right? i'd think that was where the issue might be i.e. src.id always being 0, but to be sure that is where having debug messages at the relevant branches would come in handy:

if(src.OrgID!= 0) // Btw, this if-block exists inside a mob[/.../...] path definition right?

world << "This mob's Org ID = [OrgID]!"
if(allOrganizations["[src.OrgID]"])
world << "This Mob's OrgID already has a live reference to it."
[rest of code here]
else
if(fexists(...))
world << "File found: loading..."
[and so on]

Actually Turboskill, what you refer to as a node and I refer to as a branch are not synonymous. Branches are present purely in a matter of code flow. What you call nodes would be a reference to the level of polymorphism, and not deal with the actual processes of the object. Generally speaking, one would not consider a process to be a child of an object type, as only other object types can be children. In same vein, a code branch is executed within the process, and thus is a branch only of the process, and not of the object to which the process belongs.

I suppose that you could call children types branches of the parent type, but I would not confuse this with code branches.
In response to Mightymo
Yeah i think you have a point, i was thinking about it as i've been writing/editing, i think i'll change that around. Also i'd started writing my response and delayed a bit in the middle then posted before the page updated with your more to the point explanation of branches. So just to note i didn't post mine to suggest your explanation was insufficient :P, just didn't wanna waste the effort lol.
In response to Turboskill
Best response
Turboskill wrote:
is somewhat redundant because you're already initialising the orgbounties var upon definition via '=list()' -it and new are interchangeable in a list's case- so as far as that goes i'd suggest changing it so only one of those assignments remains (you might prefer the init upon a New Org being created).

Initializing in New() is preferable, because it doesn't create a nameless init proc.
In response to Lummox JR
Ah yeah, that too.