| 172 | } |
| 173 | |
| 174 | void NetConnection::eventWritePacket(BitStream *bstream, PacketNotify *notify) |
| 175 | { |
| 176 | #ifdef TORQUE_DEBUG_NET |
| 177 | bstream->writeInt(DebugChecksum, 32); |
| 178 | #endif |
| 179 | |
| 180 | NetEventNote *packQueueHead = NULL, *packQueueTail = NULL; |
| 181 | |
| 182 | while(mUnorderedSendEventQueueHead) |
| 183 | { |
| 184 | if(bstream->isFull()) |
| 185 | break; |
| 186 | // dequeue the first event |
| 187 | NetEventNote *ev = mUnorderedSendEventQueueHead; |
| 188 | mUnorderedSendEventQueueHead = ev->mNextEvent; |
| 189 | #ifdef TORQUE_DEBUG_NET |
| 190 | U32 start = bstream->getCurPos(); |
| 191 | #endif |
| 192 | |
| 193 | bstream->writeFlag(true); |
| 194 | S32 classId = ev->mEvent->getClassId(getNetClassGroup()); |
| 195 | AssertFatal(classId>=0, "NetConnection::eventWritePacket - event not in group!"); |
| 196 | bstream->writeClassId(classId, NetClassTypeEvent, getNetClassGroup()); |
| 197 | |
| 198 | #ifdef TORQUE_NET_STATS |
| 199 | U32 beginSize = bstream->getBitPosition(); |
| 200 | #endif |
| 201 | ev->mEvent->pack(this, bstream); |
| 202 | #ifdef TORQUE_NET_STATS |
| 203 | ev->mEvent->getClassRep()->updateNetStatPack(0, bstream->getBitPosition() - beginSize); |
| 204 | #endif |
| 205 | DEBUG_LOG(("PKLOG %d EVENT %d: %s", getId(), bstream->getBitPosition() - start, ev->mEvent->getDebugName()) ); |
| 206 | |
| 207 | #ifdef TORQUE_DEBUG_NET |
| 208 | bstream->writeInt(classId ^ DebugChecksum, 32); |
| 209 | #endif |
| 210 | // add this event onto the packet queue |
| 211 | ev->mNextEvent = NULL; |
| 212 | if(!packQueueHead) |
| 213 | packQueueHead = ev; |
| 214 | else |
| 215 | packQueueTail->mNextEvent = ev; |
| 216 | packQueueTail = ev; |
| 217 | } |
| 218 | |
| 219 | bstream->writeFlag(false); |
| 220 | S32 prevSeq = -2; |
| 221 | |
| 222 | while(mSendEventQueueHead) |
| 223 | { |
| 224 | if(bstream->isFull()) |
| 225 | break; |
| 226 | |
| 227 | // if the event window is full, stop processing |
| 228 | if(mSendEventQueueHead->mSeqCount > mLastAckedEventSeq + 126) |
| 229 | break; |
| 230 | |
| 231 | // dequeue the first event |
nothing calls this directly
no test coverage detected