Ejemplo n.º 1
0
 public void UpdateGVoicePriority(GMCmdData cmdData, bool force = true)
 {
     if (cmdData.Fields.Length >= 4)
     {
         if (!(cmdData.Fields[0] != "-gvoicepriority"))
         {
             int    type      = Global.SafeConvertToInt32(cmdData.Fields[1]);
             int    unitID    = Global.SafeConvertToInt32(cmdData.Fields[2]);
             string prioritys = cmdData.Fields[3];
             lock (this.RuntimeData.Mutex)
             {
                 if (type == 1)
                 {
                     this.RuntimeData.ZhanMengGVoiceDict[unitID] = prioritys;
                 }
                 else if (type == 2)
                 {
                     this.RuntimeData.JunTuanGVoiceDict[unitID] = prioritys;
                 }
             }
             GVoicePriorityData data = new GVoicePriorityData
             {
                 ID         = unitID,
                 Type       = type,
                 RoleIdList = prioritys
             };
             if (type == 1)
             {
                 foreach (GameClient client in GameManager.ClientMgr.GetAllClients(true))
                 {
                     if (force || client.ClientData.GVoiceType == GVoiceTypes.ZhanMeng)
                     {
                         if (client.ClientData.Faction == unitID && client.ClientData.GVoicePrioritys != prioritys)
                         {
                             client.ClientData.GVoicePrioritys = prioritys;
                             client.sendCmd <GVoicePriorityData>(1112, data, false);
                         }
                     }
                 }
             }
             else if (type == 2)
             {
                 foreach (GameClient client in GameManager.ClientMgr.GetAllClients(true))
                 {
                     if (force || client.ClientData.GVoiceType == GVoiceTypes.JunTuan)
                     {
                         if (client.ClientData.JunTuanId == unitID && client.ClientData.GVoicePrioritys != prioritys)
                         {
                             client.ClientData.GVoicePrioritys = prioritys;
                             client.sendCmd <GVoicePriorityData>(1112, data, false);
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public void BroadcastGMCmdData(GMCmdData data, int serverFlag)
 {
     lock (this.Mutex)
     {
         if (serverFlag == 1)
         {
             ClientAgentManager.Instance().KFBroadCastAsyncEvent(GameTypes.HuanYingSiYuan, new AsyncDataItem(KuaFuEventTypes.GMCmd, new object[]
             {
                 data
             }));
         }
         else
         {
             ClientAgentManager.Instance().BroadCastAsyncEvent(GameTypes.HuanYingSiYuan, new AsyncDataItem(KuaFuEventTypes.GMCmd, new object[]
             {
                 data
             }), 0);
         }
     }
 }
Ejemplo n.º 3
0
 public void BroadcastGMCmdData(GMCmdData data, int serverFlag)
 {
     try
     {
         IKuaFuService kuaFuService = this.GetKuaFuService(false);
         if (null != kuaFuService)
         {
             try
             {
                 kuaFuService.BroadcastGMCmdData(data, serverFlag);
             }
             catch (Exception ex)
             {
                 this.ResetKuaFuService();
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteException(ex.ToString());
     }
 }
Ejemplo n.º 4
0
 public bool ProcessGVoiceSetRoleListCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         int              result    = 0;
         int              type      = Global.SafeConvertToInt32(cmdParams[1]);
         string           prioritys = cmdParams[2];
         int              bhid      = client.ClientData.Faction;
         int              rid       = client.ClientData.RoleID;
         string           leader    = rid.ToString();
         HashSet <string> rids      = new HashSet <string>();
         if (!string.IsNullOrEmpty(prioritys))
         {
             foreach (string str in prioritys.Split(new char[]
             {
                 ','
             }))
             {
                 if (str != leader)
                 {
                     rids.Add(str);
                 }
             }
         }
         prioritys = string.Join(",", rids);
         if (type == 1)
         {
             if (bhid <= 0 || client.ClientData.BHZhiWu != 1)
             {
                 result = -1002;
             }
             else if (rids.Count >= this.RuntimeData.VoicePowerNum[0])
             {
                 result = -1035;
             }
             else
             {
                 Global.sendToDB <string, string>(1111, string.Format("{0}:{1}:{2}", rid, bhid, prioritys), client.ServerId);
                 GMCmdData gmCmdData = new GMCmdData
                 {
                     Fields = new string[]
                     {
                         "-gvoicepriority",
                         1.ToString(),
                         bhid.ToString(),
                         prioritys
                     }
                 };
                 HuanYingSiYuanClient.getInstance().BroadcastGMCmdData(gmCmdData, 1);
                 this.UpdateGVoicePriority(gmCmdData, true);
             }
         }
         else if (type == 2)
         {
             if (client.ClientData.BHZhiWu != 1 || (client.ClientData.JunTuanId <= 0 && client.ClientData.JunTuanZhiWu == 1))
             {
                 result = -1024;
             }
             else if (rids.Count >= this.RuntimeData.VoicePowerNum[1])
             {
                 result = -1035;
             }
             else
             {
                 result = JunTuanClient.getInstance().ChangeJunTuanGVoicePrioritys(bhid, prioritys);
             }
         }
         client.sendCmd <int>(nID, result, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Ejemplo n.º 5
0
        public void EventCallBackHandler(AsyncDataItem item)
        {
            try
            {
                int      eventType = (int)item.EventType;
                object[] args      = item.Args;
                int      num       = eventType;
                if (num <= 9996)
                {
                    switch (num)
                    {
                    case 0:
                    case 1:
                        if (args.Length == 1)
                        {
                            KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                            if (null != kuaFuRoleData)
                            {
                                this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                            }
                        }
                        break;

                    case 2:
                        if (args.Length == 2)
                        {
                            int rid   = (int)args[0];
                            int count = (int)args[1];
                            this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuFuBenRoleCountEvent(rid, count), this.SceneType);
                        }
                        break;

                    case 3:
                        if (args.Length == 1)
                        {
                            KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                            if (null != kuaFuRoleData)
                            {
                                this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                                HuanYingSiYuanFuBenData huanYingSiYuanFuBenData = this.GetKuaFuFuBenData(kuaFuRoleData.GameId);
                                if (huanYingSiYuanFuBenData != null && huanYingSiYuanFuBenData.State == GameFuBenState.Start)
                                {
                                    KuaFuServerLoginData kuaFuServerLoginData = new KuaFuServerLoginData
                                    {
                                        RoleId   = kuaFuRoleData.RoleId,
                                        GameType = kuaFuRoleData.GameType,
                                        GameId   = (long)kuaFuRoleData.GameId,
                                        EndTicks = kuaFuRoleData.StateEndTicks
                                    };
                                    kuaFuServerLoginData.ServerId = this.ClientInfo.ServerId;
                                    KuaFuServerInfo kuaFuServerInfo;
                                    if (KuaFuManager.getInstance().TryGetValue(huanYingSiYuanFuBenData.ServerId, out kuaFuServerInfo))
                                    {
                                        kuaFuServerLoginData.ServerIp   = kuaFuServerInfo.Ip;
                                        kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port;
                                    }
                                    else
                                    {
                                        LogManager.WriteLog(LogTypes.Error, string.Format("服务器列表中无法找到serverid={0}的IP和端口信息", huanYingSiYuanFuBenData.ServerId), null, true);
                                    }
                                    this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), this.SceneType);
                                }
                            }
                        }
                        break;

                    default:
                        if (num == 9996)
                        {
                            if (args.Length == 1)
                            {
                                GMCmdData data = args[0] as GMCmdData;
                                GVoiceManager.getInstance().UpdateGVoicePriority(data, true);
                            }
                        }
                        break;
                    }
                }
                else if (num != 10015)
                {
                    if (num == 10029)
                    {
                        KuaFuLueDuoNtfEnterData data2 = args[0] as KuaFuLueDuoNtfEnterData;
                        KuaFuLueDuoManager.getInstance().HandleNtfEnterEvent(data2);
                    }
                }
                else if (args != null && args.Length == 2)
                {
                    KuaFuManager.getInstance().UpdateServerInfoList(args[1] as List <KuaFuServerInfo>);
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
        }