| 1136 | //---------------------------------------------------------------------------- |
| 1137 | |
| 1138 | void 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; |
nothing calls this directly
no test coverage detected