Changeset 8088 for code/trunk/src/external/enet/protocol.c
- Timestamp:
- Mar 18, 2011, 12:08:44 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/external/enet/protocol.c
r7459 r8088 189 189 ENetListIterator currentCommand; 190 190 ENetProtocolCommand commandNumber; 191 int wasSent = 1; 191 192 192 193 for (currentCommand = enet_list_begin (& peer -> sentReliableCommands); … … 218 219 if (currentCommand == enet_list_end (& peer -> outgoingReliableCommands)) 219 220 return ENET_PROTOCOL_COMMAND_NONE; 221 222 wasSent = 0; 220 223 } 221 224 … … 238 241 if (outgoingCommand -> packet != NULL) 239 242 { 240 peer -> reliableDataInTransit -= outgoingCommand -> fragmentLength; 243 if (wasSent) 244 peer -> reliableDataInTransit -= outgoingCommand -> fragmentLength; 241 245 242 246 -- outgoingCommand -> packet -> referenceCount; … … 1273 1277 } 1274 1278 1275 static void1279 static int 1276 1280 enet_protocol_send_reliable_outgoing_commands (ENetHost * host, ENetPeer * peer) 1277 1281 { … … 1283 1287 enet_uint16 reliableWindow; 1284 1288 size_t commandSize; 1289 int windowExceeded = 0, windowWrap = 0, canPing = 1; 1285 1290 1286 1291 currentCommand = enet_list_begin (& peer -> outgoingReliableCommands); … … 1292 1297 channel = outgoingCommand -> command.header.channelID < peer -> channelCount ? & peer -> channels [outgoingCommand -> command.header.channelID] : NULL; 1293 1298 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 1302 1335 commandSize = commandSizes [outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK]; 1303 1336 if (command >= & host -> commands [sizeof (host -> commands) / sizeof (ENetProtocol)] || 1304 1337 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))) 1306 1341 { 1307 1342 host -> continueSending = 1; … … 1310 1345 } 1311 1346 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 1325 1347 currentCommand = enet_list_next (currentCommand); 1326 1348 … … 1375 1397 host -> commandCount = command - host -> commands; 1376 1398 host -> bufferCount = buffer - host -> buffers; 1399 1400 return canPing; 1377 1401 } 1378 1402 … … 1415 1439 return 1; 1416 1440 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) && 1421 1444 ENET_TIME_DIFFERENCE (host -> serviceTime, currentPeer -> lastReceiveTime) >= ENET_PEER_PING_INTERVAL && 1422 1445 currentPeer -> mtu - host -> packetSize >= sizeof (ENetProtocolPing))
Note: See TracChangeset
for help on using the changeset viewer.