Running out of network mask bits with 1.4
by Markus Nuebel · in Torque Game Engine · 12/11/2005 (3:50 am) · 6 replies
Hi guys.
I am seeking a little advice in using and extending network mask bits for the Player object.
Actually our problem is that we are running out of maskbits since 1.4 introduced some new mask bits and cut down the mounted image number to 4.
To visualize the problem, I have listed the network mask bit usage for a stock tge1.4 player object.
As you can see, a stock object is already using 28 of the available 32 network mask bits, what leaves us with only 5 bits for our own usage.
If I recall this correct, 1.4 reintroduced the ExtendedInfoMask, added the ControlMask (I may be wrong here) and cut down the max number of mounted images from 8 to 4.
In our project we do not have the freedom to reduce the number of mounted images, since we already have objects that are using up to 5 mounted images. So we are left with one single bit which is far to less for things like (team, h2h, effect masks..).
We already reused the Shield mask, which is of no use for us, for our own purposes, but this is still not enough.
Since I do not see, what other masks could be reused for game specific needs, I am looking for some suggestions. Has anyone done a complex player implementation/extension with just 5 bits?
-- Markus
I am seeking a little advice in using and extending network mask bits for the Player object.
Actually our problem is that we are running out of maskbits since 1.4 introduced some new mask bits and cut down the mounted image number to 4.
To visualize the problem, I have listed the network mask bit usage for a stock tge1.4 player object.
Stock TGE (1.4)
SceneBase:
ScaleMask = BIT(0), // Bit 0
NextFreeMask = BIT(1) // Bit 1
GameBase
InitialUpdateMask = Parent::NextFreeMask, // Bit 1
DataBlockMask = InitialUpdateMask << 1, // Bit 2
ExtendedInfoMask = DataBlockMask << 1, // Bit 3
ControlMask = ExtendedInfoMask << 1, // Bit 4
NextFreeMask = ControlMask << 1 // Bit 5
ShapeBase
NameMask = Parent::NextFreeMask, // Bit 5
DamageMask = Parent::NextFreeMask << 1, // Bit 6
NoWarpMask = Parent::NextFreeMask << 2, // Bit 7
MountedMask = Parent::NextFreeMask << 3, // Bit 8
CloakMask = Parent::NextFreeMask << 4, // Bit 9
ShieldMask = Parent::NextFreeMask << 5, // Bit 10
InvincibleMask = Parent::NextFreeMask << 6, // Bit 11
SkinMask = Parent::NextFreeMask << 7, // Bit 12
SoundMaskN = Parent::NextFreeMask << 8, ///< Extends + MaxSoundThreads bits
// Bit 13, 14, 15, 16 (MaxSoundThreads default: 4)
ThreadMaskN = SoundMaskN << MaxSoundThreads, ///< Extends + MaxScriptThreads bits
// Bit 17, 18, 19, 20 (MaxScriptThreads default: 4)
ImageMaskN = ThreadMaskN << MaxScriptThreads, ///< Extends + MaxMountedImage bits
// Bit 21, 22, 23, 24 (MaxMountedImages default: 4)
NextFreeMask = ImageMaskN << MaxMountedImages // Bit 25
Player
ActionMask = Parent::NextFreeMask << 0, // Bit 25
MoveMask = Parent::NextFreeMask << 1, // Bit 26
ImpactMask = Parent::NextFreeMask << 2, // Bit 27
NextFreeMask = Parent::NextFreeMask << 3 // Bit 28 = 268435456As you can see, a stock object is already using 28 of the available 32 network mask bits, what leaves us with only 5 bits for our own usage.
If I recall this correct, 1.4 reintroduced the ExtendedInfoMask, added the ControlMask (I may be wrong here) and cut down the max number of mounted images from 8 to 4.
In our project we do not have the freedom to reduce the number of mounted images, since we already have objects that are using up to 5 mounted images. So we are left with one single bit which is far to less for things like (team, h2h, effect masks..).
We already reused the Shield mask, which is of no use for us, for our own purposes, but this is still not enough.
Since I do not see, what other masks could be reused for game specific needs, I am looking for some suggestions. Has anyone done a complex player implementation/extension with just 5 bits?
-- Markus
About the author
#2
We already did this for the ShieldMask. We need the CloakMask since we are fading players and objects in/out during spawn/respawn.
InvincibleMask and SkinMask are something to consider, though.
Besides that, is there a way, to "chain" multiple U32 variables or something like that?
I guess changing the network mask to a long would cause too much problems, since this will affect a lot of source locations.
-- Markus
12/11/2005 (8:04 am)
Thanks for the suggestions James.We already did this for the ShieldMask. We need the CloakMask since we are fading players and objects in/out during spawn/respawn.
InvincibleMask and SkinMask are something to consider, though.
Besides that, is there a way, to "chain" multiple U32 variables or something like that?
I guess changing the network mask to a long would cause too much problems, since this will affect a lot of source locations.
-- Markus
#3
12/11/2005 (8:37 am)
You could change one to a generic player mask, and maintain a seperate maskbit for player itself. The one generic maskbit would be for the network code checks to see if anything is being sent, and the seperate one would just define your various "extended" bits being sent.
#4
12/11/2005 (8:52 am)
Some time ago, In v1.3 I was useing some of the fall recovery bits and some player particle emmiter bits for other things. It may be posible to use some as mask bits??
#5
Using one of the mask bits to transfer my custom network mask that can contains up to 32 of me own bits.
Thanks a lot.
-- Markus
12/11/2005 (10:30 am)
Hey Sebastien, that is a great idea.Using one of the mask bits to transfer my custom network mask that can contains up to 32 of me own bits.
Thanks a lot.
-- Markus
#6
If I was you, I'd think very carefully about what I was trying to get my class to do and reassign dirty bits based on that assessment. You can always have two things tied to a single dirty flag, you just incur a networking overhead. Consider which cases are most common, and add some instrumentation to support your hypothesis. You may find that only a few cases happen, thus allowing you to merge other flags and have them send more data than is needed.
Also consider making more things implicit, like animation states. There's no need to network a bunch of thread & sound state when it's implicit in what you're hitting/doing/etc.
Or you could try to hack in 64bit dirty masks, but understand that that's going to be a hack - it's a lot of states to be sending down the wire.
12/11/2005 (1:59 pm)
Only thing to be aware of here is that you MUST make sure any dirty bits are tracked through the internal ghosting structures, as it keeps track of what's dirty for each connection.If I was you, I'd think very carefully about what I was trying to get my class to do and reassign dirty bits based on that assessment. You can always have two things tied to a single dirty flag, you just incur a networking overhead. Consider which cases are most common, and add some instrumentation to support your hypothesis. You may find that only a few cases happen, thus allowing you to merge other flags and have them send more data than is needed.
Also consider making more things implicit, like animation states. There's no need to network a bunch of thread & sound state when it's implicit in what you're hitting/doing/etc.
Or you could try to hack in 64bit dirty masks, but understand that that's going to be a hack - it's a lot of states to be sending down the wire.
Associate James Urquhart
I would suggest identifying what you require for your player object, and remove unneccesary masks and functionality.
The masks i personally would check are :
CloakMask - The cloaking effect, obviously not needed if you don't want cloaking, although i think it is used for something else...
ShieldMask - The shield effect, when hit by gunfire. Potentially useless if, say, you are cloaked or don't use shields.
InvincibleMask - Sets invincibility effect, which is really just flashing on the screen.
SkinMask - Used for setting the skin name. If you do not use custom skins, you do not need this.
Alternatively, i would go through the mask's and redo them, chaning their names and generalizing their concepts when neccesary.
E.g. CloakMask, ShieldMask, InvincibleMask -> EffectMask.
I hope that helps, at least.