---------------------------------------------- QUEUE COMMAND -----------------------------------------------
| 28 | |
| 29 | //---------------------------------------------- QUEUE COMMAND ----------------------------------------------- |
| 30 | void __fastcall QueueGameCommand(void *pBuffer, size_t dwLength) |
| 31 | { |
| 32 | assert(dwLength < BW::BWDATA::TurnBuffer.size()); |
| 33 | if ( !pBuffer || !dwLength || !isCorrectVersion ) |
| 34 | return; |
| 35 | |
| 36 | CAPS caps; |
| 37 | caps.dwSize = sizeof(CAPS); |
| 38 | SNetGetProviderCaps(&caps); |
| 39 | |
| 40 | DWORD dwMaxBuffer = Util::clamp<size_t>(caps.maxmessagesize, 0, BW::BWDATA::TurnBuffer.size()); |
| 41 | if ( dwLength + BW::BWDATA::sgdwBytesInCmdQueue <= dwMaxBuffer ) |
| 42 | { |
| 43 | // Copy data to primary turn buffer |
| 44 | memcpy(&BW::BWDATA::TurnBuffer[BW::BWDATA::sgdwBytesInCmdQueue], pBuffer, dwLength); |
| 45 | BW::BWDATA::sgdwBytesInCmdQueue += dwLength; |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | // Verify game mode |
| 50 | if ( BW::BWDATA::gwGameMode == BW::GAME_GLUES ) |
| 51 | return; |
| 52 | |
| 53 | int turns; |
| 54 | if ( SNetGetTurnsInTransit(&turns) ) // Buffer is full |
| 55 | { |
| 56 | int callDelay = 1; |
| 57 | if ( BW::BWDATA::NetMode ) |
| 58 | callDelay = Util::clamp<int>(caps.dwCallDelay, 2, 8); |
| 59 | |
| 60 | // This statement will probably never be hit, but just in case |
| 61 | if ( turns >= 16 - callDelay ) |
| 62 | return; |
| 63 | |
| 64 | // Send the turn and fill the new buffer |
| 65 | BW::BWDATA::BWFXN_sendTurn(); |
| 66 | memcpy(&BW::BWDATA::TurnBuffer[BW::BWDATA::sgdwBytesInCmdQueue], pBuffer, dwLength); |
| 67 | BW::BWDATA::sgdwBytesInCmdQueue += dwLength; |
| 68 | } |
| 69 | // assume no error, would be fatal in Starcraft anyway |
| 70 | } |
| 71 | int getFileType(const std::string &sFileName) |
| 72 | { |
| 73 | int rVal = 0; |
no test coverage detected