Esempio n. 1
0
  public boolean decodeCommand(String command) {
    StringTokenizer ST;
    String element;

    ST = new StringTokenizer(command, "|");
    element = TokenReader.readString(ST);
    /*    if (!element.equals("CC")) {return(false);}
    element = TokenReader.readString(ST);*/
    command = command.substring(3);

    if (element.equals("PS")) {
      if (!Player.setData(command)) {
        mwclient.addToChat("Player data load failed!<br>");
        return (false);
      }
      return (true);
    }

    if (element.equals("CC")) // Campaign Command
    {
      String commandid = TokenReader.readString(ST);
      if (commandid.equals("AT")) { // incoming attack

        if (mwclient.getConfig().isParam("ENABLEATTACKSOUND")) {
          mwclient.doPlaySound(mwclient.getConfigParam("SOUNDONATTACK"));
        }

        mwclient.addToChat(
            "<font color=\"red\"><b>Your forces are under attack!</b></font>",
            CCommPanel.CHANNEL_HMAIL);
        mwclient.addToChat(
            "<font color=\"red\"><b>Your forces are under attack!</b></font>",
            CCommPanel.CHANNEL_PMAIL,
            "Server");
        if (mwclient.getConfig().isParam("POPUPONATTACK")) {
          int opID = TokenReader.readInt(ST);
          int teams = TokenReader.readInt(ST);
          // mwclient.showInfoWindow("Your forces are under attack!");
          new ArmyViewerDialog(
              mwclient, null, ST, ArmyViewerDialog.AVD_DEFEND, null, null, opID, teams);
        }
      }
      if (commandid.equals("NT")) { // next tick

        int time = TokenReader.readInt(ST);
        boolean decrement = TokenReader.readBoolean(ST);
        mwclient.processTick(time);

        /*
         * Decrements tick counters for units without explicit auction
         * length being sent from the server to save a bit of bandwidth.
         */
        if (decrement) {
          for (CBMUnit currUnit : BlackMarket.values()) {
            currUnit.decrementSalesTicks();
          }
          mwclient.refreshGUI(MWClient.REFRESH_BMPANEL);
        }
      }
      return (true);
    }
    if (element.equals("CA")) {
      if (!setData(command)) {
        mwclient.addToChat("<b>Error: Campaign data load failed.</b><br>");
        return (false);
      }
      return (true);
    }
    if (element.equals("PL")) {
      if (!Player.decodeCommand(command)) {
        mwclient.addToChat("<b>Error: Player data load failed.</b><br>");
        return (false);
      }
      return (true);
    }
    if (element.equals("MS")) {
      if (!showMsg(command)) {
        mwclient.addToChat("<b>Error: Message show failed.</b><br>");
        return (false);
      }
      return (true);
    }
    if (element.equals("ST")) {
      if (!showStatus(command)) {
        mwclient.addToChat("<b>Error: Status show failed.</b><br>");
        return (false);
      }
      return (true);
    }

    mwclient.addToChat("<b>Error: Wrong campaign command from server.</b><br>");
    return (false);
  }
Esempio n. 2
0
 protected boolean showStatus(String command) {
   mwclient.addToChat(command);
   return (true);
 }