Jump to content

Recommended Posts

  • 5 weeks later...
  • 4 months later...
Posted

You can have 2 NPEs with this code, because :

- "knows" try to be feed with activeChar's knownlist, even if activeChar isn't ingame.

- "knows" try to search for an object, but imagine you try to enchant in a place where there is no one around ?

 

Correct way is to initialize Collection after the null check, just before the "for". And to include a null check in if (wh instanceof L2WarehouseInstance)

 

So we got (I didn't verify where you putted your "for" loop, let's say it was good) :

 

final Collection<L2Character> knowns  = activeChar.getKnownList().getKnownCharactersInRadius(400);
for (L2Object wh : knowns)
{
    if (wh != null && wh instanceof L2WarehouseInstance)
    {
        activeChar.sendMessage("You cannot enchant near warehouse.");
        return;
    }
}

  • 8 years later...
Posted
On 8/28/2011 at 8:34 PM, Prince* said:

Fix for that: http://maxcheaters.com/forum/index.php?topic=218257.0 and for enchant phx. and other enchant like near wh..

 

 


--- /trunk/gameserver/java/net/sf/l2j/gameserver/clientpackets/RequestEnchantItem.java
+++ /trunk/gameserver/java/net/sf/l2j/gameserver/clientpackets/RequestEnchantItem.java

@@ 20,1 @@

+import java.util.Collection;
import java.util.logging.Logger;

import net.sf.l2j.gameserver.model.Inventory;
+import net.sf.l2j.gameserver.model.L2Character;
import net.sf.l2j.gameserver.model.L2ItemInstance;


import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2WarehouseInstance;
import net.sf.l2j.gameserver.network.SystemMessageId;


import net.sf.l2j.gameserver.model.L2ItemInstance;
+import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2World;


@@ -61,7 +61,15 @@
     {
         L2PcInstance activeChar = getClient().getActiveChar();
+               Collection<L2Character> knowns  = activeChar.getKnownList().getKnownCharactersInRadius(400);
         if (activeChar == null || _objectId == 0)
                        return;
+              
+               for (L2Object wh : knowns)
+               {
+                       if (wh instanceof L2WarehouseInstance)
+                       {
+                               activeChar.sendMessage("You cannot enchant near warehouse.");
+                               return;
+                       }
+               }
         L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
         L2ItemInstance scroll = activeChar.getActiveEnchantItem();
 

 

 

i have search on forum and i don't found any post with that code :)

is any of that for frozen ?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..