My situation:
SDR uses its own method of creating, tracking and accessing/modifying customized actor values called "CAVs". It relies on a tiered array system:
Top tier: 1 master array, with an array entry for each active mod, + 1 for dynamic references
2nd tier: Each mod array has an array of all active actors which have their own array entry.
3rd tier: Each actor array has an array of custom actor values which could be numbers, strings, references, or arrays of other data related to the actor.
I have custom functions (either through script or the sdr.dll) that create, access, edit, and delete the data as needed.
I already have a purging script that focuses only on dynamic references to see if they are still in the game or not, and if not they get removed from the arrays.
I already have a script on game save load that checks the active mod list and if any mods are removed, those mod arrays, and thus all of that mod's actor reference's CAVs data, are removed from the master array.
Up until recently, I've been deleting an actor's array of CAVs upon the moment that they die and then remove the token that monitored and updated their CAVs.
However, I am currently experimenting with them continuing to retain their tokens even after death, 0 out appropriate CAVs at the moment of death, but continue to update a small few CAVs that are relevant to detection, and just have the token scripts exit early from the point in which they are determined to be dead.
Doing so resolves a few minor/potential issues that I've come across:
- It's necessary for other actors to be able to detect dead actors.
- Maintaining the CAVs, even if zeroed out, won't result in errors/inconsistencies when detecting dead actors vs. live actors.
- It helps prevent debugging problems in which SDR's detection system will result in Oblivion's default detection result if the token is missing.
- There is also the (rare) possibility that an actor could be resurrected. In which case the token kicks in and the CAVs are updated without having to reinitialize anything or add a new token.
- There is also the possibility that in the future I may want to track and update certain kinds of new CAVs data specific to dead actors (although nothing comes to mind at the moment)
Here's the conundrum:
My concern is that eventually a dead actor will be removed from the game. At that point, the CAVs data is definitely no longer needed, and would just end up being bloat in my opinion.
I can test for this using "IsRefDeleted RefID" and "IsFormValid RefID", which covers persistent and nonpersistent records and is what I use when checking the list of dynamic references.
It seems to me the best approach is to create a purging script that is similar to my script that goes through all the dynamic references, finds any that are marked to be deleted or invalid and then removes those CAVs from the master array.
My concern is how much processing time it would take to roll through all of the actor records stored in CAVs. If someone has been playing for a long time with a heavy mod load, there could be thousands of active actor records to go through.
One thought I had was to create a "Dead Tracker" master array that is similar to the CAVs master array:
Tier one: master array, with a list of active mods
Tier two: mod array, with a list of dead references
Whenever someone dies, they are added to the "Dead Tracker". Then, whenever a "purge" check is made, SDR rolls through the list of dead actors, and if IsRefDeleted Ref == 1 or IsFormValid Ref == 0, it removes the CAVs data from the master and then removes the actor from the "Dead Tracker". I'm thinking that would be the most efficient method.
The next question is to determine how often to run a purge check. I run the dynamic reference purge check fairly regularly: once every five minutes of active game play and once every time the game is saved. Presumably, running a "dead purge" wouldn't take too long, and I could have it run right before the dynamic references check.
------------------
Feedback welcome!