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.
 
 
 
 
 
 

291 lines
12 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sog;
using ProtoCSStruct;
namespace World
{
public static class SysSvc
{
public static void OnUpdateRolebaseToWorld(uint remoteAppID, StructPacket packet)
{
ref SSUpdateRolebaseToWorld updateReq = ref packet.GetMessage<SSUpdateRolebaseToWorld>();
long uid = updateReq.Rolebase.Uid;
TraceLog.Debug("SysSvc.OnUpdateRolebaseToWorld uid {0}", uid);
PlayerInfoWorld player = WorldServerUtils.GetPlayerTableOp().GetPlayerInfo(uid);
if (player == null)
{
TraceLog.Error("SysSvc.OnUpdateRolebaseToWorld can not find player uid {0}", uid);
return;
}
player.roleBase.CopyFrom( ref updateReq.Rolebase);
player.IpAddr = updateReq.ClientIpAddr.ToString();
player.PayInfo.PaySuccessTotalCount = updateReq.PayCount;
player.ActTimeSecond = WorldServerUtils.GetTimeSecond();
//通知下Friend
WorldServerUtils.GetPacketSender().SendToFriendServer((int)SSGameMsgID.UpdateRolebaseToWorld, ref updateReq, uid);
TraceLog.Debug("SysSvc.OnUpdateRolebaseToWorld uid {0} success, chip {1} diamond {2} level {3} exp {4}"
, uid, player.roleBase.Chip, player.roleBase.Diamond, player.roleBase.Level, player.roleBase.Exp);
}
public static void OnAddServerTimeSync(uint remoteAppID, StructPacket packet)
{
ref SSAddServerTimeSync sync = ref packet.GetMessage<SSAddServerTimeSync>();
// 广播到FriendSvr
WorldServerUtils.GetPacketSender().Broadcast<SSAddServerTimeSync>((int)ServerType.Friend, packet);
// 发送给realmlist
WorldServerUtils.GetPacketSender().SendToRealmlistServer<SSAddServerTimeSync>(packet, 0, 0);
TraceLog.Debug("SysSvc.OnAddServerTimeSync serverid {0} offset {1}"
, ServerIDUtils.IDToString(remoteAppID), sync.Offset);
WorldServerUtils.GetApp().Time.SetOffset(sync.Offset);
WorldServerUtils.GetApp().Time.UpdateTime();
TraceLog.Debug("SysSvc.OnAddServerTimeSync serverid {0} offset {1} set time success"
, ServerIDUtils.IDToString(remoteAppID), sync.Offset);
}
public static void OnUpdateRoleDataToWorld(uint serverID, StructPacket packet)
{
var player = WorldServerUtils.GetPlayerTableOp().GetPlayerInfo(packet.ObjectID);
if(player == null)
{
TraceLog.Error("SysSvc.OnUpdateRoleDataToWorld player {0} = null", packet.ObjectID);
return;
}
player.ActTimeSecond = WorldServerUtils.GetTimeSecond();
WorldServerUtils.GetPacketSender().SendToFriendServer<SSUpdateRoleDataToWorld>(packet, packet.ObjectID);
}
public static void OnTipOffPlayerReq(uint serverID, StructPacket packet)
{
ref var req = ref packet.GetMessage<CSTipOffPlayerReq>();
PlayerInfoWorld player = WorldServerUtils.GetPlayerTableOp().GetPlayerInfo(req.TargetUid);
if (player == null)
{
TraceLog.Error("SysSvc.OnTipOffPlayerReq can not find player uid {0}", req.TargetUid);
return;
}
long nowSecond = WorldServerUtils.GetTimeSecond();
bool alreadyInList = false;
foreach(var uid in player.TipOffList.Keys)
{
if(uid == packet.ObjectID)
{
alreadyInList = true;
player.TipOffList[uid] = nowSecond;
break;
}
}
if(alreadyInList == false)
{
player.TipOffList.Add(packet.ObjectID, nowSecond);
}
//举报有效时间
int tipOffTimeout = 3600;
//禁言时间
int tipOffGagTime = 3600;
//删除超时的举报玩家
List<long> timeOutPlayer = new List<long>();
foreach(var pair in player.TipOffList)
{
if(nowSecond - pair.Value > tipOffTimeout)
{
timeOutPlayer.Add(pair.Key);
}
}
foreach(var timeOutUid in timeOutPlayer)
{
player.TipOffList.Remove(timeOutUid);
}
WorldBillLogUtils.LogTipOffPlayer(req.TargetUid, packet.ObjectID, req.Reason.ToString(), player.TipOffList.Count);
TraceLog.Trace("SysSvc.OnTipOffPlayerReq uid {0} be tip off count {1}", req.TargetUid, player.TipOffList.Count);
//被6个玩家举报,则禁言1小时
if(player.TipOffList.Count >= 5)
{
player.GagChatEndTime = WorldServerUtils.GetTimeSecond() + tipOffGagTime;
player.TipOffList.Clear();
WorldBillLogUtils.LogGagChatPlayer(player.UserID, player.GagChatEndTime);
TraceLog.Trace("SysSvc.OnTipOffPlayerReq uid {0} be gag chat ,end time {1}"
, req.TargetUid, AppTime.ConvertUnixTimeToDateTime( player.GagChatEndTime*1000));
//通知game
if(player.GameServerID != 0)
{
CSGagChatNotify notify = new CSGagChatNotify();
notify.GagEndTime = player.GagChatEndTime;
notify.EnableType = 0;
notify.EnableStr.SetString("被玩家举报");
notify.OpSource.SetString("tipoff");
WorldServerUtils.GetPacketSender().SendToChatServer((int)CSGameMsgID.GagChatNotify, ref notify, player.UserID);
}
}
}
public static void OnSetLanguageReq(uint serverID, StructPacket packet)
{
PlayerInfoWorld player = WorldServerUtils.GetPlayerTableOp().GetPlayerInfo(packet.ObjectID);
if (player == null)
{
TraceLog.Error("SysSvc.OnSetLanguageReq player {0} = null", packet.ObjectID);
return;
}
ref CSSetLanguageReq req = ref packet.GetMessage<CSSetLanguageReq>();
TraceLog.Trace("SysSvc.OnSetLanguageReq uid {0} set lang {1} old {2}", packet.ObjectID, req.Lang, player.Lang);
player.Lang = req.Lang.ToString();
}
public static void OnSysNoticeLampReq(uint serverID, StructPacket packet)
{
ref SSSysNoticeLampReq req = ref packet.GetMessage<SSSysNoticeLampReq>();
WorldServerUtils.GetPacketSender().Broadcast((int)ServerType.Chat, (int)SSGameMsgID.SysNoticeLampReq, ref req, 0,0);
}
public static void OnSysNoticeLampNotify(uint serverID, StructPacket packet)
{
ref SSSysNoticeLamp req = ref packet.GetMessage<SSSysNoticeLamp>();
WorldServerUtils.GetPacketSender().Broadcast((int)ServerType.Chat, (int)SSGameMsgID.SysNoticeLamp, ref req, 0, 0);
}
public static void OnSysNotice(uint serverID, StructPacket packet)
{
ref SSSysNotice req = ref packet.GetMessage<SSSysNotice>();
WorldServerUtils.GetPacketSender().Broadcast((int)ServerType.Chat, (int)SSGameMsgID.ChatNoticeReq, ref req, 0, 0);
}
public static void OnDelSysNotice(uint serverID, StructPacket packet)
{
ref SSSysNoticeDel req = ref packet.GetMessage<SSSysNoticeDel>();
WorldServerUtils.GetPacketSender().Broadcast((int)ServerType.Chat, (int)SSGameMsgID.ChatDelNotice, ref req, 0, 0);
}
public static void OnPlayerShowInfoUpdate(uint serverID, StructPacket packet)
{
ref SSPlayerShowInfoUpdate req = ref packet.GetMessage<SSPlayerShowInfoUpdate>();
WorldServerUtils.GetPacketSender().Broadcast((int)ServerType.Chat, (int)SSGameMsgID.PlayerShowinfoUpdate, ref req, 0, 0);
}
public static void OnNoticeBackgroundsReq(uint serverID, StructPacket packet)
{
ref SSNoticeBackGroundsReq req = ref packet.GetMessage<SSNoticeBackGroundsReq>();
WorldServerUtils.GetPacketSender().Broadcast((int)ServerType.Operation, (int)SSGameMsgID.NoticeBackgroundsReq, ref req, 0, 0);
}
public static void OnNoticeBackgroundsRes(uint serverID, StructPacket packet)
{
ref SSNoticeBackGroundsRes res = ref packet.GetMessage<SSNoticeBackGroundsRes>();
WorldServerUtils.GetPacketSender().Broadcast((int)ServerType.Chat, (int)SSGameMsgID.NoticeBackgroundsRes, ref res, 0, 0);
}
public static void OnHandlePlayerEnableMsg(uint serverID, StructPacket packet)
{
ref SSEnableSendMsgReq req = ref packet.GetMessage<SSEnableSendMsgReq>();
// 通知gamedb
uint dbSvrId = DBServerIDUtils.GetGameDBServerID(req.Uid);
WorldServerUtils.GetPacketSender().SendToServerByID<SSEnableSendMsgReq>(dbSvrId, packet);
PlayerInfoWorld player = WorldServerUtils.GetPlayerTableOp().GetPlayerInfo(req.Uid);
if (player == null)
{
TraceLog.Error("SysSvc.OnHandlePlayerEnableMsg can not find player uid {0}", req.Uid);
return;
}
player.GagChatEndTime = req.EnableTime;
TraceLog.Trace("SysSvc.OnHandlePlayerEnableMsg uid {0} be gag chat ,end time {1}"
, req.Uid, AppTime.ConvertUnixTimeToDateTime(player.GagChatEndTime * 1000));
//通知chat
if (player.GameServerID != 0)
{
CSGagChatNotify notify = new CSGagChatNotify();
notify.GagEndTime = player.GagChatEndTime;
notify.EnableType = req.ReasonType;
notify.EnableStr.SetString(req.FreezeReasonStr.ToString());
notify.OpSource.SetString(req.OpSource.ToString());
WorldServerUtils.GetPacketSender().SendToChatServer((int)CSGameMsgID.GagChatNotify, ref notify, player.UserID);
}
}
public static void OnHandlePlayerEnableMsgRes(uint serverID, StructPacket packet)
{
ref SSEnableSendMsgRes res = ref packet.GetMessage<SSEnableSendMsgRes>();
if(res.Ret != 0)
{
TraceLog.Debug("SysSvc.OnHandlePlayerEnableMsgRes ret != 0");
return;
}
// 通知op
WorldServerUtils.GetPacketSender().SendToOperationServer<SSEnableSendMsgRes>(packet, 0);
//不需要禁言成功直接发送邮件了,hero舆情系统会进行发邮件的
//if (WorldServerUtils.GetApp().GetTimeSecond() < res.EnableTime)
//{
// //发送邮件给玩家
// DBMail mail = new DBMail();
// mail.Uid = res.Uid;
// mail.MailType = (int)MailType.Ban;
// var durationSec = res.EnableTime - WorldServerUtils.GetApp().GetTimeSecond();
// int duration = (int)Math.Ceiling((double)durationSec / 3600);
// mail.Param1 = duration;
// MailSender.SendNewMailToPlayerNoCheck(mail.Uid, ref mail);
//}
PlayerInfoWorld player = WorldServerUtils.GetPlayerTableOp().GetPlayerInfo(res.Uid);
if (player == null)
{
TraceLog.Error("SysSvc.OnHandlePlayerEnableMsgRes can not find player uid {0}", res.Uid);
return;
}
player.GagChatEndTime = res.EnableTime;
TraceLog.Trace("SysSvc.OnHandlePlayerEnableMsgRes uid {0} be gag chat ,end time {1}"
, res.Uid, AppTime.ConvertUnixTimeToDateTime(player.GagChatEndTime * 1000));
}
}
}