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

Method handleConnectionMessage

Engine/source/sim/netGhost.cpp:837–908  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

835//-----------------------------------------------------------------------------
836
837void NetConnection::handleConnectionMessage(U32 message, U32 sequence, U32 ghostCount)
838{
839 if(( message == SendNextDownloadRequest
840 || message == FileDownloadSizeMessage
841 || message == GhostAlwaysStarting
842 || message == GhostAlwaysDone
843 || message == EndGhosting) && !isGhostingTo())
844 {
845 setLastError("Invalid packet. (not ghosting)");
846 return;
847 }
848
849 S32 i;
850 GhostSave sv;
851 switch(message)
852 {
853 case GhostAlwaysDone:
854 mGhostingSequence = sequence;
855 NetConnection::smGhostAlwaysDone.trigger();
856 // ok, all the ghost always objects are now on the client... but!
857 // it's possible that there were some file load errors...
858 // if so, we need to indicate to the server to restart ghosting, after
859 // we download all the files...
860 sv.ghost = NULL;
861 sv.index = -1;
862 mGhostAlwaysSaveList.push_back(sv);
863 if(mGhostAlwaysSaveList.size() == 1)
864 loadNextGhostAlwaysObject(true);
865 break;
866 case ReadyForNormalGhosts:
867 if(sequence != mGhostingSequence)
868 return;
869 Con::executef(this, "onGhostAlwaysObjectsReceived");
870 Con::printf("Ghost Always objects received.");
871 mGhosting = true;
872 for(i = 0; i < mGhostFreeIndex; i++)
873 {
874 if(mGhostArray[i]->flags & GhostInfo::ScopedEvent)
875 mGhostArray[i]->flags &= ~(GhostInfo::Ghosting | GhostInfo::ScopedEvent);
876 }
877 break;
878 case EndGhosting:
879 onEndGhosting();
880 // just delete all the local ghosts,
881 // and delete all the ghosts in the current save list
882 for(i = 0; i < MaxGhostCount; i++)
883 {
884 if(mLocalGhosts[i])
885 {
886 mLocalGhosts[i]->deleteObject();
887 mLocalGhosts[i] = NULL;
888 }
889 }
890 while(mGhostAlwaysSaveList.size())
891 {
892 delete mGhostAlwaysSaveList[0].ghost;
893 mGhostAlwaysSaveList.pop_front();
894 }

Callers 1

processMethod · 0.45

Calls 8

executefFunction · 0.85
printfFunction · 0.85
getIntArgFunction · 0.85
triggerMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
deleteObjectMethod · 0.45
pop_frontMethod · 0.45

Tested by

no test coverage detected