Wrote possible fix for issue #50 (Composite command tries to remove non-existent element)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package mock.model.commandFactory;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
|
||||
/**
|
||||
* Wraps multiple commands into a composite to execute queued commands during a frame.
|
||||
@@ -10,15 +10,15 @@ public class CompositeCommand implements Command {
|
||||
private Queue<Command> commands;
|
||||
|
||||
public CompositeCommand() {
|
||||
this.commands = new ArrayDeque<>();
|
||||
this.commands = new ConcurrentLinkedDeque<>();
|
||||
}
|
||||
|
||||
public void addCommand(Command command) {
|
||||
commands.add(command);
|
||||
commands.offer(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
while(!commands.isEmpty()) commands.remove().execute();
|
||||
while(commands.peek() != null) commands.poll().execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,6 +246,11 @@ public class RaceController extends Controller {
|
||||
}
|
||||
};
|
||||
trackBoat.start();
|
||||
|
||||
System.out.println(boat.getCurrentLeg().getEndCompoundMark().toString());
|
||||
boat.legProperty().addListener((o, prev, curr) -> {
|
||||
System.out.println(curr.getEndCompoundMark().toString());
|
||||
});
|
||||
}
|
||||
// Fix initial bird's-eye position
|
||||
view3D.updatePivot(new Translate(250, 0, 210));
|
||||
|
||||
Reference in New Issue
Block a user