Beispiel #1
0
        public void ParsePacket(IBaseProtocol<IBasePacket<IBaseOpcode>, IBaseOpcode> protocol, IBasePacket<IBaseOpcode> pPacket)
        {
            mTree.Nodes.Clear();
            mSubNodes.Clear();
            pPacket.Rewind();

            string scriptPath = Application.StartupPath + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + protocol.GetScriptLocation(pPacket);
            string commonPath = Application.StartupPath + Path.DirectorySeparatorChar + "Scripts" + Path.DirectorySeparatorChar + protocol.GetCommonScriptLocation();
            if (File.Exists(scriptPath))
            {
                mParsing = pPacket;

                try
                {
                    StringBuilder scriptCode = new StringBuilder();
                    scriptCode.Append(File.ReadAllText(scriptPath));
                    if (File.Exists(commonPath)) scriptCode.Append(File.ReadAllText(commonPath));
                    Script script = Script.Compile(scriptCode.ToString());
                    script.Context.SetItem("ScriptAPI", new ScriptAPI(this));
                    script.Execute();
                }
                catch (Exception exc)
                {
                    OutputForm output = new OutputForm("Script Error");
                    output.Append(exc.ToString());
                    output.Show(DockPanel, new Rectangle(MainForm.Location, new Size(400, 400)));
                }

                mParsing = null;
            }
            if (pPacket.Remaining > 0) mTree.Nodes.Add(new StructureNode("Undefined", pPacket.Buffer, pPacket.Cursor, pPacket.Remaining));
        }
Beispiel #2
0
 public void SetProtocol(IBaseProtocol protocolObj)
 {
     _protocolObj = protocolObj;
 }