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

Method readPacket

Engine/source/T3D/gameBase/gameConnection.cpp:1138–1326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1136//----------------------------------------------------------------------------
1137
1138void GameConnection::readPacket(BitStream *bstream)
1139{
1140 bstream->clearStringBuffer();
1141 bstream->clearCompressionPoint();
1142
1143 if (isConnectionToServer())
1144 {
1145 mMoveList->clientReadMovePacket(bstream);
1146
1147 bool hadFlash = mDamageFlash > 0 || mWhiteOut > 0;
1148 mDamageFlash = 0;
1149 mWhiteOut = 0;
1150 if(bstream->readFlag())
1151 {
1152 if(bstream->readFlag())
1153 mDamageFlash = bstream->readFloat(7);
1154 if(bstream->readFlag())
1155 mWhiteOut = bstream->readFloat(7) * 1.5;
1156
1157 if(!hadFlash)
1158 {
1159 // Started a damage flash or white out
1160 onFlash_callback(true);
1161 }
1162 else
1163 {
1164 if(!(mDamageFlash > 0 || mWhiteOut > 0))
1165 {
1166 // Received a zero damage flash and white out.
1167 onFlash_callback(false);
1168 }
1169 }
1170 }
1171 else if(hadFlash)
1172 {
1173 // Catch those cases where both the damage flash and white out are at zero
1174 // on the server but we did not receive an exact zero packet due to
1175 // precision over the network issues. No problem as the flag we just
1176 // read (which is false if we're here) has also told us about the change.
1177 onFlash_callback(false);
1178 }
1179
1180 if ( bstream->readFlag() ) // gIndex != -1
1181 {
1182 if ( bstream->readFlag() ) // mMoveList->isMismatch() || mControlForceMismatch
1183 {
1184 // the control object is dirty...so we get an update:
1185 bool callScript = false;
1186 bool controlObjChange = false;
1187 if(mControlObject.isNull())
1188 callScript = true;
1189
1190 S32 gIndex = bstream->readInt(NetConnection::GhostIdBitSize);
1191 GameBase* obj = dynamic_cast<GameBase*>(resolveGhost(gIndex));
1192 if (mControlObject != obj)
1193 {
1194 setControlObject(obj);
1195 controlObjChange = true;

Callers

nothing calls this directly

Calls 15

mClampFunction · 0.85
clearStringBufferMethod · 0.80
clearCompressionPointMethod · 0.80
readFlagMethod · 0.80
readFloatMethod · 0.80
readIntMethod · 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