예제 #1
0
  public void weaponAddDamage() {
    Connection con = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;

    try {
      con = L1DatabaseFactory.getInstance().getConnection();
      pstm =
          con.prepareStatement(
              "select item_id, name, bless, enchantlvl, attr_enchantlvl, price from autoshopbuyitemlist where price > 0");
      rs = pstm.executeQuery();

      int index = 0;
      ItemInfo itemInfo = null;
      while (rs.next()) {
        itemInfo = new ItemInfo();

        itemInfo.id = rs.getInt("item_id");
        itemInfo.name = rs.getString("name");
        itemInfo.bless = rs.getInt("bless");
        itemInfo.enchantlvl = rs.getInt("enchantlvl");
        itemInfo.attrEnchantlvl = rs.getInt("attr_enchantlvl");
        itemInfo.price = rs.getInt("price");

        _idlist.put(index++, itemInfo);
      }

    } catch (SQLException e) {
      _log.log(Level.SEVERE, "AutoShopBuyTable[]Error", e);
    } finally {
      SQLUtil.close(rs);
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    }
  }
예제 #2
0
  public static void addBookmark(L1PcInstance pc, String s) {
    // クライアント側でチェックされるため不要
    //		if (s.length() > 12) {
    //			pc.sendPackets(new S_ServerMessage(204));
    //			return;
    //		}

    if (!pc.getMap().isMarkable()) {
      pc.sendPackets(new S_ServerMessage(214)); // \f1ここを記憶することができません。
      return;
    }

    int size = pc.getBookMarkSize();
    if (size > 49) {
      return;
    }

    if (pc.getBookMark(s) == null) {
      L1BookMark bookmark = new L1BookMark();
      bookmark.setId(IdFactory.getInstance().nextId());
      bookmark.setCharId(pc.getId());
      bookmark.setName(s);
      bookmark.setLocX(pc.getX());
      bookmark.setLocY(pc.getY());
      bookmark.setMapId(pc.getMapId());

      Connection con = null;
      PreparedStatement pstm = null;

      try {
        con = L1DatabaseFactory.getInstance().getConnection();
        pstm =
            con.prepareStatement(
                "INSERT INTO character_teleport SET id = ?, char_id = ?, name = ?, locx = ?, locy = ?, mapid = ?");
        pstm.setInt(1, bookmark.getId());
        pstm.setInt(2, bookmark.getCharId());
        pstm.setString(3, bookmark.getName());
        pstm.setInt(4, bookmark.getLocX());
        pstm.setInt(5, bookmark.getLocY());
        pstm.setInt(6, bookmark.getMapId());
        pstm.execute();
      } catch (SQLException e) {
        _log.log(Level.SEVERE, "ブックマークの追加でエラーが発生しました。", e);
      } finally {
        SQLUtil.close(pstm);
        SQLUtil.close(con);
      }

      pc.addBookMark(bookmark);
      pc.sendPackets(
          new S_Bookmarks(
              s, bookmark.getMapId(), bookmark.getId(), bookmark.getLocX(), bookmark.getLocY()));
    } else {
      pc.sendPackets(new S_ServerMessage(327)); // 同じ名前がすでに存在しています。
    }
  }
예제 #3
0
  public void fillSpawnTable(int mapid, int type) {
    Connection con = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;
    try {
      con = L1DatabaseFactory.getInstance().getConnection();
      pstm = con.prepareStatement("SELECT * FROM spawnlist_antaras");
      rs = pstm.executeQuery();
      while (rs.next()) {
        if (type != rs.getInt("type")) continue;

        L1Npc l1npc = NpcTable.getInstance().getTemplate(rs.getInt("npc_id"));
        if (l1npc != null) {
          L1NpcInstance field;
          try {
            field = NpcTable.getInstance().newNpcInstance(rs.getInt("npc_id"));
            field.setId(ObjectIdFactory.getInstance().nextId());
            field.setX(rs.getInt("locx"));
            field.setY(rs.getInt("locy"));
            field.setMap((short) mapid);
            field.setHomeX(field.getX());
            field.setHomeY(field.getY());
            field.getMoveState().setHeading(0);
            field.setLightSize(l1npc.getLightSize());
            field.getLight().turnOnOffLight();

            L1World.getInstance().storeObject(field);
            L1World.getInstance().addVisibleObject(field);
          } catch (Exception e) {
            _log.log(Level.SEVERE, "AntarasRaidSpawn.java error occurred", e);
          }
        }
      }
    } catch (SQLException e) {
      _log.log(Level.SEVERE, "AntarasRaidSpawn.java error occurred", e);
    } catch (SecurityException e) {
      _log.log(Level.SEVERE, "AntarasRaidSpawn.java error occurred", e);
    } catch (IllegalArgumentException e) {
      _log.log(Level.SEVERE, "AntarasRaidSpawn.java error occurred", e);
    } finally {
      SQLUtil.close(rs);
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    }
  }
예제 #4
0
  private void initialize() {
    Connection con = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;

    try {
      con = L1DatabaseFactory.getInstance().getConnection();

      pstm = con.prepareStatement("SELECT * FROM spawnlist_trap");

      rs = pstm.executeQuery();

      while (rs.next()) {
        int trapId = rs.getInt("trapId");
        L1Trap trapTemp = TrapTable.getInstance().getTemplate(trapId);
        L1Location loc = new L1Location();
        loc.setMap(rs.getInt("mapId"));
        loc.setX(rs.getInt("locX"));
        loc.setY(rs.getInt("locY"));
        Point rndPt = new Point();
        rndPt.setX(rs.getInt("locRndX"));
        rndPt.setY(rs.getInt("locRndY"));
        int count = rs.getInt("count");
        int span = rs.getInt("span");

        for (int i = 0; i < count; i++) {
          L1TrapInstance trap =
              new L1TrapInstance(IdFactory.getInstance().nextId(), trapTemp, loc, rndPt, span);
          L1World.getInstance().addVisibleObject(trap);
          _allTraps.add(trap);
        }
        L1TrapInstance base = new L1TrapInstance(IdFactory.getInstance().nextId(), loc);
        L1World.getInstance().addVisibleObject(base);
        _allBases.add(base);
      }

    } catch (SQLException e) {
      _log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    } finally {
      SQLUtil.close(rs);
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    }
  }
예제 #5
0
 public static void loadGetBack() {
   _getback.clear();
   Connection con = null;
   PreparedStatement pstm = null;
   ResultSet rs = null;
   try {
     con = L1DatabaseFactory.getInstance().getConnection();
     // 同マップでエリア指定と無指定が混在していたら、エリア指定を先に読み込む為にarea_x1 DESC
     String sSQL = "SELECT * FROM getback ORDER BY area_mapid,area_x1 DESC ";
     pstm = con.prepareStatement(sSQL);
     rs = pstm.executeQuery();
     while (rs.next()) {
       Getback getback = new Getback();
       getback._areaX1 = rs.getInt("area_x1");
       getback._areaY1 = rs.getInt("area_y1");
       getback._areaX2 = rs.getInt("area_x2");
       getback._areaY2 = rs.getInt("area_y2");
       getback._areaMapId = rs.getInt("area_mapid");
       getback._getbackX1 = rs.getInt("getback_x1");
       getback._getbackY1 = rs.getInt("getback_y1");
       getback._getbackX2 = rs.getInt("getback_x2");
       getback._getbackY2 = rs.getInt("getback_y2");
       getback._getbackX3 = rs.getInt("getback_x3");
       getback._getbackY3 = rs.getInt("getback_y3");
       getback._getbackMapId = rs.getInt("getback_mapid");
       getback._getbackTownId = rs.getInt("getback_townid");
       getback._getbackTownIdForElf = rs.getInt("getback_townid_elf");
       getback._getbackTownIdForDarkelf = rs.getInt("getback_townid_darkelf");
       rs.getBoolean("scrollescape");
       List<Getback> getbackList = _getback.get(getback._areaMapId);
       if (getbackList == null) {
         getbackList = Lists.newList();
         _getback.put(getback._areaMapId, getbackList);
       }
       getbackList.add(getback);
     }
   } catch (Exception e) {
     _log.log(Level.SEVERE, "could not Get Getback data", e);
   } finally {
     SQLUtil.close(rs);
     SQLUtil.close(pstm);
     SQLUtil.close(con);
   }
 }
예제 #6
0
  public static void deleteBookmark(L1PcInstance player, String s) {
    L1BookMark book = player.getBookMark(s);
    if (book != null) {
      Connection con = null;
      PreparedStatement pstm = null;
      try {

        con = L1DatabaseFactory.getInstance().getConnection();
        pstm = con.prepareStatement("DELETE FROM character_teleport WHERE id=?");
        pstm.setInt(1, book.getId());
        pstm.execute();
        player.removeBookMark(book);
      } catch (SQLException e) {
        _log.log(Level.SEVERE, "ブックマークの削除でエラーが発生しました。", e);
      } finally {
        SQLUtil.close(pstm);
        SQLUtil.close(con);
      }
    }
  }
예제 #7
0
  /**
   * 지정된 UBID에 대한 패턴의 최대수를 돌려준다.
   *
   * @param ubId 조사하는 UBID.
   * @return 패턴의 최대수.
   */
  public int getMaxPattern(int ubId) {
    int n = 0;
    java.sql.Connection con = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;

    try {
      con = L1DatabaseFactory.getInstance().getConnection();
      pstm = con.prepareStatement("SELECT MAX(pattern) FROM spawnlist_ub WHERE ub_id=?");
      pstm.setInt(1, ubId);
      rs = pstm.executeQuery();
      if (rs.next()) {
        n = rs.getInt(1);
      }
    } catch (SQLException e) {
      _log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    } finally {
      SQLUtil.close(rs);
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    }
    return n;
  }
예제 #8
0
 /** 디비에 UB의 랭킹등록 */
 public void writeUbScore(int ubId, L1PcInstance pc) {
   java.sql.Connection con = null;
   PreparedStatement pstm1 = null;
   PreparedStatement pstm2 = null;
   ResultSet rs = null;
   int score = 0;
   try {
     con = L1DatabaseFactory.getInstance().getConnection();
     pstm1 = con.prepareStatement("SELECT * FROM ub_rank WHERE ub_id=? AND char_name=?");
     pstm1.setInt(1, ubId);
     pstm1.setString(2, pc.getName());
     rs = pstm1.executeQuery();
     if (rs.next()) {
       score = rs.getInt("score");
       pstm2 = con.prepareStatement("UPDATE ub_rank SET score=? WHERE ub_id=? AND char_name=?");
       pstm2.setInt(1, score + pc.getUbScore());
       pstm2.setInt(2, ubId);
       pstm2.setString(3, pc.getName());
       pstm2.execute();
     } else {
       pstm2 = con.prepareStatement("INSERT INTO ub_rank SET ub_id=?, char_name=?, score=?");
       pstm2.setInt(1, ubId);
       pstm2.setString(2, pc.getName());
       pstm2.setInt(3, pc.getUbScore());
       pstm2.execute();
     }
     pc.setUbScore(0);
   } catch (SQLException e) {
     _log.log(Level.SEVERE, e.getLocalizedMessage(), e);
   } finally {
     SQLUtil.close(rs);
     SQLUtil.close(pstm1);
     SQLUtil.close(pstm2);
     SQLUtil.close(con);
   }
 }
예제 #9
0
 private void loadShops() {
   Connection con = null;
   PreparedStatement pstm = null;
   ResultSet rs = null;
   try {
     con = L1DatabaseFactory.getInstance().getConnection();
     pstm = con.prepareStatement("SELECT * FROM shop WHERE npc_id=? ORDER BY order_id");
     for (int npcId : enumNpcIds()) {
       pstm.setInt(1, npcId);
       rs = pstm.executeQuery();
       L1Shop shop = loadShop(npcId, rs);
       _allShops.put(npcId, shop);
       rs.close();
     }
   } catch (SQLException e) {
     _log.log(Level.SEVERE, e.getLocalizedMessage(), e);
   } finally {
     SQLUtil.close(rs, pstm, con);
   }
 }
예제 #10
0
  private List<Integer> enumNpcIds() {
    List<Integer> ids = Lists.newList();

    Connection con = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;
    try {
      con = L1DatabaseFactory.getInstance().getConnection();
      pstm = con.prepareStatement("SELECT DISTINCT npc_id FROM shop");
      rs = pstm.executeQuery();
      while (rs.next()) {
        ids.add(rs.getInt("npc_id"));
      }
    } catch (SQLException e) {
      _log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    } finally {
      SQLUtil.close(rs, pstm, con);
    }
    return ids;
  }
예제 #11
0
  private Dungeon() {
    Connection con = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;

    try {
      con = L1DatabaseFactory.getInstance().getConnection();

      pstm = con.prepareStatement("SELECT * FROM dungeon");
      rs = pstm.executeQuery();
      while (rs.next()) {
        int srcMapId = rs.getInt("src_mapid");
        int srcX = rs.getInt("src_x");
        int srcY = rs.getInt("src_y");
        String key = new StringBuilder().append(srcMapId).append(srcX).append(srcY).toString();
        int newX = rs.getInt("new_x");
        int newY = rs.getInt("new_y");
        int newMapId = rs.getInt("new_mapid");
        int heading = rs.getInt("new_heading");
        DungeonType dungeonType = DungeonType.NONE;
        if ((((srcX == 33423) || (srcX == 33424) || (srcX == 33425) || (srcX == 33426))
                && (srcY == 33502)
                && (srcMapId == 4 // ハイネ船着場->FI行きの船
                ))
            || (((srcX == 32733) || (srcX == 32734) || (srcX == 32735) || (srcX == 32736))
                && (srcY == 32794)
                && (srcMapId == 83))) { // FI行きの船->ハイネ船着場
          dungeonType = DungeonType.SHIP_FOR_FI;
        } else if ((((srcX == 32935) || (srcX == 32936) || (srcX == 32937))
                && (srcY == 33058)
                && (srcMapId == 70 // FI船着場->ハイネ行きの船
                ))
            || (((srcX == 32732) || (srcX == 32733) || (srcX == 32734) || (srcX == 32735))
                && (srcY == 32796)
                && (srcMapId == 84))) { // ハイネ行きの船->FI船着場
          dungeonType = DungeonType.SHIP_FOR_HEINE;
        } else if ((((srcX == 32750) || (srcX == 32751) || (srcX == 32752))
                && (srcY == 32874)
                && (srcMapId == 445 // 隠された船着場->海賊島行きの船
                ))
            || (((srcX == 32731) || (srcX == 32732) || (srcX == 32733))
                && (srcY == 32796)
                && (srcMapId == 447))) { // 海賊島行きの船->隠された船着場
          dungeonType = DungeonType.SHIP_FOR_PI;
        } else if ((((srcX == 32296) || (srcX == 32297) || (srcX == 32298))
                && (srcY == 33087)
                && (srcMapId == 440 // 海賊島船着場->隠された船着場行きの船
                ))
            || (((srcX == 32735) || (srcX == 32736) || (srcX == 32737))
                && (srcY == 32794)
                && (srcMapId == 446))) { // 隠された船着場行きの船->海賊島船着場
          dungeonType = DungeonType.SHIP_FOR_HIDDENDOCK;
        } else if ((((srcX == 32630) || (srcX == 32631) || (srcX == 32632))
                && (srcY == 32983)
                && (srcMapId == 0 // TalkingIsland->TalkingIslandShiptoAdenMainland
                ))
            || (((srcX == 32733) || (srcX == 32734) || (srcX == 32735))
                && (srcY == 32796)
                && (srcMapId == 5))) { // TalkingIslandShiptoAdenMainland->TalkingIsland
          dungeonType = DungeonType.SHIP_FOR_GLUDIN;
        } else if ((((srcX == 32540)
                    || (srcX == 32542)
                    || (srcX == 32543)
                    || (srcX == 32544)
                    || (srcX == 32545))
                && (srcY == 32728)
                && (srcMapId == 4 // AdenMainland->AdenMainlandShiptoTalkingIsland
                ))
            || (((srcX == 32734) || (srcX == 32735) || (srcX == 32736) || (srcX == 32737))
                && (srcY == 32794)
                && (srcMapId == 6))) { // AdenMainlandShiptoTalkingIsland->AdenMainland
          dungeonType = DungeonType.SHIP_FOR_TI;
        } else if ((srcX == 32600) && (srcY == 32931) && (srcMapId == 0)) { // 說話之島旅館
          dungeonType = DungeonType.TALKING_ISLAND_HOTEL;
        } else if ((srcX == 32632) && (srcY == 32761) && (srcMapId == 4)) { // 古魯丁旅館
          dungeonType = DungeonType.GLUDIO_HOTEL;
        } else if ((srcX == 33116) && (srcY == 33379) && (srcMapId == 4)) { // 銀騎士旅館
          dungeonType = DungeonType.SILVER_KNIGHT_HOTEL;
        } else if ((srcX == 32628) && (srcY == 33167) && (srcMapId == 4)) { // 風木旅館
          dungeonType = DungeonType.WINDAWOOD_HOTEL;
        } else if ((srcX == 33605) && (srcY == 33275) && (srcMapId == 4)) { // 海音旅館
          dungeonType = DungeonType.HEINE_HOTEL;
        } else if ((srcX == 33437) && (srcY == 32789) && (srcMapId == 4)) { // 奇岩旅館
          dungeonType = DungeonType.GIRAN_HOTEL;
        } else if ((srcX == 34068) && (srcY == 32254) && (srcMapId == 4)) { // 歐瑞旅館
          dungeonType = DungeonType.OREN_HOTEL;
        }
        NewDungeon newDungeon = new NewDungeon(newX, newY, (short) newMapId, heading, dungeonType);
        if (_dungeonMap.containsKey(key)) {
          _log.log(Level.WARNING, "Navicat dungeon 傳送點重複。key=" + key);
        }
        _dungeonMap.put(key, newDungeon);
      }
    } catch (SQLException e) {
      _log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    } finally {
      SQLUtil.close(rs);
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    }
  }
예제 #12
0
  private void loadTable() {

    java.sql.Connection con = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;
    try {

      con = L1DatabaseFactory.getInstance().getConnection();
      pstm = con.prepareStatement("SELECT * FROM ub_settings");
      rs = pstm.executeQuery();
      L1UltimateBattle ub = null;
      while (rs.next()) {

        ub = new L1UltimateBattle();
        ub.setUbId(rs.getInt("ub_id"));
        ub.setMapId(rs.getShort("ub_mapid"));
        ub.setLocX1(rs.getInt("ub_area_x1"));
        ub.setLocY1(rs.getInt("ub_area_y1"));
        ub.setLocX2(rs.getInt("ub_area_x2"));
        ub.setLocY2(rs.getInt("ub_area_y2"));
        ub.setMinLevel(rs.getInt("min_lvl"));
        ub.setMaxLevel(rs.getInt("max_lvl"));
        ub.setMaxPlayer(rs.getInt("max_player"));
        ub.setEnterRoyal(rs.getBoolean("enter_royal"));
        ub.setEnterKnight(rs.getBoolean("enter_knight"));
        ub.setEnterMage(rs.getBoolean("enter_mage"));
        ub.setEnterElf(rs.getBoolean("enter_elf"));
        ub.setEnterDarkelf(rs.getBoolean("enter_darkelf"));
        ub.setEnterDragonknight(rs.getBoolean("enter_dragonknight"));
        ub.setEnterBlackwizard(rs.getBoolean("enter_blackwizard"));
        ub.setEnterMale(rs.getBoolean("enter_male"));
        ub.setEnterFemale(rs.getBoolean("enter_female"));
        ub.setUsePot(rs.getBoolean("use_pot"));
        ub.setHpr(rs.getInt("hpr_bonus"));
        ub.setMpr(rs.getInt("mpr_bonus"));
        ub.resetLoc();

        _ub.put(ub.getUbId(), ub);
      }
    } catch (SQLException e) {
      _log.warning("ubsettings couldnt be initialized:" + e);
    } finally {
      SQLUtil.close(rs);
      SQLUtil.close(pstm);
    }

    // ub_managers load
    try {
      pstm = con.prepareStatement("SELECT * FROM ub_managers");
      rs = pstm.executeQuery();
      L1UltimateBattle ub = null;
      while (rs.next()) {
        ub = getUb(rs.getInt("ub_id"));
        if (ub != null) {
          ub.addManager(rs.getInt("ub_manager_npc_id"));
        }
      }
    } catch (SQLException e) {
      _log.warning("ub_managers couldnt be initialized:" + e);
    } finally {
      SQLUtil.close(rs);
      SQLUtil.close(pstm);
    }

    // ub_times load
    try {
      pstm = con.prepareStatement("SELECT * FROM ub_times");
      rs = pstm.executeQuery();
      L1UltimateBattle ub = null;
      while (rs.next()) {
        ub = getUb(rs.getInt("ub_id"));
        if (ub != null) {
          ub.addUbTime(rs.getInt("ub_time"));
        }
      }
    } catch (SQLException e) {
      _log.warning("ub_times couldnt be initialized:" + e);
    } finally {
      SQLUtil.close(rs, pstm, con);
    }
    _log.config("UB리스트 " + _ub.size() + "건 로드");
  }