Finalized binlogging update by removing another unnecessary opcode and updating the reader

This commit is contained in:
David Anderson 2006-08-21 04:18:13 +00:00
parent 45b67b6e2c
commit 5b47da7cee
9 changed files with 140 additions and 94 deletions

View File

@ -187,17 +187,8 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
} }
case BinLog_NativeRet: case BinLog_NativeRet:
{ {
int file;
cell retval = va_arg(ap, cell); cell retval = va_arg(ap, cell);
fwrite(&retval, sizeof(cell), 1, fp); 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; break;
} }
case BinLog_NativeError: case BinLog_NativeError:

View File

@ -48,7 +48,7 @@ enum BinLogOp
BinLog_End, BinLog_End,
BinLog_NativeCall, //<int32 native id> <int32_t num_params> <int32_t filename id> BinLog_NativeCall, //<int32 native id> <int32_t num_params> <int32_t filename id>
BinLog_NativeError, //<int32 errornum> <str[int16] string> BinLog_NativeError, //<int32 errornum> <str[int16] string>
BinLog_NativeRet, //<cell value> <int32_t filename id> BinLog_NativeRet, //<cell value>
BinLog_CallPubFunc, //<int32 public id> <int32_t filename id> BinLog_CallPubFunc, //<int32 public id> <int32_t filename id>
BinLog_SetLine, //<int32 line no#> <int32_t filename id> BinLog_SetLine, //<int32 line no#> <int32_t filename id>
BinLog_Registered, //<string title> <string version> BinLog_Registered, //<string title> <string version>

View File

@ -11,7 +11,8 @@ namespace BinLogReader
public class BinLog public class BinLog
{ {
private static uint BINLOG_MAGIC = 0x414D424C; 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 ArrayList oplist;
private PluginDb plugdb; private PluginDb plugdb;
@ -60,7 +61,7 @@ public static BinLog FromFile(string filename)
throw new Exception("Invalid magic log number"); throw new Exception("Invalid magic log number");
ushort version = br.ReadUInt16(); ushort version = br.ReadUInt16();
if (version > BINLOG_VERSION) if (version > BINLOG_VERSION || version < BINLOG_MIN_VERSION)
throw new Exception("Unknown log version number"); throw new Exception("Unknown log version number");
byte timesize = br.ReadByte(); byte timesize = br.ReadByte();
@ -182,19 +183,22 @@ public static BinLog FromFile(string filename)
case BinLogOp.BinLog_SetLine: case BinLogOp.BinLog_SetLine:
{ {
int line = br.ReadInt32(); int line = br.ReadInt32();
int file = br.ReadInt32();
BinLogSetLine bsl = BinLogSetLine bsl =
new BinLogSetLine(line, gametime, realtime, pl); new BinLogSetLine(line, gametime, realtime, pl, file);
bl.OpList.Add(bsl); bl.OpList.Add(bsl);
break; break;
} }
case BinLogOp.BinLog_CallPubFunc: case BinLogOp.BinLog_CallPubFunc:
{ {
int pubidx = br.ReadInt32(); int pubidx = br.ReadInt32();
int fileid = br.ReadInt32();
BinLogPublic bp = BinLogPublic bp =
new BinLogPublic(pubidx, new BinLogPublic(pubidx,
gametime, gametime,
realtime, realtime,
pl); pl,
fileid);
bl.OpList.Add(bp); bl.OpList.Add(bp);
break; break;
} }
@ -214,12 +218,14 @@ public static BinLog FromFile(string filename)
{ {
int native = br.ReadInt32(); int native = br.ReadInt32();
int parms = br.ReadInt32(); int parms = br.ReadInt32();
int file = br.ReadInt32();
BinLogNativeCall bn = BinLogNativeCall bn =
new BinLogNativeCall(native, new BinLogNativeCall(native,
parms, parms,
gametime, gametime,
realtime, realtime,
pl); pl,
file);
bl.OpList.Add(bn); bl.OpList.Add(bn);
break; break;
} }

View File

@ -10,16 +10,16 @@ public enum BinLogOp
BinLog_Invalid=0, BinLog_Invalid=0,
BinLog_Start=1, BinLog_Start=1,
BinLog_End, BinLog_End,
BinLog_NativeCall, //<int16_t native id> BinLog_NativeCall, //<int32 native id> <int32_t num_params> <int32_t filename id>
BinLog_NativeError, BinLog_NativeError, //<int32 errornum> <str[int16] string>
BinLog_NativeRet, BinLog_NativeRet, //<cell value>
BinLog_CallPubFunc, //<int16_t public id> BinLog_CallPubFunc, //<int32 public id> <int32_t filename id>
BinLog_SetLine, //<int16_t line no#> BinLog_SetLine, //<int32 line no#> <int32_t filename id>
BinLog_Registered, //<string title> <string version> BinLog_Registered, //<string title> <string version>
BinLog_FormatString, BinLog_FormatString, //<int32 param#> <int32 maxlen> <str[int16] string>
BinLog_NativeParams, BinLog_NativeParams, //<int32 num> <cell ...>
BinLog_GetString, BinLog_GetString, //<cell addr> <string[int16]>
BinLog_SetString, BinLog_SetString, //<cell addr> <int maxlen> <string[int16]>
}; };
public enum BinLogFlags public enum BinLogFlags
@ -72,6 +72,40 @@ public static void PluginText(StringBuilder sb, Plugin pl, BinLogFlags flags)
} }
} }
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) public static void BinLogString(StringBuilder sb, BinLogEntry ble, BinLogFlags flags)
{ {
bool realtime = false; bool realtime = false;
@ -130,6 +164,7 @@ public long realtime
public class BinLogSetLine : BinLogEntry public class BinLogSetLine : BinLogEntry
{ {
private int line; private int line;
private int fileid;
public int Line public int Line
{ {
@ -139,16 +174,17 @@ public int Line
} }
} }
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) : base(gt, rt, _pl)
{ {
line = _line; line = _line;
fileid = file;
} }
public override void ToLogString(StringBuilder sb, BinLogFlags flags) public override void ToLogString(StringBuilder sb, BinLogFlags flags)
{ {
sb.Append("Plugin "); sb.Append("Plugin ");
BinLogEntry.PluginText(sb, plugin, flags); BinLogEntry.PluginText(sb, plugin, flags, fileid);
sb.Append(" hit line "); sb.Append(" hit line ");
sb.Append(Line); sb.Append(Line);
sb.Append("."); sb.Append(".");
@ -163,6 +199,7 @@ public override BinLogOp Op()
public class BinLogPublic : BinLogEntry public class BinLogPublic : BinLogEntry
{ {
private int pubidx; private int pubidx;
private int fileid;
public string Public public string Public
{ {
@ -172,16 +209,17 @@ public string Public
} }
} }
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) : base(gt, rt, _pl)
{ {
pubidx = pi; pubidx = pi;
fileid = _file;
} }
public override void ToLogString(StringBuilder sb, BinLogFlags flags) public override void ToLogString(StringBuilder sb, BinLogFlags flags)
{ {
sb.Append("Plugin "); sb.Append("Plugin ");
BinLogEntry.PluginText(sb, plugin, flags); BinLogEntry.PluginText(sb, plugin, flags, fileid);
sb.Append(" had public function \""); sb.Append(" had public function \"");
sb.Append(Public); sb.Append(Public);
sb.Append("\" ("); sb.Append("\" (");
@ -283,6 +321,7 @@ public class BinLogNativeCall : BinLogEntry
{ {
private int nativeidx; private int nativeidx;
private int numparams; private int numparams;
private int fileid;
public string Native public string Native
{ {
@ -292,17 +331,18 @@ public string Native
} }
} }
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) : base(gt, rt, _pl)
{ {
nativeidx = na; nativeidx = na;
numparams = nu; numparams = nu;
fileid = _file;
} }
public override void ToLogString(StringBuilder sb, BinLogFlags flags) public override void ToLogString(StringBuilder sb, BinLogFlags flags)
{ {
sb.Append("Plugin "); sb.Append("Plugin ");
BinLogEntry.PluginText(sb, plugin, flags); BinLogEntry.PluginText(sb, plugin, flags, fileid);
sb.Append(" called native \""); sb.Append(" called native \"");
sb.Append(Native); sb.Append(Native);
sb.Append("\" ("); sb.Append("\" (");

View File

@ -22,11 +22,10 @@ public class Form1 : System.Windows.Forms.Form
private System.Windows.Forms.OpenFileDialog ofd; private System.Windows.Forms.OpenFileDialog ofd;
private System.Windows.Forms.MenuItem MenuFileOpen; private System.Windows.Forms.MenuItem MenuFileOpen;
private System.Windows.Forms.TabPage PluginsTab; 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.ListView PluginList;
private System.Windows.Forms.TabPage LogTextTab;
private System.Windows.Forms.RichTextBox TextLog; private System.Windows.Forms.RichTextBox TextLog;
private System.Windows.Forms.TabPage LogListTab;
private System.Windows.Forms.TabControl MainTab; private System.Windows.Forms.TabControl MainTab;
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -77,16 +76,15 @@ private void InitializeComponent()
this.menuItem5 = new System.Windows.Forms.MenuItem(); this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem(); this.menuItem6 = new System.Windows.Forms.MenuItem();
this.ofd = new System.Windows.Forms.OpenFileDialog(); this.ofd = new System.Windows.Forms.OpenFileDialog();
this.MainTab = new System.Windows.Forms.TabControl();
this.PluginsTab = new System.Windows.Forms.TabPage(); this.PluginsTab = new System.Windows.Forms.TabPage();
this.PluginList = new System.Windows.Forms.ListView(); this.PluginList = new System.Windows.Forms.ListView();
this.LogTextTab = new System.Windows.Forms.TabPage(); this.LogTextTab = new System.Windows.Forms.TabPage();
this.TextLog = new System.Windows.Forms.RichTextBox(); this.TextLog = new System.Windows.Forms.RichTextBox();
this.LogListTab = new System.Windows.Forms.TabPage(); this.LogListTab = new System.Windows.Forms.TabPage();
this.ViewTab = new System.Windows.Forms.TabPage(); this.MainTab = new System.Windows.Forms.TabControl();
this.MainTab.SuspendLayout();
this.PluginsTab.SuspendLayout(); this.PluginsTab.SuspendLayout();
this.LogTextTab.SuspendLayout(); this.LogTextTab.SuspendLayout();
this.MainTab.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// mainMenu1 // mainMenu1
@ -137,22 +135,6 @@ private void InitializeComponent()
// //
this.ofd.Filter = "Binary Log Files|*.blg"; 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 // PluginsTab
// //
this.PluginsTab.Controls.Add(this.PluginList); this.PluginsTab.Controls.Add(this.PluginList);
@ -187,7 +169,7 @@ private void InitializeComponent()
// TextLog // TextLog
// //
this.TextLog.Dock = System.Windows.Forms.DockStyle.Fill; 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.Location = new System.Drawing.Point(0, 0);
this.TextLog.Name = "TextLog"; this.TextLog.Name = "TextLog";
this.TextLog.Size = new System.Drawing.Size(648, 346); this.TextLog.Size = new System.Drawing.Size(648, 346);
@ -202,13 +184,21 @@ private void InitializeComponent()
this.LogListTab.TabIndex = 3; this.LogListTab.TabIndex = 3;
this.LogListTab.Text = "Event Log (List)"; this.LogListTab.Text = "Event Log (List)";
// //
// ViewTab // MainTab
// //
this.ViewTab.Location = new System.Drawing.Point(4, 22); this.MainTab.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.ViewTab.Name = "ViewTab"; | System.Windows.Forms.AnchorStyles.Left)
this.ViewTab.Size = new System.Drawing.Size(648, 346); | System.Windows.Forms.AnchorStyles.Right)));
this.ViewTab.TabIndex = 2; this.MainTab.Controls.Add(this.PluginsTab);
this.ViewTab.Text = "View Configuration"; 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 // Form1
// //
@ -219,9 +209,9 @@ private void InitializeComponent()
this.Name = "Form1"; this.Name = "Form1";
this.Text = "AMX Mod X BinLogReader"; this.Text = "AMX Mod X BinLogReader";
this.Load += new System.EventHandler(this.Form1_Load); this.Load += new System.EventHandler(this.Form1_Load);
this.MainTab.ResumeLayout(false);
this.PluginsTab.ResumeLayout(false); this.PluginsTab.ResumeLayout(false);
this.LogTextTab.ResumeLayout(false); this.LogTextTab.ResumeLayout(false);
this.MainTab.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }

View File

@ -151,24 +151,6 @@
<data name="ofd.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <data name="ofd.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>126, 17</value> <value>126, 17</value>
</data> </data>
<data name="MainTab.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="MainTab.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</data>
<data name="MainTab.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="MainTab.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="MainTab.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value>
</data>
<data name="MainTab.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>4, 4</value>
</data>
<data name="PluginsTab.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <data name="PluginsTab.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value> <value>False</value>
</data> </data>
@ -241,27 +223,30 @@
<data name="LogListTab.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <data name="LogListTab.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>8, 8</value> <value>8, 8</value>
</data> </data>
<data name="ViewTab.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <data name="MainTab.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="MainTab.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value> <value>False</value>
</data> </data>
<data name="ViewTab.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <data name="MainTab.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</data> </data>
<data name="ViewTab.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <data name="MainTab.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</data>
<data name="ViewTab.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value> <value>Private</value>
</data> </data>
<data name="ViewTab.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <data name="MainTab.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value> <value>Private</value>
</data> </data>
<data name="ViewTab.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <data name="MainTab.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>8, 8</value> <value>4, 4</value>
</data> </data>
<data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value> <value>False</value>
</data> </data>
<data name="$this.Name">
<value>Form1</value>
</data>
<data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>(Default)</value> <value>(Default)</value>
</data> </data>
@ -283,9 +268,6 @@
<data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</data> </data>
<data name="$this.Name">
<value>Form1</value>
</data>
<data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>Private</value> <value>Private</value>
</data> </data>

View File

@ -12,6 +12,7 @@ public class Plugin
private string Filename; private string Filename;
private ArrayList Natives; private ArrayList Natives;
private ArrayList Publics; private ArrayList Publics;
private ArrayList Files;
private string title; private string title;
private string version; private string version;
private int index; private int index;
@ -70,11 +71,12 @@ public int Index
} }
} }
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; Filename = name;
Natives = new ArrayList(natives); Natives = new ArrayList(natives);
Publics = new ArrayList(publics); Publics = new ArrayList(publics);
Files = new ArrayList(files+1);
status = _status; status = _status;
index = _index; index = _index;
} }
@ -89,18 +91,37 @@ public void AddPublic(string pubname)
Publics.Add(pubname); Publics.Add(pubname);
} }
public void AddFile(string filename)
{
Files.Add(filename);
}
public string FindNative(int id) public string FindNative(int id)
{ {
if (id < 0 || id >= Natives.Count) if (id < 0 || id >= Natives.Count)
{
return null; return null;
}
return (string)Natives[id]; 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) public string FindPublic(int id)
{ {
if (id < 0 || id >= Publics.Count) if (id < 0 || id >= Publics.Count)
{
return null; return null;
}
return (string)Publics[id]; return (string)Publics[id];
} }

View File

@ -47,16 +47,32 @@ public static PluginDb FromFile(BinaryReader br)
{ {
byte status = br.ReadByte(); byte status = br.ReadByte();
byte length = br.ReadByte(); byte length = br.ReadByte();
uint files = 0;
byte [] name = br.ReadBytes(length + 1); byte [] name = br.ReadBytes(length + 1);
if (status == 2)
{
files = br.ReadUInt32();
}
uint natives = br.ReadUInt32(); uint natives = br.ReadUInt32();
uint publics = br.ReadUInt32(); uint publics = br.ReadUInt32();
int id = db.CreatePlugin( int id = db.CreatePlugin(
Encoding.ASCII.GetString(name, 0, length), Encoding.ASCII.GetString(name, 0, length),
(int)natives, (int)natives,
(int)publics, (int)publics,
(int)files,
status, status,
(int)i); (int)i);
Plugin pl = db.GetPluginById(id); Plugin pl = db.GetPluginById(id);
for (uint j=0; j<files; j++)
{
length = br.ReadByte();
name = br.ReadBytes(length + 1);
pl.AddFile(Encoding.ASCII.GetString(name, 0, length));
}
if (files == 0)
{
pl.AddFile(pl.File);
}
for (uint j=0; j<natives; j++) for (uint j=0; j<natives; j++)
{ {
length = br.ReadByte(); length = br.ReadByte();
@ -74,9 +90,9 @@ public static PluginDb FromFile(BinaryReader br)
return db; return db;
} }
private int CreatePlugin(string file, int natives, int publics, byte status, int index) private int CreatePlugin(string file, int natives, int publics, int files, byte status, int index)
{ {
Plugin pl = new Plugin(file, natives, publics, status, index); Plugin pl = new Plugin(file, natives, publics, files, status, index);
PluginList.Add(pl); PluginList.Add(pl);
return PluginList.Count - 1; return PluginList.Count - 1;
} }