コード例 #1
0
   void write(NetConnection *ps, BitStream *bstream)
   {
      bstream->writeInt(ghostIndex, NetConnection::GhostIdBitSize);
      if(bstream->writeFlag(validObject))
      {
         S32 classId = object->getClassId(ps->getNetClassGroup());
         bstream->writeClassId(classId, NetClassTypeObject, ps->getNetClassGroup());
#ifdef TORQUE_NET_STATS
         U32 beginSize = bstream->getBitPosition();
#endif
         U32 retMask = object->packUpdate(ps, 0xFFFFFFFF, bstream);
         if ( retMask != 0 ) object->setMaskBits( retMask );
#ifdef TORQUE_NET_STATS
         object->getClassRep()->updateNetStatPack(0xFFFFFFFF, bstream->getBitPosition() - beginSize);
#endif
      }
   }
コード例 #2
0
   void unpack(NetConnection *ps, BitStream *bstream)
   {
      ghostIndex = bstream->readInt(NetConnection::GhostIdBitSize);

      if(bstream->readFlag())
      {
         S32 classId = bstream->readClassId(NetClassTypeObject, ps->getNetClassGroup());
         if(classId == -1)
         {
            ps->setLastError("Invalid packet. (invalid ghost class id)");
            return;
         }
         object = (NetObject *) ConsoleObject::create(ps->getNetClassGroup(), NetClassTypeObject, classId);
         if(!object)
         {
            ps->setLastError("Invalid packet. (failed to created from class id)");
            return;
         }
         object->mNetFlags = NetObject::IsGhost;
         object->mNetIndex = ghostIndex;

#ifdef TORQUE_NET_STATS
         U32 beginSize = bstream->getBitPosition();
#endif
         object->unpackUpdate(ps, bstream);
#ifdef TORQUE_NET_STATS
         object->getClassRep()->updateNetStatUnpack(bstream->getBitPosition() - beginSize);
#endif
         validObject = true;
      }
      else
      {
         object = new NetObject;
         validObject = false;
      }
   }