diff --git a/amxmodx/binlog.cpp b/amxmodx/binlog.cpp index 72861f08..4dd61dc2 100644 --- a/amxmodx/binlog.cpp +++ b/amxmodx/binlog.cpp @@ -187,17 +187,8 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...) } case BinLog_NativeRet: { - int file; cell retval = va_arg(ap, cell); fwrite(&retval, sizeof(cell), 1, fp); - if (debug) - { - file = LookupFile(dbg, amx->cip); - fwrite(&file, sizeof(int), 1, fp); - } else { - file = 0; - fwrite(&file, sizeof(int), 1, fp); - } break; } case BinLog_NativeError: diff --git a/amxmodx/binlog.h b/amxmodx/binlog.h index 22d34b6f..616adef7 100644 --- a/amxmodx/binlog.h +++ b/amxmodx/binlog.h @@ -48,7 +48,7 @@ enum BinLogOp BinLog_End, BinLog_NativeCall, // BinLog_NativeError, // - BinLog_NativeRet, // + BinLog_NativeRet, // BinLog_CallPubFunc, // BinLog_SetLine, // BinLog_Registered, // diff --git a/plugins/BinLogReader/BinLog.cs b/plugins/BinLogReader/BinLog.cs index cf6cac36..3948ac5b 100644 --- a/plugins/BinLogReader/BinLog.cs +++ b/plugins/BinLogReader/BinLog.cs @@ -11,7 +11,8 @@ namespace BinLogReader public class BinLog { private static uint BINLOG_MAGIC = 0x414D424C; - private static short BINLOG_VERSION = 0x0200; + private static short BINLOG_VERSION = 0x0300; + private static short BINLOG_MIN_VERSION = 0x0300; private ArrayList oplist; private PluginDb plugdb; @@ -60,7 +61,7 @@ namespace BinLogReader throw new Exception("Invalid magic log number"); ushort version = br.ReadUInt16(); - if (version > BINLOG_VERSION) + if (version > BINLOG_VERSION || version < BINLOG_MIN_VERSION) throw new Exception("Unknown log version number"); byte timesize = br.ReadByte(); @@ -182,19 +183,22 @@ namespace BinLogReader case BinLogOp.BinLog_SetLine: { int line = br.ReadInt32(); + int file = br.ReadInt32(); BinLogSetLine bsl = - new BinLogSetLine(line, gametime, realtime, pl); + new BinLogSetLine(line, gametime, realtime, pl, file); bl.OpList.Add(bsl); break; } case BinLogOp.BinLog_CallPubFunc: { int pubidx = br.ReadInt32(); + int fileid = br.ReadInt32(); BinLogPublic bp = new BinLogPublic(pubidx, gametime, realtime, - pl); + pl, + fileid); bl.OpList.Add(bp); break; } @@ -214,12 +218,14 @@ namespace BinLogReader { int native = br.ReadInt32(); int parms = br.ReadInt32(); + int file = br.ReadInt32(); BinLogNativeCall bn = new BinLogNativeCall(native, parms, gametime, realtime, - pl); + pl, + file); bl.OpList.Add(bn); break; } diff --git a/plugins/BinLogReader/BinLogOps.cs b/plugins/BinLogReader/BinLogOps.cs index e881029d..33a6b1a2 100644 --- a/plugins/BinLogReader/BinLogOps.cs +++ b/plugins/BinLogReader/BinLogOps.cs @@ -10,16 +10,16 @@ namespace BinLogReader BinLog_Invalid=0, BinLog_Start=1, BinLog_End, - BinLog_NativeCall, // - BinLog_NativeError, - BinLog_NativeRet, - BinLog_CallPubFunc, // - BinLog_SetLine, // + BinLog_NativeCall, // + BinLog_NativeError, // + BinLog_NativeRet, // + BinLog_CallPubFunc, // + BinLog_SetLine, // BinLog_Registered, // - BinLog_FormatString, - BinLog_NativeParams, - BinLog_GetString, - BinLog_SetString, + BinLog_FormatString, // + BinLog_NativeParams, // + BinLog_GetString, // + BinLog_SetString, // }; public enum BinLogFlags @@ -72,6 +72,40 @@ namespace BinLogReader } } + public static void PluginText(StringBuilder sb, Plugin pl, BinLogFlags flags, int fileid) + { + if (HasFlag(flags, BinLogFlags.Show_PlugId) + && HasFlag(flags, BinLogFlags.Show_PlugFile)) + { + sb.Append("\""); + sb.Append(pl.File); + if (pl.IsDebug()) + { + sb.Append(", "); + sb.Append(pl.FindFile(fileid)); + } + sb.Append("\""); + sb.Append(" ("); + sb.Append(pl.Index); + sb.Append(")"); + } + else if (HasFlag(flags, BinLogFlags.Show_PlugId)) + { + sb.Append(pl.Index); + } + else if (HasFlag(flags, BinLogFlags.Show_PlugFile)) + { + sb.Append("\""); + sb.Append(pl.File); + if (pl.IsDebug()) + { + sb.Append(", "); + sb.Append(pl.FindFile(fileid)); + } + sb.Append("\""); + } + } + public static void BinLogString(StringBuilder sb, BinLogEntry ble, BinLogFlags flags) { bool realtime = false; @@ -130,6 +164,7 @@ namespace BinLogReader public class BinLogSetLine : BinLogEntry { private int line; + private int fileid; public int Line { @@ -139,16 +174,17 @@ namespace BinLogReader } } - public BinLogSetLine(int _line, float gt, long rt, Plugin _pl) + public BinLogSetLine(int _line, float gt, long rt, Plugin _pl, int file) : base(gt, rt, _pl) { line = _line; + fileid = file; } public override void ToLogString(StringBuilder sb, BinLogFlags flags) { sb.Append("Plugin "); - BinLogEntry.PluginText(sb, plugin, flags); + BinLogEntry.PluginText(sb, plugin, flags, fileid); sb.Append(" hit line "); sb.Append(Line); sb.Append("."); @@ -163,6 +199,7 @@ namespace BinLogReader public class BinLogPublic : BinLogEntry { private int pubidx; + private int fileid; public string Public { @@ -172,16 +209,17 @@ namespace BinLogReader } } - public BinLogPublic(int pi, float gt, long rt, Plugin _pl) + public BinLogPublic(int pi, float gt, long rt, Plugin _pl, int _file) : base(gt, rt, _pl) { pubidx = pi; + fileid = _file; } public override void ToLogString(StringBuilder sb, BinLogFlags flags) { sb.Append("Plugin "); - BinLogEntry.PluginText(sb, plugin, flags); + BinLogEntry.PluginText(sb, plugin, flags, fileid); sb.Append(" had public function \""); sb.Append(Public); sb.Append("\" ("); @@ -283,6 +321,7 @@ namespace BinLogReader { private int nativeidx; private int numparams; + private int fileid; public string Native { @@ -292,17 +331,18 @@ namespace BinLogReader } } - public BinLogNativeCall(int na, int nu, float gt, long rt, Plugin _pl) + public BinLogNativeCall(int na, int nu, float gt, long rt, Plugin _pl, int _file) : base(gt, rt, _pl) { nativeidx = na; numparams = nu; + fileid = _file; } public override void ToLogString(StringBuilder sb, BinLogFlags flags) { sb.Append("Plugin "); - BinLogEntry.PluginText(sb, plugin, flags); + BinLogEntry.PluginText(sb, plugin, flags, fileid); sb.Append(" called native \""); sb.Append(Native); sb.Append("\" ("); diff --git a/plugins/BinLogReader/BinLogReader.exe b/plugins/BinLogReader/BinLogReader.exe index 72069d60..9d6d30d8 100644 Binary files a/plugins/BinLogReader/BinLogReader.exe and b/plugins/BinLogReader/BinLogReader.exe differ diff --git a/plugins/BinLogReader/Form1.cs b/plugins/BinLogReader/Form1.cs index e4a24e6b..0b07eded 100644 --- a/plugins/BinLogReader/Form1.cs +++ b/plugins/BinLogReader/Form1.cs @@ -22,11 +22,10 @@ namespace BinLogReader private System.Windows.Forms.OpenFileDialog ofd; private System.Windows.Forms.MenuItem MenuFileOpen; private System.Windows.Forms.TabPage PluginsTab; - private System.Windows.Forms.TabPage LogTextTab; - private System.Windows.Forms.TabPage ViewTab; - private System.Windows.Forms.TabPage LogListTab; private System.Windows.Forms.ListView PluginList; + private System.Windows.Forms.TabPage LogTextTab; private System.Windows.Forms.RichTextBox TextLog; + private System.Windows.Forms.TabPage LogListTab; private System.Windows.Forms.TabControl MainTab; /// /// Required designer variable. @@ -77,16 +76,15 @@ namespace BinLogReader this.menuItem5 = new System.Windows.Forms.MenuItem(); this.menuItem6 = new System.Windows.Forms.MenuItem(); this.ofd = new System.Windows.Forms.OpenFileDialog(); - this.MainTab = new System.Windows.Forms.TabControl(); this.PluginsTab = new System.Windows.Forms.TabPage(); this.PluginList = new System.Windows.Forms.ListView(); this.LogTextTab = new System.Windows.Forms.TabPage(); this.TextLog = new System.Windows.Forms.RichTextBox(); this.LogListTab = new System.Windows.Forms.TabPage(); - this.ViewTab = new System.Windows.Forms.TabPage(); - this.MainTab.SuspendLayout(); + this.MainTab = new System.Windows.Forms.TabControl(); this.PluginsTab.SuspendLayout(); this.LogTextTab.SuspendLayout(); + this.MainTab.SuspendLayout(); this.SuspendLayout(); // // mainMenu1 @@ -137,22 +135,6 @@ namespace BinLogReader // this.ofd.Filter = "Binary Log Files|*.blg"; // - // MainTab - // - this.MainTab.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.MainTab.Controls.Add(this.PluginsTab); - this.MainTab.Controls.Add(this.LogTextTab); - this.MainTab.Controls.Add(this.LogListTab); - this.MainTab.Controls.Add(this.ViewTab); - this.MainTab.Location = new System.Drawing.Point(8, 12); - this.MainTab.Name = "MainTab"; - this.MainTab.SelectedIndex = 0; - this.MainTab.Size = new System.Drawing.Size(656, 372); - this.MainTab.TabIndex = 0; - this.MainTab.SelectedIndexChanged += new System.EventHandler(this.MainTab_SelectedIndexChanged); - // // PluginsTab // this.PluginsTab.Controls.Add(this.PluginList); @@ -187,7 +169,7 @@ namespace BinLogReader // TextLog // this.TextLog.Dock = System.Windows.Forms.DockStyle.Fill; - this.TextLog.Font = new System.Drawing.Font("Lucida Sans Typewriter", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.TextLog.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.TextLog.Location = new System.Drawing.Point(0, 0); this.TextLog.Name = "TextLog"; this.TextLog.Size = new System.Drawing.Size(648, 346); @@ -202,13 +184,21 @@ namespace BinLogReader this.LogListTab.TabIndex = 3; this.LogListTab.Text = "Event Log (List)"; // - // ViewTab + // MainTab // - this.ViewTab.Location = new System.Drawing.Point(4, 22); - this.ViewTab.Name = "ViewTab"; - this.ViewTab.Size = new System.Drawing.Size(648, 346); - this.ViewTab.TabIndex = 2; - this.ViewTab.Text = "View Configuration"; + this.MainTab.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.MainTab.Controls.Add(this.PluginsTab); + this.MainTab.Controls.Add(this.LogTextTab); + this.MainTab.Controls.Add(this.LogListTab); + this.MainTab.ItemSize = new System.Drawing.Size(46, 18); + this.MainTab.Location = new System.Drawing.Point(8, 12); + this.MainTab.Name = "MainTab"; + this.MainTab.SelectedIndex = 0; + this.MainTab.Size = new System.Drawing.Size(656, 372); + this.MainTab.TabIndex = 0; + this.MainTab.SelectedIndexChanged += new System.EventHandler(this.MainTab_SelectedIndexChanged); // // Form1 // @@ -219,9 +209,9 @@ namespace BinLogReader this.Name = "Form1"; this.Text = "AMX Mod X BinLogReader"; this.Load += new System.EventHandler(this.Form1_Load); - this.MainTab.ResumeLayout(false); this.PluginsTab.ResumeLayout(false); this.LogTextTab.ResumeLayout(false); + this.MainTab.ResumeLayout(false); this.ResumeLayout(false); } diff --git a/plugins/BinLogReader/Form1.resx b/plugins/BinLogReader/Form1.resx index 761a42bb..a3cd0240 100644 --- a/plugins/BinLogReader/Form1.resx +++ b/plugins/BinLogReader/Form1.resx @@ -151,24 +151,6 @@ 126, 17 - - True - - - False - - - True - - - Private - - - Private - - - 4, 4 - False @@ -241,27 +223,30 @@ 8, 8 - + + True + + False - + True - - True - - + Private - + Private - - 8, 8 + + 4, 4 False + + Form1 + (Default) @@ -283,9 +268,6 @@ True - - Form1 - Private diff --git a/plugins/BinLogReader/Plugin.cs b/plugins/BinLogReader/Plugin.cs index 58a0ae96..015b1e6e 100644 --- a/plugins/BinLogReader/Plugin.cs +++ b/plugins/BinLogReader/Plugin.cs @@ -12,6 +12,7 @@ namespace BinLogReader private string Filename; private ArrayList Natives; private ArrayList Publics; + private ArrayList Files; private string title; private string version; private int index; @@ -70,11 +71,12 @@ namespace BinLogReader } } - public Plugin(string name, int natives, int publics, byte _status, int _index) + public Plugin(string name, int natives, int publics, int files, byte _status, int _index) { Filename = name; Natives = new ArrayList(natives); Publics = new ArrayList(publics); + Files = new ArrayList(files+1); status = _status; index = _index; } @@ -89,18 +91,37 @@ namespace BinLogReader Publics.Add(pubname); } + public void AddFile(string filename) + { + Files.Add(filename); + } + public string FindNative(int id) { if (id < 0 || id >= Natives.Count) + { return null; + } return (string)Natives[id]; } + public string FindFile(int id) + { + if (id < 0 || id >= Files.Count) + { + return null; + } + + return (string)Files[id]; + } + public string FindPublic(int id) { if (id < 0 || id >= Publics.Count) + { return null; + } return (string)Publics[id]; } diff --git a/plugins/BinLogReader/PluginDb.cs b/plugins/BinLogReader/PluginDb.cs index 9621b7fc..dd6f912a 100644 --- a/plugins/BinLogReader/PluginDb.cs +++ b/plugins/BinLogReader/PluginDb.cs @@ -47,16 +47,32 @@ namespace BinLogReader { byte status = br.ReadByte(); byte length = br.ReadByte(); + uint files = 0; byte [] name = br.ReadBytes(length + 1); + if (status == 2) + { + files = br.ReadUInt32(); + } uint natives = br.ReadUInt32(); uint publics = br.ReadUInt32(); int id = db.CreatePlugin( Encoding.ASCII.GetString(name, 0, length), (int)natives, - (int)publics, + (int)publics, + (int)files, status, (int)i); Plugin pl = db.GetPluginById(id); + for (uint j=0; j