Game Development Community

Where to clear NetObject's Mask Bits

by Huan Li · in Torque 3D Professional · 06/12/2009 (5:27 pm) · 2 replies

I have a lot net tranismition related mask in Player class, I do know there's
enum MaskBits {
      ActionMask   = Parent::NextFreeMask << 0,
      MoveMask     = Parent::NextFreeMask << 1,
      ImpactMask   = Parent::NextFreeMask << 2,
	  /*
	  //[ li-huan codes 06/11/2009 for user-custom action
	  // I don't want to define any more custom MaskBit here, because MaskBit just a 32bit int and i
	  // have too many features to work with this.
	  CustomActionMask   = Parent::NextFreeMask << 3,
	  //]
	  */
      NextFreeMask = Parent::NextFreeMask << 3
};

and I know that just do "setMaskBits(someMaskBit)" in server-side if i want some updates transmited to all clients, and I also know that "static void NetObject::collapseDirtyList()" is about to clear maskbit which i setted.

First question, is maskbit cleared every time NetObject::collapseDirtyList() is called?I see something below in "collapseDirtyList()", what does that do:
if(!obj->isDeleted() && dirtyMask)
      {
         for(GhostInfo *walk = obj->mFirstObjectRef; walk; walk = walk->nextObjectRef)
         {
            U32 orMask = obj->filterMaskBits(dirtyMask,walk->connection);
            if(!walk->updateMask && orMask)
            {
               walk->updateMask = orMask;
               walk->connection->ghostPushNonZero(walk);
            }
            else
			{
               walk->updateMask |= orMask;
			   obj->clearCustomMaskBits();
			}
         }
      }

Second question( this is what i really ask):I defined many features and feature update masks in Player class, when some feature changes the related mask will be set, then packUpdate() and unpackUpdate will work with the feature update masks, But i don't know where to clear the masks I defined. Please notice that we have to make sure that every available clients should get the update data, so i can't clear the mask every time the packUpdate() is called, if i do that, only one client can get the update data.
SO WHERE SHOULD I CLEAR MY MASKS?????

Thanks for any type of help!

#1
06/12/2009 (10:35 pm)
Why not make updateMask a U64? Then you can (hopefully) fit everything in the one mask.
#2
06/13/2009 (1:16 am)
@Ben
after reading your reponse, i think that according to make updateMask a U64, it's better to make the mask a structure(or a class) not only a value, then it'll fit everything.