MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / writePacket

Method writePacket

Engine/source/T3D/gameBase/gameConnection.cpp:1328–1485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1326}
1327
1328void GameConnection::writePacket(BitStream *bstream, PacketNotify *note)
1329{
1330 bstream->clearCompressionPoint();
1331 bstream->clearStringBuffer();
1332
1333 GamePacketNotify *gnote = (GamePacketNotify *) note;
1334
1335 U32 startPos = bstream->getBitPosition();
1336 if (isConnectionToServer())
1337 {
1338 mMoveList->clientWriteMovePacket(bstream);
1339
1340 bstream->writeFlag(mCameraPos == 1);
1341
1342 // if we're recording, we want to make sure that we get periodic updates of the
1343 // control object "just in case" - ie if the math copro is different between the
1344 // recording machine (SIMD vs FPU), we get periodic corrections
1345
1346 bool forceUpdate = false;
1347 if(isRecording())
1348 {
1349 U32 currentTime = Platform::getVirtualMilliseconds();
1350 if(currentTime - mLastControlRequestTime > ControlRequestTime)
1351 {
1352 mLastControlRequestTime = currentTime;
1353 forceUpdate=true;;
1354 }
1355 }
1356 bstream->writeFlag(forceUpdate);
1357
1358 // Control scheme changed?
1359 if(bstream->writeFlag(mUpdateControlScheme))
1360 {
1361 bstream->writeFlag(mAbsoluteRotation);
1362 bstream->writeFlag(mAddYawToAbsRot);
1363 bstream->writeFlag(mAddPitchToAbsRot);
1364 mUpdateControlScheme = false;
1365 }
1366
1367 // first person changed?
1368 if(bstream->writeFlag(mUpdateFirstPerson))
1369 {
1370 bstream->writeFlag(mFirstPerson);
1371 mUpdateFirstPerson = false;
1372 }
1373
1374 // camera fov changed? (server fov resolution is 1 degree)
1375 if(bstream->writeFlag(mUpdateCameraFov))
1376 {
1377 bstream->writeInt(mClamp(S32(mCameraFov), S32(MinCameraFov), S32(MaxCameraFov)), 8);
1378 mUpdateCameraFov = false;
1379 }
1380 DEBUG_LOG(("PKLOG %d CLIENTMOVES: %d", getId(), bstream->getCurPos() - startPos));
1381 }
1382 else
1383 {
1384 mMoveList->serverWriteMovePacket(bstream);
1385

Callers

nothing calls this directly

Calls 15

mClampFunction · 0.85
printfFunction · 0.85
clearCompressionPointMethod · 0.80
clearStringBufferMethod · 0.80
getBitPositionMethod · 0.80
writeIntMethod · 0.80
getCurPosMethod · 0.80
writeFloatMethod · 0.80
isMismatchMethod · 0.80
getClassRepMethod · 0.80
setCompressionPointMethod · 0.80

Tested by

no test coverage detected