1
0
Fork 0

Multiplayer: fix bool transmission when all 0

If all bools in a block are 0 the block would never be transmitted, i.e. fix a bug whereby each block of 0..30 used to need at least one true value to transmit the block.
This commit is contained in:
Richard Harrison 2018-05-13 06:45:10 +02:00
parent d6556f5c94
commit 5fe24f741c

View file

@ -98,9 +98,10 @@ const int V2_PROP_ID_PROTOCOL = 0x10001;
const int V2_PAD_MAGIC = 0x1face002;
/*
* boolean arrays are transmitted in blocks of 30 mapping to a single int.
* boolean arrays are transmitted in blocks of 31 mapping to a single int.
* These parameters define where these are mapped and how they are sent.
* The blocks should be in the same property range (with no other properties inside the range)
* The blocksize is set to 40 to allow for ints being 32 bits, so block 0 will be 0..30 (31 bits)
*/
const int BOOLARRAY_BLOCKSIZE = 40;
@ -1410,11 +1411,9 @@ FGMultiplayMgr::SendMyPosition(const FGExternalMotionData& motionInfo)
break;
}
case TT_BOOLARRAY:
{
if ((*it)->int_value)
{
struct BoolArrayBuffer *boolBuf = nullptr;
if ((*it)->id > BOOLARRAY_START_ID && (*it)->id <= BOOLARRAY_END_ID + BOOLARRAY_BLOCKSIZE)
if ((*it)->id >= BOOLARRAY_START_ID && (*it)->id <= BOOLARRAY_END_ID + BOOLARRAY_BLOCKSIZE)
{
int buffer_block = ((*it)->id - BOOLARRAY_BASE_1) / BOOLARRAY_BLOCKSIZE;
boolBuf = &boolBuffer[buffer_block];
@ -1423,9 +1422,9 @@ FGMultiplayMgr::SendMyPosition(const FGExternalMotionData& motionInfo)
if (boolBuf)
{
int bitidx = (*it)->id - boolBuf->propertyId;
if ((*it)->int_value)
boolBuf->boolValue |= 1 << bitidx;
}
}
break;
}
case simgear::props::INT: