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

Method readPacket

Engine/source/T3D/gameBase/gameConnection.cpp:1119–1321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1117//----------------------------------------------------------------------------
1118
1119void GameConnection::readPacket(BitStream *bstream)
1120{
1121 bstream->clearStringBuffer();
1122 bstream->clearCompressionPoint();
1123
1124 if (isConnectionToServer())
1125 {
1126 mMoveList->clientReadMovePacket(bstream);
1127
1128#ifdef TORQUE_AFX_ENABLED
1129 // selected object - do we have a change in status?
1130 if (bstream->readFlag())
1131 {
1132 if (bstream->readFlag())
1133 {
1134 S32 gIndex = bstream->readInt(NetConnection::GhostIdBitSize);
1135 setSelectedObj(static_cast<SceneObject*>(resolveGhost(gIndex)));
1136 }
1137 else
1138 setSelectedObj(NULL);
1139 }
1140#endif
1141
1142 bool hadFlash = mDamageFlash > 0 || mWhiteOut > 0;
1143 mDamageFlash = 0;
1144 mWhiteOut = 0;
1145 if(bstream->readFlag())
1146 {
1147 if(bstream->readFlag())
1148 mDamageFlash = bstream->readFloat(7);
1149 if(bstream->readFlag())
1150 mWhiteOut = bstream->readFloat(7) * 1.5;
1151
1152 if(!hadFlash)
1153 {
1154 // Started a damage flash or white out
1155 onFlash_callback(true);
1156 }
1157 else
1158 {
1159 if(!(mDamageFlash > 0 || mWhiteOut > 0))
1160 {
1161 // Received a zero damage flash and white out.
1162 onFlash_callback(false);
1163 }
1164 }
1165 }
1166 else if(hadFlash)
1167 {
1168 // Catch those cases where both the damage flash and white out are at zero
1169 // on the server but we did not receive an exact zero packet due to
1170 // precision over the network issues. No problem as the flag we just
1171 // read (which is false if we're here) has also told us about the change.
1172 onFlash_callback(false);
1173 }
1174
1175 if ( bstream->readFlag() ) // gIndex != -1
1176 {

Callers

nothing calls this directly

Calls 15

mClampFunction · 0.85
clearStringBufferMethod · 0.80
clearCompressionPointMethod · 0.80
readFlagMethod · 0.80
readIntMethod · 0.80
readFloatMethod · 0.80
getBitPositionMethod · 0.80
updateNetStatReadDataMethod · 0.80
getClassRepMethod · 0.80
setCompressionPointMethod · 0.80
getFunction · 0.50
clientReadMovePacketMethod · 0.45

Tested by

no test coverage detected