MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / EstimateBandwidth

Method EstimateBandwidth

engine/Poseidon/Network/NetworkClientActions.cpp:2302–2365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2300}
2301
2302// Subsidiary structure for sorting messages by error
2303struct 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
2316int 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
2323const 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
2336void 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;

Callers

nothing calls this directly

Calls 6

saturateFunction · 0.85
GetSendQueueInfoMethod · 0.80
GetConnectionInfoMethod · 0.80
GetAvgFrameDurationMethod · 0.80
toIntFunction · 0.50
SizeMethod · 0.45

Tested by

no test coverage detected