public bool HandlePacket(Peer peer, byte[] data) { var peerInfo = _playerManager.GetPeerInfo(peer); var champion = peerInfo.Champion; if (peerInfo == null || champion.IsDashing || champion.IsDead || champion.IsCastingSpell) { return(true); } var request = new MovementReq(data); var vMoves = readWaypoints(request.moveData, request.coordCount, _game.Map); switch (request.type) { case MoveType.STOP: //TODO anticheat, currently it trusts client 100% peerInfo.Champion.setPosition(request.x, request.y); float x = ((request.x) - _game.Map.GetWidth()) / 2; float y = ((request.y) - _game.Map.GetHeight()) / 2; for (var i = 0; i < vMoves.Count; i++) { var v = vMoves[i]; v.X = (short)request.x; v.Y = (short)request.y; } break; case MoveType.EMOTE: //Logging->writeLine("Emotion"); return(true); case MoveType.ATTACKMOVE: peerInfo.Champion.MoveOrder = MoveOrder.MOVE_ORDER_ATTACKMOVE; break; case MoveType.MOVE: peerInfo.Champion.MoveOrder = MoveOrder.MOVE_ORDER_MOVE; break; } vMoves[0] = new Vector2(peerInfo.Champion.X, peerInfo.Champion.Y); peerInfo.Champion.SetWaypoints(vMoves); var u = _game.Map.GetObjectById(request.targetNetId) as Unit; if (u == null) { peerInfo.Champion.TargetUnit = null; return(true); } peerInfo.Champion.TargetUnit = u; return(true); }
public bool HandlePacket(Peer peer, byte[] data, Game game) { var peerInfo = game.GetPeerInfo(peer); if (peerInfo == null || peerInfo.GetChampion().isDashing() || peerInfo.GetChampion().isDead()) { return(true); } var request = new MovementReq(data); var vMoves = readWaypoints(request.moveData, request.coordCount, game.GetMap()); switch (request.type) { case MoveType.STOP: //TODO anticheat, currently it trusts client 100% peerInfo.GetChampion().setPosition(request.x, request.y); float x = ((request.x) - game.GetMap().GetWidth()) / 2; float y = ((request.y) - game.GetMap().GetHeight()) / 2; for (var i = 0; i < vMoves.Count; i++) { var v = vMoves[i]; v.X = (short)request.x; v.Y = (short)request.y; } break; case MoveType.EMOTE: //Logging->writeLine("Emotion"); return(true); case MoveType.ATTACKMOVE: peerInfo.GetChampion().setMoveOrder(MoveOrder.MOVE_ORDER_ATTACKMOVE); break; case MoveType.MOVE: peerInfo.GetChampion().setMoveOrder(MoveOrder.MOVE_ORDER_MOVE); break; } vMoves[0] = new Vector2(peerInfo.GetChampion().getX(), peerInfo.GetChampion().getY()); peerInfo.GetChampion().setWaypoints(vMoves); var u = game.GetMap().GetObjectById(request.targetNetId) as Unit; if (u == null) { peerInfo.GetChampion().setTargetUnit(null); return(true); } peerInfo.GetChampion().setTargetUnit(u); return(true); }
public unsafe bool HandlePacket(ENetPeer *peer, byte[] data, Game game) { var peerInfo = game.getPeerInfo(peer); if (peerInfo == null || peerInfo.getChampion().isDashing() || peerInfo.getChampion().isDead()) { return(true); } var request = new MovementReq(data); var vMoves = new List <Vector2>();//readWaypoints(request.moveData, request.coordCount, game.getMap()); vMoves.Add(new Vector2(peerInfo.getChampion().getX(), peerInfo.getChampion().getY())); vMoves.Add(new Vector2(request.x, request.y)); // TODO switch (request.type) { case MoveType.STOP: { //TODO anticheat, currently it trusts client 100% peerInfo.getChampion().setPosition(request.x, request.y); float x = ((request.x) - game.getMap().getWidth()) / 2; float y = ((request.y) - game.getMap().getHeight()) / 2; for (var i = 0; i < vMoves.Count; i++) { var v = vMoves[i]; v.X = (short)request.x; v.Y = (short)request.y; } Logger.LogCoreInfo("Stopped at x: " + request.x + ", y: " + request.y); break; } case MoveType.EMOTE: //Logging->writeLine("Emotion"); return(true); case MoveType.ATTACKMOVE: peerInfo.getChampion().setMoveOrder(MoveOrder.MOVE_ORDER_ATTACKMOVE); break; case MoveType.MOVE: peerInfo.getChampion().setMoveOrder(MoveOrder.MOVE_ORDER_MOVE); break; } // Sometimes the client will send a wrong position as the first one, override it with server data vMoves[0] = new Vector2(peerInfo.getChampion().getX(), peerInfo.getChampion().getY()); peerInfo.getChampion().setWaypoints(vMoves); var u = game.getMap().getObjectById(request.targetNetId) as Unit; if (u == null) { peerInfo.getChampion().setTargetUnit(null); return(true); } peerInfo.getChampion().setTargetUnit(u); return(true); }