You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.7 KiB
104 lines
2.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
using ProtoCSStruct;
|
|
|
|
namespace Game
|
|
{
|
|
public static class MoveCheckSvc
|
|
{
|
|
public static int CheckMoveWalk(PlayerOnGame player, ref CSMoveWalk req, Map map)
|
|
{
|
|
TraceLog.Trace("MoveCheckSvc.CheckMoveWalk player {0} map {1}", player.UserID, req.Mapid);
|
|
|
|
int iRet = CheckPointValid(player, ref req.Points, map);
|
|
|
|
if(iRet != 0)
|
|
{
|
|
return iRet;
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
public static int CheckMoveTurn(PlayerOnGame player, ref CSMoveTurn req, Map map)
|
|
{
|
|
TraceLog.Trace("MoveCheckSvc.CheckMoveTurn player {0} map {1}", player.UserID, req.Mapid);
|
|
|
|
int iRet = CheckPointValid(player, ref req.Points, map);
|
|
|
|
if (iRet != 0)
|
|
{
|
|
return iRet;
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
public static int CheckMoveStop(PlayerOnGame player, ref CSMoveStop req, Map map)
|
|
{
|
|
TraceLog.Trace("MoveCheckSvc.CheckMoveStop player {0} map {1}", player.UserID, req.Mapid);
|
|
|
|
int iRet = CheckPointValid(player, ref req.Points, map);
|
|
|
|
if (iRet != 0)
|
|
{
|
|
return iRet;
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//校验路径是否合法
|
|
//这里先简单处理,以后需要校验走的每条路径是否在可走区域
|
|
private static int CheckPointValid(PlayerOnGame player, ref RepeatedDBPosition_16 points, Map map)
|
|
{
|
|
for(int i=0; i< points.Count;i++)
|
|
{
|
|
if(MapSvc.CheckPositionInMap(map, points[i].X, points[i].Z) == false)
|
|
{
|
|
TraceLog.Error("MoveCheckSvc.CheckPointValid map {0} point {1} {2} check failed"
|
|
, map.mapDescId, points[i].X, points[i].Z);
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
MapDesc desc = MapDescMgr.Instance.GetConfig(map.mapDescId);
|
|
if(desc == null)
|
|
{
|
|
TraceLog.Error("MoveCheckSvc.CheckPointValid map no desc {0}", map.mapDescId);
|
|
return -1;
|
|
}
|
|
|
|
if(desc.serverMode == 1)
|
|
{
|
|
int iRet = CheckPointPath(player, ref points, map);
|
|
if (iRet != 0)
|
|
{
|
|
return iRet;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
//校验点连接起来的路径是否合法,路径距离,速度是否合法
|
|
private static int CheckPointPath(PlayerOnGame player, ref RepeatedDBPosition_16 points, Map map)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|