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.
249 lines
7.7 KiB
249 lines
7.7 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 Rank
|
|
{
|
|
public class GmCmdSvc : BaseReloadableService
|
|
{
|
|
public override int GetServiceType()
|
|
{
|
|
return RankServiceType.GmCmdSvc;
|
|
}
|
|
|
|
//销毁的时候清空指令注册
|
|
public override void Dispose()
|
|
{
|
|
GmCommandMgr.Instance.ClearAll();
|
|
}
|
|
|
|
//构造的时候注册所有指令
|
|
public GmCmdSvc()
|
|
{
|
|
RegisterAllGmCmd();
|
|
}
|
|
|
|
private void RegisterAllGmCmd()
|
|
{
|
|
//添加禁止上榜名单 AddForbitRankUid -t 10001
|
|
GmCommandMgr.Instance.Register("AddForbitRankUid", "AddForbitRankUid -t uid", this.AddForbitRankUid);
|
|
//立即更新排行榜 UpdateRank 0 0
|
|
GmCommandMgr.Instance.Register("UpdateRank", "UpdataRank realmId rankId", this.ForceUpdataRank);
|
|
|
|
GmCommandMgr.Instance.Register("SendRankReward", "SendRankReward rankId", this.SendRankReward);
|
|
GmCommandMgr.Instance.Register("ClearRank", "ClearRank rankId", this.ClearRank);
|
|
|
|
GmCommandMgr.Instance.Register("TestRankAward", "TestRankAward realmId rankId", this.TestRankAward);
|
|
GmCommandMgr.Instance.Register("TestMakeAllDirty", "TestMakeAllDirty", this.TestMakeAllDirty);
|
|
GmCommandMgr.Instance.Register("GetRankInfo", "GetRankInfo", this.GetRankInfo);
|
|
GmCommandMgr.Instance.Register("ClearActRank", "ClearActRank rem rank ", this.ClearActRank);
|
|
}
|
|
|
|
public int AddForbitRankUid(long userid, string[] cmdParams)
|
|
{
|
|
if (RankSvc.AddForbitRankUid(userid))
|
|
{
|
|
return 0;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public int SendRankReward(long userid, string[] cmdParams)
|
|
{
|
|
if (cmdParams.Length < 1)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.SendRankReward invalid param, need rankId");
|
|
return -1;
|
|
}
|
|
|
|
if (!int.TryParse(cmdParams[0], out int rankId))
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
TraceLog.Debug("GmCmdSvc.SendRankReward rankId {0}", rankId);
|
|
RankSvc.GMRewardRankId = rankId;
|
|
RankSvc.GMRewardTime = (int)RankServerUtils.GetTimeSecond();
|
|
return 0;
|
|
}
|
|
|
|
|
|
public int TestRankAward(long userid, string[] cmdParams)
|
|
{
|
|
if (cmdParams.Length < 2)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.TestRankAward invalid param, need rankId");
|
|
return -1;
|
|
}
|
|
|
|
if (!int.TryParse(cmdParams[0], out int realmId))
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
if (!int.TryParse(cmdParams[1], out int rankId))
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
TraceLog.Debug("GmCmdSvc.TestRankAward realm {0} rankId {1}", realmId, rankId);
|
|
|
|
WorldRankData rankData = RankServerUtils.GetRankData();
|
|
foreach (var realmAllRank in rankData.AllRank.Values)
|
|
{
|
|
if (realmAllRank.m_loadDbDataSuccess == false)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (realmAllRank.m_realmId != realmId)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (!realmAllRank.m_rankMap.TryGetValue(rankId, out RankDataOne rankOne))
|
|
{
|
|
TraceLog.Debug("GmCmdSvc.TestRankAward realm {0} rankId {1} no rank data", realmId, rankId);
|
|
continue;
|
|
}
|
|
|
|
if (rankOne.CurRecord == null || rankOne.CurRecord.Data.Count == 0)
|
|
{
|
|
continue;
|
|
}
|
|
RankSvc.SendRankAwardMail(rankOne);
|
|
//RankSvc.SendLastRankAwardMail(rankOne);
|
|
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
public int ClearRank(long userid, string[] cmdParams)
|
|
{
|
|
if (cmdParams.Length < 1)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.ClearRank invalid param, need rankId");
|
|
return -1;
|
|
}
|
|
|
|
if (!int.TryParse(cmdParams[0], out int rankId))
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
TraceLog.Debug("GmCmdSvc.ClearRank rankId {0}", rankId);
|
|
|
|
WorldRankData rankData = RankServerUtils.GetRankData();
|
|
|
|
// realmId -> [rankId, rankDataOne]
|
|
foreach (var realmAllRank in rankData.AllRank.Values)
|
|
{
|
|
if (!realmAllRank.m_rankMap.TryGetValue(rankId, out RankDataOne rankOne))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
public int ForceUpdataRank(long userid, string[] cmdParams)
|
|
{
|
|
if (cmdParams.Length < 2)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.ForceUpdataRank no param");
|
|
return -1;
|
|
}
|
|
|
|
if (int.TryParse(cmdParams[0], out int realmId)
|
|
&& int.TryParse(cmdParams[1], out int rankId)
|
|
)
|
|
{
|
|
RankSvc.ForceUpdateAllRank(realmId, rankId, true);
|
|
RankSvc.UpdateCanAwardRank();
|
|
return 0;
|
|
}
|
|
|
|
TraceLog.Error("GmCmdSvc.ForceUpdataRank error param");
|
|
return -1;
|
|
}
|
|
|
|
public int TestMakeAllDirty(long userid, string[] cmdParams)
|
|
{
|
|
WorldRankData rankData = RankServerUtils.GetRankData();
|
|
|
|
foreach (var realIdItem in rankData.AllRank.Values)
|
|
{
|
|
foreach (var rankItem in realIdItem.m_rankMap.Values)
|
|
{
|
|
if (rankItem.CurRecord != null)
|
|
{
|
|
rankItem.CurRecord.MakeDirty();
|
|
rankItem.CurRecord.NeedUpdate = true;
|
|
}
|
|
}
|
|
}
|
|
TraceLog.Trace("GmCmdSvc.TestMakeAllDirty");
|
|
return 0;
|
|
}
|
|
|
|
public int GetRankInfo(long userid, string[] cmdParams)
|
|
{
|
|
var rankData = RankServerUtils.GetActRankData();
|
|
foreach (var realmRank in rankData.Values)
|
|
{
|
|
foreach (var rankOne in realmRank.m_AcRank.Values)
|
|
{
|
|
TraceLog.Trace("GmCmdSvc.GetRankInfo rem:{0} rankid:{1} rankCount:{2}", rankOne.RealmId, rankOne.ActRankID, rankOne.m_rankRank.Count);
|
|
}
|
|
}
|
|
TraceLog.Trace("GmCmdSvc.GetRankInfo");
|
|
return 0;
|
|
}
|
|
|
|
public int ClearActRank(long userid, string[] cmdParams)
|
|
{
|
|
if (cmdParams.Length < 2)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.ClearActRank invalid param, need rankId");
|
|
return -1;
|
|
}
|
|
|
|
var rem = Convert.ToInt32(cmdParams[0]);
|
|
var rankId = Convert.ToInt32(cmdParams[1]);
|
|
|
|
RankServerData serverData = RankServerUtils.GetRankServerData();
|
|
ActRemRank actRem = null;
|
|
serverData.m_ActRank.TryGetValue(rem, out actRem);
|
|
if (actRem == null)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.ClearActRank no rem rank error!");
|
|
return -1;
|
|
}
|
|
ActRankOne rankOne = null;
|
|
actRem.m_AcRank.TryGetValue(rankId, out rankOne);
|
|
if (rankOne == null)
|
|
{
|
|
TraceLog.Error("GmCmdSvc.ClearActRank no rank error!");
|
|
return -3;
|
|
}
|
|
RankSvc.EndClearRank(rankOne);
|
|
TraceLog.Trace("GmCmdSvc.ClearActRank");
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
}
|
|
|