Skip to content

Commit

Permalink
Merge pull request #5 from fantoms/feature-DeathMessages
Browse files Browse the repository at this point in the history
Added Player Death Messages and PlayerDeathEvent
  • Loading branch information
tfarley authored Apr 15, 2017
2 parents 7346c7f + fae9159 commit 260c961
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
110 changes: 110 additions & 0 deletions aclogview/CM_Death.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
1 change: 1 addition & 0 deletions aclogview/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions aclogview/aclogview.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<Compile Include="CM_Allegiance.cs" />
<Compile Include="CM_Combat.cs" />
<Compile Include="CM_Fellowship.cs" />
<Compile Include="CM_Death.cs" />
<Compile Include="CM_Game.cs" />
<Compile Include="CM_House.cs" />
<Compile Include="CM_Magic.cs" />
Expand Down

0 comments on commit 260c961

Please sign in to comment.