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
is not the best way to check an associative list. Use
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.