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

@ -422,6 +422,57 @@ public:
void removeScopeRef();
void setScopeRegistered(bool flag) { scope_registered = flag; }
bool getScopeRegistered() const { return scope_registered; }
protected:
/// Add a networked field
///
/// A networked field is a regular field but with a bitmask flag associated to it.
/// When the field is set, it automatically triggers a call to setMaskBits with the mask associated to the field
/// in order to streamline simple networking code
/// Register a complex field.
///
/// @param in_pFieldname Name of the field.
/// @param in_fieldType Type of the field. @see ConsoleDynamicTypes
/// @param in_fieldOffset Offset to the field from the start of the class; calculated using the Offset() macro.
/// @param in_elementCount Number of elements in this field. Arrays of elements are assumed to be contiguous in memory.
/// @param in_pFieldDocs Usage string for this field. @see console_autodoc
static void addNetworkedField(const char* in_pFieldname,
const U32 in_fieldType,
const dsize_t in_fieldOffset,
const U32 in_elementCount = 1,
const char* in_pFieldDocs = NULL,
U32 flags = 0,
U32 networkMask = 0);
static void addNetworkedField(const char* in_pFieldname,
const U32 in_fieldType,
const dsize_t in_fieldOffset,
AbstractClassRep::WriteDataNotify in_writeDataFn,
const U32 in_elementCount = 1,
const char* in_pFieldDocs = NULL,
U32 flags = 0,
U32 networkMask = 0);
/// Register a simple field.
///
/// @param in_pFieldname Name of the field.
/// @param in_fieldType Type of the field. @see ConsoleDynamicTypes
/// @param in_fieldOffset Offset to the field from the start of the class; calculated using the Offset() macro.
/// @param in_pFieldDocs Usage string for this field. @see console_autodoc
static void addNetworkedField(const char* in_pFieldname,
const U32 in_fieldType,
const dsize_t in_fieldOffset,
const char* in_pFieldDocs,
U32 flags = 0,
U32 networkMask = 0);
static void addNetworkedField(const char* in_pFieldname,
const U32 in_fieldType,
const dsize_t in_fieldOffset,
AbstractClassRep::WriteDataNotify in_writeDataFn,
const char* in_pFieldDocs,
U32 flags = 0,
U32 networkMask = 0);
};
//-----------------------------------------------------------------------------