| 1212 | //----------------------------------------------------------------------------- |
| 1213 | |
| 1214 | void NetConnection::ghostWriteStartBlock(ResizeBitStream *stream) |
| 1215 | { |
| 1216 | // Ok, writing the start block for the ghosts: |
| 1217 | // here's how it goes. |
| 1218 | // |
| 1219 | // First we record out all the indices and class ids for all the objects |
| 1220 | // This is so when the objects are read in, all the objects are instantiated |
| 1221 | // before they are unpacked. The unpack code may reference other |
| 1222 | // existing ghosts, so we want to make sure that all the ghosts are in the |
| 1223 | // table with the correct pointers before any of the unpacks are called. |
| 1224 | |
| 1225 | stream->write(mGhostingSequence); |
| 1226 | |
| 1227 | // first write out the indices and ids: |
| 1228 | for(U32 i = 0; i < MaxGhostCount; i++) |
| 1229 | { |
| 1230 | if(mLocalGhosts[i]) |
| 1231 | { |
| 1232 | stream->writeFlag(true); |
| 1233 | stream->writeInt(i, GhostIdBitSize); |
| 1234 | stream->writeClassId(mLocalGhosts[i]->getClassId(getNetClassGroup()), NetClassTypeObject, getNetClassGroup()); |
| 1235 | stream->validate(); |
| 1236 | } |
| 1237 | } |
| 1238 | // mark off the end of the ghost list: |
| 1239 | // it would be more space efficient to write out a count of active ghosts followed |
| 1240 | // by index run lengths, but hey, what's a few bits here and there? |
| 1241 | |
| 1242 | stream->writeFlag(false); |
| 1243 | |
| 1244 | // then, for each ghost written into the start block, write the full pack update |
| 1245 | // into the start block. For demos to work properly, packUpdate must |
| 1246 | // be callable from client objects. |
| 1247 | for(U32 i = 0; i < MaxGhostCount; i++) |
| 1248 | { |
| 1249 | if(mLocalGhosts[i]) |
| 1250 | { |
| 1251 | U32 retMask = mLocalGhosts[i]->packUpdate(this, 0xFFFFFFFF, stream); |
| 1252 | if ( retMask != 0 ) mLocalGhosts[i]->setMaskBits( retMask ); |
| 1253 | stream->validate(); |
| 1254 | } |
| 1255 | } |
| 1256 | } |
| 1257 | |
| 1258 | void NetConnection::ghostReadStartBlock(BitStream *stream) |
| 1259 | { |
nothing calls this directly
no test coverage detected