Beispiel #1
0
  public static void Error(int code, String fmt, Vargs vargs) throws LongJmpException {
    // va_list argptr;
    // static char msg[MAXPRINTMSG];

    if (recursive) {
      Sys.Error("recursive error after: " + msg);
    }
    recursive = true;

    msg = sprintf(fmt, vargs);

    if (code == Constants.ERR_DISCONNECT) {
      Client.drop();
      recursive = false;
      throw new LongJmpException();
    } else if (code == Constants.ERR_DROP) {
      Com.Printf("********************\nERROR: " + msg + "\n********************\n");
      ServerMain.SV_Shutdown("Server crashed: " + msg + "\n", false);
      Client.drop();
      recursive = false;
      throw new LongJmpException();
    } else {
      ServerMain.SV_Shutdown("Server fatal crashed: %s" + msg + "\n", false);
      Client.shutdown();
    }

    Sys.Error(msg);
  }
Beispiel #2
0
  /**
   * Com_InitArgv checks the number of command line arguments and copies all arguments with valid
   * length into com_argv.
   */
  static void InitArgv(String[] args) throws LongJmpException {

    if (args.length > Constants.MAX_NUM_ARGVS) {
      Com.Error(Constants.ERR_FATAL, "argc > MAX_NUM_ARGVS");
    }

    Com.com_argc = args.length;
    for (int i = 0; i < Com.com_argc; i++) {
      if (args[i].length() >= Constants.MAX_TOKEN_CHARS) Com.com_argv[i] = "";
      else Com.com_argv[i] = args[i];
    }
  }
Beispiel #3
0
  // See GameSpanw.ED_ParseEdict() to see how to use it now.
  public static String Parse(ParseHelp hlp) {
    int c;
    int len = 0;

    if (hlp.data == null) {
      return "";
    }

    while (true) {
      //	   skip whitespace
      hlp.skipwhites();
      if (hlp.isEof()) {
        hlp.data = null;
        return "";
      }

      //	   skip // comments
      if (hlp.getchar() == '/') {
        if (hlp.nextchar() == '/') {
          hlp.skiptoeol();
          // goto skip whitespace
          continue;
        } else {
          hlp.prevchar();
          break;
        }
      } else break;
    }

    //	   handle quoted strings specially
    if (hlp.getchar() == '\"') {
      hlp.nextchar();
      while (true) {
        c = hlp.getchar();
        hlp.nextchar();
        if (c == '\"' || c == 0) {
          return new String(com_token, 0, len);
        }
        if (len < Constants.MAX_TOKEN_CHARS) {
          com_token[len] = (char) c;
          len++;
        }
      }
    }

    //	   parse a regular word
    c = hlp.getchar();
    do {
      if (len < Constants.MAX_TOKEN_CHARS) {
        com_token[len] = (char) c;
        len++;
      }
      c = hlp.nextchar();
    } while (c > 32);

    if (len == Constants.MAX_TOKEN_CHARS) {
      Com.Printf("Token exceeded " + Constants.MAX_TOKEN_CHARS + " chars, discarded.\n");
      len = 0;
    }

    return new String(com_token, 0, len);
  }