| 773 | void NetworkClient::ClientReady(NetworkGameState state) |
| 774 | { |
| 775 | ChangeGameState gs(state); |
| 776 | SendMsg(&gs, NMFGuaranteed); |
| 777 | } |
| 778 | |
| 779 | bool NetworkClient::CreateVehicle(Vehicle* veh, VehicleListType list, RString name, int idVeh) |
| 780 | { |
| 781 | if (!veh) |
| 782 | { |
| 783 | return false; |
| 784 | } |
| 785 | if (_state < NGSLoadIsland) |
| 786 | { |
| 787 | return false; |
| 788 | } |
| 789 | |
| 790 | NetworkId id = CreateLocalObject(veh); |
| 791 | |
| 792 | // send message to center |
| 793 | NetworkMessageType msgType = veh->GetNMType(NMCCreate); |
| 794 | NetworkMessageFormatBase* format = GetFormat(/*LOCAL_PLAYER, */ msgType); |
| 795 | |
| 796 | // create message |
| 797 | Ref<NetworkMessage> msg = new NetworkMessage(); |
| 798 | msg->time = Glob.time; |
| 799 | NetworkMessageContext ctx(msg, format, this, TO_SERVER, MSG_SEND); |
| 800 | ctx.SetClass(NMCCreate); |
| 801 | |
| 802 | // difference from CreateObject - vehicle doesnot known its list, name, id: |
| 803 | NET_ERROR(dynamic_cast<const IndicesCreateVehicle*>(ctx.GetIndices())) |
| 804 | const IndicesCreateVehicle* indices = static_cast<const IndicesCreateVehicle*>(ctx.GetIndices()); |
| 805 | |
| 806 | if (ctx.IdxTransfer(indices->list, (int&)list) != TMOK) |
| 807 | { |
| 808 | return false; |
| 809 | } |
| 810 | if (ctx.IdxTransfer(indices->name, name) != TMOK) |
| 811 | { |
| 812 | return false; |
| 813 | } |
| 814 | if (ctx.IdxTransfer(indices->idVehicle, idVeh) != TMOK) |
| 815 | { |
| 816 | return false; |
| 817 | } |
| 818 | |
| 819 | if (veh->TransferMsg(ctx) != TMOK) |
| 820 | { |
| 821 | return false; |
| 822 | } |
| 823 | |
| 824 | // send message |
| 825 | DWORD dwMsgId = NetworkComponent::SendMsg(TO_SERVER, msg, msgType, NMFGuaranteed); |
| 826 | return dwMsgId != 0xFFFFFFFF; |
nothing calls this directly
no test coverage detected