/// <summary> /// 判断功能是否开启 /// </summary> public static bool IsSpreadOpen() { // 如果1.8的功能没开放 if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot8)) { return(false); } int state = 0; PlatformTypes platformType = GameCoreInterface.getinstance().GetPlatformType(); switch (platformType) { case PlatformTypes.Android: state = (int)GameManager.systemParamsList.GetParamValueIntByName("TuiGuang_Android"); break; case PlatformTypes.APP: state = (int)GameManager.systemParamsList.GetParamValueIntByName("TuiGuang_APP"); break; case PlatformTypes.YueYu: state = (int)GameManager.systemParamsList.GetParamValueIntByName("TuiGuang_YueYu"); break; } return(state > 0); }
public bool HandleKuaFuLogin(KuaFuServerLoginData data) { if (data == null) { return(false); } lock (Mutex) { CopyTeamData td = null; if (!this.TeamDict.TryGetValue(data.GameId, out td) || td.StartTime <= 0) { // 防止本跨服服务器保存的队伍信息不是最新的,从中心取一下 td = KFCopyRpcClient.getInstance().GetTeamData(data.GameId); if (td == null) { return(false); } this.TeamDict[td.TeamID] = td; HashSet <long> teamList = null; if (this.FuBenId2Teams.TryGetValue(td.FuBenId, out teamList) && !teamList.Contains(td.TeamID)) { teamList.Add(td.TeamID); } } if (td == null) { return(false); } if (td.KFServerId != ThisServerId) { return(false); } if (td.StartTime <= 0) { return(false); } if (!td.TeamRoles.Exists(_role => _role.RoleID == data.RoleId)) { return(false); } if (td.FuBenSeqID <= 0) { td.FuBenSeqID = GameCoreInterface.getinstance().GetNewFuBenSeqId(); } data.FuBenSeqId = td.FuBenSeqID; FuBenSeq2TeamId[td.FuBenSeqID] = td.TeamID; return(true); } }
private EUserActivateState ActivateAward(GameClient client, int roleId, string userID, int activateType, string activateInfo, string error) { string checkInfo = GetCheckInfo(userID, error, activateType); if (checkInfo != activateInfo) { return(EUserActivateState.ECheck); } if (activateType != 0) { return(EUserActivateState.EnoBind); } PlatformTypes platformType = GameCoreInterface.getinstance().GetPlatformType(); if (platformType != PlatformTypes.APP) { return(EUserActivateState.EPlatform); } int awardState = DBActivateStateGet(client); if (awardState == 1) { return(EUserActivateState.EIsAward); } List <GoodsData> awardList = GetAwardList(); if (awardList == null || awardList.Count <= 0) { return(EUserActivateState.ENoAward); } if (!Global.CanAddGoodsDataList(client, awardList)) { return(EUserActivateState.EBag); } bool result = DBActivateStateSet(client); if (!result) { return(EUserActivateState.EFail); } for (int i = 0; i < awardList.Count; i++) { Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, awardList[i].GoodsID, awardList[i].GCount, awardList[i].Quality, "", awardList[i].Forge_level, awardList[i].Binding, 0, "", true, 1, /**/ "账号绑定奖励", Global.ConstGoodsEndTime, awardList[i].AddPropIndex, awardList[i].BornIndex, awardList[i].Lucky, awardList[i].Strong, awardList[i].ExcellenceInfo, awardList[i].AppendPropLev); } return(EUserActivateState.Success); }
/// <summary> /// 跨服初始化游戏 /// </summary> /// <param name="client"></param> /// <returns></returns> public bool KuaFuInitGame(GameClient client) { long gameId = Global.GetClientKuaFuServerLoginData(client).GameId; lock (Mutex) { CoupleArenaFuBenData fubenData = null; if (!GameId2FuBenData.TryGetValue(gameId, out fubenData)) { fubenData = TianTiClient.getInstance().GetFuBenData(gameId); if (fubenData != null) { if (fubenData.FuBenSeq == 0) { fubenData.FuBenSeq = GameCoreInterface.getinstance().GetNewFuBenSeqId(); } GameId2FuBenData.Add(gameId, fubenData); } } if (fubenData == null) { return(false); } if (fubenData.KfServerId != GameCoreInterface.getinstance().GetLocalServerId()) { return(false); } KuaFuFuBenRoleData roleData = null; if (fubenData.RoleList == null || (roleData = fubenData.RoleList.Find(_r => _r.RoleId == client.ClientData.RoleID)) == null) { return(false); } client.ClientData.MapCode = WarCfg.MapCode; client.ClientData.BattleWhichSide = roleData.Side; int _posx = 0, _posy = 0; if (!GetBirthPoint(client.ClientData.MapCode, client.ClientData.BattleWhichSide, out _posx, out _posy)) { LogManager.WriteLog(LogTypes.Error, string.Format("找不到出生点mapcode={0},side={1}", client.ClientData.MapCode, client.ClientData.BattleWhichSide)); return(false); } client.ClientData.PosX = _posx; client.ClientData.PosY = _posy; Global.GetClientKuaFuServerLoginData(client).FuBenSeqId = fubenData.FuBenSeq; client.ClientData.FuBenSeqID = fubenData.FuBenSeq; } return(true); }
private bool ProcessCmdActivateInfo(GameClient client, int nID, byte[] bytes, string[] cmdParams) { try { // 如果1.9的功能没开放 if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot9)) { client.sendCmd((int)TCPGameServerCmds.CMD_SPR_ACTIVATE_INFO, (int)EUserActivateState.NotOpen); return(true); } bool isCheck = CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 5); if (!isCheck) { return(false); } int roleID = int.Parse(cmdParams[0]); string userID = cmdParams[1]; int activateType = Convert.ToInt32(cmdParams[2]); string activateInfo = cmdParams[3].ToLower(); string error = cmdParams[4]; string checkInfo = GetCheckInfo(userID, error, activateType); if (checkInfo != activateInfo) { client.sendCmd((int)TCPGameServerCmds.CMD_SPR_ACTIVATE_INFO, (int)EUserActivateState.ECheck); return(true); } PlatformTypes platformType = GameCoreInterface.getinstance().GetPlatformType(); if (platformType != PlatformTypes.APP) { client.sendCmd((int)TCPGameServerCmds.CMD_SPR_ACTIVATE_INFO, (int)EUserActivateState.EPlatform); return(true); } if (activateType != 0) { client.sendCmd((int)TCPGameServerCmds.CMD_SPR_ACTIVATE_INFO, (int)EUserActivateState.EnoBind); return(true); } int awardState = DBActivateStateGet(client); client.sendCmd((int)TCPGameServerCmds.CMD_SPR_ACTIVATE_INFO, awardState); return(true); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false); } return(false); }
private UserActivateManager.EUserActivateState ActivateAward(GameClient client, int roleId, string userID, int activateType, string activateInfo, string error) { string checkInfo = this.GetCheckInfo(userID, error, activateType); UserActivateManager.EUserActivateState result; if (checkInfo != activateInfo) { result = UserActivateManager.EUserActivateState.ECheck; } else if (activateType != 0) { result = UserActivateManager.EUserActivateState.EnoBind; } else { PlatformTypes platformType = GameCoreInterface.getinstance().GetPlatformType(); if (platformType != PlatformTypes.APP) { result = UserActivateManager.EUserActivateState.EPlatform; } else { int awardState = this.DBActivateStateGet(client); if (awardState == 1) { result = UserActivateManager.EUserActivateState.EIsAward; } else { List <GoodsData> awardList = this.GetAwardList(); if (awardList == null || awardList.Count <= 0) { result = UserActivateManager.EUserActivateState.ENoAward; } else if (!Global.CanAddGoodsDataList(client, awardList)) { result = UserActivateManager.EUserActivateState.EBag; } else if (!this.DBActivateStateSet(client)) { result = UserActivateManager.EUserActivateState.EFail; } else { for (int i = 0; i < awardList.Count; i++) { Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, awardList[i].GoodsID, awardList[i].GCount, awardList[i].Quality, "", awardList[i].Forge_level, awardList[i].Binding, 0, "", true, 1, "账号绑定奖励", "1900-01-01 12:00:00", awardList[i].AddPropIndex, awardList[i].BornIndex, awardList[i].Lucky, awardList[i].Strong, awardList[i].ExcellenceInfo, awardList[i].AppendPropLev, 0, null, null, 0, true); } result = UserActivateManager.EUserActivateState.Success; } } } } return(result); }
private bool ProcessCmdActivateInfo(GameClient client, int nID, byte[] bytes, string[] cmdParams) { try { if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot9)) { client.sendCmd <int>(1040, -8, false); return(true); } if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 5)) { return(false); } int roleID = int.Parse(cmdParams[0]); string userID = cmdParams[1]; int activateType = Convert.ToInt32(cmdParams[2]); string activateInfo = cmdParams[3].ToLower(); string error = cmdParams[4]; string checkInfo = this.GetCheckInfo(userID, error, activateType); if (checkInfo != activateInfo) { client.sendCmd <int>(1040, -1, false); return(true); } PlatformTypes platformType = GameCoreInterface.getinstance().GetPlatformType(); if (platformType != PlatformTypes.APP) { client.sendCmd <int>(1040, -2, false); return(true); } if (activateType != 0) { client.sendCmd <int>(1040, -7, false); return(true); } int awardState = this.DBActivateStateGet(client); client.sendCmd <int>(1040, awardState, false); return(true); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false); } return(false); }
private static void NewKFClient(string host, int port) { AutoCSer.Net.TcpInternalServer.ServerAttribute attribute = new AutoCSer.Net.TcpInternalServer.ServerAttribute(); attribute.IsAutoClient = true; attribute.Host = host; attribute.Port = port; attribute.ServerSendBufferMaxSize = 33554432; attribute.ClientSendBufferMaxSize = 4194304; KuaFuClientContext clientInfo = new KuaFuClientContext(); clientInfo.ServerId = GameManager.ServerId; clientInfo.Token = GameCoreInterface.getinstance().GetLocalAddressIPs(); KFCallManager.Host = host; KFCallManager.Port = port; KFCallManager.ClientInfo = clientInfo; AutoCSer.Net.TcpStaticServer.Client tcpClient = KfCall.NewTcpClient(attribute, null, MyLogAdapter.GetILog(), new Func <AutoCSer.Net.TcpInternalServer.ClientSocketSender, bool>(KFCallManager.verifyMethod)); KFCallManager.Current = new KFCallManager.KFClient(tcpClient, attribute, clientInfo, new Action <KFCallManager.KFClient>(KFCallManager.OnSetSocket)); tcpClient.TryCreateSocket(); }
public void Init() { this.CurrSecond = (int)Global.GetOffsetSecond(TimeUtil.NowDateTime()); this.ThisServerId = (long)GameCoreInterface.getinstance().GetLocalServerId(); }
public bool LoadConfig() { bool bResult = true; try { } catch (Exception ex) { bResult = false; LogManager.WriteLog(LogTypes.Error, "load " + GoodsPriceCfgFile + " exception!", ex); } try { List <TradeConfigItem> tmpTradeCfgItems = new List <TradeConfigItem>(); XElement xml = XElement.Load(Global.GameResPath(TradeBlackCfgFile)); foreach (var xmlItem in xml.Elements()) { TradeConfigItem item = new TradeConfigItem(); item.Id = (int)Global.GetSafeAttributeLong(xmlItem, "ID"); item.MinVip = (int)Global.GetSafeAttributeLong(xmlItem, "MinVip"); item.MaxVip = (int)Global.GetSafeAttributeLong(xmlItem, "MaxVip"); item.MaxPrice = (int)Global.GetSafeAttributeLong(xmlItem, "MaxPrice"); item.MaxTimes = (int)Global.GetSafeAttributeLong(xmlItem, "MaxNum"); int cl, lvl; cl = (int)Global.GetSafeAttributeLong(xmlItem, "MinZhuanSheng"); lvl = (int)Global.GetSafeAttributeLong(xmlItem, "MinLevel"); item.UnionMinLevel = Global.GetUnionLevel(cl, lvl); cl = (int)Global.GetSafeAttributeLong(xmlItem, "MaxZhuanSheng"); lvl = (int)Global.GetSafeAttributeLong(xmlItem, "MaxLevel"); item.UnionMaxLevel = Global.GetUnionLevel(cl, lvl); tmpTradeCfgItems.Add(item); } this.TradeCfgItems = tmpTradeCfgItems; } catch (Exception ex) { bResult = false; LogManager.WriteLog(LogTypes.Error, "load " + TradeBlackCfgFile + " exception!", ex); } string szPlatFlag = string.Empty; PlatformTypes pt = GameCoreInterface.getinstance().GetPlatformType(); if (pt == PlatformTypes.Android) { szPlatFlag = "Android"; } else if (pt == PlatformTypes.YueYu) { szPlatFlag = "YueYu"; } else if (pt == PlatformTypes.APP) { szPlatFlag = "APP"; } else if (pt == PlatformTypes.YYB) { szPlatFlag = "YYB"; } this.BanTradeSec = (int)GameManager.systemParamsList.GetParamValueIntByName("NoTrade_" + szPlatFlag); this.BanTradeLog = (int)GameManager.systemParamsList.GetParamValueIntByName("TradeLog_" + szPlatFlag); this.BanTradeLogin = (int)GameManager.systemParamsList.GetParamValueIntByName("TradeKill_" + szPlatFlag); return(bResult); }