Exemple #1
0
    public CODES() {
      super();
      char c = Thread.currentThread().getThreadGroup().getName().charAt(0);
      if (insts == null) insts = new CODES[256];
      if (insts[c] == null) insts[c] = this;
      synchronized (this) {
        String[][] addExtra = CMProps.instance().getStrsStarting("ADDWEARLOC_");
        String[][] repExtra = CMProps.instance().getStrsStarting("REPLACEWEARLOC_");
        for (int i = 0; i < Wearable.DEFAULT_WORN_CODES.length; i++)
          add(
              DEFAULT_WORN_DESCS[i],
              DEFAULT_WORN_DEPENDENCYGRID[i],
              DEFAULT_WORN_WEIGHTS[i],
              CMParms.indexOf(DEFAULT_WORN_ORDER, DEFAULT_WORN_CODES[i]),
              DEFAULT_WORN_WEIGHT_POINTS[i][0],
              DEFAULT_WORN_WEIGHT_POINTS[i][1],
              DEFAULT_WORN_WEIGHT_POINTS[i][2]);
        // now, stupid as it is, I have to fix the worn orders
        allCodesInOrder =
            Arrays.copyOf(Wearable.DEFAULT_WORN_ORDER, Wearable.DEFAULT_WORN_ORDER.length);

        for (int i = 0; i < addExtra.length + repExtra.length; i++) {
          String[] array = (i >= addExtra.length) ? repExtra[i - addExtra.length] : addExtra[i];
          boolean replace = i >= addExtra.length;
          String stat = array[0].toLowerCase().trim().replace('_', ' ');
          String p = array[1];
          List<String> V = CMParms.parseCommas(p, false);
          if (V.size() != 6) {
            Log.errOut(
                "Wearable",
                "Bad coffeemud.ini wear loc row (requires 6 elements, separated by ,): " + p);
            continue;
          }
          String type = "ADD";
          int oldLocationCodeIndex = -1;
          if (replace) {
            int idx = CMParms.indexOf(DEFAULT_WORN_DESCS, stat);
            if (idx >= 0) {
              oldLocationCodeIndex = idx;
              type = "REPLACE";
            } else {
              Log.errOut("Wearable", "Bad replace worn loc in coffeemud.ini file: " + stat);
              continue;
            }
          }
          String dependencyMaskStr = ((String) V.get(0)).toLowerCase();
          long dependencyMask = 0;
          List<String> subLocs = CMParms.parseAny(dependencyMaskStr, '|', true);
          for (int s = 0; s < subLocs.size(); s++) {
            int idx = CMParms.indexOf(DEFAULT_WORN_DESCS, subLocs.get(s).toLowerCase());
            if (idx >= 0) dependencyMask |= DEFAULT_WORN_CODES[idx];
            else
              Log.errOut(
                  "Wearable",
                  "Bad dependency mask in coffeemud.ini file: " + subLocs.get(s).toLowerCase());
          }
          double armorStrength = CMath.s_double(V.get(1));
          int wornOrder = CMath.s_int(V.get(2));
          double clothWeight = CMath.s_double(V.get(3));
          double leatherWeight = CMath.s_double(V.get(4));
          double metalWeight = CMath.s_double(V.get(5));
          if (type.equalsIgnoreCase("ADD"))
            add(
                stat,
                dependencyMask,
                armorStrength,
                wornOrder,
                clothWeight,
                leatherWeight,
                metalWeight);
          else if (type.equalsIgnoreCase("REPLACE") && (oldLocationCodeIndex >= 0))
            replace(
                oldLocationCodeIndex,
                stat,
                dependencyMask,
                armorStrength,
                wornOrder,
                clothWeight,
                leatherWeight,
                metalWeight);
        }
      }
    }