Quests plethora cause load too long DC.

Results 1 to 1 of 1
  1. #1
    Apprentice t9540513 is offline
    MemberRank
    Jan 2017 Join Date
    22Posts

    Quests plethora cause load too long DC.

    I always have no solution, Please help me....

    Quests plethora Players load exceed 30 second DC.





    PHP Code:
     public static MapleCharacter loadCharFromDB(int charidMapleClient clientboolean channelserverthrows SQLException {
            try {
            
    MapleCharacter ret = new MapleCharacter();
            
    ret.client client;
            
    ret.id charid;

            
    Connection con DatabaseConnection.getConnection();
            
    PreparedStatement ps con.prepareStatement("SELECT * FROM characters WHERE id = ?");
            
    ps.setInt(1charid);
            
    ResultSet rs ps.executeQuery();
            if (!
    rs.next()) {
                 
    rs.close();
                 
    ps.close();
                 throw new 
    RuntimeException("無法正確讀取文字字符 (nao encontrado)");
            }
            
    ret.name rs.getString("name");
            
    ret.level rs.getInt("level");
            
    ret.fame rs.getInt("fame");
            
    ret.str rs.getInt("str");
            
    ret.dex rs.getInt("dex");
            
    ret.int_ rs.getInt("int");
            
    ret.luk rs.getInt("luk");
            
    ret.exp.set(rs.getInt("exp"));

            
    ret.hp rs.getInt("hp");
            
    ret.maxhp rs.getInt("maxhp");
            
    ret.mp rs.getInt("mp");
            
    ret.maxmp rs.getInt("maxmp");

            
    ret.hpApUsed rs.getInt("hpApUsed");
            
    ret.mpApUsed rs.getInt("mpApUsed");
            
    ret.remainingSp rs.getInt("sp");
            
    ret.remainingAp rs.getInt("ap");
        
            
    ret.meso.set(rs.getInt("meso"));

            
    ret.gmLevel rs.getInt("gm");
            
    ret.LeaderPoints rs.getInt("LeaderPoints");
            
    ret.FestivalPoints rs.getInt("FestivalPoints");
            
    ret.AriantPontos rs.getInt("AriantPontos");
            
    ret.hpMpApUsed rs.getInt("hpMpUsed");
            
    ret.skinColor MapleSkinColor.getById(rs.getInt("skincolor"));
            
    ret.gender rs.getInt("gender");
            
    ret.job MapleJob.getById(rs.getInt("job"));
            
    //Mini-jogos
            
    ret.omokwins rs.getInt("omokwins");
            
    ret.omoklosses rs.getInt("omoklosses");
            
    ret.omokties rs.getInt("omokties");
            
    ret.matchcardwins rs.getInt("matchcardwins");
            
    ret.matchcardlosses rs.getInt("matchcardlosses");
            
    ret.matchcardties rs.getInt("matchcardties");
            
    //cantalk
            
    ret.canTalk rs.getInt("cantalk");
            
    //marriage
            
    ret.married rs.getInt("married") == false true;
            
    ret.partnerid rs.getInt("partnerid");
            
    ret.marriageQuestLevel rs.getInt("marriagequest");

            
    //mount
            
    int mountexp rs.getInt("mountexp");
            
    int mountlevel rs.getInt("mountlevel");
            
    int mounttiredness rs.getInt("mounttiredness");

            
    ret.merchantMesos rs.getInt("MerchantMesos");
            
    ret.hasMerchant rs.getInt("HasMerchant") == 1;

            
    ret.zakumLvl rs.getInt("zakumLvl");

            
    ret.hair rs.getInt("hair");
            
    ret.face rs.getInt("face");
            
    ret.accountid rs.getInt("accountid");

            
    ret.mapid rs.getInt("map");
            
    ret.initialSpawnPoint rs.getInt("spawnpoint");
            
    ret.world rs.getInt("world");

            
    ret.rank rs.getInt("rank");
            
    ret.rankMove rs.getInt("rankMove");
            
    ret.jobRank rs.getInt("jobRank");
            
    ret.jobRankMove rs.getInt("jobRankMove");

            
    ret.guildid rs.getInt("guildid");
            
    ret.guildrank rs.getInt("guildrank");
            
    ret.allianceRank rs.getInt("allianceRank");
            if (
    ret.guildid 0) {
                
    ret.mgc = new MapleGuildCharacter(ret);
            }
            
    int buddyCapacity rs.getInt("buddyCapacity");
            
    ret.buddylist = new BuddyList(buddyCapacity);
            
    ret.bosspoints rs.getInt("bosspoints");

            if (
    channelserver) {
               
    // ret.chatlog = ChatLog.load(ret.name);
                
    MapleMapFactory mapFactory ChannelServer.getInstance(client.getChannel()).getMapFactory();
                
    ret.map mapFactory.getMap(ret.mapid);
                if (
    ret.map == null) { //char is on a map that doesn't exist warp it to henesys
                    
    ret.map mapFactory.getMap(100000000);
                }
                
    int rMap ret.map.getForcedReturnId();
                if (
    rMap != 999999999) {
                    
    ret.map mapFactory.getMap(rMap);
                }
                
    MaplePortal portal ret.map.getPortal(ret.initialSpawnPoint);
                if (
    portal == null) {
                    
    portal ret.map.getPortal(0); // char is on a spawnpoint that doesn't exist - select the first spawnpoint instead
                    
    ret.initialSpawnPoint 0;
                }
                
    ret.setPosition(portal.getPosition());
     
                
    int partyid rs.getInt("party");
                    try {
                        
    MapleParty party client.getChannelServer().getWorldInterface().getParty(partyid);
                        if (
    party != null) {
                            
    ret.mpc party.getMemberById(ret.id);
                            if (
    ret.mpc != null) {
                                
    ret.party party;
                            }
                        }
                    } catch (
    RemoteException ex) {
                        
    client.getChannelServer().reconnectWorld();
                 }

                
    int messengerid rs.getInt("messengerid");
                
    int position rs.getInt("messengerposition");
                if (
    messengerid && position && position > -1) {
                    try {
                        
    WorldChannelInterface wci ChannelServer.getInstance(client.getChannel()).getWorldInterface();
                        
    MapleMessenger messenger wci.getMessenger(messengerid);
                        if (
    messenger != null) {
                            
    ret.messenger messenger;
                            
    ret.messengerposition position;
                        }
                    } catch (
    RemoteException e) {
                        
    client.getChannelServer().reconnectWorld();
                    }
                }
                if (
    ChannelServer.getInstance(1).getLordId() == ret.id) {
                    
    ret.lord true;
                }
                
    //ret.loadCooldowns(con);
            
    }

            
    rs.close();
            
    ps.close();

            
    ps con.prepareStatement("SELECT * FROM accounts WHERE id = ?");
            
    ps.setInt(1ret.accountid);
            
    rs ps.executeQuery();
            while (
    rs.next()) {
                
    ret.getClient().setAccountName(rs.getString("name"));
                
    ret.paypalnx rs.getInt("paypalNX");
                
    ret.maplepoints rs.getInt("mPoints");
                
    ret.cardnx rs.getInt("cardNX");
                
    ret.donatorPoints rs.getInt("donatorpoints");
                
    ret.votePoints rs.getInt("votePoints");
            }
            
    rs.close();
            
    ps.close();
            
            
    ps con.prepareStatement("SELECT * FROM accounts WHERE id = ?");
            
    ps.setInt(1ret.accountid);
            
    rs ps.executeQuery();
            while (
    rs.next()) {
                
    ret.getClient().setAccountName(rs.getString("name"));
                
    ret.launcher rs.getInt("launcher");
            }
            
    rs.close();
            
    ps.close();

            
    String sql "SELECT * FROM inventoryitems " "LEFT JOIN inventoryequipment USING (inventoryitemid) " "WHERE characterid = ?";
            if (!
    channelserver) {
                
    sql += " AND inventorytype = " MapleInventoryType.EQUIPPED.getType();
            }
            
    ps con.prepareStatement(sql);
            
    ps.setInt(1charid);
            
    rs ps.executeQuery();
            while (
    rs.next()) {
                
    MapleInventoryType type MapleInventoryType.getByType((byters.getInt("inventorytype"));
                if (
    type.equals(MapleInventoryType.EQUIP) || type.equals(MapleInventoryType.EQUIPPED)) {
                    
    int itemid rs.getInt("itemid");
                    
    Equip equip = new Equip(itemid, (byters.getInt("position"), rs.getInt("ringid"));
                    
    equip.setOwner(rs.getString("owner"));
                    
    equip.setQuantity((shortrs.getInt("quantity"));
                    
    equip.setAcc((shortrs.getInt("acc"));
                    
    equip.setAvoid((shortrs.getInt("avoid"));
                    
    equip.setDex((shortrs.getInt("dex"));
                    
    equip.setHands((shortrs.getInt("hands"));
                    
    equip.setHp((shortrs.getInt("hp"));
                    
    equip.setInt((shortrs.getInt("int"));
                    
    equip.setJump((shortrs.getInt("jump"));
                    
    equip.setLuk((shortrs.getInt("luk"));
                    
    equip.setMatk((shortrs.getInt("matk"));
                    
    equip.setMdef((shortrs.getInt("mdef"));
                    
    equip.setMp((shortrs.getInt("mp"));
                    
    equip.setSpeed((shortrs.getInt("speed"));
                    
    equip.setStr((shortrs.getInt("str"));
                    
    equip.setWatk((shortrs.getInt("watk"));
                    
    equip.setWdef((shortrs.getInt("wdef"));
                    
    equip.setUpgradeSlots((byters.getInt("upgradeslots"));
                    
    equip.setLocked((byters.getInt("locked"));
                    
    equip.setLevel((byters.getInt("level"));
                    
    equip.setExpiration(rs.getLong("expiration"));
                    
    equip.setVicious((shortrs.getInt("vicious"));
                    
    ret.getInventory(type).addFromDB(equip);
                    if (
    equip.getRingId() > -1) {
                        
    ret.addRingToCache(equip.getRingId());
                    }
                } else {
                    
    Item item = new Item(rs.getInt("itemid"), (byters.getInt("position"), (shortrs.getInt("quantity"), rs.getInt("petid"));
                    
    item.setOwner(rs.getString("owner"));
                    
    item.setExpiration(rs.getLong("expiration"));
                    
                    
    ret.getInventory(type).addFromDB(item);
                }
            }
            
    rs.close();
            
    ps.close();
            
    //有角色連進頻道
            
    if (channelserver) {
                    
    ps con.prepareStatement("SELECT * FROM queststatus WHERE characterid = ?");
                    
    ps.setInt(1charid);
                    
    rs ps.executeQuery();
                    
    PreparedStatement pse con.prepareStatement("SELECT * FROM questprogress WHERE queststatusid = ?");
                    
                        while (
    rs.next()) {
                            
    System.out.println("Load quests");
                            
    MapleQuest q MapleQuest.getInstance(rs.getShort("quest"));
                            
    MapleQuestStatus status = new MapleQuestStatus(qMapleQuestStatus.Status.getById(rs.getInt("status")));
                            
                            
    long cTime rs.getLong("time");
                            if (
    cTime > -1) {
                                
    status.setCompletionTime(cTime 1000 );
                            }
                            
                            
    status.setForfeited(rs.getInt("forfeited"));
                            
    ret.quests.put(q.getId(), status);
                            
    pse.setInt(1rs.getInt("queststatusid"));
                            try (
    ResultSet rsProgress pse.executeQuery()) {
                                while (
    rsProgress.next()) {
                                    
    status.setProgress(rsProgress.getInt("progressid"), rsProgress.getString("progress"));
                                }
                            }
                            
                        }
                        
    rs.close();
                        
    ps.close();
                        
    pse.close();
                
                
    ps con.prepareStatement("SELECT skillid,skilllevel,masterlevel FROM skills WHERE characterid = ?");
                
    ps.setInt(1charid);
                
    rs ps.executeQuery();
                while (
    rs.next()) {
                    
    //System.out.println("載入技能");
                    
    ret.skills.put(SkillFactory.getSkill(rs.getInt("skillid")), new SkillEntry(rs.getInt("skilllevel"), rs.getInt("masterlevel")));
                }
                
    rs.close();
                
    ps.close();

                
    ps con.prepareStatement("SELECT * FROM skillmacros WHERE characterid = ?");
                
    ps.setInt(1charid);
                
    rs ps.executeQuery();
                while (
    rs.next()) {
                    
    //System.out.println("載入技能組");
                    
    int skill1 rs.getInt("skill1");
                    
    int skill2 rs.getInt("skill2");
                    
    int skill3 rs.getInt("skill3");
                    
    String name rs.getString("name");
                    
    int shout rs.getInt("shout");
                    
    int position rs.getInt("position");
                    
    SkillMacro macro = new SkillMacro(skill1skill2skill3nameshoutposition);
                    
    ret.skillMacros[position] = macro;
                }
                
    rs.close();
                
    ps.close();

                
    ps con.prepareStatement("SELECT `key`,`type`,`action` FROM keymap WHERE characterid = ?");
                
    ps.setInt(1charid);
                
    rs ps.executeQuery();
                while (
    rs.next()) {
                    
    //System.out.println("載入鍵盤");
                    
    int key rs.getInt("key");
                    
    int type rs.getInt("type");
                    
    int action rs.getInt("action");
                    
    ret.keymap.put(Integer.valueOf(key), new MapleKeyBinding(typeaction));
                }
                
    rs.close();
                
    ps.close();

                
    ps con.prepareStatement("SELECT `locationtype`,`map` FROM savedlocations WHERE characterid = ?");
                
    ps.setInt(1charid);
                
    rs ps.executeQuery();
                while (
    rs.next()) {
                    
    String locationType rs.getString("locationtype");
                    
    int mapid rs.getInt("map");
                    
    ret.savedLocations[SavedLocationType.valueOf(locationType).ordinal()] = mapid;
                }
                
    rs.close();
                
    ps.close();

                
    ps con.prepareStatement("SELECT `characterid_to`,`when` FROM famelog WHERE characterid = ? AND DATEDIFF(NOW(),`when`) < 30");
                
    ps.setInt(1charid);
                
    rs ps.executeQuery();
                
    ret.lastfametime 0;
                
    ret.lastmonthfameids = new ArrayList<Integer>(31);
                while (
    rs.next()) {
                    
    ret.lastfametime Math.max(ret.lastfametimers.getTimestamp("when").getTime());
                    
    ret.lastmonthfameids.add(Integer.valueOf(rs.getInt("characterid_to")));
                }
                
    rs.close();
                
    ps.close();
                
    ps con.prepareStatement("SELECT `sn` FROM wishlist WHERE `characterid` = ?");
                
    ps.setInt(1ret.id);
                
    rs ps.executeQuery();
                while (
    rs.next()) {
                    
    ret.wishList.add(rs.getInt("sn"));
                }
                
    rs.close();
                
    ps.close();
                
                
    ret.buddylist.loadFromDb(charid);
                
    ret.storage MapleStorage.loadOrCreateFromDB(ret.accountid);
                
            }
           if (
    ret.getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -18) != null) {
                
    ret.maplemount = new MapleMount(retret.getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -18).getItemId(), 1004);
                
    ret.maplemount.setExp(mountexp);
                
    ret.maplemount.setLevel(mountlevel);
                
    ret.maplemount.setTiredness(mounttiredness);
                
    ret.maplemount.setActive(false);
            } else {
                
    ret.maplemount = new MapleMount(ret01004);
                
    ret.maplemount.setExp(mountexp);
                
    ret.maplemount.setLevel(mountlevel);
                
    ret.maplemount.setTiredness(mounttiredness);
                
    ret.maplemount.setActive(false);
            }
            
    ret.recalcLocalStats();
            
    ret.silentEnforceMaxHpMp();
            return 
    ret;
         } catch (
    SQLException RuntimeException e) {
                
    e.printStackTrace();
            }
            return 
    null;
        } 




Advertisement