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

Method EstimateBandwidth

engine/Poseidon/Network/NetworkServerMission.cpp:1580–1646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1578}
1579
1580// Remove a player id (decimal) or IPv4 from the dynamic ban lists and rewrite
1581// the corresponding file. An argument that parses as a dotted quad is treated
1582// as an IP, otherwise as a decimal player id.
1583void NetworkServer::Unban(const char* idOrIp)
1584{
1585 uint32_t ip = 0;
1586 if (Poseidon::ParseIPv4(idOrIp, ip))
1587 {
1588 if (_banListIPLocal.Delete(ip))
1589 {
1590 Poseidon::SaveIpBanList(Poseidon::GetUserDirectory() + RString("ipban.txt"), _banListIPLocal);
1591 }
1592 return;
1593 }
1594
1595 const __int64 id64 = _atoi64(idOrIp);
1596 if (_banListLocal.Delete(id64))
1597 {
1598 SaveBanList(Poseidon::GetUserDirectory() + RString("ban.txt"), _banListLocal);
1599 }
1600}
1601
1602void NetworkServer::ChatToAllPlayers(RString message)
1603{
1604 RefArray<NetworkObject> dummy;
1605 ChatMessage msg(CCGlobal, nullptr, dummy, "", message);
1606 for (int i = 0; i < _players.Size(); i++)
1607 {
1608 if (_players[i].state >= NGSCreate)
1609 {
1610 SendMsg(_players[i].dpid, &msg, NMFGuaranteed);
1611 }
1612 }
1613}
1614
1615#if LOG_ERRORS
1616// diagnostic logs of error (difference) between messages
1617static void LogError(NetworkMessageType type, int dpid1, NetworkMessage* msg1, int dpid2, NetworkMessage* msg2)
1618{
1619 if (type < 0 || type >= NMTN)
1620 return;
1621 NetworkMessageFormat* format = GMsgFormats[type];
1622
1623 float dt = msg1->time - msg2->time;
1624
1625 // new version of message comparing
1626 for (int i = 0; i < format->NItems(); i++)
1627 {
1628 const NetworkMessageErrorInfo& info = format->GetErrorInfo(i);
1629 if (info.type == ET_NONE)
1630 continue;
1631
1632 const RefNetworkData& value1 = msg1->values[i];
1633 const RefNetworkData& value2 = msg2->values[i];
1634 float value = value1.CalculateError(info.type, value2, format->GetItem(i), dt);
1635 float coef = info.coef;
1636 float error = coef * value;
1637

Callers

nothing calls this directly

Calls 8

IsDedicatedServerFunction · 0.85
saturateFunction · 0.85
GetSendQueueInfoMethod · 0.80
GetConnectionInfoMethod · 0.80
GetAvgFrameDurationMethod · 0.80
toIntFunction · 0.50
SampleMethod · 0.45
GetConnectionInfoRawMethod · 0.45

Tested by

no test coverage detected