ID:154238
 
Hrm. I'm trying to set up a system to permanently track all objects with a unique identifier, though naturally I'd like to avoid instantiating every object that's ever been created every time the world loads up. Would a system for this need anything beyond a counter that gets saved and loaded as the world goes down and up, and is incremented every time a new (well, non-placeholder) object is created (with an identifier based off of the current counter)?
Leftley wrote:
Hrm. I'm trying to set up a system to permanently track all objects with a unique identifier, though naturally I'd like to avoid instantiating every object that's ever been created every time the world loads up. Would a system for this need anything beyond a counter that gets saved and loaded as the world goes down and up, and is incremented every time a new (well, non-placeholder) object is created (with an identifier based off of the current counter)?

Generally not -- my ID tracking system for my MUD takes this to a new level, in that when a given ID is freed up somehow (i.e. the object that formerly owned the ID is permanently destroyed), that ID is added back to the free_IDs list.

When something wants to grab a new ID, it fishes the first one off the free_IDs list. If none is there, it takes the current number off of the counter and increments the counter.

Both the free_IDs list and the counter are saved.


The only advantage to my system in favour of yours is that it allows you to reuse IDs that were committed to the grave, without actually polling the world to see which IDs have or haven't been used. In your case, if ever you made billions upon billions of objects, eventually you'd start getting into floating point numbers, which aren't precisely accurate.
In response to Spuzzum
The only advantage to my system in favour of yours is that it allows you to reuse IDs that were committed to the grave, without actually polling the world to see which IDs have or haven't been used. In your case, if ever you made billions upon billions of objects, eventually you'd start getting into floating point numbers, which aren't precisely accurate.

I think there would be workarounds for this... for one thing, these would be converted to strings for most purposes anyways (for list association), which would involve a different set of limits. Anyways, I'm a bit leery of using a list for freed objects, as such a list could become rather large and BYOND doesn't seem to handle lots of large lists and other such alliterative problems. I could cut down on the number of necessary IDs by not assigning them until they're called for, so generic loot that just gets ignored or sold right away doesn't take up IDs.

Ooops. It just occured to me that I never decided whether to make this a centrally hosted game or player-run server game, and I had been leaning toward the latter. I was toying with the concept of having a character-validation type server anyways, which would mostly be workable with this scheme, or I suppose I could always pull off the clock time and add a randomized tag to mostly eliminate ID overlaps.