public void LoadServerAddr() { string sFileName; TStringList LoadList; int I; int nServerIdx; string sLineText; sFileName = ".\\!ServerAddr.txt"; nServerIdx = 0; if (File.Exists(sFileName)) { LoadList = new TStringList(); LoadList.LoadFromFile(sFileName); for (I = 0; I < LoadList.Count; I++) { sLineText = LoadList[I].Trim(); if ((sLineText != "") && (sLineText[I] != ';')) { if (HUtil32.TagCount(sLineText, '.') == 3) { LSShare.ServerAddr[nServerIdx] = sLineText; nServerIdx++; if (nServerIdx >= LSShare.MAXGATEROUTE - 1) { break; } } } } } }
public void LoadCastleList() { TStringList LoadList; TUserCastle Castle; string sCastleDir; if (File.Exists(M2Share.g_Config.sCastleFile)) { LoadList = new TStringList(); LoadList.LoadFromFile(M2Share.g_Config.sCastleFile); if (LoadList.Count > 0) { for (int I = 0; I < LoadList.Count; I++) { sCastleDir = LoadList[I].Trim(); if (sCastleDir != "") { Castle = new TUserCastle(sCastleDir); m_CastleList.Add(Castle); } } } Dispose(LoadList); M2Share.MainOutMessage("已读取 [" + m_CastleList.Count + "] 个城堡信息..."); } else { M2Share.MainOutMessage("城堡列表文件未找到!!!"); } }
// IniFile Constructor. public TIniFile(string strIniPath) { m_Path = strIniPath; TmpList = new TStringList(); TmpList.Clear(); if (File.Exists(m_Path)) { TmpList.LoadFromFile(m_Path); } }
public bool LoadCustomItemName() { bool result; TStringList LoadList; string sFileName; string sLineText; string sMakeIndex = string.Empty; string sItemIndex = string.Empty; int nMakeIndex = 0; int nItemIndex = 0; string sItemName = string.Empty; TItemName ItemName; result = false; sFileName = M2Share.g_Config.sEnvirDir + "ItemNameList.txt"; LoadList = new TStringList(); if (File.Exists(sFileName)) { lock (m_ItemNameList) try { if (m_ItemNameList.Count > 0) { m_ItemNameList.Clear(); } LoadList.LoadFromFile(sFileName); for (int I = 0; I < LoadList.Count; I++) { sLineText = LoadList[I].Trim(); sLineText = HUtil32.GetValidStr3(sLineText, ref sMakeIndex, new string[] { " ", "\09" }); sLineText = HUtil32.GetValidStr3(sLineText, ref sItemIndex, new string[] { " ", "\09" }); sLineText = HUtil32.GetValidStr3(sLineText, ref sItemName, new string[] { " ", "\09" }); nMakeIndex = HUtil32.Str_ToInt(sMakeIndex, -1); nItemIndex = HUtil32.Str_ToInt(sItemIndex, -1); if ((nMakeIndex >= 0) && (nItemIndex >= 0)) { ItemName = new TItemName(); ItemName.nMakeIndex = nMakeIndex; ItemName.nItemIndex = nItemIndex; ItemName.sItemName = sItemName; m_ItemNameList.Add(ItemName); } } result = true; } finally { } } else { LoadList.SaveToFile(sFileName); } Dispose(LoadList); return(result); }
/// <summary> /// 刷新表格 /// </summary> private void Refresh() { dgvNoticeList.Rows.Clear(); if (File.Exists(StrListFile)) { StrList.LoadFromFile(StrListFile); for (int i = 0; i < StrList.Count; i++) { dgvNoticeList.Rows.Add(StrList[i]); } } else { StrList.SaveToFile(StrListFile); } }
/// <summary> /// 加载游戏行会 /// </summary> public void LoadGuildInfo() { TStringList LoadList; TGUild Guild; string sGuildName; if (File.Exists(M2Share.g_Config.sGuildFile)) { LoadList = new TStringList(); LoadList.LoadFromFile(M2Share.g_Config.sGuildFile); if (LoadList.Count > 0) { for (int I = 0; I < LoadList.Count; I++) { sGuildName = LoadList[I].Trim(); if (sGuildName != "") { Guild = new TGUild(sGuildName); GuildList.Add(Guild); } } } Dispose(LoadList); for (int I = GuildList.Count - 1; I >= 0; I--) { if (GuildList.Count <= 0) { break; } Guild = GuildList[I]; if (!Guild.LoadGuild()) { M2Share.MainOutMessage(Guild.sGuildName + " 读取出错!!!"); Dispose(Guild); GuildList.RemoveAt(I); SaveGuildList(); } } M2Share.MainOutMessage("已读取 [" + (GuildList.Count).ToString() + "] 个行会信息..."); } else { M2Share.MainOutMessage("行会信息文件未找到!!!"); } }
private void LoadRobot() { TStringList LoadList; string sFileName = string.Empty; string sLineText = string.Empty; string sRobotName = string.Empty; string sScriptFileName = string.Empty; string sRobotType = string.Empty; TPlayRobotObject RobotHuman; sFileName = M2Share.g_Config.sEnvirDir + "Robot.txt"; if (File.Exists(sFileName)) { LoadList = new TStringList(); LoadList.LoadFromFile(sFileName); if (LoadList.Count > 0) { for (int I = 0; I < LoadList.Count; I++) { sLineText = LoadList[I]; if ((sLineText != "") && (sLineText[0] != ';')) { sLineText = HUtil32.GetValidStr3(sLineText, ref sRobotName, new string[] { " ", "/", "\09" }); sLineText = HUtil32.GetValidStr3(sLineText, ref sScriptFileName, new string[] { " ", "/", "\09" }); sLineText = HUtil32.GetValidStr3(sLineText, ref sRobotType, new string[] { " ", "/", "\09" }); if ((sRobotName != "") && (sScriptFileName != "") && (sRobotType == "1")) { RobotHuman = new TPlayRobotObject(); RobotHuman.m_sCharName = sRobotName; RobotHuman.m_sScriptFileName = sScriptFileName; RobotHuman.LoadScript(); RobotHumanList.Add(RobotHuman); } } } } Dispose(LoadList); } }
public void LoadUserLimit() { TStringList LoadList; string sFileName = string.Empty; int I; int nC; string sLineText = string.Empty; string sServerName = string.Empty; string s10 = string.Empty; string s14 = string.Empty; nC = 0; sFileName = ".\\!UserLimit.txt"; if (File.Exists(sFileName)) { LoadList = new TStringList(); LoadList.LoadFromFile(sFileName); for (I = 0; I < LoadList.Count; I++) { sLineText = LoadList[I]; sLineText = HUtil32.GetValidStr3(sLineText, ref sServerName, new string[] { " ", "\t" }); sLineText = HUtil32.GetValidStr3(sLineText, ref s10, new string[] { " ", "\t" }); sLineText = HUtil32.GetValidStr3(sLineText, ref s14, new string[] { " ", "\t" }); if (sServerName != "") { UserLimit[nC].sServerName = sServerName; UserLimit[nC].sName = s10; UserLimit[nC].nLimitCountMax = HUtil32.Str_ToInt(s14, 3000); UserLimit[nC].nLimitCountMin = 0; nC++; } } nUserLimit = nC; } else { MessageBox.Show("[Critical Failure] file not found. .\\!UserLimit.txt"); } }
/// <summary> /// 加载数据(如果子类的内容不是单行文本构成,则自行重写实现解析),不返回null /// </summary> public virtual List <T> Load() { textString.LoadFromFile(this.FilePath, Encoding.ASCII); if (textString.Count > 0) { for (int i = 0; i < textString.Count; i++) { if (null == textString || textString[0] == ";") { continue; //跳过空行,注释行 } T t = ConvertFromString(textString[i]); if (t != null) { list.Add(t); } } } return(list); }
public void AddItemsFromConfig() { TStringList LoadList; TMonItemInfo MonItem; string s28; string s2C; string s30 = string.Empty; int n18; int n1C; int n20; IniFile ItemIni; // ---------------------------读取怪物配置---------------------------------- string sFileName = M2Share.g_Config.sEnvirDir + "MonUseItems\\" + m_sCharName + ".txt"; if (File.Exists(sFileName)) { ItemIni = new IniFile(sFileName); if (ItemIni != null) { m_nButchChargeClass = ItemIni.ReadInteger("Info", "ButchChargeClass", (byte)3); // 收费模式(0金币,1元宝,2金刚石,3灵符) m_nButchChargeCount = ItemIni.ReadInteger("Info", "ButchChargeCount", 1); // 挖每次收费点数 boIntoTrigger = ItemIni.ReadBool("Info", "ButchCloneItem", false); // 怪挖是否进入触发 // ---------------------------读取探索物品---------------------------------- sFileName = M2Share.g_Config.sEnvirDir + "MonUseItems\\" + m_sCharName + "-Item.txt"; if (File.Exists(sFileName)) { if (m_ButchItemList != null) { if (m_ButchItemList.Count > 0) { for (int I = 0; I < m_ButchItemList.Count; I++) { if (m_ButchItemList[I] != null) { Dispose(m_ButchItemList[I]); } } } m_ButchItemList.Clear(); } LoadList = new TStringList(); LoadList.LoadFromFile(sFileName); if (LoadList.Count > 0) { for (int I = 0; I < LoadList.Count; I++) { s28 = LoadList[I]; if ((s28 != "") && (s28[0] != ';')) { s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "/", "\09" }); n18 = HUtil32.Str_ToInt(s30, -1); s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "/", "\09" }); n1C = HUtil32.Str_ToInt(s30, -1); s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "\09" }); if (s30 != "") { if (s30[0] == '\"') { HUtil32.ArrestStringEx(s30, "\"", "\"", ref s30); } } s2C = s30; s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "\09" }); n20 = HUtil32.Str_ToInt(s30, 1); if ((n18 > 0) && (n1C > 0) && (s2C != "")) { MonItem = new TMonItemInfo(); MonItem.SelPoint = n18 - 1; MonItem.MaxPoint = n1C; MonItem.ItemName = s2C; MonItem.Count = n20; if (HUtil32.Random(MonItem.MaxPoint) <= MonItem.SelPoint) // 计算机率 1/10 随机10<=1 即为所得的物品 { m_ButchItemList.Add(MonItem); } } } } } if (m_ButchItemList.Count > 0) { m_boExploration = true; // 是否可探索 } Dispose(LoadList); } Dispose(ItemIni); } } }
// 是否已执行操作; public void LoadScript() { TStringList LoadList; string sFileName = string.Empty; string sLineText = string.Empty; string sActionType = string.Empty; string sRunCmd = string.Empty; string sMoethod = string.Empty; string sParam1 = string.Empty; string sParam2 = string.Empty; string sParam3 = string.Empty; string sParam4 = string.Empty; TAutoRunInfo AutoRunInfo; sFileName = M2Share.g_Config.sEnvirDir + "Robot_def\\" + m_sScriptFileName + ".txt"; if (File.Exists(sFileName)) { LoadList = new TStringList(); LoadList.LoadFromFile(sFileName); if (LoadList.Count > 0) { for (int I = 0; I < LoadList.Count; I++) { sLineText = LoadList[I]; if ((sLineText != "") && (sLineText[0] != ';')) { sLineText = HUtil32.GetValidStr3(sLineText, ref sActionType, new string[] { " ", "/", "\09" }); sLineText = HUtil32.GetValidStr3(sLineText, ref sRunCmd, new string[] { " ", "/", "\09" }); sLineText = HUtil32.GetValidStr3(sLineText, ref sMoethod, new string[] { " ", "/", "\09" }); sLineText = HUtil32.GetValidStr3(sLineText, ref sParam1, new string[] { " ", "/", "\09" }); sLineText = HUtil32.GetValidStr3(sLineText, ref sParam2, new string[] { " ", "/", "\09" }); sLineText = HUtil32.GetValidStr3(sLineText, ref sParam3, new string[] { " ", "/", "\09" }); sLineText = HUtil32.GetValidStr3(sLineText, ref sParam4, new string[] { " ", "/", "\09" }); if (string.Compare(sActionType, SDK.sROAUTORUN, true) == 0) { if (string.Compare(sRunCmd, SDK.sRONPCLABLEJMP, true) == 0) { AutoRunInfo = new TAutoRunInfo(); AutoRunInfo.dwRunTick = HUtil32.GetTickCount(); AutoRunInfo.dwRunTimeLen = 0; AutoRunInfo.boStatus = false; AutoRunInfo.nRunCmd = SDK.nRONPCLABLEJMP; if (string.Compare(sMoethod, SDK.sRODAY, true) == 0) { AutoRunInfo.nMoethod = SDK.nRODAY; } if (string.Compare(sMoethod, SDK.sROHOUR, true) == 0) { AutoRunInfo.nMoethod = SDK.nROHOUR; } if (string.Compare(sMoethod, SDK.sROMIN, true) == 0) { AutoRunInfo.nMoethod = SDK.nROMIN; } if (string.Compare(sMoethod, SDK.sROSEC, true) == 0) { AutoRunInfo.nMoethod = SDK.nROSEC; } if (string.Compare(sMoethod, SDK.sRUNONWEEK, true) == 0) { AutoRunInfo.nMoethod = SDK.nRUNONWEEK; } if (string.Compare(sMoethod, SDK.sRUNONDAY, true) == 0) { AutoRunInfo.nMoethod = SDK.nRUNONDAY; } AutoRunInfo.sParam1 = sParam1; AutoRunInfo.sParam2 = sParam2; AutoRunInfo.sParam3 = sParam3; AutoRunInfo.sParam4 = sParam4; AutoRunInfo.nParam1 = HUtil32.Str_ToInt(sParam1, 1); m_AutoRunList.Add(AutoRunInfo); } } } } } // Dispose(LoadList); } }
public void NpcScript(TPlayObject PlayObject, string[] @Params) { int nPermission = @Params.Length > 0 ? int.Parse(@Params[0]) : 0; string sParam1 = @Params.Length > 1 ? @Params[1] : ""; string sParam2 = @Params.Length > 2 ? @Params[2] : ""; string sParam3 = @Params.Length > 3 ? @Params[3] : ""; TBaseObject BaseObject; int nNPCType; string sScriptFileName = string.Empty; TMerchant Merchant; TNormNpc NormNpc; TStringList LoadList; string sScriptLine; if ((sParam1 == "") || ((sParam1 != "") && (sParam1[0] == '?'))) { if (M2Share.g_Config.boGMShowFailMsg) { PlayObject.SysMsg(string.Format(GameMsgDef.g_sGameCommandParamUnKnow, this.Attributes.Name, GameMsgDef.g_sGameCommandNpcScriptHelpMsg), TMsgColor.c_Red, TMsgType.t_Hint); } return; } nNPCType = -1; BaseObject = PlayObject.GetPoseCreate(); if (BaseObject != null) { for (int I = 0; I < UserEngine.m_MerchantList.Count; I++) { if (((UserEngine.m_MerchantList[I]) as TBaseObject) == BaseObject) { nNPCType = 0; break; } } for (int I = 0; I < UserEngine.QuestNPCList.Count; I++) { if (((UserEngine.QuestNPCList[I]) as TBaseObject) == BaseObject) { nNPCType = 1; break; } } } if (nNPCType < 0) { PlayObject.SysMsg("命令使用方法不正确,必须与NPC面对面,才能使用此命令!!!", TMsgColor.c_Red, TMsgType.t_Hint); return; } if (sParam1 == "") { if (nNPCType == 0) { Merchant = ((TMerchant)(BaseObject)); sScriptFileName = M2Share.g_Config.sEnvirDir + M2Share.sMarket_Def + Merchant.m_sScript + "-" + Merchant.m_sMapName + ".txt"; } if (nNPCType == 1) { NormNpc = ((TNormNpc)(BaseObject)); sScriptFileName = M2Share.g_Config.sEnvirDir + M2Share.sNpc_def + NormNpc.m_sCharName + "-" + NormNpc.m_sMapName + ".txt"; } if (File.Exists(sScriptFileName)) { LoadList = new TStringList(); try { LoadList.LoadFromFile(sScriptFileName); } catch { PlayObject.SysMsg("读取脚本文件错误: " + sScriptFileName, TMsgColor.c_Red, TMsgType.t_Hint); } for (int I = 0; I < LoadList.Count; I++) { sScriptLine = LoadList[I].Trim(); sScriptLine = HUtil32.ReplaceChar(sScriptLine, ' ', ','); PlayObject.SysMsg(I + "," + sScriptLine, TMsgColor.c_Blue, TMsgType.t_Hint); } HUtil32.Dispose(LoadList); } } }
public void Execute() { int I; uint dwTick2C; string s18 = string.Empty; string s1C = string.Empty; string s24 = string.Empty; string s28 = string.Empty; int nC; int n10; int n14; TConfig Config; Config = LSShare.g_Config; dwTick2C = 0; while (true) { if ((HUtil32.GetTickCount() - dwTick2C) > 5 * 60 * 1000) { dwTick2C = HUtil32.GetTickCount(); try { if (File.Exists(Config.sFeedIDList)) { AccountLoadList.Clear(); AccountLoadList.LoadFromFile(Config.sFeedIDList); if (AccountLoadList.Count > 0) { AccountCostList.Clear(); for (I = 0; I < AccountLoadList.Count; I++) { s18 = AccountLoadList[I].Trim(); s18 = HUtil32.GetValidStr3(s18, ref s1C, new string[] { " ", "\t" }); s18 = HUtil32.GetValidStr3(s18, ref s24, new string[] { " ", "\t" }); s18 = HUtil32.GetValidStr3(s18, ref s28, new string[] { " ", "\t" }); n10 = HUtil32.Str_ToInt(s24, 0); n14 = HUtil32.Str_ToInt(s28, 0); nC = HUtil32.MakeLong(HUtil32._MAX(n14, 0), HUtil32._MAX(n10, 0)); AccountCostList.Add(s1C, nC); if (!bo40) { if ((I % 100) == 0) { Thread.Sleep(1); } } } } //LoadAccountCostList(Config, AccountCostList); } } catch { LSShare.MainOutMessage("Exception] loading on IDStrList."); } try { if (File.Exists(Config.sFeedIPList)) { IPaddrLoadList.Clear(); IPaddrLoadList.LoadFromFile(Config.sFeedIPList); if (IPaddrLoadList.Count > 0) { IPaddrCostList.Clear(); for (I = 0; I < IPaddrLoadList.Count; I++) { s18 = IPaddrLoadList[I].Trim(); s18 = HUtil32.GetValidStr3(s18, ref s1C, new string[] { " ", "\t" }); s18 = HUtil32.GetValidStr3(s18, ref s24, new string[] { " ", "\t" }); s18 = HUtil32.GetValidStr3(s18, ref s28, new string[] { " ", "\t" }); n10 = HUtil32.Str_ToInt(s24, 0); n14 = HUtil32.Str_ToInt(s28, 0); //@ Unsupported function or procedure: 'MakeLong' nC = HUtil32.MakeLong(HUtil32._MAX(n14, 0), HUtil32._MAX(n10, 0)); IPaddrCostList.Add(s1C, nC); if (!bo40) { if ((I % 100) == 0) { Thread.Sleep(1); } } } } //LoadIPaddrCostList(Config, IPaddrCostList); } } catch { LSShare.MainOutMessage("Exception] loading on IPStrList."); } } Thread.Sleep(10); //@ Unsupported property or method(C): 'Terminated' //if (this.Terminated) //{ // break; //} } }
/// <summary> /// 读取怪物爆率文件 /// </summary> /// <param name="MonName">怪物名称</param> /// <param name="ItemList">物品列表</param> /// <returns></returns> internal int LoadMonitems(string MonName, ref IList <TMonItem> ItemList) { int result = 0; TStringList LoadList; TMonItem MonItem; string s28 = string.Empty; string s2C = string.Empty; string s30 = string.Empty; int n18; int n1C; int n20; string sFileName = M2Share.g_Config.sEnvirDir + "MonItems\\" + MonName + ".txt"; if (File.Exists(sFileName)) { if (ItemList != null) { if (ItemList.Count > 0) { for (int I = 0; I < ItemList.Count; I++) { if (ItemList[I] != null) { Dispose(ItemList[I]); } } } ItemList.Clear(); } LoadList = new TStringList(); LoadList.LoadFromFile(sFileName); for (int I = 0; I < LoadList.Count; I++) { s28 = LoadList[I]; if ((s28 != "") && (s28[0] != ';')) { s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "/", "\t" }); n18 = HUtil32.Str_ToInt(s30, -1); s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "/", "\t" }); n1C = HUtil32.Str_ToInt(s30, -1); s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "\t" }); if (s30 != "") { if (s30[0] == '\'') { HUtil32.ArrestStringEx(s30, "\"", "\"", ref s30); } } s2C = s30; s28 = HUtil32.GetValidStr3(s28, ref s30, new string[] { " ", "\t" }); n20 = HUtil32.Str_ToInt(s30, 1); if ((n18 > 0) && (n1C > 0) && (s2C != "")) { if (ItemList == null) { ItemList = new List <TMonItem>(); } MonItem = new TMonItem(); MonItem.n00 = n18 - 1; MonItem.n04 = n1C; MonItem.sMonName = s2C; MonItem.n18 = n20; ItemList.Add(MonItem); result++; } } } } return(result); }