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

Method AssignPlayer

engine/Poseidon/Network/NetworkClientActions.cpp:1496–1540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1494 players.Resize(0);
1495 for (int i = 0; i < _identities.Size(); i++)
1496 {
1497 int index = players.Add();
1498 players[index].dpid = _identities[i].dpnid;
1499 players[index].name = _identities[i].GetName();
1500 }
1501}
1502
1503void NetworkClient::AssignPlayer(int role, int player)
1504{
1505 if (role < 0 || role >= _playerRoles.Size())
1506 {
1507 return;
1508 }
1509
1510 if (_playerRoles[role].player == player)
1511 {
1512 return;
1513 }
1514
1515 PlayerRole info = Poseidon::BuildNetworkPlayerRoleAssignmentRequest(_playerRoles[role], player);
1516
1517 // create message
1518 NetworkMessageType type = info.GetNMType(NMCCreate);
1519 NetworkMessageFormatBase* format = GetFormat(type);
1520 Ref<NetworkMessage> msg = new NetworkMessage();
1521 msg->time = Glob.time;
1522 NetworkMessageContext ctx(msg, format, this, TO_SERVER, MSG_SEND);
1523
1524 NET_ERROR(dynamic_cast<const IndicesPlayerRole*>(ctx.GetIndices()))
1525 const IndicesPlayerRole* indices = static_cast<const IndicesPlayerRole*>(ctx.GetIndices());
1526
1527 TMError err;
1528 err = ctx.IdxTransfer(indices->index, role);
1529 if (err != TMOK)
1530 {
1531 return;
1532 }
1533 err = info.TransferMsg(ctx);
1534 if (err != TMOK)
1535 {
1536 return;
1537 }
1538
1539 // send message
1540 NetworkComponent::SendMsg(TO_SERVER, msg, type, NMFGuaranteed);
1541}
1542
1543void NetworkClient::AskForDammage(Object* who, EntityAI* owner, Vector3Par modelPos, float val, float valRange,

Callers

nothing calls this directly

Calls 5

SizeMethod · 0.45
GetNMTypeMethod · 0.45
GetIndicesMethod · 0.45
IdxTransferMethod · 0.45
TransferMsgMethod · 0.45

Tested by

no test coverage detected