Adds a new function for defining static console fields on NetObjects - addNetworkedField()

This lets you attach a 32 bit netMask to the field, so that when it is changed, it automatically flags the associated bitmasks on the netobject as dirty.

This is to shortcut having to flag certain masks being marked as dirty through protected fields and just simplify/streamline the code.
This commit is contained in:
Areloch 2018-01-16 00:47:53 -06:00
parent 463cd50d0a
commit b0e8a1f032
5 changed files with 167 additions and 2 deletions

View file

@ -41,6 +41,8 @@
#include "core/fileObject.h"
#include "persistence/taml/tamlCustom.h"
#include "sim/netObject.h"
IMPLEMENT_CONOBJECT( SimObject );
// See full description in the new CHM manual
@ -912,6 +914,12 @@ void SimObject::assignFieldsFrom(SimObject *parent)
if((*f->setDataFn)( this, NULL, bufferSecure ) )
Con::setData(f->type, (void *) (((const char *)this) + f->offset), j, 1, &fieldVal, f->table);
if (f->networkMask != 0)
{
NetObject* netObj = static_cast<NetObject*>(this);
netObj->setMaskBits(f->networkMask);
}
}
}
}
@ -988,6 +996,12 @@ void SimObject::setDataField(StringTableEntry slotName, const char *array, const
if(fld->validator)
fld->validator->validateType(this, (void *) (((const char *)this) + fld->offset));
if (fld->networkMask != 0)
{
NetObject* netObj = static_cast<NetObject*>(this);
netObj->setMaskBits(fld->networkMask);
}
onStaticModified( slotName, value );
return;