public static void SyncIniString(IniFile conf, string section, string key, string defaultValue, ref string gameMsgDefField) { string LoadString = conf.ReadString(section, key, defaultValue); if (LoadString == "") { conf.WriteString(section, key, gameMsgDefField); } else { gameMsgDefField = LoadString; } }
public static void LoadConfig() { int LoadInteger; GameFramework.IniFile Conf = new GameFramework.IniFile(g_sConfFileName); if (Conf != null) { g_sDataDBFilePath = Conf.ReadString("DB", "Dir", g_sDataDBFilePath); g_sHumDBFilePath = Conf.ReadString("DB", "HumDir", g_sHumDBFilePath); g_sFeedPath = Conf.ReadString("DB", "FeeDir", g_sFeedPath); g_sBackupPath = Conf.ReadString("DB", "Backup", g_sBackupPath); g_sConnectPath = Conf.ReadString("DB", "ConnectDir", g_sConnectPath); g_sLogPath = Conf.ReadString("DB", "LogDir", g_sLogPath); g_nServerPort = Conf.ReadInteger("Setup", "ServerPort", g_nServerPort); g_sServerAddr = Conf.ReadString("Setup", "ServerAddr", g_sServerAddr); g_nGatePort = Conf.ReadInteger("Setup", "GatePort", g_nGatePort); g_sGateAddr = Conf.ReadString("Setup", "GateAddr", g_sGateAddr); g_sIDServerAddr = Conf.ReadString("Server", "IDSAddr", g_sIDServerAddr); g_nIDServerPort = Conf.ReadInteger("Server", "IDSPort", g_nIDServerPort); g_sServerName = Conf.ReadString("Setup", "ServerName", g_sServerName); g_boDenyChrName = Conf.ReadBool("Setup", "DenyChrName", g_boDenyChrName); g_boMinimize = Conf.ReadBool("Setup", "Minimize", g_boMinimize); g_boDeleteChrName = Conf.ReadBool("Setup", "DeleteChrName", g_boDeleteChrName); g_boRandomNumber = Conf.ReadBool("Setup", "RandomNumber", g_boRandomNumber); // boViewHackMsg := Conf.ReadBool('Setup', 'ViewHackMsg', boViewHackMsg); // // boClearLevel1:=Conf.ReadBool('DBClear','ClearLevel1',boClearLevel1); // boClearLevel2:=Conf.ReadBool('DBClear','ClearLevel2',boClearLevel2); // boClearLevel3:=Conf.ReadBool('DBClear','ClearLevel3',boClearLevel3); // // dwInterval := Conf.ReadInteger('DBClear', 'Interval', dwInterval); // nLevel1 := Conf.ReadInteger('DBClear', 'Level1', nLevel1); // nLevel2 := Conf.ReadInteger('DBClear', 'Level2', nLevel2); // nLevel3 := Conf.ReadInteger('DBClear', 'Level3', nLevel3); // nDay1 := Conf.ReadInteger('DBClear', 'Day1', nDay1); // nDay2 := Conf.ReadInteger('DBClear', 'Day2', nDay2); // nDay3 := Conf.ReadInteger('DBClear', 'Day3', nDay3); // nMonth1 := Conf.ReadInteger('DBClear', 'Month1', nMonth1); // nMonth2 := Conf.ReadInteger('DBClear', 'Month2', nMonth2); // nMonth3 := Conf.ReadInteger('DBClear', 'Month3', nMonth3); LoadInteger = Conf.ReadInteger("Setup", "DynamicIPMode", -1); if (LoadInteger < 0) { Conf.WriteBool("Setup", "DynamicIPMode", g_boDynamicIPMode); } else { g_boDynamicIPMode = LoadInteger == 1; } g_boAutoRefRanking = Conf.ReadBool("Setup", "AutoRefRanking", g_boAutoRefRanking); g_nRankingMinLevel = Conf.ReadInteger("Setup", "RankingMinLevel", g_nRankingMinLevel); g_nRankingMaxLevel = Conf.ReadInteger("Setup", "RankingMaxLevel", g_nRankingMaxLevel); g_nRefRankingHour1 = Conf.ReadInteger("Setup", "RefRankingHour1", g_nRefRankingHour1); g_nRefRankingHour2 = Conf.ReadInteger("Setup", "RefRankingHour2", g_nRefRankingHour2); g_nRefRankingMinute1 = Conf.ReadInteger("Setup", "RefRankingMinute1", g_nRefRankingMinute1); g_nRefRankingMinute2 = Conf.ReadInteger("Setup", "RefRankingMinute2", g_nRefRankingMinute2); g_nAutoRefRankingType = Conf.ReadInteger("Setup", "AutoRefRankingType", g_nAutoRefRankingType); g_boAllowAddChar = Conf.ReadBool("Setup", "AllowAddChar", g_boAllowAddChar); g_boAllowDelChar = Conf.ReadBool("Setup", "AllowDelChar", g_boAllowDelChar); g_boAllowGetBackChar = Conf.ReadBool("Setup", "AllowGetBackChar", g_boAllowGetBackChar); g_nStoreDeleteCharDay = Conf.ReadInteger("Setup", "StoreDeleteCharDay", g_nStoreDeleteCharDay); g_nAllowDelCharCount = Conf.ReadInteger("Setup", "AllowDelCharCount", g_nAllowDelCharCount); } LoadIPTable(); LoadGateID(); LoadServerInfo(); LoadChrNameList("DenyChrName.txt"); LoadAICharNameList("AICharName.txt"); LoadClearMakeIndexList("ClearMakeIndex.txt"); }
public static void LoadServerInfo() { int I; GameFramework.TStringList LoadList; int nRouteIdx; int nGateIdx; int nServerIndex; string sLineText; string sSelGateIPaddr = string.Empty; string sGameGateIPaddr = string.Empty; string sGameGate; string sGameGatePort = string.Empty; string sMapName = string.Empty; string sMapInfo; string sServerIndex; if (!File.Exists(g_sGateConfFileName))//如果文件不存在 则生成!serverinfo.txt { LoadList = new GameFramework.TStringList(); LoadList.Add("127.0.0.1 127.0.0.1 7200"); try { LoadList.SaveToFile(g_sGateConfFileName); } catch { } } if (File.Exists(g_sGateConfFileName))//如果文件存在 { LoadList = new GameFramework.TStringList(); try { LoadList.LoadFromFile(g_sGateConfFileName); } catch { } nRouteIdx = 0; nGateIdx = 0; for (I = 0; I < LoadList.Count; I++) { sLineText = LoadList[I].Trim(); if ((sLineText != "") && (sLineText[1] != ';')) { sGameGate = GameFramework.HUtil32.GetValidStr3(sLineText, ref sSelGateIPaddr, new string[] { " ", "\09" }); if ((sGameGate == "") || (sSelGateIPaddr == ""))//如果为空继续 { continue; } g_RouteInfo[nRouteIdx].sSelGateIP = sSelGateIPaddr.Trim();//第一个IP 选择网关IP g_RouteInfo[nRouteIdx].nGateCount = 0; nGateIdx = 0; while ((sGameGate != ""))//如果剩下的字符串不为空 如果一直不为空 { sGameGate = GameFramework.HUtil32.GetValidStr3(sGameGate, ref sGameGateIPaddr, new string[] { " ", "\09" }); sGameGate = GameFramework.HUtil32.GetValidStr3(sGameGate, ref sGameGatePort, new string[] { " ", "\09" }); g_RouteInfo[nRouteIdx].sGameGateIP.Add(sGameGateIPaddr.Trim());//游戏网关IP g_RouteInfo[nRouteIdx].nGameGatePort.Add(GameFramework.HUtil32.Str_ToInt(sGameGatePort, 0)); nGateIdx++; } g_RouteInfo[nRouteIdx].nGateCount = nGateIdx; nRouteIdx++; } } LoadList.Dispose(); } GameFramework.IniFile Conf = new GameFramework.IniFile(g_sConfFileName);//Dbsrc.ini g_sMapFile = Conf.ReadString("Setup", "MapFile", g_sMapFile); g_MapList.Clear(); if (File.Exists(g_sMapFile)) { LoadList = new GameFramework.TStringList(); try { LoadList.LoadFromFile(g_sMapFile); } catch { } for (I = 0; I < LoadList.Count; I++) { sLineText = LoadList[I]; if ((sLineText != "") && (sLineText[0] == '[')) { sLineText = GameFramework.HUtil32.ArrestStringEx(sLineText, "[", "]", ref sMapName); sMapInfo = GameFramework.HUtil32.GetValidStr3(sMapName, ref sMapName, new string[] { " ", "\09" }); sServerIndex = GameFramework.HUtil32.GetValidStr3(sMapInfo, ref sMapInfo, new string[] { " ", "\09" }).Trim(); nServerIndex = GameFramework.HUtil32.Str_ToInt(sServerIndex, 0); g_MapList.Add(sMapName, ((nServerIndex) as Object)); } } } }