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

Method TransferCustomRadio

engine/Poseidon/Network/NetworkMisc.cpp:1007–1034  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1005 LOG_WARN(Network, "[TransferFile] refusing empty file '{}'", (const char*)source);
1006 return;
1007 }
1008 if (data.empty())
1009 {
1010 LOG_WARN(Network, "[TransferFile] failed to read '{}'", (const char*)source);
1011 return;
1012 }
1013
1014 if (IsNetworkPlayerCustomTransferPath(dest))
1015 {
1016 Poseidon::Foundation::CRCCalculator calculator;
1017 const uint32_t contentCrc = calculator.CRC(data.data(), static_cast<int>(data.size()));
1018 char recipientPrefix[32];
1019 snprintf(recipientPrefix, sizeof(recipientPrefix), "%d:", to);
1020 // Valid transferred-asset paths contain no ':', so the trailing separator makes route matching exact.
1021 const RString transferRoute = RString(recipientPrefix) + dest + RString(":");
1022 char signatureSuffix[64];
1023 snprintf(signatureSuffix, sizeof(signatureSuffix), "%zu:%08x", data.size(), contentCrc);
1024 const RString transferKey = transferRoute + RString(signatureSuffix);
1025 bool knownRoute = false;
1026 for (int i = 0; i < _sentCustomFileTransfers.Size(); ++i)
1027 {
1028 RString& previousTransfer = _sentCustomFileTransfers[i];
1029 if (strncmp((const char*)previousTransfer, (const char*)transferRoute, transferRoute.GetLength()) != 0)
1030 {
1031 continue;
1032 }
1033 if (previousTransfer == transferKey)
1034 {
1035 LOG_DEBUG(Network, "[NMTTransferFile] duplicate custom relay skipped to {} dst='{}' bytes={}", to,
1036 (const char*)dest, data.size());
1037 return;

Callers

nothing calls this directly

Calls 5

GetServerTmpDirFunction · 0.85
CreatePathFunction · 0.85
GetClientMethod · 0.80
RStringClass · 0.50
GetPlayerMethod · 0.45

Tested by

no test coverage detected