| 2300 | } |
| 2301 | |
| 2302 | // Subsidiary structure for sorting messages by error |
| 2303 | struct UpdateLocalObjectInfo |
| 2304 | { |
| 2305 | // Local object info |
| 2306 | NetworkLocalObjectInfo* oInfo; |
| 2307 | // Message class type |
| 2308 | NetworkMessageClass cls; |
| 2309 | // Error (difference) |
| 2310 | float error; |
| 2311 | // Critical update |
| 2312 | bool criticalUpdate; |
| 2313 | }; |
| 2314 | |
| 2315 | // Compare local object infos by error |
| 2316 | int CmpLocalObjects(const UpdateLocalObjectInfo* info1, const UpdateLocalObjectInfo* info2) |
| 2317 | { |
| 2318 | float diff = info2->error - info1->error; |
| 2319 | return sign(diff); |
| 2320 | } |
| 2321 | |
| 2322 | // Format value of error for output |
| 2323 | const char* FormatVal(float val, char* buffer) |
| 2324 | { |
| 2325 | if (val == FLT_MAX) |
| 2326 | { |
| 2327 | snprintf(buffer, sizeof(buffer), "%s", (const char*)"MAX"); |
| 2328 | } |
| 2329 | else |
| 2330 | { |
| 2331 | snprintf(buffer, sizeof(buffer), "%.0f", val); |
| 2332 | } |
| 2333 | return buffer; |
| 2334 | } |
| 2335 | |
| 2336 | void NetworkClient::EstimateBandwidth(int& nMsgMax, int& nBytesMax) |
| 2337 | { |
| 2338 | if (IsBotClient()) |
| 2339 | { |
| 2340 | // unlimited bandwidth |
| 2341 | nMsgMax = INT_MAX; |
| 2342 | nBytesMax = INT_MAX; |
| 2343 | } |
| 2344 | else |
| 2345 | { |
| 2346 | int nMsg = 0; |
| 2347 | int nBytes = 0; |
| 2348 | /* |
| 2349 | #if _ENABLE_CHEATS |
| 2350 | if (outputDiags == 1 && nMsg > 0) snprintf(output, sizeof(output), "Waiting (%d, %d); ", nBytes, nMsg); |
| 2351 | #endif |
| 2352 | */ |
| 2353 | nMsgMax = MaxMsgSend; |
| 2354 | nBytesMax = 1024; |
| 2355 | |
| 2356 | int latencyMS, throughputBPS; |
| 2357 | if (_client->GetConnectionInfo(latencyMS, throughputBPS)) |
| 2358 | { |
| 2359 | // nBytesMax += 1.25 * info.dwThroughputBPS; |
nothing calls this directly
no test coverage detected