Skip to content

Commit a347583

Browse files
committed
Fix origin-only position reading
1 parent 6817147 commit a347583

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

aclogview/CM_Movement.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public class UpdatePosition : Message {
213213
public uint object_id;
214214
public uint flags;
215215
public Position position;
216-
public Vector3 velocity = new Vector3();
216+
public Vector3 velocity;
217217
public uint placement_id;
218218
public bool has_contact;
219219
public ushort instance_timestamp;
@@ -243,9 +243,7 @@ public static UpdatePosition read(BinaryReader binaryReader) {
243243
newObj.position.frame.cache();
244244

245245
if ((newObj.flags & 0x1) != 0) {
246-
newObj.velocity.x = binaryReader.ReadSingle();
247-
newObj.velocity.y = binaryReader.ReadSingle();
248-
newObj.velocity.z = binaryReader.ReadSingle();
246+
newObj.velocity = Vector3.read(binaryReader);
249247
}
250248

251249
if ((newObj.flags & 0x2) != 0) {
@@ -269,8 +267,12 @@ public override void contributeToTreeView(TreeView treeView) {
269267
rootNode.Nodes.Add("flags = " + flags);
270268
TreeNode positionNode = rootNode.Nodes.Add("position = ");
271269
position.contributeToTreeNode(positionNode);
272-
rootNode.Nodes.Add("velocity = " + velocity);
273-
rootNode.Nodes.Add("placement_id = " + placement_id);
270+
if ((flags & 0x1) != 0) {
271+
rootNode.Nodes.Add("velocity = " + velocity);
272+
}
273+
if ((flags & 0x2) != 0) {
274+
rootNode.Nodes.Add("placement_id = " + placement_id);
275+
}
274276
rootNode.Nodes.Add("has_contact = " + has_contact);
275277
rootNode.Nodes.Add("instance_timestamp = " + instance_timestamp);
276278
rootNode.Nodes.Add("position_timestamp = " + position_timestamp);

aclogview/Packets.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,7 @@ public static Position read(BinaryReader binaryReader) {
358358
public static Position readOrigin(BinaryReader binaryReader) {
359359
Position newObj = new Position();
360360
newObj.objcell_id = binaryReader.ReadUInt32();
361-
newObj.frame.m_fOrigin.x = binaryReader.ReadSingle();
362-
newObj.frame.m_fOrigin.y = binaryReader.ReadSingle();
363-
newObj.frame.m_fOrigin.z = binaryReader.ReadSingle();
361+
newObj.frame.m_fOrigin = Vector3.read(binaryReader);
364362
return newObj;
365363
}
366364

0 commit comments

Comments
 (0)