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

Method eventReadPacket

Engine/source/sim/netEvent.cpp:275–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273}
274
275void NetConnection::eventReadPacket(BitStream *bstream)
276{
277#ifdef TORQUE_DEBUG_NET
278 U32 sum = bstream->readInt(32);
279 AssertISV(sum == DebugChecksum, "Invalid checksum.");
280#endif
281
282 S32 prevSeq = -2;
283 NetEventNote **waitInsert = &mWaitSeqEvents;
284 bool unguaranteedPhase = true;
285
286 while(true)
287 {
288 bool bit = bstream->readFlag();
289 if(unguaranteedPhase && !bit)
290 {
291 unguaranteedPhase = false;
292 bit = bstream->readFlag();
293 }
294 if(!unguaranteedPhase && !bit)
295 break;
296
297 S32 seq = -1;
298
299 if(!unguaranteedPhase) // get the sequence
300 {
301 if(bstream->readFlag())
302 seq = (prevSeq + 1) & 0x7f;
303 else
304 seq = bstream->readInt(7);
305 prevSeq = seq;
306 }
307 S32 classId = bstream->readClassId(NetClassTypeEvent, getNetClassGroup());
308 if(classId == -1)
309 {
310 setLastError("Invalid packet. (bad event class id)");
311 return;
312 }
313 StrongRefPtr<NetEvent> evt = (NetEvent *) ConsoleObject::create(getNetClassGroup(), NetClassTypeEvent, classId);
314 if(evt.isNull())
315 {
316 setLastError("Invalid packet. (bad ghost class id)");
317 return;
318 }
319 AbstractClassRep *rep = evt->getClassRep();
320 if((rep->mNetEventDir == NetEventDirServerToClient && !isConnectionToServer())
321 || (rep->mNetEventDir == NetEventDirClientToServer && isConnectionToServer()) )
322 {
323 setLastError("Invalid Packet. (invalid direction)");
324 return;
325 }
326
327
328 evt->mSourceId = getId();
329#ifdef TORQUE_NET_STATS
330 U32 beginSize = bstream->getBitPosition();
331#endif
332 evt->unpack(this, bstream);

Callers

nothing calls this directly

Calls 15

avarFunction · 0.85
readIntMethod · 0.80
readFlagMethod · 0.80
readClassIdMethod · 0.80
getClassRepMethod · 0.80
getBitPositionMethod · 0.80
updateNetStatUnpackMethod · 0.80
isNullMethod · 0.45
unpackMethod · 0.45
isNotEmptyMethod · 0.45
getClassNameMethod · 0.45
processMethod · 0.45

Tested by

no test coverage detected