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

Method activateGhosting

Engine/source/sim/netGhost.cpp:910–1033  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

908}
909
910void NetConnection::activateGhosting()
911{
912 if(!isGhostingFrom())
913 return;
914
915 mGhostingSequence++;
916
917 // iterate through the ghost always objects and InScope them...
918 // also post em all to the other side.
919
920 SimSet* ghostAlwaysSet = Sim::getGhostAlwaysSet();
921
922 SimSet::iterator i;
923
924 AssertFatal((mGhostFreeIndex == 0) && (mGhostZeroUpdateIndex == 0), "Error: ghosts in the ghost list before activate.");
925
926 U32 sz = ghostAlwaysSet->size();
927 S32 j;
928
929 for(j = 0; j < sz; j++)
930 {
931 U32 idx = MaxGhostCount - sz + j;
932 mGhostArray[j] = mGhostRefs + idx;
933 mGhostArray[j]->arrayIndex = j;
934 }
935 for(j = sz; j < MaxGhostCount; j++)
936 {
937 U32 idx = j - sz;
938 mGhostArray[j] = mGhostRefs + idx;
939 mGhostArray[j]->arrayIndex = j;
940 }
941 mScoping = true; // so that objectInScope will work
942 for(i = ghostAlwaysSet->begin(); i != ghostAlwaysSet->end(); i++)
943 {
944 AssertFatal(dynamic_cast<NetObject *>(*i) != NULL, avar("Non NetObject in GhostAlwaysSet: %s", (*i)->getClassName()));
945 NetObject *obj = (NetObject *)(*i);
946 if(obj->mNetFlags.test(NetObject::Ghostable))
947 objectInScope(obj);
948 }
949 // Send the initial ghosting connection message.
950 sendConnectionMessage(GhostAlwaysStarting, mGhostingSequence, ghostAlwaysSet->size());
951
952 // If this is the connection to the local client...
953 if (getLocalClientConnection() == this)
954 {
955 // Get a pointer to the local client.
956 NetConnection* pClient = NetConnection::getConnectionToServer();
957
958 Con::executef("onGhostAlwaysStarted", Con::getIntArg(mGhostZeroUpdateIndex));
959
960 // Set up a buffer for the object send.
961 U8 iBuffer[4096];
962 BitStream mStream(iBuffer, 4096);
963
964 // Iterate through the scope always objects...
965 for (j = mGhostZeroUpdateIndex - 1; j >= 0; j--)
966 {
967 AssertFatal((mGhostArray[j]->flags & GhostInfo::ScopeAlways) != 0, "NetConnection::activateGhosting: Non-scope always in the scope always list.");

Callers 1

gameConnection.cppFile · 0.80

Calls 15

avarFunction · 0.85
executefFunction · 0.85
getIntArgFunction · 0.85
clearCompressionPointMethod · 0.80
getNetClassGroupMethod · 0.80
setGhostAlwaysObjectMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getClassNameMethod · 0.45
testMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected