Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 18, 2011, 12:08:44 AM (13 years ago)
Author:
adrfried
Message:

Updated Enet to version 1.3.1

updated patch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/external/enet/protocol.c

    r7459 r8088  
    189189    ENetListIterator currentCommand;
    190190    ENetProtocolCommand commandNumber;
     191    int wasSent = 1;
    191192
    192193    for (currentCommand = enet_list_begin (& peer -> sentReliableCommands);
     
    218219       if (currentCommand == enet_list_end (& peer -> outgoingReliableCommands))
    219220         return ENET_PROTOCOL_COMMAND_NONE;
     221
     222       wasSent = 0;
    220223    }
    221224
     
    238241    if (outgoingCommand -> packet != NULL)
    239242    {
    240        peer -> reliableDataInTransit -= outgoingCommand -> fragmentLength;
     243       if (wasSent)
     244         peer -> reliableDataInTransit -= outgoingCommand -> fragmentLength;
    241245
    242246       -- outgoingCommand -> packet -> referenceCount;
     
    12731277}
    12741278
    1275 static void
     1279static int
    12761280enet_protocol_send_reliable_outgoing_commands (ENetHost * host, ENetPeer * peer)
    12771281{
     
    12831287    enet_uint16 reliableWindow;
    12841288    size_t commandSize;
     1289    int windowExceeded = 0, windowWrap = 0, canPing = 1;
    12851290
    12861291    currentCommand = enet_list_begin (& peer -> outgoingReliableCommands);
     
    12921297       channel = outgoingCommand -> command.header.channelID < peer -> channelCount ? & peer -> channels [outgoingCommand -> command.header.channelID] : NULL;
    12931298       reliableWindow = outgoingCommand -> reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE;
    1294        if (channel != NULL &&
    1295            outgoingCommand -> sendAttempts < 1 &&
    1296            ! (outgoingCommand -> reliableSequenceNumber % ENET_PEER_RELIABLE_WINDOW_SIZE) &&
    1297            (channel -> reliableWindows [(reliableWindow + ENET_PEER_RELIABLE_WINDOWS - 1) % ENET_PEER_RELIABLE_WINDOWS] >= ENET_PEER_RELIABLE_WINDOW_SIZE ||
    1298              channel -> usedReliableWindows & ((((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) << reliableWindow) |
    1299                (((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOW_SIZE - reliableWindow)))))
    1300          break;
    1301  
     1299       if (channel != NULL)
     1300       {
     1301           if (! windowWrap &&     
     1302               outgoingCommand -> sendAttempts < 1 &&
     1303               ! (outgoingCommand -> reliableSequenceNumber % ENET_PEER_RELIABLE_WINDOW_SIZE) &&
     1304               (channel -> reliableWindows [(reliableWindow + ENET_PEER_RELIABLE_WINDOWS - 1) % ENET_PEER_RELIABLE_WINDOWS] >= ENET_PEER_RELIABLE_WINDOW_SIZE ||
     1305                 channel -> usedReliableWindows & ((((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) << reliableWindow) |
     1306                   (((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOW_SIZE - reliableWindow)))))
     1307             windowWrap = 1;
     1308          if (windowWrap)
     1309          {
     1310             currentCommand = enet_list_next (currentCommand);
     1311 
     1312             continue;
     1313          }
     1314       }
     1315 
     1316       if (outgoingCommand -> packet != NULL)
     1317       {
     1318          if (! windowExceeded)
     1319          {
     1320             enet_uint32 windowSize = (peer -> packetThrottle * peer -> windowSize) / ENET_PEER_PACKET_THROTTLE_SCALE;
     1321             
     1322             if (peer -> reliableDataInTransit + outgoingCommand -> fragmentLength > ENET_MAX (windowSize, peer -> mtu))
     1323               windowExceeded = 1;
     1324          }
     1325          if (windowExceeded)
     1326          {
     1327             currentCommand = enet_list_next (currentCommand);
     1328
     1329             continue;
     1330          }
     1331       }
     1332
     1333       canPing = 0;
     1334
    13021335       commandSize = commandSizes [outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK];
    13031336       if (command >= & host -> commands [sizeof (host -> commands) / sizeof (ENetProtocol)] ||
    13041337           buffer + 1 >= & host -> buffers [sizeof (host -> buffers) / sizeof (ENetBuffer)] ||
    1305            peer -> mtu - host -> packetSize < commandSize)
     1338           peer -> mtu - host -> packetSize < commandSize ||
     1339           (outgoingCommand -> packet != NULL &&
     1340             (enet_uint16) (peer -> mtu - host -> packetSize) < (enet_uint16) (commandSize + outgoingCommand -> fragmentLength)))
    13061341       {
    13071342          host -> continueSending = 1;
     
    13101345       }
    13111346
    1312        if (outgoingCommand -> packet != NULL)
    1313        {
    1314           if (peer -> reliableDataInTransit + outgoingCommand -> fragmentLength > peer -> windowSize)
    1315             break;
    1316 
    1317           if ((enet_uint16) (peer -> mtu - host -> packetSize) < (enet_uint16) (commandSize + outgoingCommand -> fragmentLength))
    1318           {
    1319              host -> continueSending = 1;
    1320 
    1321              break;
    1322           }
    1323        }
    1324      
    13251347       currentCommand = enet_list_next (currentCommand);
    13261348
     
    13751397    host -> commandCount = command - host -> commands;
    13761398    host -> bufferCount = buffer - host -> buffers;
     1399
     1400    return canPing;
    13771401}
    13781402
     
    14151439          return 1;
    14161440
    1417         if (! enet_list_empty (& currentPeer -> outgoingReliableCommands))
    1418           enet_protocol_send_reliable_outgoing_commands (host, currentPeer);
    1419         else
    1420         if (enet_list_empty (& currentPeer -> sentReliableCommands) &&
     1441        if ((enet_list_empty (& currentPeer -> outgoingReliableCommands) ||
     1442              enet_protocol_send_reliable_outgoing_commands (host, currentPeer)) &&
     1443            enet_list_empty (& currentPeer -> sentReliableCommands) &&
    14211444            ENET_TIME_DIFFERENCE (host -> serviceTime, currentPeer -> lastReceiveTime) >= ENET_PEER_PING_INTERVAL &&
    14221445            currentPeer -> mtu - host -> packetSize >= sizeof (ENetProtocolPing))
Note: See TracChangeset for help on using the changeset viewer.