diff --git a/aclogview/CM_Death.cs b/aclogview/CM_Death.cs new file mode 100644 index 0000000..a729a72 --- /dev/null +++ b/aclogview/CM_Death.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +public class CM_Death : MessageProcessor +{ + + public override bool acceptMessageData(BinaryReader messageDataReader, TreeView outputTreeView) + { + bool handled = true; + + PacketOpcode opcode = Util.readOpcode(messageDataReader); + switch (opcode) + { + case PacketOpcode.PLAYER_DEATH_EVENT: + { + PlayerDeathEvent message = PlayerDeathEvent.read(messageDataReader); + message.contributeToTreeView(outputTreeView); + break; + } + case PacketOpcode.VICTIM_NOTIFICATION_EVENT: + { + VictimDeathNotice message = VictimDeathNotice.read(messageDataReader); + message.contributeToTreeView(outputTreeView); + break; + } + case PacketOpcode.KILLER_NOTIFICATION_EVENT: + { + KillerDeathNotice message = KillerDeathNotice.read(messageDataReader); + message.contributeToTreeView(outputTreeView); + break; + } + default: + { + handled = false; + break; + } + } + + return handled; + } + + public class PlayerDeathEvent : Message + { + public PStringChar DeathMessageText; + public uint VictimId; + public uint KillerId; + + public static PlayerDeathEvent read(BinaryReader binaryReader) + { + PlayerDeathEvent newObj = new PlayerDeathEvent(); + newObj.DeathMessageText = PStringChar.read(binaryReader); + newObj.VictimId = binaryReader.ReadUInt32(); + newObj.KillerId = binaryReader.ReadUInt32(); + return newObj; + } + + public override void contributeToTreeView(TreeView treeView) + { + TreeNode rootNode = new TreeNode(this.GetType().Name); + rootNode.Expand(); + rootNode.Nodes.Add("death_message = " + DeathMessageText); + rootNode.Nodes.Add("victim_id = " + VictimId); + rootNode.Nodes.Add("killer_id = " + KillerId); + treeView.Nodes.Add(rootNode); + } + } + + public class VictimDeathNotice : Message + { + public PStringChar DeathMessageText; + public static VictimDeathNotice read(BinaryReader binaryReader) + { + VictimDeathNotice newObj = new VictimDeathNotice(); + newObj.DeathMessageText = PStringChar.read(binaryReader); + return newObj; + } + + public override void contributeToTreeView(TreeView treeView) + { + TreeNode rootNode = new TreeNode(this.GetType().Name); + rootNode.Expand(); + rootNode.Nodes.Add("death_message = " + DeathMessageText); + treeView.Nodes.Add(rootNode); + } + } + + public class KillerDeathNotice : Message + { + public PStringChar DeathMessageText; + public static KillerDeathNotice read(BinaryReader binaryReader) + { + KillerDeathNotice newObj = new KillerDeathNotice(); + newObj.DeathMessageText = PStringChar.read(binaryReader); + return newObj; + } + + public override void contributeToTreeView(TreeView treeView) + { + TreeNode rootNode = new TreeNode(this.GetType().Name); + rootNode.Expand(); + rootNode.Nodes.Add("death_message = " + DeathMessageText); + treeView.Nodes.Add(rootNode); + } + } +} \ No newline at end of file diff --git a/aclogview/Form1.cs b/aclogview/Form1.cs index 9dcc8fd..4d3d924 100644 --- a/aclogview/Form1.cs +++ b/aclogview/Form1.cs @@ -43,6 +43,7 @@ private void Form1_Load(object sender, EventArgs e) { messageProcessors.Add(new CM_Character()); messageProcessors.Add(new CM_Combat()); messageProcessors.Add(new CM_Communication()); + messageProcessors.Add(new CM_Death()); messageProcessors.Add(new CM_Examine()); messageProcessors.Add(new CM_Fellowship()); messageProcessors.Add(new CM_Game()); diff --git a/aclogview/aclogview.csproj b/aclogview/aclogview.csproj index 53b75de..27e9185 100644 --- a/aclogview/aclogview.csproj +++ b/aclogview/aclogview.csproj @@ -51,6 +51,7 @@ +