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

Method CreateCommand

engine/Poseidon/Network/NetworkClientActions.cpp:825–864  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823
824 // send message
825 DWORD dwMsgId = NetworkComponent::SendMsg(TO_SERVER, msg, msgType, NMFGuaranteed);
826 return dwMsgId != 0xFFFFFFFF;
827}
828
829bool NetworkClient::CreateCommand(AISubgroup* subgrp, int index, Command* cmd)
830{
831 if (_state < NGSLoadIsland)
832 {
833 return false;
834 }
835
836 NetworkId id = CreateLocalObject(cmd);
837
838 // send message to center
839 NetworkMessageType msgType = cmd->GetNMType(NMCCreate);
840 NetworkMessageFormatBase* format = GetFormat(/*LOCAL_PLAYER, */ msgType);
841
842 // create message
843 Ref<NetworkMessage> msg = new NetworkMessage();
844 msg->time = Glob.time;
845 NetworkMessageContext ctx(msg, format, this, TO_SERVER, MSG_SEND);
846 ctx.SetClass(NMCCreate);
847
848 // difference from CreateObject - command doesnot known its subgrp, index
849 NET_ERROR(dynamic_cast<const IndicesCreateCommand*>(ctx.GetIndices()))
850 const IndicesCreateCommand* indices = static_cast<const IndicesCreateCommand*>(ctx.GetIndices());
851
852 if (ctx.IdxTransferRef(indices->subgroup, subgrp) != TMOK)
853 {
854 return false;
855 }
856 if (ctx.IdxTransfer(indices->index, index) != TMOK)
857 {
858 return false;
859 }
860 if (cmd->TransferMsg(ctx) != TMOK)
861 {
862 return false;
863 }
864
865 // send message
866 DWORD dwMsgId = NetworkComponent::SendMsg(TO_SERVER, msg, msgType, NMFGuaranteed);
867 return dwMsgId != 0xFFFFFFFF;

Callers

nothing calls this directly

Calls 6

SetClassMethod · 0.80
IdxTransferRefMethod · 0.80
GetNMTypeMethod · 0.45
GetIndicesMethod · 0.45
IdxTransferMethod · 0.45
TransferMsgMethod · 0.45

Tested by

no test coverage detected