Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing select agent in drawing protocol where the second byte of the … #42

Merged
merged 2 commits into from
Jun 1, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/rv/comm/drawing/commands/Control.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package rv.comm.drawing.commands;

import java.nio.ByteBuffer;
import js.io.ByteUtil;
import rv.Viewer;
import rv.world.objects.Agent;

Expand All @@ -13,7 +14,17 @@ public class Control extends Command {
public Control(ByteBuffer buf, Viewer viewer) {
super();
this.viewer = viewer;
agent = Command.readAgent(buf, viewer.getWorldModel());

int type = ByteUtil.uValue(buf.get());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this line is the one that actually fixes the issue since it increments the byte position? I thought we could get away checking the type here at all, similar to https://github.com/Gama11/RoboViz/blob/master/src/rv/comm/drawing/commands/DrawOption.java that also only has one command, guess not. :)

Also, I suppose it's preferable from a user perspective to print an error instead of ignoring the type like DrawOption does - maybe we should print an error there as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the sort of thing where unit tests would be really helpful (#43).


switch (type) {
case AGENT_SELECT:
agent = Command.readAgent(buf, viewer.getWorldModel());
break;
default:
System.err.println("Unknown control : " + type);
agent = null;
}
}

@Override
Expand Down