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

Method writePacketData

Engine/source/T3D/player.cpp:6183–6234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6181//----------------------------------------------------------------------------
6182
6183void Player::writePacketData(GameConnection *connection, BitStream *stream)
6184{
6185 Parent::writePacketData(connection, stream);
6186
6187 stream->writeInt(mState,NumStateBits);
6188 if (stream->writeFlag(mState == RecoverState))
6189 stream->writeInt(mRecoverTicks,PlayerData::RecoverDelayBits);
6190 if (stream->writeFlag(mJumpDelay > 0))
6191 stream->writeInt(mJumpDelay,PlayerData::JumpDelayBits);
6192
6193 Point3F pos;
6194 getTransform().getColumn(3,&pos);
6195 if (stream->writeFlag(!isMounted())) {
6196 // Will get position from mount
6197 stream->setCompressionPoint(pos);
6198 stream->write(pos.x);
6199 stream->write(pos.y);
6200 stream->write(pos.z);
6201 stream->write(mVelocity.x);
6202 stream->write(mVelocity.y);
6203 stream->write(mVelocity.z);
6204 stream->writeInt(mJumpSurfaceLastContact > 15 ? 15 : mJumpSurfaceLastContact, 4);
6205
6206 if (stream->writeFlag(!mAllowSprinting || !mAllowCrouching || !mAllowProne || !mAllowJumping || !mAllowJetJumping || !mAllowSwimming))
6207 {
6208 stream->writeFlag(mAllowJumping);
6209 stream->writeFlag(mAllowJetJumping);
6210 stream->writeFlag(mAllowSprinting);
6211 stream->writeFlag(mAllowCrouching);
6212 stream->writeFlag(mAllowProne);
6213 stream->writeFlag(mAllowSwimming);
6214 }
6215 }
6216 stream->write(mHead.x);
6217 if(stream->writeFlag(mDataBlock->cameraCanBank))
6218 {
6219 // Include mHead.y to allow for camera banking
6220 stream->write(mHead.y);
6221 }
6222 stream->write(mHead.z);
6223 stream->write(mRot.z);
6224
6225 if (mControlObject) {
6226 S32 gIndex = connection->getGhostIndex(mControlObject);
6227 if (stream->writeFlag(gIndex != -1)) {
6228 stream->writeInt(gIndex,NetConnection::GhostIdBitSize);
6229 mControlObject->writePacketData(connection, stream);
6230 }
6231 }
6232 else
6233 stream->writeFlag(false);
6234}
6235
6236
6237void Player::readPacketData(GameConnection *connection, BitStream *stream)

Callers

nothing calls this directly

Calls 6

writeIntMethod · 0.80
getColumnMethod · 0.80
setCompressionPointMethod · 0.80
getGhostIndexMethod · 0.80
writeFlagMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected