| 1353 | } |
| 1354 | } |
| 1355 | } |
| 1356 | |
| 1357 | DWORD NetworkComponent::SendMsgRemote(int to, NetworkMessage* msg, NetworkMessageType type, NetMsgFlags dwFlags) |
| 1358 | { |
| 1359 | NetworkMessageFormatBase* format = GetFormat(type); |
| 1360 | if (!format) |
| 1361 | { |
| 1362 | return 0xFFFFFFFF; |
| 1363 | } |
| 1364 | |
| 1365 | #if _ENABLE_CHEATS |
| 1366 | if (outputLogs) |
| 1367 | { |
| 1368 | if (dwFlags & NMFHighPriority) |
| 1369 | { |
| 1370 | DiagLogF("%s: send HP message %s to %d", GetDebugName(), NetworkMessageTypeNames[type], to); |
| 1371 | NetworkMessageContext ctx(msg, format, this, to, MSG_RECEIVE); |
| 1372 | ctx.LogMessage(3, "\t"); |
| 1373 | } |
| 1374 | } |
| 1375 | #endif |
| 1376 | |
| 1377 | #if _ENABLE_CHEATS |
| 1378 | int level = GetDiagLevel(type, !_parent->GetClient() || to != _parent->GetClient()->GetPlayer()); |
| 1379 | if (level >= 2) |
| 1380 | { |
| 1381 | DiagLogF("%s: send message %s to %d, flags %d", GetDebugName(), NetworkMessageTypeNames[type], to, dwFlags); |
| 1382 | NetworkMessageContext ctx(msg, format, this, to, MSG_RECEIVE); |
| 1383 | ctx.LogMessage(level, "\t"); |
| 1384 | } |
| 1385 | |
| 1386 | if (outputLogs) |
| 1387 | LOG_DEBUG(Network, "{}: send message {} to {}, flags {}", GetDebugName(), NetworkMessageTypeNames[type], to, |
| 1388 | dwFlags); |
| 1389 | #else |
| 1390 | int level = 0; |
| 1391 | #endif |
| 1392 | |
| 1393 | NetworkMessageRaw rawMsg; |
| 1394 | |
| 1395 | // Message header |
| 1396 | rawMsg.Put(type, NCTSmallUnsigned); |
| 1397 | rawMsg.Put(msg->time, NCTNone); |
| 1398 | |
| 1399 | // Message body |
| 1400 | EncodeMsg(rawMsg, msg, format); |
| 1401 | |
| 1402 | msg->size = rawMsg.GetSize(); |
| 1403 | |
| 1404 | #if _ENABLE_CHEATS |
| 1405 | // note: all SendMsgRemote message are already counted in stats |
| 1406 | // we can probably remove this flag |
| 1407 | NET_ERROR((dwFlags & NMFStatsAlreadyDone) != 0); |
| 1408 | |
| 1409 | if ((dwFlags & NMFStatsAlreadyDone) == 0) |
| 1410 | { |
| 1411 | StatMsgSent(type, msg->size); |
| 1412 | } |
nothing calls this directly
no test coverage detected