public static void LoadIPTable() { if (!File.Exists(g_sServerIPConfFileNmae)) { g_ServerIPList.Add("127.0.0.1"); try { g_ServerIPList.SaveToFile(g_sServerIPConfFileNmae); } catch { } } else { g_ServerIPList.Clear(); try { g_ServerIPList.LoadFromFile(g_sServerIPConfFileNmae); } catch { MainOutMessage("加载IP列表文件 " + g_sServerIPConfFileNmae + " 出错!!!"); } } }
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)); } } } }