| 1256 | } |
| 1257 | |
| 1258 | void NetConnection::ghostReadStartBlock(BitStream *stream) |
| 1259 | { |
| 1260 | stream->read(&mGhostingSequence); |
| 1261 | |
| 1262 | // read em back in. |
| 1263 | // first, read in the index/class id, construct the object, and place it in mLocalGhosts[i] |
| 1264 | |
| 1265 | while(stream->readFlag()) |
| 1266 | { |
| 1267 | U32 index = stream->readInt(GhostIdBitSize); |
| 1268 | S32 tag = stream->readClassId(NetClassTypeObject, getNetClassGroup()); |
| 1269 | NetObject *obj = (NetObject *) ConsoleObject::create(getNetClassGroup(), NetClassTypeObject, tag); |
| 1270 | if(!obj) |
| 1271 | { |
| 1272 | setLastError("Invalid packet. (failed to create ghost from demo block)"); |
| 1273 | return; |
| 1274 | } |
| 1275 | obj->mNetFlags = NetObject::IsGhost; |
| 1276 | obj->mNetIndex = index; |
| 1277 | mLocalGhosts[index] = obj; |
| 1278 | } |
| 1279 | |
| 1280 | // now, all the ghosts are in the mLocalGhosts, so we loop |
| 1281 | // through all non-null mLocalGhosts, unpacking the objects |
| 1282 | // as we go: |
| 1283 | |
| 1284 | for(U32 i = 0; i < MaxGhostCount; i++) |
| 1285 | { |
| 1286 | if(mLocalGhosts[i]) |
| 1287 | { |
| 1288 | mLocalGhosts[i]->unpackUpdate(this, stream); |
| 1289 | if(!mLocalGhosts[i]->registerObject()) |
| 1290 | { |
| 1291 | if(mErrorBuffer.isEmpty()) |
| 1292 | setLastError("Invalid packet. (failed to register ghost from demo block)"); |
| 1293 | return; |
| 1294 | } |
| 1295 | addObject(mLocalGhosts[i]); |
| 1296 | } |
| 1297 | } |
| 1298 | // MARKF - TODO - looks like we could have memory leaks here |
| 1299 | // if there are errors. |
| 1300 | } |
nothing calls this directly
no test coverage detected