Пример #1
0
    protected void CoverEnter(int coverIndex, E_CoverDirection coverDirection, uLink.NetworkMessageInfo info)
    {
        Cover cover = Mission.Instance.GameZone.GetCover(coverIndex);

        if (cover == null)
        {
            Debug.LogWarning("Received CoverEnter RPC but no cover was found at the specified position. This could indicate a position sync problem.");
            return;
        }

#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            //Only server has the right to ignore the cover enter
            if (Owner.BlackBoard.DontUpdate)
            {
                return;
            }

            ServerAnticheat.ReportCoverEnter(Owner.NetworkView.owner, cover, coverDirection, info);
            Owner.NetworkView.RPC("CoverEnter", uLink.RPCMode.OthersExceptOwner, coverIndex, coverDirection);
        }
#endif

        Owner.CoverStart(cover, coverDirection);
    }
Пример #2
0
    protected void MineDetected(NetworkViewID mineID, uLink.NetworkMessageInfo info)
    {
        uLink.NetworkView view = uLink.NetworkView.Find(mineID);
        if (view == null)
        {
            return;
        }

        Mine mine = view.GetComponent <Mine>();

        if (mine == null)
        {
            return;
        }

#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportMineDetected(Owner.NetworkView.owner, mine, info);
        }
#endif

        if (!mine.IsDetected)
        {
            mine.SetDetected(true);
        }

//		Debug.Log ("MineDetected(), Owner=" + Owner.name + ", mine=" + mine.name);
    }
Пример #3
0
    protected void AgentDetected(NetworkViewID senderID, NetworkViewID agentID, bool detected, uLink.NetworkMessageInfo info)
    {
        uLink.NetworkView agentView = uLink.NetworkView.Find(agentID);
        if (!agentView)
        {
            return;
        }

        uLink.NetworkView senderView = uLink.NetworkView.Find(senderID);
        if (!senderView)
        {
            return;
        }

        AgentHuman agent  = agentView.GetComponent <AgentHuman>();
        AgentHuman sender = senderView.GetComponent <AgentHuman>();

#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportAgentDetected(Owner.NetworkView.owner, agent, sender, info);
        }
#endif

        if (sender && sender.IsAlive && agent && agent.IsAlive && sender.IsFriend(agent) == false)
        {
            agent.BlackBoard.IsDetected = detected;

//			Debug.Log ("AgentDetected(), detected=" + detected + ", Owner=" + Owner.name + ", sender=" + sender.name + ", agent=" + agent.name);
        }
    }
Пример #4
0
    protected void UseItemInCover(E_ItemID gadget, E_CoverPose coverPose, E_CoverDirection coverDirection, uLink.NetworkMessageInfo info)
    {
        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportUseItemInCover(Owner.NetworkView.owner, gadget, coverPose, coverDirection, info);
            Owner.NetworkView.RPC("UseItemInCover", uLink.RPCMode.OthersExceptOwner, gadget, coverPose, coverDirection);
        }
#endif

        Owner.BlackBoard.KeepMotion     = false;
        Owner.BlackBoard.Desires.Gadget = gadget;

        AgentActionUseItem a = AgentActionFactory.Create(AgentActionFactory.E_Type.UseItem) as AgentActionUseItem;

        a.CoverDirection = coverDirection;
        a.CoverPose      = coverPose;

        Owner.BlackBoard.ActionAdd(a);

        Owner.WorldState.SetWSProperty(E_PropKey.AtTargetPos, true);
    }
Пример #5
0
    protected void CoverLeave(AgentActionCoverLeave.E_Type typeOfLeave, uLink.NetworkMessageInfo info)
    {
        //TODO: How is this? I believe we definitelly cannot afford to ignore the CoverLeave event on both on proxies and I think we
        //should not ignore it on server too. No doubt about proxies - they should just do what they are told to do.
        //About the server - how can we ignore it without fixing a client? If we ignore it, the player stayes in a cover forever
        //which might cause both: visual artefacts and even detecting player as a cheater.
        //I don't think that a potential cheater can gain much of benefit by leaving the cover prematurely.

        //if (Owner.BlackBoard.DontUpdate)
        //	return;

        if (Owner.IsInCover)
        {
#if !DEADZONE_CLIENT
            if (Owner.IsServer)
            {
                ServerAnticheat.ReportCoverLeave(Owner.NetworkView.owner, typeOfLeave, info);
                Owner.NetworkView.RPC("CoverLeave", uLink.RPCMode.OthersExceptOwner, typeOfLeave);
            }
#endif

            AgentActionCoverLeave action = AgentActionFactory.Create(AgentActionFactory.E_Type.CoverLeave) as AgentActionCoverLeave;
            action.TypeOfLeave        = typeOfLeave;
            action.FinalViewDirection = Owner.BlackBoard.Cover.Forward;
            action.Cover = Owner.BlackBoard.Cover;

            Owner.BlackBoard.ActionAdd(action);
        }
    }
Пример #6
0
    protected void Melee(E_MeleeType meleeType, uLink.NetworkViewID viewID, uLink.NetworkMessageInfo info)
    {
        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

        uLink.NetworkView view = uLink.NetworkView.Find(viewID);

        if (null == view)
        {
            // target was just destroyed
            return;
        }

        Agent targetAgent = view.GetComponent <Agent>();

        if (targetAgent == null)
        {
            return;             // wtf ?
        }
#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            if (!ServerAnticheat.ReportAndValidateMelee(Owner.NetworkView.owner, Owner, targetAgent, info))
            {
                // Ignore the action when it is not valid. This may happen even in a regular/fair game when
                // an attacking playerexperiences a lag.
                return;
            }
        }
#endif

        AgentActionMelee a = AgentActionFactory.Create(AgentActionFactory.E_Type.Melee) as AgentActionMelee;
        a.Target    = targetAgent;
        a.MeleeType = meleeType;
        Owner.BlackBoard.ActionAdd(a);

        if (a.IsFailed())
        {
            return;             // wtf ?
        }
        if (Owner.IsServer)
        {
            //send to proxies
            Owner.NetworkView.RPC("Melee", uLink.RPCMode.OthersExceptOwner, meleeType, viewID);

            //knockdown target immediatly, its player, we dont have time wait ....
            Vector3 direction = (a.Target.Position - Owner.Position).normalized;
            a.Target.KnockDown(Owner, meleeType, direction);
        }

        //Debug.Log(Time.timeSinceLevelLoad + " " + "Melee " + a.MeleeType + " " + a.Target.name);
    }
Пример #7
0
    protected bool ValidateHit(RaycastHit hit)
    {
#if !DEADZONE_CLIENT
        if (uLink.Network.isServer)
        {
            return(ServerAnticheat.ValidateHit(Agent, this, hit));
        }
#endif

        return(true);
    }
Пример #8
0
    protected void AttackS(Vector3 fromPos, Vector3 attackDir, uLink.NetworkMessageInfo info)
    {
        if (!Owner.IsServer)
        {
            return;
        }

        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

        // player cannot attack during spawn protection timer
        if (Owner.IsSpawnedRecently)
        {
            return;
        }

        WeaponBase weapon = Owner.WeaponComponent.GetCurrentWeapon();

        if (weapon == null)
        {
            return;
        }

        // Neni penis, neni laska :-)
        if (weapon.ClipAmmo == 0)
        {
            return;
        }

        if (!ServerAnticheat.ReportAndValidateAttack(Owner.NetworkView.owner, weapon, fromPos, attackDir, info))
        {
            //Ignore this attack as it is not valid
            weapon.DecreaseAmmo();
            return;
        }

        if (ServerWeaponIsBusy(weapon))
        {
            PostponedServerAttack.FromPos   = fromPos;
            PostponedServerAttack.AttackDir = attackDir;
            PostponedServerAttack.Weapon    = weapon;
        }
        else
        {
            ProcessServerAttack(weapon, fromPos, attackDir);
        }
    }
Пример #9
0
    protected void Roll(E_Direction direction, uLink.NetworkMessageInfo info)
    {
#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportRoll(Owner.NetworkView.owner, direction, info);
            Owner.NetworkView.RPC("Roll", uLink.RPCMode.OthersExceptOwner, direction);
        }
#endif

        AgentActionRoll a = AgentActionFactory.Create(AgentActionFactory.E_Type.Roll) as AgentActionRoll;
        a.Direction = direction;

        Owner.BlackBoard.ActionAdd(a);
    }
Пример #10
0
    protected bool ValidateHitAgainstEnemy(RaycastHit hit)
    {
#if !DEADZONE_CLIENT
        if (uLink.Network.isServer)
        {
            AgentHuman other = hit.transform.gameObject.GetComponent <AgentHuman>();
            if ((other != null) && !other.IsFriend(Agent))
            {
                return(ServerAnticheat.ValidateHit(Agent, this, hit));
            }
        }
#endif

        return(true);
    }
Пример #11
0
    protected void TeamCmd(E_CommandID id, uLink.NetworkMessageInfo info)
    {
#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportTeamCmd(Owner.NetworkView.owner, id, info);

            Owner.NetworkView.RPC("TeamCmd", uLink.RPCMode.OthersExceptOwner, id);
            return;
        }
#endif

        AgentActionTeamCommand a = AgentActionFactory.Create(AgentActionFactory.E_Type.TeamCommand) as AgentActionTeamCommand;
        a.Command = id;

        Owner.BlackBoard.ActionAdd(a);
    }
Пример #12
0
    void ChangeWeaponC(E_WeaponID weapon, uLink.NetworkMessageInfo info)
    {
#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportPotentialCheatAttempt("ChangeWeaponC", "should never be called on the server side", Owner.NetworkView.owner);
            return;
        }
#endif

        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

        AgentActionWeaponChange action = AgentActionFactory.Create(AgentActionFactory.E_Type.WeaponChange) as AgentActionWeaponChange;
        action.NewWeapon = weapon;
        Owner.BlackBoard.ActionAdd(action);
    }
Пример #13
0
    protected void AttackC(Vector3 attackDir)
    {
        // TODO: I'm not sure what causes DontUpdate to be set to true on clients (especially proxies) but I would
        //say f**k it on proxies! The proxy has to do what server says. No way to ignore to spawn a projectile.
        //if (Owner.BlackBoard.DontUpdate)
        //	return;

#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportPotentialCheatAttempt("AttackC", "should never be called on the server side", Owner.NetworkView.owner);
            return;
        }
#endif

        AgentActionAttack action = AgentActionFactory.Create(AgentActionFactory.E_Type.Attack) as AgentActionAttack;
        action.AttackDir = attackDir;
        Owner.BlackBoard.ActionAdd(action);
    }
Пример #14
0
    protected void Death(NetworkViewID attackerNVId, Vector3 pos, Vector3 impuls, short damage, short bodyPart)
    {
#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportPotentialCheatAttempt("Death", "should never be called on the server side", Owner.NetworkView.owner);
            return;
        }
#endif

        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

        uLink.NetworkView View = (attackerNVId != uLink.NetworkViewID.unassigned) ? uLink.NetworkView.Find(attackerNVId) : null;

        Owner.Die(View ? View.GetComponent <AgentHuman>() : null, pos, impuls, damage, (E_BodyPart)bodyPart);
    }
Пример #15
0
    void ChangeWeapon(E_WeaponID weapon, uLink.NetworkMessageInfo info)
    {
        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportChangeWeapon(Owner.NetworkView.owner, weapon, info);
        }
#endif

        AgentActionWeaponChange action = AgentActionFactory.Create(AgentActionFactory.E_Type.WeaponChange) as AgentActionWeaponChange;
        action.NewWeapon = weapon;
        Owner.BlackBoard.ActionAdd(action);

        Owner.NetworkView.RPC("ChangeWeaponC", uLink.RPCMode.OthersExceptOwner, weapon);
    }
Пример #16
0
    protected void Knockdown(E_MeleeType meleeType, uLink.NetworkViewID viewId, Vector3 direction)
    {
#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportPotentialCheatAttempt("Knockdown", "should never be called on the server side", Owner.NetworkView.owner);
            return;
        }
#endif

        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

        uLink.NetworkView View     = (viewId != uLink.NetworkViewID.unassigned) ? uLink.NetworkView.Find(viewId) : null;
        AgentHuman        attacker = View ? View.GetComponent <AgentHuman>() : null;

        Owner.KnockDown(attacker, meleeType, direction);
    }
Пример #17
0
    protected void CoverFireStop(uLink.NetworkMessageInfo info)
    {
        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportCoverFireStop(Owner.NetworkView.owner, info);
            Owner.NetworkView.RPC("CoverFireStop", uLink.RPCMode.OthersExceptOwner);
        }
#endif

        if (Owner.IsInCover)
        {
            AgentActionCoverFireCancel action = AgentActionFactory.Create(AgentActionFactory.E_Type.CoverFireCancel) as AgentActionCoverFireCancel;

            Owner.BlackBoard.ActionAdd(action);
        }
    }
Пример #18
0
    protected void UseItem(E_ItemID gadget, bool keepMotion, uLink.NetworkMessageInfo info)
    {
//		Debug.Log ("ComponentNetworkAction.UseItem(), time=" + Time.timeSinceLevelLoad + ", BlackBoard.KeepMotion=" + Owner.BlackBoard.KeepMotion + ", Owner.IsOwner=" + Owner.IsOwner + ", Owner.IsServer=" + Owner.IsServer + ", BlackBoard.DontUpdate=" + Owner.BlackBoard.DontUpdate);

        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportUseItem(Owner.NetworkView.owner, gadget, keepMotion, info);
            Owner.NetworkView.RPC("UseItem", uLink.RPCMode.OthersExceptOwner, gadget, keepMotion);
        }
#endif

        Owner.BlackBoard.KeepMotion     = keepMotion;
        Owner.BlackBoard.Desires.Gadget = gadget;
        Owner.BlackBoard.ActionAdd(AgentActionFactory.Create(AgentActionFactory.E_Type.UseItem));

        Owner.WorldState.SetWSProperty(E_PropKey.AtTargetPos, true);
    }
Пример #19
0
    protected void Reload(uLink.NetworkMessageInfo info)
    {
        //TODO: What about this condition on the proxies. Again, I would say f**k it
        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportReload(Owner.NetworkView.owner, info);
            Owner.NetworkView.RPC("Reload", uLink.RPCMode.OthersExceptOwner);
        }
#endif

        if (Owner.IsInCover)
        {
            Owner.BlackBoard.ActionAdd((AgentActionIdle)AgentActionFactory.Create(AgentActionFactory.E_Type.Idle));
        }

        AgentAction reloadAction = AgentActionFactory.Create(AgentActionFactory.E_Type.Reload) as AgentActionReload;
        Owner.BlackBoard.ActionAdd(reloadAction);
    }
Пример #20
0
    protected void CoverFireStart(E_CoverPose pose, E_CoverDirection direction, uLink.NetworkMessageInfo info)
    {
        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportCoverFireStart(Owner.NetworkView.owner, pose, direction, info);
            Owner.NetworkView.RPC("CoverFireStart", uLink.RPCMode.OthersExceptOwner, pose, direction);
        }
#endif

        if (Owner.IsInCover)
        {
            AgentActionCoverFire action = AgentActionFactory.Create(AgentActionFactory.E_Type.CoverFire) as AgentActionCoverFire;
            action.CoverPose      = pose;
            action.CoverDirection = direction;

            Owner.BlackBoard.ActionAdd(action);
        }
    }
Пример #21
0
    void ServerUpdate(Vector3 ownerPos,
                      Vector3 vel,
                      byte quantBodyYaw,
                      byte quantAimPitch,
                      byte quantAimYaw,
                      Vector3 FireTargetPlace,
                      uLink.NetworkMessageInfo info)
    {
        if (!Owner.IsAlive || Owner.IsInKnockdown)
        {
            // ignore any data from client when the character is dead
            //ignore any data when he is in knockdown, because move is handled by server now...
            return;
        }

        if (info.timestamp <= serverLastTimestamp)
        {
            return;
        }

        float      bodyYaw      = NetUtils.DequantizeAngle(quantBodyYaw, 8);
        Quaternion bodyRotation = Quaternion.Euler(0, bodyYaw, 0);

        float      aimPitch    = NetUtils.DequantizeAngle(quantAimPitch, 8);
        float      aimYaw      = NetUtils.DequantizeAngle(quantAimYaw, 8);
        Quaternion aimRotation = Quaternion.Euler(aimPitch, aimYaw, 0);
        Vector3    fireDir     = aimRotation * Vector3.forward;

        Owner.BlackBoard.Desires.Rotation = aimRotation;

#if !DEADZONE_CLIENT
        ServerAnticheat.ReportMove(Owner.NetworkView.owner, ownerPos, vel, info);
#endif

        //TODO remove/reimplement this is a very naive code. The server accepts the position from the client but limits the speed at the same time.
        //The only benefit I can see that the character will not move too fast once a no more messages will come from its client.
        if (vel.sqrMagnitude > sqrMaxServerSpeed)
        {
            vel.x = vel.y = vel.z = Mathf.Sqrt(sqrMaxServerSpeed) / 3.0f;
        }

        //float deltaTime = (float)( info.timestamp - serverLastTimestamp );
        //Vector3 deltaPos = vel * deltaTime;

        if (applyTransformations)
        {
            //m_Transform.rotation = bodyRotation;
            m_Transform.localRotation = bodyRotation;

            // character.Move( deltaPos ); // HACK for now
        }

        //m_Transform.position = ownerPos;
        m_Transform.localPosition = ownerPos;         // TODO Hack, this means the server is no longer authoritative.

        rotation = bodyRotation;
        velocity = vel;

        Owner.BlackBoard.Desires.FireDirection = Owner.BlackBoard.FireDir = fireDir;

        Owner.BlackBoard.Desires.FireTargetPlace = FireTargetPlace;

        serverLastTimestamp = info.timestamp;

        /*Vector3 serverPos = m_Transform.position;
         * Vector3 diff = serverPos - ownerPos;*/

        /*
         * if( Vector3.SqrMagnitude( diff ) > sqrMaxServerError )
         * {
         #if USE_RPC_INSTEAD_UNRELIABLERPC
         *      networkView.RPC( "AdjustOwnerPos", uLink.RPCMode.Owner, serverPos );
         #else
         *      networkView.UnreliableRPC( "AdjustOwnerPos", uLink.RPCMode.Owner, serverPos );
         #endif //USE_RPC_INSTEAD_UNRELIABLERPC
         *
         * }
         * else
         * {
         #if USE_RPC_INSTEAD_UNRELIABLERPC
         *      networkView.RPC( "GoodOwnerPos", uLink.RPCMode.Owner );
         #else
         *      networkView.UnreliableRPC( "GoodOwnerPos", uLink.RPCMode.Owner );
         #endif // USE_RPC_INSTEAD_UNRELIABLERPC
         * }
         *
         */
        if (velocity.sqrMagnitude > Mathf.Epsilon)
        {
            Owner.cbServerUserInput();
        }
    }
Пример #22
0
 void Start()
 {
     ServerAnticheat.ReportAgentSpawned(Owner);
 }