Example #1
0
  /** Default constructor. Sets up all needed base variables to init the class. */
  public People() {
    showMapNames = IllaClient.getCfg().getInteger(CFG_NAMEMODE_KEY);
    showIDs = IllaClient.getCfg().getBoolean(CFG_SHOWID_KEY);
    IllaClient.getCfg().addListener(CFG_NAMEMODE_KEY, this);
    IllaClient.getCfg().addListener(CFG_SHOWID_KEY, this);

    removalList = new FastTable<Char>();
    chars = new HashMap<CharacterId, Char>();
    charsLock = new ReentrantReadWriteLock();

    final File playerDir =
        new File(
            DirectoryManager.getInstance().getUserDirectory(),
            Login.getInstance().getSelectedCharacterName());
    final File nameTable = new File(playerDir, "names.tbl");
    final File nameTableNew = new File(playerDir, "names.dat");
    names = new NamesTable(nameTableNew);

    if (nameTable.exists() && nameTable.isFile()) {
      new TableLoader(nameTable, this);
      if (!nameTable.delete()) {
        LOGGER.error("Failed to delete old name table.");
      }
    }
  }
Example #2
0
 /** Change the name mode and toggle between no name, short name and full name. */
 public void toggleNameMode() {
   if (showMapNames == NAME_LONG) {
     IllaClient.getCfg().set(CFG_NAMEMODE_KEY, NAME_SHORT);
   } else {
     IllaClient.getCfg().set(CFG_NAMEMODE_KEY, NAME_LONG);
   }
 }
Example #3
0
  /**
   * Establish a connection with the server.
   *
   * @return true in case the connection got established. False if not.
   */
  @SuppressWarnings("nls")
  public boolean connect() {
    try {
      final Servers usedServer = IllaClient.getInstance().getUsedServer();

      final String serverAddress;
      final int serverPort;
      if (usedServer == Servers.customserver) {
        serverAddress = IllaClient.getCfg().getString("serverAddress");
        serverPort = IllaClient.getCfg().getInteger("serverPort");
      } else {
        serverAddress = usedServer.getServerHost();
        serverPort = usedServer.getServerPort();
      }

      final InetSocketAddress address = new InetSocketAddress(serverAddress, serverPort);
      socket = SelectorProvider.provider().openSocketChannel();
      socket.configureBlocking(true);
      socket.socket().setPerformancePreferences(0, 2, 1);

      if (!socket.connect(address)) {
        while (socket.isConnectionPending()) {
          socket.finishConnect();
          try {
            Thread.sleep(1);
          } catch (@Nonnull final InterruptedException e) {
            LOGGER.warn("Waiting time for connection finished got interrupted");
          }
        }
      }

      sender = new Sender(outputQueue, socket);
      sender.setUncaughtExceptionHandler(NetCommCrashHandler.getInstance());
      inputThread = new Receiver(inputQueue, socket);
      inputThread.setUncaughtExceptionHandler(NetCommCrashHandler.getInstance());
      messageHandler = new MessageExecutor(inputQueue);
      messageHandler.setUncaughtExceptionHandler(NetCommCrashHandler.getInstance());

      sender.start();
      inputThread.start();
      messageHandler.start();

      keepAliveTimer =
          new Timer(
              INITIAL_DELAY,
              KEEP_ALIVE_DELAY,
              new Runnable() {
                @Override
                public void run() {
                  World.getNet().sendCommand(keepAliveCmd);
                }
              });
      keepAliveTimer.setRepeats(true);
      keepAliveTimer.start();
    } catch (@Nonnull final IOException e) {
      LOGGER.fatal("Connection error");
      return false;
    }
    return true;
  }
  public MapDisplayManager() {
    active = false;
    ani = new MoveAnimation(this);

    display = new FastTable<DisplayItem>();
    displayListComperator = new DisplayListComparator();
    display.setValueComparator(displayListComperator);
    corridor = FadingCorridor.getInstance();
    origin = new Location();

    legacyRendering = IllaClient.getCfg().getBoolean("legacyRender");

    dX = 0;
    dY = 0;

    levelAni =
        new MoveAnimation(
            new AnimatedMove() {
              @Override
              public void animationFinished(final boolean ok) {
                // nothing to do here
              }

              @Override
              public void setPosition(final int x, final int y, final int z) {
                dL = y;
              }
            });
    elevation = 0;
    dL = 0;
  }
Example #5
0
  /**
   * Put command in send queue so its send at the next send loop.
   *
   * @param cmd the command that shall be added to the queue
   */
  @SuppressWarnings("nls")
  public void sendCommand(@Nonnull final AbstractCommand cmd) {
    if (IllaClient.isDebug(Debug.protocol)) {
      if (cmd.getId() != CommandList.CMD_KEEPALIVE) {
        LOGGER.debug("SND: " + cmd.toString());
      }
    }

    try {
      outputQueue.put(cmd);
    } catch (@Nonnull final InterruptedException e) {
      LOGGER.error("Got interrupted while trying to add a command to to the queue.");
    }
  }
Example #6
0
  /**
   * Execute the disconnect message and send the decoded data to the rest of the client.
   *
   * @return true if the execution is done, false if it shall be called again
   */
  @SuppressWarnings("nls")
  @Override
  public boolean executeUpdate() {
    BUILDER.setLength(0);
    BUILDER.append(Lang.getMsg("logout"));
    BUILDER.append("\n");
    BUILDER.append(Lang.getMsg("logout.reason"));
    BUILDER.append(" ");

    if (reason < REASONS.length) {
      BUILDER.append(Lang.getMsg("logout." + REASONS[reason]));
    } else {
      BUILDER.append(Lang.getMsg("logout.unknown"));
      BUILDER.append(Integer.toHexString(reason));
    }
    BUILDER.append("\n");
    BUILDER.append(Lang.getMsg("logout.char"));
    BUILDER.append(" ");
    BUILDER.append(Game.getInstance().getLogin());
    IllaClient.fallbackToLogin(BUILDER.toString());
    return true;
  }
 private int getMapCenterY() {
   final GameContainer window = IllaClient.getInstance().getContainer();
   return window.getHeight() >> 1;
 }
Example #8
0
 DelayGoToItemHandler() {
   super(IllaClient.getCfg().getInteger("doubleClickInterval"), 2);
 }
 private static int getMapCenterX() {
   GameContainer window = IllaClient.getInstance().getContainer();
   return window.getWidth() >> 1;
 }