示例#1
0
 public static String getChannelServerIPFromSubnet(String clientIPAddress, int channel) {
   long ipAddress = dottedQuadToLong(clientIPAddress);
   Properties subnetInfo = LoginServer.getInstance().getSubnetInfo();
   if (subnetInfo.contains("net.login.subnetcount")) {
     int subnetCount = Integer.parseInt(subnetInfo.getProperty("net.login.subnetcount"));
     for (int i = 0; i < subnetCount; i++) {
       String[] connectionInfo = subnetInfo.getProperty("net.login.subnet." + i).split(":");
       long subnet = dottedQuadToLong(connectionInfo[0]);
       long channelIP = dottedQuadToLong(connectionInfo[1]);
       int channelNumber = Integer.parseInt(connectionInfo[2]);
       if (((ipAddress & subnet) == (channelIP & subnet)) && (channel == channelNumber)) {
         return connectionInfo[1];
       }
     }
   }
   return "0.0.0.0";
 }
示例#2
0
 public byte deleteCharacter(int cid) {
   Connection con = DatabaseConnection.getConnection();
   String charname = "";
   try {
     PreparedStatement ps =
         con.prepareStatement(
             "SELECT id, guildid, guildrank, name, allianceRank FROM characters WHERE id = ? AND accountid = ?");
     ps.setInt(1, cid);
     ps.setInt(2, accId);
     ResultSet rs = ps.executeQuery();
     rs.next();
     charname = rs.getString("name");
     if (rs.getInt("guildid") > 0) {
       if (rs.getInt("guildrank") == 1) {
         rs.close();
         ps.close();
         return 22;
       }
       try {
         LoginServer.getInstance()
             .getWorldInterface()
             .deleteGuildCharacter(
                 new MapleGuildCharacter(
                     cid,
                     0,
                     charname,
                     -1,
                     0,
                     rs.getInt("guildrank"),
                     rs.getInt("guildid"),
                     false,
                     rs.getInt("allianceRank")),
                 world);
       } catch (RemoteException re) {
         rs.close();
         ps.close();
         return 1;
       }
     }
     rs.close();
     /*    ps = con.prepareStatement("UPDATE characters set `deleted` = 1, `name` = ? WHERE id = ?");
     ps.setString(1, "___" + charname);
     ps.setInt(2, cid);
     ps.executeUpdate();
     ps.close();*/
     ps = con.prepareStatement("DELETE FROM characters WHERE id = ?");
     ps.setInt(1, cid);
     ps.executeUpdate();
     ps.close();
     String[] toDel = {
       "famelog", "keymap", "queststatus", "savedlocations", "skillmacros", "skills", "eventstats"
     };
     for (String s : toDel) {
       ps = con.prepareStatement("DELETE FROM `" + s + "` WHERE characterid = ?");
       ps.setInt(1, cid);
       ps.executeUpdate();
       ps.close();
     }
     ps = con.prepareStatement("DELETE FROM koccharacters WHERE knightId = ?");
     ps.setInt(1, cid);
     ps.executeUpdate();
     ps.close();
     ps = con.prepareStatement("DELETE FROM koccharacters WHERE linkedId = ?");
     ps.setInt(1, cid);
     ps.executeUpdate();
     ps.close();
     return 0;
   } catch (SQLException e) {
     e.printStackTrace();
     return 1;
   }
 }