static Config() { if (!File.Exists(Engine.m_IniPath)) { Engine.WantDirectory(Path.GetDirectoryName(Engine.m_IniPath)); StreamWriter writer = new StreamWriter(Engine.m_IniPath, false); for (int i = 0; i < m_FileNames.Length; i++) { writer.WriteLine(m_FileNames[i]); } writer.Flush(); writer.Close(); } else { StreamReader reader = new StreamReader(Engine.m_IniPath); for (int j = 0; (j < m_FileNames.Length) && (reader.Peek() != -1); j++) { m_FileNames[j] = reader.ReadLine(); } reader.Close(); } if (!File.Exists(Engine.FileManager.ResolveMUL(Files.Verdata))) { string path = Engine.FileManager.BasePath("Data/Binary/EmptyVerdata.mul"); m_FileNames[0x18] = path; if (!File.Exists(path)) { using (Stream stream = File.Create(path, 4)) { stream.Write(new byte[4], 0, 4); stream.Flush(); } } } m_PaperdollCFG = new ArrayList(); Engine.WantDirectory("Data/Config/"); if (File.Exists(Engine.FileManager.BasePath("Data/Config/Paperdoll.cfg"))) { StreamReader reader2 = new StreamReader(Engine.FileManager.BasePath("Data/Config/Paperdoll.cfg")); string str2 = null; while ((str2 = reader2.ReadLine()) != null) { string[] strArray = str2.Split(new char[] { '\t' }); if (strArray.Length >= 2) { try { m_PaperdollCFG.Add(new PaperdollEntry(Convert.ToInt32(strArray[0], 0x10), Convert.ToInt32(strArray[1], 0x10))); continue; } catch { continue; } } } reader2.Close(); } }
static unsafe Network() { Engine.WantDirectory("Data/Logs/Network/"); m_Leaves = new UnpackLeaf[0x201]; int index = 0; m_Tree = new UnpackLeaf(index); m_Leaves[index++] = m_Tree; fixed(short *numRef = m_Table) { short *numPtr = numRef; for (short i = 0; i <= 0x100; i = (short)(i + 1)) { UnpackLeaf tree = m_Tree; numPtr++; int num3 = numPtr[0]; int num4 = num3 & 15; for (int j = num3 >> 4; --num4 >= 0; j = j >> 1) { switch ((j & 1)) { case 0: if (tree.m_Left == null) { tree.m_Left = new UnpackLeaf(index); m_Leaves[index++] = tree.m_Left; } tree = tree.m_Left; break; case 1: if (tree.m_Right == null) { tree.m_Right = new UnpackLeaf(index); m_Leaves[index++] = tree.m_Right; } tree = tree.m_Right; break; } } tree.m_Value = i; } } m_Table = null; }
public static void Save(Mobile who, string filename) { if (m_List != null) { Engine.WantDirectory("Data/Plugins/Macros"); using (StreamWriter writer = new StreamWriter(Engine.FileManager.BasePath(string.Format("Data/Plugins/Macros/{0}.txt", filename)))) { if (who == null) { writer.WriteLine("; Default macro definitions file"); } else { writer.WriteLine("; Macro definition file for {0} on {1}", who.Name, Engine.m_ServerName); } writer.WriteLine("; Format:"); writer.WriteLine("; Control Alt Shift"); writer.WriteLine("; Key"); writer.WriteLine("; [list]"); writer.WriteLine("; <name> [param]"); writer.WriteLine("; #####"); writer.WriteLine(); Cleanup(); for (int i = 0; i < m_List.Count; i++) { Macro macro = (Macro)m_List[i]; writer.WriteLine("{0} {1} {2}", macro.Control ? "1" : "0", macro.Alt ? "1" : "0", macro.Shift ? "1" : "0"); switch (macro.Key) { case 0x11000: writer.WriteLine("Wheel Up"); break; case 0x11001: writer.WriteLine("Wheel Down"); break; case 0x11002: writer.WriteLine("Wheel Press"); break; default: writer.WriteLine(macro.Key); break; } for (int j = 0; j < macro.Actions.Length; j++) { Action action = macro.Actions[j]; if (action.Handler == null) { writer.WriteLine(action.Line); } else if (action.Param.Length > 0) { writer.WriteLine("{0} {1}", action.Handler.Action, action.Param); } else { writer.WriteLine(action.Handler.Action); } } if (i == (m_List.Count - 1)) { writer.Write("#####"); } else { writer.WriteLine("#####"); } } } } }