Best way to keep track of individual objects?

Everything about development and the OpenMW source code.
Post Reply
Posts: 59
Joined: 17 Jul 2017, 14:45

Best way to keep track of individual objects?

Post by mattwla » 28 Mar 2018, 14:08

Hi all, I've been working on a project based on OpenMW, and I'm wondering the best way to keep track of references that might travel between cells a lot.

I've been messing with AI schedules (engine side not script side), so the NPCs have been travelling to and fro cells a lot more than intended in Morrowind. Keeping track of them is tricky.

Ptrs seem to be the engines de facto way to reference individual objects, but those can easily become outdated when NPCs change cells.
There is a string ID look up, but that only works if that object is the ONLY object with that ID (so I couldn't reference a particular loaf of bread). Also it is slow performance wise

I might make my own sort of class, which I can register an object I want to keep track of, and it keeps track of the object's refnum and homecell (the original cell an object appears in seems to keep track of wherever that object ends up outside of the cell), which could likely be used to quickly find them wherever they end up (so I would call this class and it would make a nice updated ptr when I need it... the question is what to call it with)

but before I do that, was wondering everyone's opinion on the matter?


User avatar
Posts: 1393
Joined: 26 Aug 2011, 02:04

Re: Best way to keep track of individual objects?

Post by Greendogo » 28 Mar 2018, 23:36

My opinion is that not every object should start out as static/global, but that when you do need to reference something that isn't static or global yet, you should be able to, and it should elevate it to something akin to static/global so it takes less time to find it/verify its existence.

When you're done with an object, though, the engine should know when it needs to demote an object so that it isn't clogging up that reference table.

Post Reply