MCPcopy Create free account
hub / github.com/bwapi/bwapi / spiReceive

Function spiReceive

bwapi/SNP_DirectIP/SNP/SNPModule.cpp:422–472  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

420 }
421 //------------------------------------------------------------------------------------------------------------------------------------
422 BOOL __stdcall spiReceive(SOCKADDR **senderPeer, char **data, DWORD *databytes)
423 {
424 INTERLOCKED;
425// DropMessage(0, "spiReceive %d", GetCurrentThreadId());
426 // Passes pointers from queued receive data to storm
427
428 *senderPeer = nullptr;
429 *data = nullptr;
430 *databytes = 0;
431
432 try
433 {
434 pluggedNetwork->receive();
435
436 while(true)
437 {
438 // check if packets available
439 if(incomingGamePackets.empty())
440 {
441 SErrSetLastError(STORM_ERROR_NO_MESSAGES_WAITING);
442 return FALSE;
443 }
444
445 // save the packet before removing it from queue
446 GamePacket *loan = new GamePacket();
447 *loan = incomingGamePackets.front();
448 incomingGamePackets.pop();
449
450 // paket outdated?
451 if(GetTickCount() > loan->timeStamp + 10000)
452 {
453 DropMessage(1, "Dropped outdated packet (%dms delay)", GetTickCount() - loan->timeStamp);
454 continue;
455 }
456
457 // give saved data to storm
458 *senderPeer =&loan->sender;
459 *data = loan->data;
460 *databytes = loan->packetSize;
461// DropMessage(0, "R %s", sprintfBytes(*data, *databytes));
462// DropMessage(0, "Received storm packet %d bytes", *databytes);
463 break;
464 }
465 }
466 catch(GeneralException &e)
467 {
468 DropLastError("spiLockGameList failed: %s", e.getMessage());
469 return FALSE;
470 }
471 return TRUE;
472 }
473 //------------------------------------------------------------------------------------------------------------------------------------
474 BOOL __stdcall spiFree(SOCKADDR * addr, char *data, DWORD databytes)
475 {

Callers

nothing calls this directly

Calls 4

DropMessageFunction · 0.85
DropLastErrorFunction · 0.85
getMessageMethod · 0.80
receiveMethod · 0.45

Tested by

no test coverage detected