| 74 | } |
| 75 | |
| 76 | unsigned int dthread_handler(void *) |
| 77 | { |
| 78 | const char *error_buf; |
| 79 | TMegaPkt *pkt; |
| 80 | DWORD dwMilliseconds; |
| 81 | |
| 82 | while (dthread_running) { |
| 83 | if (!sgpInfoHead && WaitForEvent(sghWorkToDoEvent) == -1) { |
| 84 | error_buf = TraceLastError(); |
| 85 | app_fatal("dthread4:\n%s", error_buf); |
| 86 | } |
| 87 | |
| 88 | sgMemCrit.Enter(); |
| 89 | pkt = sgpInfoHead; |
| 90 | if (sgpInfoHead) |
| 91 | sgpInfoHead = sgpInfoHead->pNext; |
| 92 | else |
| 93 | ResetEvent(sghWorkToDoEvent); |
| 94 | sgMemCrit.Leave(); |
| 95 | |
| 96 | if (pkt) { |
| 97 | if (pkt->dwSpaceLeft != MAX_PLRS) |
| 98 | multi_send_zero_packet(pkt->dwSpaceLeft, pkt->data[0], &pkt->data[8], *(DWORD *)&pkt->data[4]); |
| 99 | |
| 100 | dwMilliseconds = 1000 * *(DWORD *)&pkt->data[4] / gdwDeltaBytesSec; |
| 101 | if (dwMilliseconds >= 1) |
| 102 | dwMilliseconds = 1; |
| 103 | |
| 104 | mem_free_dbg(pkt); |
| 105 | |
| 106 | if (dwMilliseconds) |
| 107 | SDL_Delay(dwMilliseconds); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | void dthread_cleanup() |
| 115 | { |
nothing calls this directly
no test coverage detected