Browse Source

Merge default into minor

--HG--
branch : minor
Bart van Strien 9 years ago
parent
commit
db8e7a7670

+ 17 - 0
changes.txt

@@ -1,3 +1,20 @@
+LOVE 0.10.2 [Super Toast]
+-------------------------
+
+Released: N/A
+
+  * Added lovec.exe in Windows. It is the same as love.exe but built with the Console subsystem, so it always uses or provides a console.
+
+  * Fixed os.execute always returning -1 on Linux.
+  * Fixed the video decoding thread to not do any work when there are no videos to decode.
+  * Fixed stencils inside Canvases on some OpenGL ES 2 devices.
+  * Fixed love.window.setMode crashing when called with a Canvas active.
+  * Fixed gamma correction of ImageFonts and BMFonts with colored images.
+  * Fixed the default shader improperly applying gamma correction to per-vertex colors when gamma correction is requested but not supported on OpenGL ES.
+
+  * Improved performance of Channel methods by roughly 2x in many cases.
+
+
 LOVE 0.10.1 [Super Toast]
 LOVE 0.10.1 [Super Toast]
 -------------------------
 -------------------------
 
 

+ 14 - 0
src/libraries/enet/libenet/ChangeLog

@@ -1,3 +1,17 @@
+* use getaddrinfo and getnameinfo where available
+
+ENet 1.3.13 (April 30, 2015):
+
+* miscellaneous bug fixes
+* added premake and cmake support
+* miscellaneous documentation cleanups
+
+ENet 1.3.12 (April 24, 2014):
+
+* added maximumPacketSize and maximumWaitingData fields to ENetHost to limit the amount of 
+data waiting to be delivered on a peer (beware that the default maximumPacketSize is
+32MB and should be set higher if desired as should maximumWaitingData)
+
 ENet 1.3.11 (December 26, 2013):
 ENet 1.3.11 (December 26, 2013):
 
 
 * allow an ENetHost to connect to itself
 * allow an ENetHost to connect to itself

+ 1 - 1
src/libraries/enet/libenet/LICENSE

@@ -1,4 +1,4 @@
-Copyright (c) 2002-2013 Lee Salzman
+Copyright (c) 2002-2016 Lee Salzman
 
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 
 

+ 2 - 0
src/libraries/enet/libenet/host.c

@@ -100,6 +100,8 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
     host -> connectedPeers = 0;
     host -> connectedPeers = 0;
     host -> bandwidthLimitedPeers = 0;
     host -> bandwidthLimitedPeers = 0;
     host -> duplicatePeers = ENET_PROTOCOL_MAXIMUM_PEER_ID;
     host -> duplicatePeers = ENET_PROTOCOL_MAXIMUM_PEER_ID;
+    host -> maximumPacketSize = ENET_HOST_DEFAULT_MAXIMUM_PACKET_SIZE;
+    host -> maximumWaitingData = ENET_HOST_DEFAULT_MAXIMUM_WAITING_DATA;
 
 
     host -> compressor.context = NULL;
     host -> compressor.context = NULL;
     host -> compressor.compress = NULL;
     host -> compressor.compress = NULL;

+ 14 - 5
src/libraries/enet/libenet/include/enet/enet.h

@@ -25,7 +25,7 @@ extern "C"
 
 
 #define ENET_VERSION_MAJOR 1
 #define ENET_VERSION_MAJOR 1
 #define ENET_VERSION_MINOR 3
 #define ENET_VERSION_MINOR 3
-#define ENET_VERSION_PATCH 11
+#define ENET_VERSION_PATCH 13
 #define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch))
 #define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch))
 #define ENET_VERSION_GET_MAJOR(version) (((version)>>16)&0xFF)
 #define ENET_VERSION_GET_MAJOR(version) (((version)>>16)&0xFF)
 #define ENET_VERSION_GET_MINOR(version) (((version)>>8)&0xFF)
 #define ENET_VERSION_GET_MINOR(version) (((version)>>8)&0xFF)
@@ -138,7 +138,11 @@ typedef void (ENET_CALLBACK * ENetPacketFreeCallback) (struct _ENetPacket *);
  *    (not supported for reliable packets)
  *    (not supported for reliable packets)
  *
  *
  *    ENET_PACKET_FLAG_NO_ALLOCATE - packet will not allocate data, and user must supply it instead
  *    ENET_PACKET_FLAG_NO_ALLOCATE - packet will not allocate data, and user must supply it instead
- 
+ *
+ *    ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT - packet will be fragmented using unreliable
+ *    (instead of reliable) sends if it exceeds the MTU
+ *
+ *    ENET_PACKET_FLAG_SENT - whether the packet has been sent from all queues it has been entered into
    @sa ENetPacketFlag
    @sa ENetPacketFlag
  */
  */
 typedef struct _ENetPacket
 typedef struct _ENetPacket
@@ -209,6 +213,8 @@ enum
    ENET_HOST_SEND_BUFFER_SIZE             = 256 * 1024,
    ENET_HOST_SEND_BUFFER_SIZE             = 256 * 1024,
    ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL  = 1000,
    ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL  = 1000,
    ENET_HOST_DEFAULT_MTU                  = 1400,
    ENET_HOST_DEFAULT_MTU                  = 1400,
+   ENET_HOST_DEFAULT_MAXIMUM_PACKET_SIZE  = 32 * 1024 * 1024,
+   ENET_HOST_DEFAULT_MAXIMUM_WAITING_DATA = 32 * 1024 * 1024,
 
 
    ENET_PEER_DEFAULT_ROUND_TRIP_TIME      = 500,
    ENET_PEER_DEFAULT_ROUND_TRIP_TIME      = 500,
    ENET_PEER_DEFAULT_PACKET_THROTTLE      = 32,
    ENET_PEER_DEFAULT_PACKET_THROTTLE      = 32,
@@ -310,6 +316,7 @@ typedef struct _ENetPeer
    enet_uint16   outgoingUnsequencedGroup;
    enet_uint16   outgoingUnsequencedGroup;
    enet_uint32   unsequencedWindow [ENET_PEER_UNSEQUENCED_WINDOW_SIZE / 32]; 
    enet_uint32   unsequencedWindow [ENET_PEER_UNSEQUENCED_WINDOW_SIZE / 32]; 
    enet_uint32   eventData;
    enet_uint32   eventData;
+   size_t        totalWaitingData;
 } ENetPeer;
 } ENetPeer;
 
 
 /** An ENet packet compressor for compressing UDP packets before socket sends or receives.
 /** An ENet packet compressor for compressing UDP packets before socket sends or receives.
@@ -384,6 +391,8 @@ typedef struct _ENetHost
    size_t               connectedPeers;
    size_t               connectedPeers;
    size_t               bandwidthLimitedPeers;
    size_t               bandwidthLimitedPeers;
    size_t               duplicatePeers;              /**< optional number of allowed peers from duplicate IPs, defaults to ENET_PROTOCOL_MAXIMUM_PEER_ID */
    size_t               duplicatePeers;              /**< optional number of allowed peers from duplicate IPs, defaults to ENET_PROTOCOL_MAXIMUM_PEER_ID */
+   size_t               maximumPacketSize;           /**< the maximum allowable packet size that may be sent or received on a peer */
+   size_t               maximumWaitingData;          /**< the maximum aggregate amount of buffer space a peer may use waiting for packets to be delivered */
 } ENetHost;
 } ENetHost;
 
 
 /**
 /**
@@ -446,7 +455,7 @@ ENET_API int enet_initialize (void);
   Initializes ENet globally and supplies user-overridden callbacks. Must be called prior to using any functions in ENet. Do not use enet_initialize() if you use this variant. Make sure the ENetCallbacks structure is zeroed out so that any additional callbacks added in future versions will be properly ignored.
   Initializes ENet globally and supplies user-overridden callbacks. Must be called prior to using any functions in ENet. Do not use enet_initialize() if you use this variant. Make sure the ENetCallbacks structure is zeroed out so that any additional callbacks added in future versions will be properly ignored.
 
 
   @param version the constant ENET_VERSION should be supplied so ENet knows which version of ENetCallbacks struct to use
   @param version the constant ENET_VERSION should be supplied so ENet knows which version of ENetCallbacks struct to use
-  @param inits user-overriden callbacks where any NULL callbacks will use ENet's defaults
+  @param inits user-overridden callbacks where any NULL callbacks will use ENet's defaults
   @returns 0 on success, < 0 on failure
   @returns 0 on success, < 0 on failure
 */
 */
 ENET_API int enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits);
 ENET_API int enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits);
@@ -510,7 +519,7 @@ ENET_API int        enet_socketset_select (ENetSocket, ENetSocketSet *, ENetSock
 */
 */
 ENET_API int enet_address_set_host (ENetAddress * address, const char * hostName);
 ENET_API int enet_address_set_host (ENetAddress * address, const char * hostName);
 
 
-/** Gives the printable form of the ip address specified in the address parameter.
+/** Gives the printable form of the IP address specified in the address parameter.
     @param address    address printed
     @param address    address printed
     @param hostName   destination for name, must not be NULL
     @param hostName   destination for name, must not be NULL
     @param nameLength maximum length of hostName.
     @param nameLength maximum length of hostName.
@@ -565,7 +574,7 @@ extern int                   enet_peer_throttle (ENetPeer *, enet_uint32);
 extern void                  enet_peer_reset_queues (ENetPeer *);
 extern void                  enet_peer_reset_queues (ENetPeer *);
 extern void                  enet_peer_setup_outgoing_command (ENetPeer *, ENetOutgoingCommand *);
 extern void                  enet_peer_setup_outgoing_command (ENetPeer *, ENetOutgoingCommand *);
 extern ENetOutgoingCommand * enet_peer_queue_outgoing_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32, enet_uint16);
 extern ENetOutgoingCommand * enet_peer_queue_outgoing_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32, enet_uint16);
-extern ENetIncomingCommand * enet_peer_queue_incoming_command (ENetPeer *, const ENetProtocol *, ENetPacket *, enet_uint32);
+extern ENetIncomingCommand * enet_peer_queue_incoming_command (ENetPeer *, const ENetProtocol *, const void *, size_t, enet_uint32, enet_uint32);
 extern ENetAcknowledgement * enet_peer_queue_acknowledgement (ENetPeer *, const ENetProtocol *, enet_uint16);
 extern ENetAcknowledgement * enet_peer_queue_acknowledgement (ENetPeer *, const ENetProtocol *, enet_uint16);
 extern void                  enet_peer_dispatch_incoming_unreliable_commands (ENetPeer *, ENetChannel *);
 extern void                  enet_peer_dispatch_incoming_unreliable_commands (ENetPeer *, ENetChannel *);
 extern void                  enet_peer_dispatch_incoming_reliable_commands (ENetPeer *, ENetChannel *);
 extern void                  enet_peer_dispatch_incoming_reliable_commands (ENetPeer *, ENetChannel *);

+ 0 - 1
src/libraries/enet/libenet/include/enet/protocol.h

@@ -17,7 +17,6 @@ enum
    ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT   = 1,
    ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT   = 1,
    ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT   = 255,
    ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT   = 255,
    ENET_PROTOCOL_MAXIMUM_PEER_ID         = 0xFFF,
    ENET_PROTOCOL_MAXIMUM_PEER_ID         = 0xFFF,
-   ENET_PROTOCOL_MAXIMUM_PACKET_SIZE     = 1024 * 1024 * 1024,
    ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT  = 1024 * 1024
    ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT  = 1024 * 1024
 };
 };
 
 

+ 0 - 1
src/libraries/enet/libenet/include/enet/win32.h

@@ -7,7 +7,6 @@
 
 
 #ifdef _MSC_VER
 #ifdef _MSC_VER
 #ifdef ENET_BUILDING_LIB
 #ifdef ENET_BUILDING_LIB
-#pragma warning (disable: 4996) // 'strncpy' was declared deprecated
 #pragma warning (disable: 4267) // size_t to int conversion
 #pragma warning (disable: 4267) // size_t to int conversion
 #pragma warning (disable: 4244) // 64bit to 32bit int
 #pragma warning (disable: 4244) // 64bit to 32bit int
 #pragma warning (disable: 4018) // signed/unsigned mismatch
 #pragma warning (disable: 4018) // signed/unsigned mismatch

+ 1 - 1
src/libraries/enet/libenet/packet.c

@@ -11,7 +11,7 @@
 */
 */
 
 
 /** Creates a packet that may be sent to a peer.
 /** Creates a packet that may be sent to a peer.
-    @param dataContents initial contents of the packet's data; the packet's data will remain uninitialized if dataContents is NULL.
+    @param data         initial contents of the packet's data; the packet's data will remain uninitialized if data is NULL.
     @param dataLength   size of the data allocated for this packet
     @param dataLength   size of the data allocated for this packet
     @param flags        flags for this packet as described for the ENetPacket structure.
     @param flags        flags for this packet as described for the ENetPacket structure.
     @returns the packet on success, NULL on failure
     @returns the packet on success, NULL on failure

+ 28 - 13
src/libraries/enet/libenet/peer.c

@@ -105,7 +105,7 @@ enet_peer_send (ENetPeer * peer, enet_uint8 channelID, ENetPacket * packet)
 
 
    if (peer -> state != ENET_PEER_STATE_CONNECTED ||
    if (peer -> state != ENET_PEER_STATE_CONNECTED ||
        channelID >= peer -> channelCount ||
        channelID >= peer -> channelCount ||
-       packet -> dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE)
+       packet -> dataLength > peer -> host -> maximumPacketSize)
      return -1;
      return -1;
 
 
    fragmentLength = peer -> mtu - sizeof (ENetProtocolHeader) - sizeof (ENetProtocolSendFragment);
    fragmentLength = peer -> mtu - sizeof (ENetProtocolHeader) - sizeof (ENetProtocolSendFragment);
@@ -241,6 +241,8 @@ enet_peer_receive (ENetPeer * peer, enet_uint8 * channelID)
 
 
    enet_free (incomingCommand);
    enet_free (incomingCommand);
 
 
+   peer -> totalWaitingData -= packet -> dataLength;
+
    return packet;
    return packet;
 }
 }
 
 
@@ -415,6 +417,7 @@ enet_peer_reset (ENetPeer * peer)
     peer -> incomingUnsequencedGroup = 0;
     peer -> incomingUnsequencedGroup = 0;
     peer -> outgoingUnsequencedGroup = 0;
     peer -> outgoingUnsequencedGroup = 0;
     peer -> eventData = 0;
     peer -> eventData = 0;
+    peer -> totalWaitingData = 0;
 
 
     memset (peer -> unsequencedWindow, 0, sizeof (peer -> unsequencedWindow));
     memset (peer -> unsequencedWindow, 0, sizeof (peer -> unsequencedWindow));
     
     
@@ -424,7 +427,7 @@ enet_peer_reset (ENetPeer * peer)
 /** Sends a ping request to a peer.
 /** Sends a ping request to a peer.
     @param peer destination for the ping request
     @param peer destination for the ping request
     @remarks ping requests factor into the mean round trip time as designated by the 
     @remarks ping requests factor into the mean round trip time as designated by the 
-    roundTripTime field in the ENetPeer structure.  Enet automatically pings all connected
+    roundTripTime field in the ENetPeer structure.  ENet automatically pings all connected
     peers at regular intervals, however, this function may be called to ensure more
     peers at regular intervals, however, this function may be called to ensure more
     frequent ping requests.
     frequent ping requests.
 */
 */
@@ -486,7 +489,7 @@ enet_peer_timeout (ENetPeer * peer, enet_uint32 timeoutLimit, enet_uint32 timeou
     @param peer peer to disconnect
     @param peer peer to disconnect
     @param data data describing the disconnection
     @param data data describing the disconnection
     @remarks No ENET_EVENT_DISCONNECT event will be generated. The foreign peer is not
     @remarks No ENET_EVENT_DISCONNECT event will be generated. The foreign peer is not
-    guarenteed to receive the disconnect notification, and is reset immediately upon
+    guaranteed to receive the disconnect notification, and is reset immediately upon
     return from this function.
     return from this function.
 */
 */
 void
 void
@@ -818,7 +821,7 @@ enet_peer_dispatch_incoming_reliable_commands (ENetPeer * peer, ENetChannel * ch
 }
 }
 
 
 ENetIncomingCommand *
 ENetIncomingCommand *
-enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, ENetPacket * packet, enet_uint32 fragmentCount)
+enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command, const void * data, size_t dataLength, enet_uint32 flags, enet_uint32 fragmentCount)
 {
 {
     static ENetIncomingCommand dummyCommand;
     static ENetIncomingCommand dummyCommand;
 
 
@@ -827,9 +830,10 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
     enet_uint16 reliableWindow, currentWindow;
     enet_uint16 reliableWindow, currentWindow;
     ENetIncomingCommand * incomingCommand;
     ENetIncomingCommand * incomingCommand;
     ENetListIterator currentCommand;
     ENetListIterator currentCommand;
+    ENetPacket * packet = NULL;
 
 
     if (peer -> state == ENET_PEER_STATE_DISCONNECT_LATER)
     if (peer -> state == ENET_PEER_STATE_DISCONNECT_LATER)
-      goto freePacket;
+      goto discardCommand;
 
 
     if ((command -> header.command & ENET_PROTOCOL_COMMAND_MASK) != ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED)
     if ((command -> header.command & ENET_PROTOCOL_COMMAND_MASK) != ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED)
     {
     {
@@ -841,7 +845,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
            reliableWindow += ENET_PEER_RELIABLE_WINDOWS;
            reliableWindow += ENET_PEER_RELIABLE_WINDOWS;
 
 
         if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS - 1)
         if (reliableWindow < currentWindow || reliableWindow >= currentWindow + ENET_PEER_FREE_RELIABLE_WINDOWS - 1)
-          goto freePacket;
+          goto discardCommand;
     }
     }
                     
                     
     switch (command -> header.command & ENET_PROTOCOL_COMMAND_MASK)
     switch (command -> header.command & ENET_PROTOCOL_COMMAND_MASK)
@@ -849,7 +853,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
     case ENET_PROTOCOL_COMMAND_SEND_FRAGMENT:
     case ENET_PROTOCOL_COMMAND_SEND_FRAGMENT:
     case ENET_PROTOCOL_COMMAND_SEND_RELIABLE:
     case ENET_PROTOCOL_COMMAND_SEND_RELIABLE:
        if (reliableSequenceNumber == channel -> incomingReliableSequenceNumber)
        if (reliableSequenceNumber == channel -> incomingReliableSequenceNumber)
-         goto freePacket;
+         goto discardCommand;
        
        
        for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingReliableCommands));
        for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingReliableCommands));
             currentCommand != enet_list_end (& channel -> incomingReliableCommands);
             currentCommand != enet_list_end (& channel -> incomingReliableCommands);
@@ -871,7 +875,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
              if (incomingCommand -> reliableSequenceNumber < reliableSequenceNumber)
              if (incomingCommand -> reliableSequenceNumber < reliableSequenceNumber)
                break;
                break;
 
 
-             goto freePacket;
+             goto discardCommand;
           }
           }
        }
        }
        break;
        break;
@@ -882,7 +886,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
 
 
        if (reliableSequenceNumber == channel -> incomingReliableSequenceNumber && 
        if (reliableSequenceNumber == channel -> incomingReliableSequenceNumber && 
            unreliableSequenceNumber <= channel -> incomingUnreliableSequenceNumber)
            unreliableSequenceNumber <= channel -> incomingUnreliableSequenceNumber)
-         goto freePacket;
+         goto discardCommand;
 
 
        for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingUnreliableCommands));
        for (currentCommand = enet_list_previous (enet_list_end (& channel -> incomingUnreliableCommands));
             currentCommand != enet_list_end (& channel -> incomingUnreliableCommands);
             currentCommand != enet_list_end (& channel -> incomingUnreliableCommands);
@@ -913,7 +917,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
              if (incomingCommand -> unreliableSequenceNumber < unreliableSequenceNumber)
              if (incomingCommand -> unreliableSequenceNumber < unreliableSequenceNumber)
                break;
                break;
 
 
-             goto freePacket;
+             goto discardCommand;
           }
           }
        }
        }
        break;
        break;
@@ -923,9 +927,16 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
        break;
        break;
 
 
     default:
     default:
-       goto freePacket;
+       goto discardCommand;
     }
     }
 
 
+    if (peer -> totalWaitingData >= peer -> host -> maximumWaitingData)
+      goto notifyError;
+
+    packet = enet_packet_create (data, dataLength, flags);
+    if (packet == NULL)
+      goto notifyError;
+
     incomingCommand = (ENetIncomingCommand *) enet_malloc (sizeof (ENetIncomingCommand));
     incomingCommand = (ENetIncomingCommand *) enet_malloc (sizeof (ENetIncomingCommand));
     if (incomingCommand == NULL)
     if (incomingCommand == NULL)
       goto notifyError;
       goto notifyError;
@@ -952,7 +963,11 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
     }
     }
 
 
     if (packet != NULL)
     if (packet != NULL)
-      ++ packet -> referenceCount;
+    {
+       ++ packet -> referenceCount;
+      
+       peer -> totalWaitingData += packet -> dataLength;
+    }
 
 
     enet_list_insert (enet_list_next (currentCommand), incomingCommand);
     enet_list_insert (enet_list_next (currentCommand), incomingCommand);
 
 
@@ -970,7 +985,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
 
 
     return incomingCommand;
     return incomingCommand;
 
 
-freePacket:
+discardCommand:
     if (fragmentCount > 0)
     if (fragmentCount > 0)
       goto notifyError;
       goto notifyError;
 
 

+ 23 - 36
src/libraries/enet/libenet/protocol.c

@@ -424,7 +424,6 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet
 static int
 static int
 enet_protocol_handle_send_reliable (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData)
 enet_protocol_handle_send_reliable (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData)
 {
 {
-    ENetPacket * packet;
     size_t dataLength;
     size_t dataLength;
 
 
     if (command -> header.channelID >= peer -> channelCount ||
     if (command -> header.channelID >= peer -> channelCount ||
@@ -433,16 +432,12 @@ enet_protocol_handle_send_reliable (ENetHost * host, ENetPeer * peer, const ENet
 
 
     dataLength = ENET_NET_TO_HOST_16 (command -> sendReliable.dataLength);
     dataLength = ENET_NET_TO_HOST_16 (command -> sendReliable.dataLength);
     * currentData += dataLength;
     * currentData += dataLength;
-    if (dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
+    if (dataLength > host -> maximumPacketSize ||
         * currentData < host -> receivedData ||
         * currentData < host -> receivedData ||
         * currentData > & host -> receivedData [host -> receivedDataLength])
         * currentData > & host -> receivedData [host -> receivedDataLength])
       return -1;
       return -1;
 
 
-    packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendReliable),
-                                 dataLength,
-                                 ENET_PACKET_FLAG_RELIABLE);
-    if (packet == NULL ||
-        enet_peer_queue_incoming_command (peer, command, packet, 0) == NULL)
+    if (enet_peer_queue_incoming_command (peer, command, (const enet_uint8 *) command + sizeof (ENetProtocolSendReliable), dataLength, ENET_PACKET_FLAG_RELIABLE, 0) == NULL)
       return -1;
       return -1;
 
 
     return 0;
     return 0;
@@ -451,7 +446,6 @@ enet_protocol_handle_send_reliable (ENetHost * host, ENetPeer * peer, const ENet
 static int
 static int
 enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData)
 enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData)
 {
 {
-    ENetPacket * packet;
     enet_uint32 unsequencedGroup, index;
     enet_uint32 unsequencedGroup, index;
     size_t dataLength;
     size_t dataLength;
 
 
@@ -461,7 +455,7 @@ enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const E
 
 
     dataLength = ENET_NET_TO_HOST_16 (command -> sendUnsequenced.dataLength);
     dataLength = ENET_NET_TO_HOST_16 (command -> sendUnsequenced.dataLength);
     * currentData += dataLength;
     * currentData += dataLength;
-    if (dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
+    if (dataLength > host -> maximumPacketSize ||
         * currentData < host -> receivedData ||
         * currentData < host -> receivedData ||
         * currentData > & host -> receivedData [host -> receivedDataLength])
         * currentData > & host -> receivedData [host -> receivedDataLength])
       return -1; 
       return -1; 
@@ -487,11 +481,7 @@ enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const E
     if (peer -> unsequencedWindow [index / 32] & (1 << (index % 32)))
     if (peer -> unsequencedWindow [index / 32] & (1 << (index % 32)))
       return 0;
       return 0;
       
       
-    packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendUnsequenced),
-                                 dataLength,
-                                 ENET_PACKET_FLAG_UNSEQUENCED);
-    if (packet == NULL ||
-        enet_peer_queue_incoming_command (peer, command, packet, 0) == NULL)
+    if (enet_peer_queue_incoming_command (peer, command, (const enet_uint8 *) command + sizeof (ENetProtocolSendUnsequenced), dataLength, ENET_PACKET_FLAG_UNSEQUENCED, 0) == NULL)
       return -1;
       return -1;
    
    
     peer -> unsequencedWindow [index / 32] |= 1 << (index % 32);
     peer -> unsequencedWindow [index / 32] |= 1 << (index % 32);
@@ -502,7 +492,6 @@ enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const E
 static int
 static int
 enet_protocol_handle_send_unreliable (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData)
 enet_protocol_handle_send_unreliable (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData)
 {
 {
-    ENetPacket * packet;
     size_t dataLength;
     size_t dataLength;
 
 
     if (command -> header.channelID >= peer -> channelCount ||
     if (command -> header.channelID >= peer -> channelCount ||
@@ -511,16 +500,12 @@ enet_protocol_handle_send_unreliable (ENetHost * host, ENetPeer * peer, const EN
 
 
     dataLength = ENET_NET_TO_HOST_16 (command -> sendUnreliable.dataLength);
     dataLength = ENET_NET_TO_HOST_16 (command -> sendUnreliable.dataLength);
     * currentData += dataLength;
     * currentData += dataLength;
-    if (dataLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
+    if (dataLength > host -> maximumPacketSize ||
         * currentData < host -> receivedData ||
         * currentData < host -> receivedData ||
         * currentData > & host -> receivedData [host -> receivedDataLength])
         * currentData > & host -> receivedData [host -> receivedDataLength])
       return -1;
       return -1;
 
 
-    packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendUnreliable),
-                                 dataLength,
-                                 0);
-    if (packet == NULL ||
-        enet_peer_queue_incoming_command (peer, command, packet, 0) == NULL)
+    if (enet_peer_queue_incoming_command (peer, command, (const enet_uint8 *) command + sizeof (ENetProtocolSendUnreliable), dataLength, 0, 0) == NULL)
       return -1;
       return -1;
 
 
     return 0;
     return 0;
@@ -546,7 +531,7 @@ enet_protocol_handle_send_fragment (ENetHost * host, ENetPeer * peer, const ENet
 
 
     fragmentLength = ENET_NET_TO_HOST_16 (command -> sendFragment.dataLength);
     fragmentLength = ENET_NET_TO_HOST_16 (command -> sendFragment.dataLength);
     * currentData += fragmentLength;
     * currentData += fragmentLength;
-    if (fragmentLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
+    if (fragmentLength > host -> maximumPacketSize ||
         * currentData < host -> receivedData ||
         * currentData < host -> receivedData ||
         * currentData > & host -> receivedData [host -> receivedDataLength])
         * currentData > & host -> receivedData [host -> receivedDataLength])
       return -1;
       return -1;
@@ -569,7 +554,7 @@ enet_protocol_handle_send_fragment (ENetHost * host, ENetPeer * peer, const ENet
     
     
     if (fragmentCount > ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT ||
     if (fragmentCount > ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT ||
         fragmentNumber >= fragmentCount ||
         fragmentNumber >= fragmentCount ||
-        totalLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
+        totalLength > host -> maximumPacketSize ||
         fragmentOffset >= totalLength ||
         fragmentOffset >= totalLength ||
         fragmentLength > totalLength - fragmentOffset)
         fragmentLength > totalLength - fragmentOffset)
       return -1;
       return -1;
@@ -607,13 +592,10 @@ enet_protocol_handle_send_fragment (ENetHost * host, ENetPeer * peer, const ENet
     if (startCommand == NULL)
     if (startCommand == NULL)
     {
     {
        ENetProtocol hostCommand = * command;
        ENetProtocol hostCommand = * command;
-       ENetPacket * packet = enet_packet_create (NULL, totalLength, ENET_PACKET_FLAG_RELIABLE);
-       if (packet == NULL)
-         return -1;
 
 
        hostCommand.header.reliableSequenceNumber = startSequenceNumber;
        hostCommand.header.reliableSequenceNumber = startSequenceNumber;
 
 
-       startCommand = enet_peer_queue_incoming_command (peer, & hostCommand, packet, fragmentCount);
+       startCommand = enet_peer_queue_incoming_command (peer, & hostCommand, NULL, totalLength, ENET_PACKET_FLAG_RELIABLE, fragmentCount);
        if (startCommand == NULL)
        if (startCommand == NULL)
          return -1;
          return -1;
     }
     }
@@ -659,7 +641,7 @@ enet_protocol_handle_send_unreliable_fragment (ENetHost * host, ENetPeer * peer,
 
 
     fragmentLength = ENET_NET_TO_HOST_16 (command -> sendFragment.dataLength);
     fragmentLength = ENET_NET_TO_HOST_16 (command -> sendFragment.dataLength);
     * currentData += fragmentLength;
     * currentData += fragmentLength;
-    if (fragmentLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
+    if (fragmentLength > host -> maximumPacketSize ||
         * currentData < host -> receivedData ||
         * currentData < host -> receivedData ||
         * currentData > & host -> receivedData [host -> receivedDataLength])
         * currentData > & host -> receivedData [host -> receivedDataLength])
       return -1;
       return -1;
@@ -688,7 +670,7 @@ enet_protocol_handle_send_unreliable_fragment (ENetHost * host, ENetPeer * peer,
 
 
     if (fragmentCount > ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT ||
     if (fragmentCount > ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT ||
         fragmentNumber >= fragmentCount ||
         fragmentNumber >= fragmentCount ||
-        totalLength > ENET_PROTOCOL_MAXIMUM_PACKET_SIZE ||
+        totalLength > host -> maximumPacketSize ||
         fragmentOffset >= totalLength ||
         fragmentOffset >= totalLength ||
         fragmentLength > totalLength - fragmentOffset)
         fragmentLength > totalLength - fragmentOffset)
       return -1;
       return -1;
@@ -731,11 +713,7 @@ enet_protocol_handle_send_unreliable_fragment (ENetHost * host, ENetPeer * peer,
 
 
     if (startCommand == NULL)
     if (startCommand == NULL)
     {
     {
-       ENetPacket * packet = enet_packet_create (NULL, totalLength, ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT);
-       if (packet == NULL)
-         return -1;
-
-       startCommand = enet_peer_queue_incoming_command (peer, command, packet, fragmentCount);
+       startCommand = enet_peer_queue_incoming_command (peer, command, NULL, totalLength, ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT, fragmentCount);
        if (startCommand == NULL)
        if (startCommand == NULL)
          return -1;
          return -1;
     }
     }
@@ -786,6 +764,10 @@ enet_protocol_handle_bandwidth_limit (ENetHost * host, ENetPeer * peer, const EN
 
 
     if (peer -> incomingBandwidth == 0 && host -> outgoingBandwidth == 0)
     if (peer -> incomingBandwidth == 0 && host -> outgoingBandwidth == 0)
       peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE;
       peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE;
+    else
+    if (peer -> incomingBandwidth == 0 || host -> outgoingBandwidth == 0)
+      peer -> windowSize = (ENET_MAX (peer -> incomingBandwidth, host -> outgoingBandwidth) /
+                             ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE;
     else
     else
       peer -> windowSize = (ENET_MIN (peer -> incomingBandwidth, host -> outgoingBandwidth) /
       peer -> windowSize = (ENET_MIN (peer -> incomingBandwidth, host -> outgoingBandwidth) /
                              ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE;
                              ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE;
@@ -1213,7 +1195,9 @@ commandError:
 static int
 static int
 enet_protocol_receive_incoming_commands (ENetHost * host, ENetEvent * event)
 enet_protocol_receive_incoming_commands (ENetHost * host, ENetEvent * event)
 {
 {
-    for (;;)
+    int packets;
+
+    for (packets = 0; packets < 256; ++ packets)
     {
     {
        int receivedLength;
        int receivedLength;
        ENetBuffer buffer;
        ENetBuffer buffer;
@@ -1506,7 +1490,7 @@ enet_protocol_send_reliable_outgoing_commands (ENetHost * host, ENetPeer * peer)
                ! (outgoingCommand -> reliableSequenceNumber % ENET_PEER_RELIABLE_WINDOW_SIZE) &&
                ! (outgoingCommand -> reliableSequenceNumber % ENET_PEER_RELIABLE_WINDOW_SIZE) &&
                (channel -> reliableWindows [(reliableWindow + ENET_PEER_RELIABLE_WINDOWS - 1) % ENET_PEER_RELIABLE_WINDOWS] >= ENET_PEER_RELIABLE_WINDOW_SIZE ||
                (channel -> reliableWindows [(reliableWindow + ENET_PEER_RELIABLE_WINDOWS - 1) % ENET_PEER_RELIABLE_WINDOWS] >= ENET_PEER_RELIABLE_WINDOW_SIZE ||
                  channel -> usedReliableWindows & ((((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) << reliableWindow) | 
                  channel -> usedReliableWindows & ((((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) << reliableWindow) | 
-                   (((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOW_SIZE - reliableWindow)))))
+                   (((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOWS - reliableWindow)))))
              windowWrap = 1;
              windowWrap = 1;
           if (windowWrap)
           if (windowWrap)
           {
           {
@@ -1904,6 +1888,9 @@ enet_host_service (ENetHost * host, ENetEvent * event, enet_uint32 timeout)
           }
           }
        }
        }
 
 
+       if (ENET_TIME_GREATER_EQUAL (host -> serviceTime, timeout))
+         return 0;
+
        do
        do
        {
        {
           host -> serviceTime = enet_time_get ();
           host -> serviceTime = enet_time_get ();

+ 81 - 19
src/libraries/enet/libenet/unix.c

@@ -38,6 +38,12 @@
 #ifndef HAS_SOCKLEN_T
 #ifndef HAS_SOCKLEN_T
 #define HAS_SOCKLEN_T 1
 #define HAS_SOCKLEN_T 1
 #endif
 #endif
+#ifndef HAS_GETADDRINFO
+#define HAS_GETADDRINFO 1
+#endif
+#ifndef HAS_GETNAMEINFO
+#define HAS_GETNAMEINFO 1
+#endif
 #endif
 #endif
 
 
 #ifdef HAS_FCNTL
 #ifdef HAS_FCNTL
@@ -48,7 +54,6 @@
 #include <sys/poll.h>
 #include <sys/poll.h>
 #endif
 #endif
 
 
-#include "common/config.h"
 #ifndef HAS_SOCKLEN_T
 #ifndef HAS_SOCKLEN_T
 typedef int socklen_t;
 typedef int socklen_t;
 #endif
 #endif
@@ -99,13 +104,39 @@ enet_time_set (enet_uint32 newTimeBase)
 int
 int
 enet_address_set_host (ENetAddress * address, const char * name)
 enet_address_set_host (ENetAddress * address, const char * name)
 {
 {
+#ifdef HAS_GETADDRINFO
+    struct addrinfo hints, * resultList = NULL, * result = NULL;
+
+    memset (& hints, 0, sizeof (hints));
+    hints.ai_family = AF_INET;
+
+    if (getaddrinfo (name, NULL, NULL, & resultList) != 0)
+      return -1;
+
+    for (result = resultList; result != NULL; result = result -> ai_next)
+    {
+        if (result -> ai_family == AF_INET && result -> ai_addr != NULL && result -> ai_addrlen >= sizeof (struct sockaddr_in))
+        {
+            struct sockaddr_in * sin = (struct sockaddr_in *) result -> ai_addr;
+
+            address -> host = sin -> sin_addr.s_addr;
+
+            freeaddrinfo (resultList);
+
+            return 0;
+        }
+    }
+
+    if (resultList != NULL)
+      freeaddrinfo (resultList);
+#else
     struct hostent * hostEntry = NULL;
     struct hostent * hostEntry = NULL;
 #ifdef HAS_GETHOSTBYNAME_R
 #ifdef HAS_GETHOSTBYNAME_R
     struct hostent hostData;
     struct hostent hostData;
     char buffer [2048];
     char buffer [2048];
     int errnum;
     int errnum;
 
 
-#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
     gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum);
     gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum);
 #else
 #else
     hostEntry = gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & errnum);
     hostEntry = gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & errnum);
@@ -114,19 +145,20 @@ enet_address_set_host (ENetAddress * address, const char * name)
     hostEntry = gethostbyname (name);
     hostEntry = gethostbyname (name);
 #endif
 #endif
 
 
-    if (hostEntry == NULL ||
-        hostEntry -> h_addrtype != AF_INET)
+    if (hostEntry != NULL && hostEntry -> h_addrtype == AF_INET)
     {
     {
-#ifdef HAS_INET_PTON
-        if (! inet_pton (AF_INET, name, & address -> host))
-#else
-        if (! inet_aton (name, (struct in_addr *) & address -> host))
-#endif
-            return -1;
+        address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0];
+
         return 0;
         return 0;
     }
     }
+#endif
 
 
-    address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0];
+#ifdef HAS_INET_PTON
+    if (! inet_pton (AF_INET, name, & address -> host))
+#else
+    if (! inet_aton (name, (struct in_addr *) & address -> host))
+#endif
+        return -1;
 
 
     return 0;
     return 0;
 }
 }
@@ -139,7 +171,12 @@ enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameL
 #else
 #else
     char * addr = inet_ntoa (* (struct in_addr *) & address -> host);
     char * addr = inet_ntoa (* (struct in_addr *) & address -> host);
     if (addr != NULL)
     if (addr != NULL)
-        strncpy (name, addr, nameLength);
+    {
+        size_t addrLen = strlen(addr);
+        if (addrLen >= nameLength)
+          return -1;
+        memcpy (name, addr, addrLen + 1);
+    } 
     else
     else
 #endif
 #endif
         return -1;
         return -1;
@@ -149,6 +186,26 @@ enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameL
 int
 int
 enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength)
 enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength)
 {
 {
+#ifdef HAS_GETNAMEINFO
+    struct sockaddr_in sin;
+    int err;
+
+    memset (& sin, 0, sizeof (struct sockaddr_in));
+
+    sin.sin_family = AF_INET;
+    sin.sin_port = ENET_HOST_TO_NET_16 (address -> port);
+    sin.sin_addr.s_addr = address -> host;
+
+    err = getnameinfo ((struct sockaddr *) & sin, sizeof (sin), name, nameLength, NULL, 0, NI_NAMEREQD);
+    if (! err)
+    {
+        if (name != NULL && nameLength > 0 && ! memchr (name, '\0', nameLength))
+          return -1;
+        return 0;
+    }
+    if (err != EAI_NONAME)
+      return -1;
+#else
     struct in_addr in;
     struct in_addr in;
     struct hostent * hostEntry = NULL;
     struct hostent * hostEntry = NULL;
 #ifdef HAS_GETHOSTBYADDR_R
 #ifdef HAS_GETHOSTBYADDR_R
@@ -158,7 +215,7 @@ enet_address_get_host (const ENetAddress * address, char * name, size_t nameLeng
 
 
     in.s_addr = address -> host;
     in.s_addr = address -> host;
 
 
-#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
     gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum);
     gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum);
 #else
 #else
     hostEntry = gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & errnum);
     hostEntry = gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & errnum);
@@ -169,12 +226,17 @@ enet_address_get_host (const ENetAddress * address, char * name, size_t nameLeng
     hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET);
     hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET);
 #endif
 #endif
 
 
-    if (hostEntry == NULL)
-      return enet_address_get_host_ip (address, name, nameLength);
-
-    strncpy (name, hostEntry -> h_name, nameLength);
+    if (hostEntry != NULL)
+    {
+       size_t hostLen = strlen (hostEntry -> h_name);
+       if (hostLen >= nameLength)
+         return -1;
+       memcpy (name, hostEntry -> h_name, hostLen + 1);
+       return 0;
+    }
+#endif
 
 
-    return 0;
+    return enet_address_get_host_ip (address, name, nameLength);
 }
 }
 
 
 int
 int
@@ -237,7 +299,7 @@ enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value)
     {
     {
         case ENET_SOCKOPT_NONBLOCK:
         case ENET_SOCKOPT_NONBLOCK:
 #ifdef HAS_FCNTL
 #ifdef HAS_FCNTL
-            result = fcntl (socket, F_SETFL, O_NONBLOCK | fcntl (socket, F_GETFL));
+            result = fcntl (socket, F_SETFL, (value ? O_NONBLOCK : 0) | (fcntl (socket, F_GETFL) & ~O_NONBLOCK));
 #else
 #else
             result = ioctl (socket, FIONBIO, & value);
             result = ioctl (socket, FIONBIO, & value);
 #endif
 #endif

+ 17 - 5
src/libraries/enet/libenet/win32.c

@@ -4,9 +4,10 @@
 */
 */
 #ifdef _WIN32
 #ifdef _WIN32
 
 
-#include <time.h>
 #define ENET_BUILDING_LIB 1
 #define ENET_BUILDING_LIB 1
 #include "enet/enet.h"
 #include "enet/enet.h"
+#include <windows.h>
+#include <mmsystem.h>
 
 
 static enet_uint32 timeBase = 0;
 static enet_uint32 timeBase = 0;
 
 
@@ -85,7 +86,13 @@ enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameL
     char * addr = inet_ntoa (* (struct in_addr *) & address -> host);
     char * addr = inet_ntoa (* (struct in_addr *) & address -> host);
     if (addr == NULL)
     if (addr == NULL)
         return -1;
         return -1;
-    strncpy (name, addr, nameLength);
+    else
+    {
+        size_t addrLen = strlen(addr);
+        if (addrLen >= nameLength)
+          return -1;
+        memcpy (name, addr, addrLen + 1);
+    }
     return 0;
     return 0;
 }
 }
 
 
@@ -94,14 +101,19 @@ enet_address_get_host (const ENetAddress * address, char * name, size_t nameLeng
 {
 {
     struct in_addr in;
     struct in_addr in;
     struct hostent * hostEntry;
     struct hostent * hostEntry;
-    
+ 
     in.s_addr = address -> host;
     in.s_addr = address -> host;
     
     
     hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET);
     hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET);
     if (hostEntry == NULL)
     if (hostEntry == NULL)
       return enet_address_get_host_ip (address, name, nameLength);
       return enet_address_get_host_ip (address, name, nameLength);
-
-    strncpy (name, hostEntry -> h_name, nameLength);
+    else
+    {
+       size_t hostLen = strlen (hostEntry -> h_name);
+       if (hostLen >= nameLength)
+         return -1;
+       memcpy (name, hostEntry -> h_name, hostLen + 1);
+    }
 
 
     return 0;
     return 0;
 }
 }

File diff suppressed because it is too large
+ 408 - 178
src/libraries/stb/stb_image.h


+ 11 - 2
src/modules/filesystem/wrap_Filesystem.cpp

@@ -111,11 +111,20 @@ int w_getSource(lua_State *L)
 
 
 int w_mount(lua_State *L)
 int w_mount(lua_State *L)
 {
 {
-	const char *archive = luaL_checkstring(L, 1);
+	std::string archive;
+
+	if (luax_istype(L, 1, FILESYSTEM_DROPPED_FILE_ID))
+	{
+		DroppedFile *file = luax_totype<DroppedFile>(L, 1, FILESYSTEM_DROPPED_FILE_ID);
+		archive = file->getFilename();
+	}
+	else
+		archive = luax_checkstring(L, 1);
+
 	const char *mountpoint = luaL_checkstring(L, 2);
 	const char *mountpoint = luaL_checkstring(L, 2);
 	bool append = luax_optboolean(L, 3, false);
 	bool append = luax_optboolean(L, 3, false);
 
 
-	luax_pushboolean(L, instance()->mount(archive, mountpoint, append));
+	luax_pushboolean(L, instance()->mount(archive.c_str(), mountpoint, append));
 	return 1;
 	return 1;
 }
 }
 
 

+ 33 - 15
src/modules/graphics/opengl/Font.cpp

@@ -25,6 +25,7 @@
 
 
 #include "common/math.h"
 #include "common/math.h"
 #include "common/Matrix.h"
 #include "common/Matrix.h"
+#include "graphics/Graphics.h"
 
 
 #include <math.h>
 #include <math.h>
 #include <sstream>
 #include <sstream>
@@ -112,12 +113,36 @@ Font::TextureSize Font::getNextTextureSize() const
 	return size;
 	return size;
 }
 }
 
 
+GLenum Font::getTextureFormat(FontType fontType, GLenum *internalformat) const
+{
+	GLenum format = fontType == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA;
+	GLenum iformat = fontType == FONT_TRUETYPE ? GL_LUMINANCE8_ALPHA8 : GL_RGBA8;
+
+	if (format == GL_RGBA && isGammaCorrect())
+	{
+		// In ES2, the internalformat and format params of TexImage must match.
+		// ES3 doesn't allow "GL_SRGB_ALPHA" as the internal format. But it also
+		// requires GL_LUMINANCE_ALPHA rather than GL_LUMINANCE8_ALPHA8 as the
+		// internal format, for LA.
+		if (GLAD_ES_VERSION_2_0 && !GLAD_ES_VERSION_3_0)
+			format = iformat = GL_SRGB_ALPHA;
+		else
+			iformat = GL_SRGB8_ALPHA8;
+	}
+	else if (GLAD_ES_VERSION_2_0)
+		iformat = format;
+
+	if (internalformat != nullptr)
+		*internalformat = iformat;
+
+	return format;
+}
+
 void Font::createTexture()
 void Font::createTexture()
 {
 {
 	OpenGL::TempDebugGroup debuggroup("Font create texture");
 	OpenGL::TempDebugGroup debuggroup("Font create texture");
 
 
-	GLenum format = type == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA;
-	size_t bpp = format == GL_LUMINANCE_ALPHA ? 2 : 4;
+	size_t bpp = type == FONT_TRUETYPE ? 2 : 4;
 
 
 	size_t prevmemsize = textureMemorySize;
 	size_t prevmemsize = textureMemorySize;
 	if (prevmemsize > 0)
 	if (prevmemsize > 0)
@@ -151,13 +176,8 @@ void Font::createTexture()
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
 
-	GLenum internalformat = type == FONT_TRUETYPE ? GL_LUMINANCE8_ALPHA8 : GL_RGBA8;
-
-	// In GLES2, the internalformat and format params of TexImage have to match.
-	// There is still no GL_LUMINANCE8_ALPHA8 in GLES3, so we have to use
-	// GL_LUMINANCE_ALPHA even on ES3.
-	if (GLAD_ES_VERSION_2_0)
-		internalformat = format;
+	GLenum internalformat = GL_RGBA;
+	GLenum format = getTextureFormat(type, &internalformat);
 
 
 	// Initialize the texture with transparent black.
 	// Initialize the texture with transparent black.
 	std::vector<GLubyte> emptydata(size.width * size.height * bpp, 0);
 	std::vector<GLubyte> emptydata(size.width * size.height * bpp, 0);
@@ -268,14 +288,12 @@ const Font::Glyph &Font::addGlyph(uint32 glyph)
 	// don't waste space for empty glyphs. also fixes a divide by zero bug with ATI drivers
 	// don't waste space for empty glyphs. also fixes a divide by zero bug with ATI drivers
 	if (w > 0 && h > 0)
 	if (w > 0 && h > 0)
 	{
 	{
-		const GLuint t = textures.back();
+		GLenum format = getTextureFormat(type);
+		g.texture = textures.back();
 
 
-		gl.bindTexture(t);
+		gl.bindTexture(g.texture);
 		glTexSubImage2D(GL_TEXTURE_2D, 0, textureX, textureY, w, h,
 		glTexSubImage2D(GL_TEXTURE_2D, 0, textureX, textureY, w, h,
-		                (type == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA),
-		                GL_UNSIGNED_BYTE, gd->getData());
-
-		g.texture = t;
+		                format, GL_UNSIGNED_BYTE, gd->getData());
 
 
 		double tX     = (double) textureX,     tY      = (double) textureY;
 		double tX     = (double) textureX,     tY      = (double) textureY;
 		double tWidth = (double) textureWidth, tHeight = (double) textureHeight;
 		double tWidth = (double) textureWidth, tHeight = (double) textureHeight;

+ 1 - 0
src/modules/graphics/opengl/Font.h

@@ -222,6 +222,7 @@ private:
 	};
 	};
 
 
 	TextureSize getNextTextureSize() const;
 	TextureSize getNextTextureSize() const;
+	GLenum getTextureFormat(FontType fontType, GLenum *internalformat = nullptr) const;
 	void createTexture();
 	void createTexture();
 	love::font::GlyphData *getRasterizerGlyphData(uint32 glyph);
 	love::font::GlyphData *getRasterizerGlyphData(uint32 glyph);
 	const Glyph &addGlyph(uint32 glyph);
 	const Glyph &addGlyph(uint32 glyph);

+ 4 - 2
src/modules/graphics/opengl/Graphics.cpp

@@ -317,18 +317,20 @@ bool Graphics::setMode(int width, int height)
 	pixelSizeStack.reserve(5);
 	pixelSizeStack.reserve(5);
 	pixelSizeStack.push_back(1);
 	pixelSizeStack.push_back(1);
 
 
+	int gammacorrect = isGammaCorrect() ? 1 : 0;
+
 	// We always need a default shader.
 	// We always need a default shader.
 	if (!Shader::defaultShader)
 	if (!Shader::defaultShader)
 	{
 	{
 		Renderer renderer = GLAD_ES_VERSION_2_0 ? RENDERER_OPENGLES : RENDERER_OPENGL;
 		Renderer renderer = GLAD_ES_VERSION_2_0 ? RENDERER_OPENGLES : RENDERER_OPENGL;
-		Shader::defaultShader = newShader(Shader::defaultCode[renderer]);
+		Shader::defaultShader = newShader(Shader::defaultCode[renderer][gammacorrect]);
 	}
 	}
 
 
 	// and a default video shader.
 	// and a default video shader.
 	if (!Shader::defaultVideoShader)
 	if (!Shader::defaultVideoShader)
 	{
 	{
 		Renderer renderer = GLAD_ES_VERSION_2_0 ? RENDERER_OPENGLES : RENDERER_OPENGL;
 		Renderer renderer = GLAD_ES_VERSION_2_0 ? RENDERER_OPENGLES : RENDERER_OPENGL;
-		Shader::defaultVideoShader = newShader(Shader::defaultVideoCode[renderer]);
+		Shader::defaultVideoShader = newShader(Shader::defaultVideoCode[renderer][gammacorrect]);
 	}
 	}
 
 
 	// A shader should always be active, but the default shader shouldn't be
 	// A shader should always be active, but the default shader shouldn't be

+ 2 - 2
src/modules/graphics/opengl/Image.cpp

@@ -221,8 +221,8 @@ void Image::loadDefaultTexture()
 	setFilter(filter);
 	setFilter(filter);
 
 
 	// A nice friendly checkerboard to signify invalid textures...
 	// A nice friendly checkerboard to signify invalid textures...
-	GLubyte px[] = {0xFF,0xFF,0xFF,0xFF, 0xFF,0xC0,0xC0,0xFF,
-	                0xFF,0xC0,0xC0,0xFF, 0xFF,0xFF,0xFF,0xFF};
+	GLubyte px[] = {0xFF,0xFF,0xFF,0xFF, 0xFF,0xA0,0xA0,0xFF,
+	                0xFF,0xA0,0xA0,0xFF, 0xFF,0xFF,0xFF,0xFF};
 
 
 	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, px);
 	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, px);
 }
 }

+ 5 - 4
src/modules/graphics/opengl/Shader.cpp

@@ -66,8 +66,8 @@ Shader *Shader::current = nullptr;
 Shader *Shader::defaultShader = nullptr;
 Shader *Shader::defaultShader = nullptr;
 Shader *Shader::defaultVideoShader = nullptr;
 Shader *Shader::defaultVideoShader = nullptr;
 
 
-Shader::ShaderSource Shader::defaultCode[Graphics::RENDERER_MAX_ENUM];
-Shader::ShaderSource Shader::defaultVideoCode[Graphics::RENDERER_MAX_ENUM];
+Shader::ShaderSource Shader::defaultCode[Graphics::RENDERER_MAX_ENUM][2];
+Shader::ShaderSource Shader::defaultVideoCode[Graphics::RENDERER_MAX_ENUM][2];
 
 
 std::vector<int> Shader::textureCounters;
 std::vector<int> Shader::textureCounters;
 
 
@@ -250,9 +250,10 @@ bool Shader::loadVolatile()
 
 
 	std::vector<GLuint> shaderids;
 	std::vector<GLuint> shaderids;
 
 
-	const ShaderSource *defaults = &defaultCode[Graphics::RENDERER_OPENGL];
+	bool gammacorrect = graphics::isGammaCorrect();
+	const ShaderSource *defaults = &defaultCode[Graphics::RENDERER_OPENGL][gammacorrect ? 1 : 0];
 	if (GLAD_ES_VERSION_2_0)
 	if (GLAD_ES_VERSION_2_0)
-		defaults = &defaultCode[Graphics::RENDERER_OPENGLES];
+		defaults = &defaultCode[Graphics::RENDERER_OPENGLES][gammacorrect ? 1 : 0];
 
 
 	// The shader program must have both vertex and pixel shader stages.
 	// The shader program must have both vertex and pixel shader stages.
 	const std::string &vertexcode = shaderSource.vertex.empty() ? defaults->vertex : shaderSource.vertex;
 	const std::string &vertexcode = shaderSource.vertex.empty() ? defaults->vertex : shaderSource.vertex;

+ 2 - 2
src/modules/graphics/opengl/Shader.h

@@ -95,8 +95,8 @@ public:
 	static Shader *defaultVideoShader;
 	static Shader *defaultVideoShader;
 
 
 	// Default shader code (a shader is always required internally.)
 	// Default shader code (a shader is always required internally.)
-	static ShaderSource defaultCode[Graphics::RENDERER_MAX_ENUM];
-	static ShaderSource defaultVideoCode[Graphics::RENDERER_MAX_ENUM];
+	static ShaderSource defaultCode[Graphics::RENDERER_MAX_ENUM][2];
+	static ShaderSource defaultVideoCode[Graphics::RENDERER_MAX_ENUM][2];
 
 
 	/**
 	/**
 	 * Creates a new Shader using a list of source codes.
 	 * Creates a new Shader using a list of source codes.

+ 21 - 28
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -1346,41 +1346,34 @@ int w_getShader(lua_State *L)
 int w_setDefaultShaderCode(lua_State *L)
 int w_setDefaultShaderCode(lua_State *L)
 {
 {
 	luaL_checktype(L, 1, LUA_TTABLE);
 	luaL_checktype(L, 1, LUA_TTABLE);
+	luaL_checktype(L, 2, LUA_TTABLE);
 
 
-	lua_getfield(L, 1, "opengl");
-	lua_rawgeti(L, -1, 1);
-	lua_rawgeti(L, -2, 2);
-	lua_rawgeti(L, -3, 3);
-
-	Shader::ShaderSource openglcode;
-	openglcode.vertex = luax_checkstring(L, -3);
-	openglcode.pixel = luax_checkstring(L, -2);
-
-	Shader::ShaderSource openglVideocode;
-	openglVideocode.vertex = luax_checkstring(L, -3);
-	openglVideocode.pixel = luax_checkstring(L, -1);
+	for (int i = 0; i < 2; i++)
+	{
+		for (int renderer = 0; renderer < Graphics::RENDERER_MAX_ENUM; renderer++)
+		{
+			const char *lang = renderer == Graphics::RENDERER_OPENGLES ? "glsles" : "glsl";
 
 
-	lua_pop(L, 4);
+			lua_getfield(L, i + 1, lang);
 
 
-	lua_getfield(L, 1, "opengles");
-	lua_rawgeti(L, -1, 1);
-	lua_rawgeti(L, -2, 2);
-	lua_rawgeti(L, -3, 3);
+			lua_getfield(L, -1, "vertex");
+			lua_getfield(L, -2, "pixel");
+			lua_getfield(L, -3, "videopixel");
 
 
-	Shader::ShaderSource openglescode;
-	openglescode.vertex = luax_checkstring(L, -3);
-	openglescode.pixel = luax_checkstring(L, -2);
+			Shader::ShaderSource code;
+			code.vertex = luax_checkstring(L, -3);
+			code.pixel = luax_checkstring(L, -2);
 
 
-	Shader::ShaderSource openglesVideocode;
-	openglesVideocode.vertex = luax_checkstring(L, -3);
-	openglesVideocode.pixel = luax_checkstring(L, -1);
+			Shader::ShaderSource videocode;
+			videocode.vertex = luax_checkstring(L, -3);
+			videocode.pixel = luax_checkstring(L, -1);
 
 
-	lua_pop(L, 4);
+			lua_pop(L, 4);
 
 
-	Shader::defaultCode[Graphics::RENDERER_OPENGL]   = openglcode;
-	Shader::defaultCode[Graphics::RENDERER_OPENGLES] = openglescode;
-	Shader::defaultVideoCode[Graphics::RENDERER_OPENGL]   = openglVideocode;
-	Shader::defaultVideoCode[Graphics::RENDERER_OPENGLES] = openglesVideocode;
+			Shader::defaultCode[renderer][i] = code;
+			Shader::defaultVideoCode[renderer][i] = videocode;
+		}
+	}
 
 
 	return 0;
 	return 0;
 }
 }

+ 36 - 42
src/modules/graphics/opengl/wrap_Graphics.lua

@@ -23,6 +23,7 @@ misrepresented as being the original software.
 --]]
 --]]
 
 
 local table_concat = table.concat
 local table_concat = table.concat
+local ipairs = ipairs
 
 
 -- SHADERS
 -- SHADERS
 
 
@@ -139,6 +140,8 @@ varying vec4 VaryingColor;
 uniform mediump float love_PointSize;
 uniform mediump float love_PointSize;
 #endif]],
 #endif]],
 
 
+	FUNCTIONS = "",
+
 	FOOTER = [[
 	FOOTER = [[
 void main() {
 void main() {
 	VaryingTexCoord = VertexTexCoord;
 	VaryingTexCoord = VertexTexCoord;
@@ -210,33 +213,21 @@ void main() {
 }]],
 }]],
 }
 }
 
 
-local function createVertexCode(vertexcode, lang)
-	local vertexcodes = {
+local function createShaderStageCode(stage, code, lang, gammacorrect, multicanvas)
+	stage = stage:upper()
+	local lines = {
 		lang == "glsles" and GLSL.VERSION_ES or GLSL.VERSION,
 		lang == "glsles" and GLSL.VERSION_ES or GLSL.VERSION,
 		GLSL.SYNTAX,
 		GLSL.SYNTAX,
-		love.graphics.isGammaCorrect() and "#define LOVE_GAMMA_CORRECT 1" or "",
-		GLSL.VERTEX.HEADER, GLSL.UNIFORMS,
+		gammacorrect and "#define LOVE_GAMMA_CORRECT 1" or "",
+		GLSL[stage].HEADER,
+		GLSL.UNIFORMS,
 		GLSL.FUNCTIONS,
 		GLSL.FUNCTIONS,
+		GLSL[stage].FUNCTIONS,
 		lang == "glsles" and "#line 1" or "#line 0",
 		lang == "glsles" and "#line 1" or "#line 0",
-		vertexcode,
-		GLSL.VERTEX.FOOTER,
+		code,
+		multicanvas and GLSL[stage].FOOTER_MULTI_CANVAS or GLSL[stage].FOOTER,
 	}
 	}
-	return table_concat(vertexcodes, "\n")
-end
-
-local function createPixelCode(pixelcode, is_multicanvas, lang)
-	local pixelcodes = {
-		lang == "glsles" and GLSL.VERSION_ES or GLSL.VERSION,
-		GLSL.SYNTAX,
-		love.graphics.isGammaCorrect() and "#define LOVE_GAMMA_CORRECT 1" or "",
-		GLSL.PIXEL.HEADER, GLSL.UNIFORMS,
-		GLSL.FUNCTIONS,
-		GLSL.PIXEL.FUNCTIONS,
-		lang == "glsles" and "#line 1" or "#line 0",
-		pixelcode,
-		is_multicanvas and GLSL.PIXEL.FOOTER_MULTI_CANVAS or GLSL.PIXEL.FOOTER,
-	}
-	return table_concat(pixelcodes, "\n")
+	return table_concat(lines, "\n")
 end
 end
 
 
 local function isVertexCode(code)
 local function isVertexCode(code)
@@ -258,11 +249,6 @@ function love.graphics._shaderCodeToGLSL(arg1, arg2)
 	local vertexcode, pixelcode
 	local vertexcode, pixelcode
 	local is_multicanvas = false -- whether pixel code has "effects" function instead of "effect"
 	local is_multicanvas = false -- whether pixel code has "effects" function instead of "effect"
 
 
-	local lang = "glsl"
-	if (love.graphics.getRendererInfo()) == "OpenGL ES" then
-		lang = "glsles"
-	end
-
 	if arg1 then
 	if arg1 then
 		if isVertexCode(arg1) then
 		if isVertexCode(arg1) then
 			vertexcode = arg1 -- first arg contains vertex shader code
 			vertexcode = arg1 -- first arg contains vertex shader code
@@ -287,11 +273,18 @@ function love.graphics._shaderCodeToGLSL(arg1, arg2)
 		end
 		end
 	end
 	end
 
 
+	local lang = "glsl"
+	if love.graphics.getRendererInfo() == "OpenGL ES" then
+		lang = "glsles"
+	end
+
+	local gammacorrect = love.graphics.isGammaCorrect()
+
 	if vertexcode then
 	if vertexcode then
-		vertexcode = createVertexCode(vertexcode, lang)
+		vertexcode = createShaderStageCode("VERTEX", vertexcode, lang, gammacorrect)
 	end
 	end
 	if pixelcode then
 	if pixelcode then
-		pixelcode = createPixelCode(pixelcode, is_multicanvas, lang)
+		pixelcode = createShaderStageCode("PIXEL", pixelcode, lang, gammacorrect, is_multicanvas)
 	end
 	end
 
 
 	return vertexcode, pixelcode
 	return vertexcode, pixelcode
@@ -339,20 +332,21 @@ vec4 effect(mediump vec4 vcolor, Image tex, vec2 texcoord, vec2 pixcoord) {
 }]],
 }]],
 }
 }
 
 
-local defaults = {
-	opengl = {
-		createVertexCode(defaultcode.vertex, "glsl"),
-		createPixelCode(defaultcode.pixel, false, "glsl"),
-		createPixelCode(defaultcode.videopixel, false, "glsl"),
-	},
-	opengles = {
-		createVertexCode(defaultcode.vertex, "glsles"),
-		createPixelCode(defaultcode.pixel, false, "glsles"),
-		createPixelCode(defaultcode.videopixel, false, "glsles"),
-	},
-}
+local defaults = {}
+local defaults_gammacorrect = {}
+
+for _, lang in ipairs{"glsl", "glsles"} do
+	for _, gammacorrect in ipairs{false, true} do
+		local t = gammacorrect and defaults_gammacorrect or defaults
+		t[lang] = {
+			vertex = createShaderStageCode("VERTEX", defaultcode.vertex, lang, gammacorrect),
+			pixel = createShaderStageCode("PIXEL", defaultcode.pixel, lang, gammacorrect, false),
+			videopixel = createShaderStageCode("PIXEL", defaultcode.videopixel, lang, gammacorrect, false),
+		}
+	end
+end
 
 
-love.graphics._setDefaultShaderCode(defaults)
+love.graphics._setDefaultShaderCode(defaults, defaults_gammacorrect)
 
 
 function love.graphics.newVideo(file, loadaudio)
 function love.graphics.newVideo(file, loadaudio)
 	local video = love.graphics._newVideo(file)
 	local video = love.graphics._newVideo(file)

+ 4 - 4
src/modules/video/theora/VideoStream.cpp

@@ -151,12 +151,12 @@ bool VideoStream::readPacket(bool mustSucceed)
 
 
 	while (ogg_stream_packetout(&stream, &packet) != 1)
 	while (ogg_stream_packetout(&stream, &packet) != 1)
 	{
 	{
-		// We need to read another page, but there is none, we're at the end
-		if (ogg_page_eos(&page) && !mustSucceed)
-			return eos = true;
-
 		do
 		do
 		{
 		{
+			// We need to read another page, but there is none, we're at the end
+			if (ogg_page_eos(&page) && !mustSucceed)
+				return eos = true;
+
 			readPage();
 			readPage();
 		} while (ogg_page_serialno(&page) != videoSerial);
 		} while (ogg_page_serialno(&page) != videoSerial);
 
 

Some files were not shown because too many files changed in this diff