22 package com.realtime.crossfire.jxclient.queue;
29 import java.util.LinkedList;
30 import java.util.List;
31 import org.jetbrains.annotations.NotNull;
74 @SuppressWarnings(
"FieldCanBeLocal")
77 final int index = pendingCommands.indexOf(packetNo);
79 System.err.println(
"Error: got unexpected comc command #"+packetNo);
83 System.err.println(
"Warning: got out of order comc command #"+packetNo);
86 for (
int i = 0; i <= index; i++) {
87 pendingCommands.remove(0);
97 @SuppressWarnings(
"FieldCanBeLocal")
101 public void start() {
106 public void metaserver() {
111 public void preConnecting(@NotNull
final String serverInfo) {
116 public void connecting(@NotNull
final String serverInfo) {
126 public void connected() {
131 public void connectFailed(@NotNull
final String reason) {
156 return oldRepeatCount;
171 assert 0 <= digit && digit <= 9;
194 public void sendNcom(
final boolean mustSend, @NotNull
final String command) {
206 public void sendNcom(
final boolean mustSend,
final int repeat, @NotNull
final String command) {
215 if (command.startsWith(
"run ")) {
217 }
else if (command.startsWith(
"run_stop")) {
264 public void sendMove(
final int to,
final int tag) {
boolean checkRun()
Returns whether the character is running.
Interface for listeners interested gui state changes.
Maintains the current GuiState.
void sendMove(final int to, final int tag)
Sends a "move" command to the server.
final List< Integer > pendingCommands
Records command ids of commands sent to the server for which no comc commands has been received...
void sendNcom(final boolean mustSend, @NotNull final String command)
Sends an "ncom" command to the server.
boolean stopRunning()
Tells the server to stop running.
final CrossfireComcListener crossfireComcListener
The listener to track comc commands.
int sendNcom(int repeat, @NotNull String command)
Sends a "ncom" command to the server.
void addCrossfireComcListener(@NotNull CrossfireComcListener listener)
Adds a listener to be notified about received comc commands.
CommandQueue(@NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final GuiStateManager guiStateManager)
Creates a new instance.
void clear()
Forgets about sent commands.
void addToRepeatCount(final int digit)
Adds a digit to the current repeat count.
boolean isRunning
Whether a "run" command has been sent without a following "run_stop" command.
final CrossfireServerConnection crossfireServerConnection
The server connection for sending ncom commands.
int repeatCount
The default repeat counter for ncom commands.
void resetRepeatCount()
Resets the current repeat count to zero.
final GuiStateListener guiStateListener
The GuiStateListener for detecting established or dropped connections.
void sendNcom(final boolean mustSend, final int repeat, @NotNull final String command)
Sends an "ncom" command to the server.
static final int MAX_PENDING_COMMANDS
Maximum number of pending commands sent to the server.
boolean checkFire()
Returns whether the character is firing.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
Maintains the pending (ncom) commands sent to the server.
Interface for listeners interested in comc commands received from the server.
int getRepeatCount()
Returns the current repeat count and reset it to zero.
Connection progress states of the Crossfire server connection.
void sendMove(int to, int tag, int nrof)
Sends a "move" command to the server.