| 908 | } |
| 909 | |
| 910 | void 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."); |
no test coverage detected