Game Development Community

Combining netmasks, eg Shield, Cloak, Invincible

by Orion Elenzil · in Torque Game Engine · 07/31/2006 (3:07 pm) · 6 replies

So we're out of netmasks.

what do folks think of just combining a few netmasks thusly:

change this:
NameMask        = Parent::NextFreeMask,
      DamageMask      = Parent::NextFreeMask << 1,
      NoWarpMask      = Parent::NextFreeMask << 2,
      MountedMask     = Parent::NextFreeMask << 3,
      CloakMask       = Parent::NextFreeMask << 4,
      ShieldMask      = Parent::NextFreeMask << 5,
      InvincibleMask  = Parent::NextFreeMask << 6,
      SkinMask        = Parent::NextFreeMask << 7,
      SoundMaskN      = Parent::NextFreeMask << 8,       ///< Extends + MaxSoundThreads bits

to this:
NameMask        = Parent::NextFreeMask,
      DamageMask      = Parent::NextFreeMask << 1,
      NoWarpMask      = Parent::NextFreeMask << 2,
      MountedMask     = Parent::NextFreeMask << 3,
      CloakMask       = Parent::NextFreeMask << 4,
      ShieldMask      = CloakMask,
      InvincibleMask  = CloakMask,
      SkinMask        = Parent::NextFreeMask << 5,
      SoundMaskN      = Parent::NextFreeMask << 6,       ///< Extends + MaxSoundThreads bits

our app doesn't really use cloak, shield, or invincible,
and it seems like all this change will do is make the information for all three be sent whenever any one of them changes.

#1
07/31/2006 (3:55 pm)
If you're not changing skins (or are changing them, but infrequently), lump SKinMask in with cloak, shield and invincible too.

The other thing you could do is reduce SoundMask to 1 bit and use a seperate bitmask for the individual sounds. When any of the sounds change, you'd set SoundMask in the net mask and whatever is relevant in the new mask, and you'd change pack/unpack to use the new mask in addition to SoundMask when it's doing its stuff.

To clarify, it's only important that something gets set in the netmask to cause the netcode to update the object. The format of the data you write is irrelevant ... it's whatever you want it to be. The logic for the masks in pack/unpack comes from the "control" bits you write in it, the source of those bits is irrelevant.

T.
#2
07/31/2006 (5:08 pm)
The stock player class is full of typemasks you will probably never need, especially for your project Orion. Shoot you can probably just remove CloakMask, ShieldMask, and Invicible Mask all together. Just go look up where any of them are being used to see if you ever call any of that funcionality and throw it out if you don't.
#3
07/31/2006 (5:40 pm)
Roger that,
thanks guys.

as it happens i just dialed down MaxSoundThreads and MaxMountedImages,
which gets us four bits to work with before combining those other guys.

Speaking of which,
any idea why it's recommended those guys be powers of two ?
it looks to me like we just get N sounds for N bits, not 2^N sounds for N bits..

MaxSoundThreads =  2,            ///< Should be a power of 2  // oxe 20060731 - why ?
      MaxScriptThreads = 4,            ///< Should be a power of 2
      MaxMountedImages = 2,            ///< Should be a power of 2
#4
07/31/2006 (7:36 pm)
I havent checked, but it might be because it uses the max as a max count to write/readRangedU32 to write the IDs. If that is the case then it not being a power of 2 would cause some wasted bits.

Just a guess, may be totally wrong.
#5
07/31/2006 (8:14 pm)
Mm that's possible. i'll give a look tomorrow.
#6
11/28/2011 (9:20 am)
I was thinking on similar lines but more like using one of those three
as a Flag to check a different group of masks...

So simliar to the Update mask:

if !(lastmask (say Shield) is set)
{
Do Normal Masks
}
else
{
Loop thru my own masks instead
}

Can have another 32 masks and only need to worry about them with your own
stuff without affecting the originals except for the one you take over.
That one needs to be added into the new mask list. This would require
a very simple addition to where any sends/receives occur.

*edit* Yeah I know... OLD Post... *grin* was half asleep in the early morning
when I was reading a post that reffered to this one :)