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

Method EncodeMsgItem

engine/Poseidon/Network/NetworkMsgContext.cpp:1513–1700  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1511 }
1512 return msgID;
1513}
1514
1515void NetworkComponent::EncodeMsgItem(NetworkMessageRaw& dst, NetworkMessage* msg, const RefNetworkData& val,
1516 const NetworkMessageFormatItem& formatItem)
1517{
1518 switch (formatItem.type)
1519 {
1520 case NDTBool:
1521 {
1522 CHECK_ASSIGN(valTyped, val, const RefNetworkDataTyped<bool>)
1523 dst.Put(valTyped.GetVal(), formatItem.compression);
1524 }
1525 break;
1526 case NDTInteger:
1527 {
1528 CHECK_ASSIGN(valTyped, val, const RefNetworkDataTyped<int>)
1529 dst.Put(valTyped.GetVal(), formatItem.compression);
1530 }
1531 break;
1532 case NDTFloat:
1533 {
1534 CHECK_ASSIGN(valTyped, val, const RefNetworkDataTyped<float>)
1535 dst.Put(valTyped.GetVal(), formatItem.compression);
1536 }
1537 break;
1538 case NDTString:
1539 {
1540 CHECK_ASSIGN(valTyped, val, const RefNetworkDataTyped<RString>)
1541 dst.Put(valTyped.GetVal(), formatItem.compression);
1542 }
1543 break;
1544 case NDTRawData:
1545 {
1546 CHECK_ASSIGN(valTyped, val, const RefNetworkDataTyped<AutoArray<char>>)
1547 AutoArray<char>& array = valTyped.GetVal();
1548 int m = array.Size();
1549 dst.Put(m, NCTSmallUnsigned);
1550 for (int j = 0; j < m; j++)
1551 {
1552 dst.Put(array[j], formatItem.compression);
1553 }
1554 }
1555 break;
1556 case NDTTime:
1557 {
1558 CHECK_ASSIGN(valTyped, val, const RefNetworkDataTyped<Time>)
1559 dst.Put(valTyped.GetVal(), formatItem.compression);
1560 }
1561 break;
1562 case NDTVector:
1563 {
1564 CHECK_ASSIGN(valTyped, val, const RefNetworkDataTyped<Vector3>)
1565 dst.Put(valTyped.GetVal(), formatItem.compression);
1566 }
1567 break;
1568 case NDTMatrix:
1569 {
1570 CHECK_ASSIGN(valTyped, val, const RefNetworkDataTyped<Matrix3>)

Callers

nothing calls this directly

Calls 2

PutMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected