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

Method ghostReadPacket

Engine/source/sim/netGhost.cpp:519–662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519void NetConnection::ghostReadPacket(BitStream *bstream)
520{
521#ifdef TORQUE_DEBUG_NET
522 U32 sum = bstream->readInt(32);
523 AssertISV(sum == DebugChecksum, "Invalid checksum.");
524#endif
525
526 if(!isGhostingTo())
527 return;
528 if(!bstream->readFlag())
529 return;
530
531 S32 idSize;
532 idSize = bstream->readInt( GhostIndexBitSize);
533 idSize += 3;
534
535 // while there's an object waiting...
536 gGhostUpdates = 0;
537
538 while(bstream->readFlag())
539 {
540
541 gGhostUpdates++;
542
543 U32 index;
544 //S32 startPos = bstream->getCurPos();
545 index = (U32) bstream->readInt(idSize);
546 if(bstream->readFlag()) // is this ghost being deleted?
547 {
548 mGhostsActive--;
549 AssertFatal(mLocalGhosts[index] != NULL, "Error, NULL ghost encountered.");
550 mLocalGhosts[index]->deleteObject();
551 mLocalGhosts[index] = NULL;
552 }
553 else
554 {
555 if(!mLocalGhosts[index]) // it's a new ghost... cool
556 {
557 mGhostsActive++;
558 S32 classId = bstream->readClassId(NetClassTypeObject, getNetClassGroup());
559 if(classId == -1)
560 {
561 setLastError("Invalid packet. (invalid new ghost class id)");
562 return;
563 }
564
565 NetObject *obj = (NetObject *) ConsoleObject::create(getNetClassGroup(), NetClassTypeObject, classId);
566 if(!obj)
567 {
568 setLastError("Invalid packet. (failed to create new ghost)");
569 return;
570 }
571 // remove all flags associated with netobject
572 obj->mNetFlags &= ~(BIT(NetObject::MaxNetFlagBit+1)-1);
573 // we're a ghost...
574 obj->mNetFlags |= NetObject::IsGhost;
575
576 // object gets initial update before adding to the manager

Callers

nothing calls this directly

Calls 15

avarFunction · 0.85
readIntMethod · 0.80
readFlagMethod · 0.80
readClassIdMethod · 0.80
getBitPositionMethod · 0.80
updateNetStatUnpackMethod · 0.80
getClassRepMethod · 0.80
deleteObjectMethod · 0.45
getClassIdMethod · 0.45
getClassNameMethod · 0.45
unpackUpdateMethod · 0.45

Tested by

no test coverage detected