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.
 
 
 
 
 
 

163 lines
6.5 KiB

using System.Collections.Generic;
using Sog;
using ProtoCSStruct;
namespace Game
{
public class DirtyStringSvc
{
public static void AddCheckObj(PlayerOnGame player, DirtyStringCheckObj checkObj, string str)
{
var serverData = GameServerUtils.GetGameServerData().m_dirtyStringData;
checkObj.seq = serverData.GetNextSeq();
player.lastDirtyCheckSeq = checkObj.seq;
if (serverData.checkObjMap.ContainsKey(checkObj.seq))
{
TraceLog.Error("DirtyStringSvc.AddCheckObj seq {0} exist {1} {2}", checkObj.seq, player.UserID, checkObj.checkType);
}
else
{
serverData.checkObjMap.Add(checkObj.seq, checkObj);
SSCheckDirtyStringReq checkReq = new SSCheckDirtyStringReq();
checkReq.ServerId = GameServerUtils.GetAppID();
checkReq.Uid = player.UserID;
checkReq.CheckSeq = checkObj.seq;
checkReq.Content.SetString(str);
GameServerUtils.GetPacketSender().SendToChatServer((int)SSGameMsgID.CheckDirtyStringReq, ref checkReq, player.UserID);
}
}
public static void DealDirtyStringCheck<T>(PlayerOnGame player, DirtyStringCheckType checkType, ref T structMessage, string str)
where T : struct, IStructMessage<T>
{
DirtyStringCheckObj checkObj = new DirtyStringCheckObj()
{
checkType = checkType,
};
checkObj.obj = structMessage;
checkObj.timeSec = GameServerUtils.GetApp().GetTimeSecond();
AddCheckObj(player, checkObj, str);
}
public static void OnCheckDirtyStringRes(uint serverID, StructPacket packet)
{
ref SSCheckDirtyStringRes res = ref packet.GetMessage<SSCheckDirtyStringRes>();
var serverData = GameServerUtils.GetGameServerData().m_dirtyStringData;
if(serverData.checkObjMap.TryGetValue(res.CheckSeq, out DirtyStringCheckObj checkObj))
{
serverData.checkObjMap.Remove(res.CheckSeq);
PlayerOnGame player = GameServerUtils.GetPlayerTableOp().GetPlayerByUid(res.Uid);
if (player == null)
{
TraceLog.Debug("DirtyStringSvc.OnCheckDirtyStringRes no player object uid {0} {1}", res.Uid, checkObj.checkType);
return;
}
//seq对不上直接丢了, 防止重复点击
if(res.CheckSeq != player.lastDirtyCheckSeq)
{
TraceLog.Debug("DirtyStringSvc.OnCheckDirtyStringRes player {0} seq not equal {1} {2}", res.Uid, res.CheckSeq, player.lastDirtyCheckSeq);
return;
}
switch (checkObj.checkType)
{
case DirtyStringCheckType.CSSetPersonalizedSignatureReq:
DealSetPersonalizedSignatureReq(player, checkObj, ref res);
break;
case DirtyStringCheckType.CSRenameReq:
DealCSRenameReq(player, checkObj, ref res);
break;
case DirtyStringCheckType.SSRenameReq:
DealSSReRoleNameReq(player, checkObj, ref res);
break;
case DirtyStringCheckType.CSPresetRenameReq:
PlayerPresetSvc.DealCSPresetRenameReq(player, checkObj, ref res);
break;
default:
TraceLog.Error("DirtyStringSvc.OnCheckDirtyStringRes error type uid {0} {1}", res.Uid, checkObj.checkType);
break;
}
}
}
public static void DealSetPersonalizedSignatureReq(PlayerOnGame player, DirtyStringCheckObj checkObj, ref SSCheckDirtyStringRes checkRes)
{
CSSetPersonalizedSignatureReq req = (CSSetPersonalizedSignatureReq)checkObj.obj;
int ret = 0;
if (checkRes.Result == 0)
{
GameServerUtils.GetPacketSender().SendToWorldServer((int)CSGameMsgID.SetPersonalizedSignatureReq, ref req, player.UserID);
return;
}
else if (checkRes.Result == 1)
{
ret = (int)CSErrCode.IncludeIllegalWord;;
}
else
{
ret = (int)CSErrCode.SysFailure;
}
if(ret != 0)
{
CSSetPersonalizedSignatureRes res = new CSSetPersonalizedSignatureRes();
res.Ret = ret;
player.SendToClient((int)CSGameMsgID.SetPersonalizedSignatureRes, ref res);
}
}
public static void DealCSRenameReq(PlayerOnGame player, DirtyStringCheckObj checkObj, ref SSCheckDirtyStringRes checkRes)
{
CSRenameReq req = (CSRenameReq)checkObj.obj;
int ret = 0;
if (checkRes.Result == 0)
{
PlayerUtils.DealCSRenameReq(player, ref req);
return;
}
else if (checkRes.Result == 1)
{
ret = (int)CSErrCode.IncludeIllegalWord;
}
else
{
ret = (int)CSErrCode.SysFailure;
}
if (ret != 0)
{
CSRenameRes res = new CSRenameRes();
res.Ret = ret;
player.SendToClient((int)CSGameMsgID.RenameRes, ref res);
}
}
public static void DealSSReRoleNameReq(PlayerOnGame player, DirtyStringCheckObj checkObj, ref SSCheckDirtyStringRes checkRes)
{
SSGmChangeRoleNameReq req = (SSGmChangeRoleNameReq)checkObj.obj;
int ret = 0;
if (checkRes.Result == 0)
{
PlayerUtils.DealSSRenameReq(player, ref req);
return;
}
else if (checkRes.Result == 1)
{
ret = (int)CSErrCode.IncludeIllegalWord;
}
else
{
ret = (int)CSErrCode.SysFailure;
}
if (ret != 0)
{
SSGmChangeRoleNameRes res = new SSGmChangeRoleNameRes();
res.Ret = ret;
res.Id = req.Id;
GameServerUtils.GetPacketSender().SendToServerByID(GameServerUtils.GetWorldServerID(), (int)SSGameMsgID.GmChangeRoleNameRes, ref res, player.UserID);
}
}
}
}