Skip to content

Commit

Permalink
More movement packets
Browse files Browse the repository at this point in the history
  • Loading branch information
tfarley committed Jan 22, 2017
1 parent 93082e5 commit cd11d06
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 8 deletions.
173 changes: 165 additions & 8 deletions aclogview/CM_Movement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,29 @@ public override bool acceptMessageData(BinaryReader messageDataReader, TreeView

PacketOpcode opcode = Util.readOpcode(messageDataReader);
switch (opcode) {
// TODO: PacketOpcode.Evt_Movement__PositionAndMovement_ID
case PacketOpcode.Evt_Movement__Jump_ID: {
Jump message = Jump.read(messageDataReader);
message.contributeToTreeView(outputTreeView);
break;
}
case PacketOpcode.Evt_Movement__MoveToState_ID: {
MoveToState message = MoveToState.read(messageDataReader);
message.contributeToTreeView(outputTreeView);
break;
}
case PacketOpcode.Evt_Movement__DoMovementCommand_ID: {
DoMovementCommand message = DoMovementCommand.read(messageDataReader);
message.contributeToTreeView(outputTreeView);
break;
}
// TODO: PacketOpcode.Evt_Movement__TurnEvent_ID
// TODO: PacketOpcode.Evt_Movement__TurnToEvent_ID
case PacketOpcode.Evt_Movement__StopMovementCommand_ID: {
StopMovementCommand message = StopMovementCommand.read(messageDataReader);
message.contributeToTreeView(outputTreeView);
break;
}
case PacketOpcode.Evt_Movement__UpdatePosition_ID: {
UpdatePosition message = UpdatePosition.read(messageDataReader);
message.contributeToTreeView(outputTreeView);
Expand All @@ -28,11 +46,21 @@ public override bool acceptMessageData(BinaryReader messageDataReader, TreeView
message.contributeToTreeView(outputTreeView);
break;
}
case PacketOpcode.Evt_Movement__AutonomyLevel_ID: {
AutonomyLevel message = AutonomyLevel.read(messageDataReader);
message.contributeToTreeView(outputTreeView);
break;
}
case PacketOpcode.Evt_Movement__AutonomousPosition_ID: {
AutonomousPosition message = AutonomousPosition.read(messageDataReader);
message.contributeToTreeView(outputTreeView);
break;
}
case PacketOpcode.Evt_Movement__Jump_NonAutonomous_ID: {
Jump_NonAutonomous message = Jump_NonAutonomous.read(messageDataReader);
message.contributeToTreeView(outputTreeView);
break;
}
default: {
handled = false;
break;
Expand All @@ -42,6 +70,51 @@ public override bool acceptMessageData(BinaryReader messageDataReader, TreeView
return handled;
}

public class JumpPack {
public Vector3 velocity;
public ushort instance_timestamp;
public ushort server_control_timestamp;
public ushort teleport_timestamp;
public ushort force_position_ts;

public static JumpPack read(BinaryReader binaryReader) {
JumpPack newObj = new JumpPack();
newObj.velocity = Vector3.read(binaryReader);
newObj.instance_timestamp = binaryReader.ReadUInt16();
newObj.server_control_timestamp = binaryReader.ReadUInt16();
newObj.teleport_timestamp = binaryReader.ReadUInt16();
newObj.force_position_ts = binaryReader.ReadUInt16();
Util.readToAlign(binaryReader);
return newObj;
}

public void contributeToTreeNode(TreeNode node) {
node.Nodes.Add("velocity = " + velocity);
node.Nodes.Add("instance_timestamp = " + instance_timestamp);
node.Nodes.Add("server_control_timestamp = " + server_control_timestamp);
node.Nodes.Add("teleport_timestamp = " + teleport_timestamp);
node.Nodes.Add("force_position_ts = " + force_position_ts);
}
}

public class Jump : Message {
public JumpPack i_jp;

public static Jump read(BinaryReader binaryReader) {
Jump newObj = new Jump();
newObj.i_jp = JumpPack.read(binaryReader);
return newObj;
}

public override void contributeToTreeView(TreeView treeView) {
TreeNode rootNode = new TreeNode(this.GetType().Name);
rootNode.Expand();
TreeNode jumpNode = rootNode.Nodes.Add("i_jp = ");
i_jp.contributeToTreeNode(jumpNode);
treeView.Nodes.Add(rootNode);
}
}

public class MoveToState : Message {
public RawMotionState raw_motion_state;
public Position position;
Expand Down Expand Up @@ -88,6 +161,54 @@ public override void contributeToTreeView(TreeView treeView) {
}
}

public class DoMovementCommand : Message {
public uint i_motion;
public float i_speed;
public HoldKey i_hold_key;

public static DoMovementCommand read(BinaryReader binaryReader) {
DoMovementCommand newObj = new DoMovementCommand();
newObj.i_motion = binaryReader.ReadUInt32();
Util.readToAlign(binaryReader);
newObj.i_speed = binaryReader.ReadSingle();
Util.readToAlign(binaryReader);
newObj.i_hold_key = (HoldKey)binaryReader.ReadUInt32();
Util.readToAlign(binaryReader);
return newObj;
}

public override void contributeToTreeView(TreeView treeView) {
TreeNode rootNode = new TreeNode(this.GetType().Name);
rootNode.Expand();
rootNode.Nodes.Add("i_motion = " + i_motion);
rootNode.Nodes.Add("i_speed = " + i_speed);
rootNode.Nodes.Add("i_hold_key = " + i_hold_key);
treeView.Nodes.Add(rootNode);
}
}

public class StopMovementCommand : Message {
public uint i_motion;
public HoldKey i_hold_key;

public static StopMovementCommand read(BinaryReader binaryReader) {
StopMovementCommand newObj = new StopMovementCommand();
newObj.i_motion = binaryReader.ReadUInt32();
Util.readToAlign(binaryReader);
newObj.i_hold_key = (HoldKey)binaryReader.ReadUInt32();
Util.readToAlign(binaryReader);
return newObj;
}

public override void contributeToTreeView(TreeView treeView) {
TreeNode rootNode = new TreeNode(this.GetType().Name);
rootNode.Expand();
rootNode.Nodes.Add("i_motion = " + i_motion);
rootNode.Nodes.Add("i_hold_key = " + i_hold_key);
treeView.Nodes.Add(rootNode);
}
}

public class UpdatePosition : Message {
public uint object_id;
public uint flags;
Expand Down Expand Up @@ -372,6 +493,24 @@ public override void contributeToTreeView(TreeView treeView) {
}
}

public class AutonomyLevel : Message {
public uint i_autonomy_level;

public static AutonomyLevel read(BinaryReader binaryReader) {
AutonomyLevel newObj = new AutonomyLevel();
newObj.i_autonomy_level = binaryReader.ReadUInt32();
Util.readToAlign(binaryReader);
return newObj;
}

public override void contributeToTreeView(TreeView treeView) {
TreeNode rootNode = new TreeNode(this.GetType().Name);
rootNode.Expand();
rootNode.Nodes.Add("i_autonomy_level = " + i_autonomy_level);
treeView.Nodes.Add(rootNode);
}
}

public class RawMotionState {
public enum PackBitfield {
current_holdkey = (1 << 0),
Expand All @@ -388,23 +527,23 @@ public enum PackBitfield {
}

public uint bitfield;
public uint current_holdkey;
public HoldKey current_holdkey;
public MotionStyle current_style = MotionStyle.Motion_NonCombat;
public MotionStyle forward_command = MotionStyle.Motion_Ready;
public uint forward_holdkey;
public HoldKey forward_holdkey;
public float forward_speed = 1.0f;
public MotionStyle sidestep_command;
public uint sidestep_holdkey;
public HoldKey sidestep_holdkey;
public float sidestep_speed = 1.0f;
public MotionStyle turn_command;
public uint turn_holdkey;
public HoldKey turn_holdkey;
public float turn_speed = 1.0f;

public static RawMotionState read(BinaryReader binaryReader) {
RawMotionState newObj = new RawMotionState();
newObj.bitfield = binaryReader.ReadUInt32();
if ((newObj.bitfield & (uint)PackBitfield.current_holdkey) != 0) {
newObj.current_holdkey = binaryReader.ReadUInt32();
newObj.current_holdkey = (HoldKey)binaryReader.ReadUInt32();
}
if ((newObj.bitfield & (uint)PackBitfield.current_style) != 0) {
newObj.current_style = (MotionStyle)binaryReader.ReadUInt32();
Expand All @@ -413,7 +552,7 @@ public static RawMotionState read(BinaryReader binaryReader) {
newObj.forward_command = (MotionStyle)binaryReader.ReadUInt32();
}
if ((newObj.bitfield & (uint)PackBitfield.forward_holdkey) != 0) {
newObj.forward_holdkey = binaryReader.ReadUInt32();
newObj.forward_holdkey = (HoldKey)binaryReader.ReadUInt32();
}
if ((newObj.bitfield & (uint)PackBitfield.forward_speed) != 0) {
newObj.forward_speed = binaryReader.ReadSingle();
Expand All @@ -422,7 +561,7 @@ public static RawMotionState read(BinaryReader binaryReader) {
newObj.sidestep_command = (MotionStyle)binaryReader.ReadUInt32();
}
if ((newObj.bitfield & (uint)PackBitfield.sidestep_holdkey) != 0) {
newObj.sidestep_holdkey = binaryReader.ReadUInt32();
newObj.sidestep_holdkey = (HoldKey)binaryReader.ReadUInt32();
}
if ((newObj.bitfield & (uint)PackBitfield.sidestep_speed) != 0) {
newObj.sidestep_speed = binaryReader.ReadSingle();
Expand All @@ -431,7 +570,7 @@ public static RawMotionState read(BinaryReader binaryReader) {
newObj.turn_command = (MotionStyle)binaryReader.ReadUInt32();
}
if ((newObj.bitfield & (uint)PackBitfield.turn_holdkey) != 0) {
newObj.turn_holdkey = binaryReader.ReadUInt32();
newObj.turn_holdkey = (HoldKey)binaryReader.ReadUInt32();
}
if ((newObj.bitfield & (uint)PackBitfield.turn_speed) != 0) {
newObj.turn_speed = binaryReader.ReadSingle();
Expand Down Expand Up @@ -505,6 +644,24 @@ public override void contributeToTreeView(TreeView treeView) {
}
}

public class Jump_NonAutonomous : Message {
public float i_extent;

public static Jump_NonAutonomous read(BinaryReader binaryReader) {
Jump_NonAutonomous newObj = new Jump_NonAutonomous();
newObj.i_extent = binaryReader.ReadSingle();
Util.readToAlign(binaryReader);
return newObj;
}

public override void contributeToTreeView(TreeView treeView) {
TreeNode rootNode = new TreeNode(this.GetType().Name);
rootNode.Expand();
rootNode.Nodes.Add("i_extent = " + i_extent);
treeView.Nodes.Add(rootNode);
}
}

static uint[] command_ids = {
2147483648,
2231369729,
Expand Down
7 changes: 7 additions & 0 deletions aclogview/Enums/Movement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,10 @@ public enum Type {
TurnToHeading
}
}

public enum HoldKey {
HoldKey_Invalid,
HoldKey_None,
HoldKey_Run,
Num_HoldKeys
}

0 comments on commit cd11d06

Please sign in to comment.