 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.queue;
30 import java.util.LinkedList;
31 import java.util.List;
32 import org.jetbrains.annotations.NotNull;
82 @SuppressWarnings(
"FieldCanBeLocal")
91 public void metaserver() {
96 public void preConnecting(@NotNull
final String serverInfo) {
101 public void connecting(@NotNull
final String serverInfo) {
106 public void connecting(@NotNull
final ClientSocketState clientSocketState, @NotNull
final String param) {
111 public void connected() {
116 public void connectFailed(@NotNull
final String reason) {
145 return oldRepeatCount;
160 assert 0 <= digit && digit <= 9;
184 public void sendNcom(
final boolean mustSend, @NotNull
final String command) {
196 public void sendNcom(
final boolean mustSend,
final int repeat, @NotNull
final String command) {
205 final String[] tmp = command.split(
" ", 2);
206 if (tmp[0].equalsIgnoreCase(
"run")) {
209 if (tmp.length >= 2) {
211 final int direction = Integer.parseInt(tmp[1]);
212 if (1 <= direction && direction <= 8) {
215 }
catch (
final NumberFormatException ignored) {
218 }
else if (tmp[0].equalsIgnoreCase(
"run_stop")) {
223 if (command.equalsIgnoreCase(
"north")) {
225 }
else if (command.equalsIgnoreCase(
"northeast")) {
227 }
else if (command.equalsIgnoreCase(
"east")) {
229 }
else if (command.equalsIgnoreCase(
"southeast")) {
231 }
else if (command.equalsIgnoreCase(
"south")) {
233 }
else if (command.equalsIgnoreCase(
"southwest")) {
235 }
else if (command.equalsIgnoreCase(
"west")) {
237 }
else if (command.equalsIgnoreCase(
"northwest")) {
242 if (direction != -1) {
304 public void sendMove(
final int to,
final int tag) {
315 if (dx == 0 && dy == -1) {
317 }
else if (dx == 1 && dy == -1) {
319 }
else if (dx == 1 && dy == 0) {
321 }
else if (dx == 1 && dy == 1) {
323 }
else if (dx == 0 && dy == 1) {
325 }
else if (dx == -1 && dy == 1) {
327 }
else if (dx == -1 && dy == 0) {
329 }
else if (dx == -1 && dy == -1) {
346 System.err.println(
"Error: got unexpected comc command #"+packetNo);
350 System.err.println(
"Warning: got out of order comc command #"+packetNo);
void addCrossfireComcListener(@NotNull CrossfireComcListener listener)
Adds a listener to be notified about received comc commands.
final PendingDirections pendingDirections
The PendingDirections instance that is updated.
void sendMove(int to, int tag, int nrof)
Sends a "move" command to the server.
Implements the map model which is shown in the map and magic map views.
Adds encoding/decoding of crossfire protocol packets to a ServerConnection.
final List< Integer > pendingCommands
Records command ids of commands sent to the server for which no comc commands has been received.
boolean checkFire()
Returns whether the character is firing.
final GuiStateListener guiStateListener
The GuiStateListener for detecting established or dropped connections.
final CrossfireServerConnection crossfireServerConnection
The server connection for sending ncom commands.
void comcReceived(final int packetNo, final int time)
Called whenever a comc command was received.
Interface for listeners interested gui state changes.
void sendNcom(final boolean mustSend, final int repeat, @NotNull final String command)
Sends a "ncom" command to the server.
void sendMove(final int to, final int tag)
Sends a "move" command to the server.
void add(final int direction, final int packetNo)
Adds a pending step.
void tick()
Must be called when a tick message has been received.
static final int MAX_PENDING_COMMANDS
Maximum number of pending commands sent to the server.
void mapScrollReceived(final int dx, final int dy)
Processes a received map scroll command.
boolean isRunning
Whether a "run" command has been sent without a following "run_stop" command.
Maintains pending movements of the character.
Maintains the current GuiState.
void sendNcom(final boolean mustSend, @NotNull final String command)
Sends a "ncom" command to the server.
boolean stopRunning()
Tells the server to stop running.
int sendNcom(int repeat, @NotNull String command)
Sends a "ncom" command to the server.
void sendRawString(@NotNull String command)
Sends an arbitrary string command to the server.
void addCrossfireMapScrollListener(@NotNull CrossfireMapScrollListener listener)
Registers a listener to be called whenever the map was scolled.
void mapScroll(final int direction)
Must be called when the map has been scrolled.
void run(final int direction)
Sets the directions the character is currently running to.
void comc(final int packetNo)
Must be called when a comc message has been received from the server.
void tickReceived(final int tickNo)
Called whenever a tick command was received.
void clear()
Forgets about sent commands.
CommandQueue(@NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final GuiStateManager guiStateManager, @NotNull final PendingDirections pendingDirections)
Creates a new instance.
int getRepeatCount()
Returns the current repeat count and reset it to zero.
Connection progress states of the Crossfire server connection.
int repeatCount
The default repeat counter for ncom commands.
void addToRepeatCount(final int digit)
Adds a digit to the current repeat count.
void sendRawString(@NotNull final String command)
Sends a raw command to the server.
Maintains the pending (ncom) commands sent to the server.
void clear()
Clears the state.
boolean checkRun()
Returns whether the character is running.
void resetRepeatCount()
Resets the current repeat count to zero.
void addCrossfireTickListener(@NotNull CrossfireTickListener listener)
Adds a listener to be notified about tick changes.