MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / packUpdate

Method packUpdate

Engine/source/T3D/projectile.cpp:1344–1399  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1342
1343//--------------------------------------------------------------------------
1344U32 Projectile::packUpdate( NetConnection *con, U32 mask, BitStream *stream )
1345{
1346 U32 retMask = Parent::packUpdate( con, mask, stream );
1347
1348 const bool isInitalUpdate = mask & GameBase::InitialUpdateMask;
1349
1350 // InitialUpdateMask
1351 if ( stream->writeFlag( isInitalUpdate ) )
1352 {
1353 stream->writeRangedU32( mCurrTick, 0, MaxLivingTicks );
1354
1355 if ( mSourceObject.isValid() )
1356 {
1357 // Potentially have to write this to the client, let's make sure it has a
1358 // ghost on the other side...
1359 S32 ghostIndex = con->getGhostIndex( mSourceObject );
1360 if ( stream->writeFlag( ghostIndex != -1 ) )
1361 {
1362 stream->writeRangedU32( U32(ghostIndex),
1363 0,
1364 NetConnection::MaxGhostCount );
1365
1366 stream->writeRangedU32( U32(mSourceObjectSlot),
1367 0,
1368 ShapeBase::MaxMountedImages - 1 );
1369 stream->writeFlag(ignoreSourceTimeout);
1370 }
1371 else
1372 // have not recieved the ghost for the source object yet, try again later
1373 retMask |= GameBase::InitialUpdateMask;
1374 }
1375 else
1376 stream->writeFlag( false );
1377 }
1378
1379 // ExplosionMask
1380 //
1381 // ExplosionMask will be set during the initial update but hidden is
1382 // only true if we have really exploded.
1383 if ( stream->writeFlag( ( mask & ExplosionMask ) && mHasExploded ) )
1384 {
1385 mathWrite(*stream, mExplosionPosition);
1386 mathWrite(*stream, mExplosionNormal);
1387 stream->write(mCollideHitType);
1388 }
1389
1390 // BounceMask
1391 if ( stream->writeFlag( mask & BounceMask ) )
1392 {
1393 // Bounce against dynamic object
1394 mathWrite(*stream, mCurrPosition);
1395 mathWrite(*stream, mCurrVelocity);
1396 }
1397
1398 return retMask;
1399}
1400
1401void Projectile::unpackUpdate(NetConnection* con, BitStream* stream)

Callers

nothing calls this directly

Calls 7

mathWriteFunction · 0.85
writeRangedU32Method · 0.80
getGhostIndexMethod · 0.80
U32Enum · 0.50
writeFlagMethod · 0.45
isValidMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected