Exemple #1
0
        public void Set(NetConnection udp, TcpConnection tcp, bool isTcp, string userId, byte team, byte worldId, byte selectedCharacter, int spawnIndex, int characterLevel)
        {
            mConnection   = udp;
            mTcpConnecton = tcp;
            IsTcp         = isTcp;
            UserId        = userId;
            mTeam         = team;
            mSpawnIndex   = spawnIndex;

            mReplicationManagerServer    = new ReplicationManagerServer();
            mDeliveryNotificationManager = new DeliveryNotificationManager(false, true);
            mIsLastMoveTimestampDirty    = false;
            mTimeToRespawn     = 0.0f;
            mWorldId           = worldId;
            mSelectedCharacter = selectedCharacter;
            mCharacterLevel    = characterLevel;


            // todo : 임시코드 데모 시연용
            //mSelectedCharacter = (byte)(inPlayerId % 2);

            UpdateLastPacketTime();

            mTimeOfLastSatePacket = 0.0f;

            IsStartedPlay = false;

            // 게임 종료후 일정 시간 여유를 두고 강제 종료 처리를 한다.
            mExpirePlayTime = World.Instance(worldId).GameMode.EndTime + GameMode.ExpiredTime;

            mCharacterState = null;

            Log.Information($"PlayerController set last_user_id:{UserId}, cur_user_id:{userId}, team{team}, session:{mSessionId.ToString()}, ip:{GetIpAddress()}, lv:{characterLevel}");
        }
        public override void HandleDeliveryFailure(DeliveryNotificationManager inDeliveryNotificationManager)
        {
            if (mTransmissions.Count > 10)
            {
                Log.Warning($"HandleDeliveryFailure FailCount:{mTransmissions.Count}");
            }
            //Log.Warning($"HandleDeliveryFailure NetworkIDs:{string.Join(",", mTransmissions.Select(x => x.GetNetworkId()))}");
            //Log.Warning($"HandleDeliveryFailure Actions:{string.Join(",", mTransmissions.Select(x => x.GetAction()))}");

            //run through the transmissions
            foreach (var rt in mTransmissions)
            {
                switch (rt.GetAction())
                {
                case ReplicationAction.RA_Create:
                    HandleCreateDeliveryFailure(rt.GetNetworkId(), rt.GetWorldId());
                    break;

                case ReplicationAction.RA_Update:
                    HandleUpdateStateDeliveryFailure(rt.GetNetworkId(), rt.GetState(), inDeliveryNotificationManager, rt.GetWorldId());
                    break;

                case ReplicationAction.RA_Destroy:
                    HandleDestroyDeliveryFailure(rt.GetNetworkId());
                    break;
                }
            }
        }
Exemple #3
0
        public ClientProxy(System.Net.IPEndPoint inSocketAddress, string inName, int inPlayerId, byte worldId)
        {
            mSocketAddress = inSocketAddress;
            mName          = inName;
            mPlayerId      = inPlayerId;
            mDeliveryNotificationManager = new DeliveryNotificationManager(false, true);
            mIsLastMoveTimestampDirty    = false;
            mTimeToRespawn = 0.0f;
            mWorldId       = worldId;

            UpdateLastPacketTime();
        }
Exemple #4
0
        public override void HandleDeliverySuccess(DeliveryNotificationManager inDeliveryNotificationManager)
        {
            //run through the transmissions, if any are Destroyed then we can remove this network id from the map
            foreach (var rt in mTransmissions)
            {
                switch (rt.GetAction())
                {
                case ReplicationAction.RA_Create:
                    HandleCreateDeliverySuccess(rt.GetNetworkId());
                    break;

                case ReplicationAction.RA_Destroy:
                    HandleDestroyDeliverySuccess(rt.GetNetworkId());
                    break;
                }
            }
        }
Exemple #5
0
        public override void HandleDeliveryFailure(DeliveryNotificationManager inDeliveryNotificationManager)
        {
            //run through the transmissions
            foreach (var rt in mTransmissions)
            {
                //is it a create? then we have to redo the create.
                int networkId = rt.GetNetworkId();

                switch (rt.GetAction())
                {
                case ReplicationAction.RA_Create:
                    HandleCreateDeliveryFailure(networkId);
                    break;

                case ReplicationAction.RA_Update:
                    HandleUpdateStateDeliveryFailure(networkId, rt.GetState(), inDeliveryNotificationManager);
                    break;

                case ReplicationAction.RA_Destroy:
                    HandleDestroyDeliveryFailure(networkId);
                    break;
                }
            }
        }
Exemple #6
0
        void HandleUpdateStateDeliveryFailure(int inNetworkId, uint32_t inState, DeliveryNotificationManager inDeliveryNotificationManager)
        {
            //does the object still exist? it might be dead, in which case we don't resend an update
            if (NetworkManagerServer.sInstance.GetGameObject(inNetworkId) != null)
            {
                //look in all future in flight packets, in all transmissions
                //remove written state from dirty state
                foreach (var inFlightPacket in inDeliveryNotificationManager.GetInFlightPackets())
                {
                    ReplicationManagerTransmissionData rmtdp = (ReplicationManagerTransmissionData)(inFlightPacket.GetTransmissionData((int)TransmissionDataType.kReplicationManager));

                    foreach (var otherRT in rmtdp.mTransmissions)
                    {
                        inState &= ~otherRT.GetState();
                    }
                }

                //if there's still any dirty state, mark it
                if (inState != 0)
                {
                    mReplicationManagerServer.SetStateDirty(inNetworkId, inState);
                }
            }
        }