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

Method unpack

Engine/source/sim/netGhost.cpp:103–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101 }
102 }
103 void unpack(NetConnection *ps, BitStream *bstream)
104 {
105 ghostIndex = bstream->readInt(NetConnection::GhostIdBitSize);
106
107 if(bstream->readFlag())
108 {
109 S32 classId = bstream->readClassId(NetClassTypeObject, ps->getNetClassGroup());
110 if(classId == -1)
111 {
112 ps->setLastError("Invalid packet. (invalid ghost class id)");
113 return;
114 }
115 object = (NetObject *) ConsoleObject::create(ps->getNetClassGroup(), NetClassTypeObject, classId);
116 if(!object)
117 {
118 ps->setLastError("Invalid packet. (failed to created from class id)");
119 return;
120 }
121 object->mNetFlags = NetObject::IsGhost;
122 object->mNetIndex = ghostIndex;
123
124#ifdef TORQUE_NET_STATS
125 U32 beginSize = bstream->getBitPosition();
126#endif
127 object->unpackUpdate(ps, bstream);
128#ifdef TORQUE_NET_STATS
129 object->getClassRep()->updateNetStatUnpack(bstream->getBitPosition() - beginSize);
130#endif
131 validObject = true;
132 }
133 else
134 {
135 object = new NetObject;
136 validObject = false;
137 }
138 }
139 void process(NetConnection *ps)
140 {
141 Con::executef("onGhostAlwaysObjectReceived");

Callers

nothing calls this directly

Calls 9

readIntMethod · 0.80
readFlagMethod · 0.80
readClassIdMethod · 0.80
getNetClassGroupMethod · 0.80
getBitPositionMethod · 0.80
updateNetStatUnpackMethod · 0.80
getClassRepMethod · 0.80
setLastErrorMethod · 0.45
unpackUpdateMethod · 0.45

Tested by

no test coverage detected