Explorar o código

Merge pull request #167 from DavidWyand-GG/issue166-ClientNotLoading

Fix for Issue #166 for Client Not Loading
David Wyand %!s(int64=12) %!d(string=hai) anos
pai
achega
37f44a6341
Modificáronse 1 ficheiros con 9 adicións e 1 borrados
  1. 9 1
      Engine/source/core/dnet.cpp

+ 9 - 1
Engine/source/core/dnet.cpp

@@ -83,7 +83,15 @@ void ConnectionProtocol::buildSendPacketHeader(BitStream *stream, S32 packetType
    stream->writeInt(mLastSeqRecvd & 0x1FF, 9);
    stream->writeInt(mLastSeqRecvd & 0x1FF, 9);
    stream->writeInt(packetType & 0x3, 2);
    stream->writeInt(packetType & 0x3, 2);
    stream->writeInt(ackByteCount & 0x7, 3);
    stream->writeInt(ackByteCount & 0x7, 3);
-   stream->writeInt(mAckMask & (~(0xFFFFFFFF << ackByteCount*8)), ackByteCount * 8);
+   U32 bitmask = ~(0xFFFFFFFF << (ackByteCount*8));
+   if(ackByteCount == 4)
+   {
+      // Performing a bit shift that is the same size as the variable being shifted
+      // is undefined in the C/C++ standard.  Handle that exception here when
+      // ackByteCount*8 == 4*8 == 32
+      bitmask = 0xFFFFFFFF;
+   }
+   stream->writeInt(mAckMask & bitmask, ackByteCount * 8);
 
 
    // if we're resending this header, we can't advance the
    // if we're resending this header, we can't advance the
    // sequence recieved (in case this packet drops and the prev one
    // sequence recieved (in case this packet drops and the prev one