pub struct ObjectId(/* private fields */);Expand description
A runtime object handle, as the engine hands them out.
A newtype rather than a bare u32 because the two are not
interchangeable: zero is a perfectly ordinary object id, so a plain
integer field cannot tell “object number zero” from “no object”. Every
type carrying one of these had that bug, defaulting to zero and thereby
claiming an unplaced object referred to whichever object the engine
numbered first.
Default is Self::INVALID, which is what makes the fix structural.
A type holding this can keep #[derive(Default)] and get the right value,
where a bare u32 needs every author to remember.
Implementations§
Source§impl ObjectId
impl ObjectId
Sourcepub const INVALID: Self
pub const INVALID: Self
The engine-wide OBJECT_INVALID placeholder, carried by anything that
has not been assigned a runtime id.
It never lands live. CSWSObject’s base constructor checks for this
value and, on a match, discards it for a freshly allocated unique id.
Every object type inherits that constructor, so this holds for every
ObjectId on the axis: the ten GIT object lists, Ifo’s
Mod_Area_list, and the item entries on creatures, placeables and
stores alike.
The audited absent-value is still this sentinel, because the
replacement is resolution and a typed view projects the file. What
changes is what the value means to whoever reads it back: an
ObjectId of 0x7F000000 says “allocate me one”, not “this is my id”.
A save editor displaying it as an identifier is displaying a request.
Trait Implementations§
Source§impl GffScalar for ObjectId
The mapping lives beside the newtype rather than in a table inside the
derive, which is what lets a view declare an ObjectId field with no edit
anywhere else.
impl GffScalar for ObjectId
The mapping lives beside the newtype rather than in a table inside the
derive, which is what lets a view declare an ObjectId field with no edit
anywhere else.