Esempio n. 1
0
 /// <summary>
 /// 获取指定逻辑ID的SS信息
 /// </summary>
 public CSSSInfo GetSSInfoByNSID(uint nsID)
 {
     for (int i = 0; i < this.csKernelCfg.un32MaxSSNum; ++i)
     {
         CSSSInfo pcInfo = this.ssNetInfoList[i].pcSSInfo;
         if (null == pcInfo)
         {
             continue;
         }
         if (pcInfo.m_n32NSID == nsID)
         {
             return(pcInfo);
         }
     }
     return(null);
 }
        public ErrorCode Load()
        {
            Hashtable json;

            try
            {
                string content = File.ReadAllText(@".\Config\CSCfg.json");
                json = ( Hashtable )MiniJSON.JsonDecode(content);
            }
            catch (Exception e)
            {
                Logger.Error($"load CSCfg failed:{e}");
                return(ErrorCode.CfgFailed);
            }
            this.unCSId               = json.GetUInt("GameWorldID");
            this.ipaddress            = json.GetString("CSIP");
            this.n32SSNetListenerPort = json.GetInt("SSPort");
            this.n32GSNetListenerPort = json.GetInt("GSPort");
            this.un32MaxSSNum         = json.GetUInt("MaxSSNum");
            this.un32SSBaseIdx        = json.GetUInt("SSBaseIndex");
            this.un32MaxGSNum         = json.GetUInt("MaxGSNum");
            this.un32GSBaseIdx        = json.GetUInt("GSBaseIndex");
            this.maxWaitingDBNum      = json.GetInt("WaitingDBNum");
            this.redisAddress         = json.GetString("redisAddress");
            this.redisPort            = json.GetInt("redisPort");
            this.redisPwd             = json.GetString("redisPwd");
            this.redisLogicAddress    = json.GetString("redisLogicAddress");
            this.redisLogicPort       = json.GetInt("redisLogicPort");
            this.redisLogicPwd        = json.GetString("redisLogicPwd");
            this.LogAddress           = json.GetString("LogAddress");
            this.LogPort              = json.GetInt("LogPort");

            string ssIndexStr = json.GetString("AllSSIndex");

            string[] ssIndexVec = ssIndexStr.Split(';');

            if (ssIndexVec.Length > 100000)
            {
                Logger.Warn($"too many ss!");
                return(ErrorCode.CfgFailed);
            }

            this.ssInfoList = new CSSSInfo[ssIndexVec.Length];
            for (int i = 0; i != ssIndexVec.Length; ++i)
            {
                string[] ssInfoVec = ssIndexVec[i].Split(',');
                if (ssInfoVec.Length != 3)
                {
                    Logger.Error("load CSCfg.xml failed.");
                    continue;
                }
                CSSSInfo csssInfo = new CSSSInfo();
                csssInfo.m_n32SSID   = int.Parse(ssInfoVec[0]);
                csssInfo.m_szName    = ssInfoVec[1];
                csssInfo.m_szUserPwd = ssInfoVec[2];
                this.ssInfoList[i]   = csssInfo;
            }

            string gsIndexStr = json.GetString("AllGSIndex");

            string[] gsIndexVec = gsIndexStr.Split(';');
            this.gsInfoList = new CSGSInfo[gsIndexVec.Length];
            for (int i = 0; i != gsIndexVec.Length; ++i)
            {
                string[] gsInfoVec = gsIndexVec[i].Split(',');
                if (gsInfoVec.Length != 3)
                {
                    Logger.Error("load CSCfg.xml failed.");
                    continue;
                }
                CSGSInfo csgsInfo = new CSGSInfo();
                csgsInfo.m_n32GSID   = int.Parse(gsInfoVec[0]);
                csgsInfo.m_szName    = gsInfoVec[1];
                csgsInfo.m_szUserPwd = gsInfoVec[2];
                this.gsInfoList[i]   = csgsInfo;
            }

            this.n32RCNetListenerPort = json.GetInt("RSPort");
            this.remoteConsolekey     = json.GetString("RSKey");

            return(ErrorCode.Success);
        }