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.
207 lines
7.4 KiB
207 lines
7.4 KiB
/*
|
|
Sog 游戏基础库
|
|
2016 by zouwei
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.IO;
|
|
|
|
using Sog;
|
|
using ProtoCSStruct;
|
|
using Sog.IO;
|
|
|
|
namespace Friend
|
|
{
|
|
public class GmCmdSvc : BaseReloadableService
|
|
{
|
|
public override int GetServiceType()
|
|
{
|
|
return FriendServiceType.GmCmdSvc;
|
|
}
|
|
|
|
//销毁的时候清空指令注册
|
|
public override void Dispose()
|
|
{
|
|
GmCommandMgr.Instance.ClearAll();
|
|
}
|
|
|
|
//构造的时候注册所有指令
|
|
public GmCmdSvc()
|
|
{
|
|
RegisterAllGmCmd();
|
|
}
|
|
|
|
private void RegisterAllGmCmd()
|
|
{
|
|
GmCommandMgr.Instance.Register("LogErrIconCount", "LogErrIconCount ;", this.LogErrIconCount);
|
|
GmCommandMgr.Instance.Register("ClearErrIconCount", "ClearErrIconCount ;", this.ClearErrIconCount);
|
|
GmCommandMgr.Instance.Register("LogUserFriend", "LogUserFriend ;", this.LogUserFriend);
|
|
GmCommandMgr.Instance.Register("AddFakePlayer", "AddFakePlayer", this.AddFakePlayer);
|
|
GmCommandMgr.Instance.Register("DeleteFriendCache", "DeleteFriendCache", this.DeleteFriendCache);
|
|
GmCommandMgr.Instance.Register("LogMemOnStop", "LogMemOnStop", this.LogMemOnStop);
|
|
}
|
|
|
|
public static void OnDealGmCmd(StructPacket packet)
|
|
{
|
|
ref SSNotifyServerDealGMCmd gmCmd = ref packet.GetMessage<SSNotifyServerDealGMCmd>();
|
|
string[] splitStr = gmCmd.CmdParams.GetString().Split(' ');
|
|
GmCommandMgr.Instance.HandlerGmCommand(gmCmd.GmCmd.GetString(), gmCmd.UserId, splitStr, false);
|
|
}
|
|
|
|
public int LogErrIconCount(long userid, string[] cmdParams)
|
|
{
|
|
var cache = FriendServerUtils.GetFriendInfoCacheTable();
|
|
if (cache != null)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.LogErrIconCount ErrIconCount {0}", cache.ErrIconCount);
|
|
TraceLog.Stat("GmCmdSvc.LogErrIconCount ErrIconCount {0}", cache.ErrIconCount);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public int ClearErrIconCount(long userid, string[] cmdParams)
|
|
{
|
|
var cache = FriendServerUtils.GetFriendInfoCacheTable();
|
|
if (cache != null)
|
|
{
|
|
cache.ErrIconCount = 0;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public int LogUserFriend(long userid, string[] cmdParams)
|
|
{
|
|
TraceLog.Stat("GmCmdSvc.LogUserFriend begin uid {0}", userid);
|
|
|
|
var player = FriendServerUtils.GetPlayerTableOp().GetPlayerInfo(userid);
|
|
if (player != null)
|
|
{
|
|
if (player.roleBase.Uid == 0)
|
|
{
|
|
TraceLog.Stat("GmCmdSvc.LogUserFriend player uid {0} icon {1}",
|
|
player.UserID, player.roleBase.Icon);
|
|
}
|
|
|
|
if (player.accountInfo.AccountID.Count == 0)
|
|
{
|
|
TraceLog.Stat("GmCmdSvc.LogUserFriend accountType {0} accountId {1}",
|
|
player.accountInfo.AccountType, player.accountInfo.AccountID);
|
|
}
|
|
}
|
|
|
|
TraceLog.Stat("GmCmdSvc.LogUserFriend end uid {0}", userid);
|
|
return 0;
|
|
}
|
|
|
|
public int AddFakePlayer(long userid, string[] cmdParams)
|
|
{
|
|
if (cmdParams.Length < 2)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.AddFakePlayer no param, need uid");
|
|
return -1;
|
|
}
|
|
|
|
int.TryParse(cmdParams[0], out int uid);
|
|
if (uid >= 1000)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.AddFakePlayer invalid uid {0}", uid);
|
|
return -1;
|
|
}
|
|
|
|
int.TryParse(cmdParams[1], out int worldSvcId);
|
|
if (worldSvcId <= 0)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
PlayerInfoFriend player = FriendServerUtils.GetPlayerTableOp().GetPlayerInfo(uid);
|
|
if (player != null)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.AddFakePlayer uid {0} exist", uid);
|
|
return -1;
|
|
}
|
|
|
|
player = new PlayerInfoFriend { UserID = uid, WorldServerID = (uint)worldSvcId };
|
|
player.roleBase.Uid = uid;
|
|
player.LoginTime = FriendServerUtils.GetTimeSecond();
|
|
player.IsOnline = true;
|
|
FriendServerUtils.GetPlayerTableOp().AddPlayerInfo(player);
|
|
|
|
TraceLog.Trace("GmCmdSvc.AddFakePlayer uid {0} succ", uid);
|
|
return 0;
|
|
}
|
|
|
|
public int DeleteFriendCache(long userid, string[] cmdParams)
|
|
{
|
|
TraceLog.Trace("GmCmdSvc.DeleteFriendCache");
|
|
|
|
if (cmdParams.Length < 1)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.DeleteFriendCache no param, need 0/1");
|
|
return -1;
|
|
}
|
|
|
|
int.TryParse(cmdParams[0], out int flag);
|
|
|
|
FriendOp.GMDeleteFriendCache = flag != 0;
|
|
return 0;
|
|
}
|
|
|
|
public int LogMemOnStop(long userid, string[] cmdParams)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.LogMemOnStop");
|
|
|
|
if (!FriendServerUtils.GetApp().IsStopping)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.LogMemOnStop server not stopping");
|
|
return -1;
|
|
}
|
|
|
|
TraceLog.Error("GmCmdSvc.LogMemOnStop WaitAckStructRequestSender {0}", WaitAckStructRequestSender.Instance.IsEmpty());
|
|
TraceLog.Error("GmCmdSvc.LogMemOnStop m_selfIDMap {0}", FriendInfoCache.m_selfIDMap.Count);
|
|
|
|
// 打印在m_selfIDMap中的friendInfo
|
|
foreach (KeyValuePair<long, long> kvp in FriendInfoCache.m_selfIDMap)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.LogMemOnStop uid {0} pos {1}", kvp.Key, kvp.Value);
|
|
|
|
ref FriendCacheInfoStruct friendInfo = ref FriendOp.GetFriendInfoByUid(kvp.Key);
|
|
if (friendInfo.IsNull())
|
|
{
|
|
TraceLog.Error("GmCmdSvc.LogMemOnStop uid {0} no FriendCacheInfo", kvp.Key);
|
|
continue;
|
|
}
|
|
|
|
var seq = friendInfo.GetDataSeqSave();
|
|
TraceLog.Error("GmCmdSvc.LogMemOnStop uid {0} dataSeq {1} saveSeq {2} lastSaveTime {3} waitSaveTime {4} NeedSave {5}"
|
|
, friendInfo.Self.Uid, seq.DataSeq, seq.SavedSuccessSeq, seq.LastSaveDBReqTime
|
|
, seq.SaveReqWaitAckTimeout, friendInfo.NeedSave);
|
|
}
|
|
|
|
// 打印还在内存中的friendInfo
|
|
int count = 0;
|
|
int usedIdx = FriendInfoCache.m_cacheStructFriendInfo.GetUsedIndex(1);
|
|
while (usedIdx > 0 && count < 1000)
|
|
{
|
|
// 以防万一, 最多打印1000个
|
|
count++;
|
|
|
|
ref FriendCacheInfoStruct friendInfo = ref FriendInfoCache.m_cacheStructFriendInfo.GetByIndex(usedIdx);
|
|
if (! friendInfo.IsNull())
|
|
{
|
|
var seq = friendInfo.GetDataSeqSave();
|
|
TraceLog.Error("GmCmdSvc.LogMemOnStop used FriendCacheInfo, uid {0} dataSeq {1} saveSeq {2} lastSaveTime {3} waitSaveTime {4} NeedSave {5}"
|
|
, friendInfo.Self.Uid, seq.DataSeq, seq.SavedSuccessSeq, seq.LastSaveDBReqTime
|
|
, seq.SaveReqWaitAckTimeout, friendInfo.NeedSave);
|
|
}
|
|
|
|
usedIdx = FriendInfoCache.m_cacheStructFriendInfo.GetUsedIndex(usedIdx + 1);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|