client.getTrace()

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
dleogr
Posts: 34
Joined: Fri Nov 13, 2009 5:56 pm

client.getTrace()

Post by dleogr »

Hello
I have a problem and i need some help about:
IpPack pack = new IpPack(client.getAdress(), client.getTrace());
Is a part of code from MultiBoxProtection.java (Sorry i cant post there since i dont have 20 posts)
So i have problem on eclipse with this one: client.getTrace());
Any idea ?
User avatar
Tavo22
Posts: 258
Joined: Mon Mar 22, 2010 8:14 pm

Re: client.getTrace()

Post by Tavo22 »

With the last rev the patch works fine.
But suddenly i get this error
Exception in thread "SelectorThread-216" java.lang.NullPointerException
at com.l2jserver.gameserver.network.MultiBoxProtection$IpPack.hashCode(MultiBoxProtection.java:122)
at javolution.util.FastMap.getEntry(FastMap.java:418)
at javolution.util.FastMap.get(FastMap.java:406)
at com.l2jserver.gameserver.network.MultiBoxProtection.removeConnection(MultiBoxProtection.java:83)
at com.l2jserver.gameserver.network.L2GameClient.onForcedDisconnection(L2GameClient.java:575)
at org.mmocore.network.SelectorThread.readPacket(SelectorThread.java:321)
at org.mmocore.network.SelectorThread.run(SelectorThread.java:176)
and the server crash.
charly911
Posts: 3
Joined: Thu Nov 06, 2008 4:03 am

Re: client.getTrace()

Post by charly911 »

Tavo22 wrote:With the last rev the patch works fine.
But suddenly i get this error
Exception in thread "SelectorThread-216" java.lang.NullPointerException
at com.l2jserver.gameserver.network.MultiBoxProtection$IpPack.hashCode(MultiBoxProtection.java:122)
at javolution.util.FastMap.getEntry(FastMap.java:418)
at javolution.util.FastMap.get(FastMap.java:406)
at com.l2jserver.gameserver.network.MultiBoxProtection.removeConnection(MultiBoxProtection.java:83)
at com.l2jserver.gameserver.network.L2GameClient.onForcedDisconnection(L2GameClient.java:575)
at org.mmocore.network.SelectorThread.readPacket(SelectorThread.java:321)
at org.mmocore.network.SelectorThread.run(SelectorThread.java:176)
and the server crash.
Same problem here, what is your L2J, L2JDP version?
User avatar
Tavo22
Posts: 258
Joined: Mon Mar 22, 2010 8:14 pm

Re: client.getTrace()

Post by Tavo22 »

L2J Revision Number: 4411
L2JDP Revision Number: 7664

The problem is here, but i really dont know how this method works...

Code: Select all

        @Override        public int hashCode()        {            final int prime = 31;            int result = 1;            result = prime * result + ((ip == null) ? 0 : ip.hashCode());            for (int[] array: tracert)                result = prime * result + Arrays.hashCode(array);            return result;        }
charly911
Posts: 3
Joined: Thu Nov 06, 2008 4:03 am

Re: client.getTrace()

Post by charly911 »

What the H*** is this?

for (int[] array: tracert)
Probe
Posts: 915
Joined: Thu Sep 03, 2009 6:36 pm
Location: Israel
Contact:

Re: client.getTrace()

Post by Probe »

it's an iteration over every array inside tracert
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: client.getTrace()

Post by JIV »

it just compute hashcode for multidimensional array, afaik it was generated by eclipse.
reason why you get npe is tracert is null because it wasnt set yet, called disconnection before enterworld.
User avatar
Tavo22
Posts: 258
Joined: Mon Mar 22, 2010 8:14 pm

Re: client.getTrace()

Post by Tavo22 »

Thanks Jiv! now is working =)
kama3a
Posts: 125
Joined: Mon Jul 07, 2008 4:01 pm

Re: client.getTrace()

Post by kama3a »

can some one explain better...
coz i didnt get what mean jiv.. :)
what exactly is the fix...
User avatar
Tavo22
Posts: 258
Joined: Mon Mar 22, 2010 8:14 pm

Re: client.getTrace()

Post by Tavo22 »

You are calling the removeConnection before EnterWorld, so you don't have tracert.
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((ip == null) ? 0 : ip.hashCode());
if(tracert == null)
return result;

for (int[] array: tracert)
result = prime * result + Arrays.hashCode(array);
return result;
}
dleogr
Posts: 34
Joined: Fri Nov 13, 2009 5:56 pm

Re: client.getTrace()

Post by dleogr »

Sorry but i cant really understand. I have error on eclipse and the error say: they cant find it on L2GameClient.java.
So i think is at least my error is not somthing about pre or post enter world.
I'm wrong about that ?
That is what i got from error on my eclipse.
Sorry for my english and let me know where i'm wrong please!

PS: client.getTrace() exactly here is the problem on my eclipse.
maxstyleboy
Posts: 183
Joined: Thu Jul 15, 2010 12:26 am

Re: client.getTrace()

Post by maxstyleboy »

I'm having some errors.

Code: Select all

    [javac] C:\L2jServer\GameServer\java\com\l2jserver\gameserver\network\MultiBoxProtection.java:49: cannot find symbol    [javac] symbol  : method getAdress()    [javac] location: class com.l2jserver.gameserver.network.L2GameClient    [javac]         IpPack pack = new IpPack(client.getAdress(), client.getTrace());    [javac]                                        ^    [javac] C:\L2jServer\GameServer\java\com\l2jserver\gameserver\network\MultiBoxProtection.java:56: cannot find symbol    [javac] symbol  : method getAdress()    [javac] location: class com.l2jserver.gameserver.network.L2GameClient    [javac]                 _log.info("MultiBoxProtection.registerNewConnection(): Set Count for: "+ client.getActiveChar().getName() +" (" + client.getAdress() + ") to " + count);    [javac]                                                                                                                                         ^    [javac] C:\L2jServer\GameServer\java\com\l2jserver\gameserver\network\MultiBoxProtection.java:64: cannot find symbol    [javac] symbol  : method getAdress()    [javac] location: class com.l2jserver.gameserver.network.L2GameClient    [javac]                 _log.info("MultiBoxProtection.registerNewConnection(): Increase Count for: "+ client.getActiveChar().getName() +" (" + client.getAdress() + ") to " + count);    [javac]                                                                                                                                              ^    [javac] C:\L2jServer\GameServer\java\com\l2jserver\gameserver\network\MultiBoxProtection.java:72: cannot find symbol    [javac] symbol  : method getAdress()    [javac] location: class com.l2jserver.gameserver.network.L2GameClient    [javac]                 _log.info("MultiBoxProtection.registerNewConnection(): Count for: "+ client.getActiveChar().getName() +" (" + client.getAdress() + ") is " + count);    [javac]                                                                                                                                     ^    [javac] C:\L2jServer\GameServer\java\com\l2jserver\gameserver\network\MultiBoxProtection.java:82: cannot find symbol    [javac] symbol  : method getAdress()    [javac] location: class com.l2jserver.gameserver.network.L2GameClient    [javac]         IpPack pack = new IpPack(client.getAdress(), client.getTrace());    [javac]                                        ^    [javac] C:\L2jServer\GameServer\java\com\l2jserver\gameserver\network\MultiBoxProtection.java:89: cannot find symbol    [javac] symbol  : method getAdress()    [javac] location: class com.l2jserver.gameserver.network.L2GameClient    [javac]                 _log.info("MultiBoxProtection.removeConnection(): Decrease Count for: "+ client.getActiveChar().getName() +" (" + client.getAdress() + ") to " + count);    [javac]                                                                                                                                         ^    [javac] C:\L2jServer\GameServer\java\com\l2jserver\gameserver\network\MultiBoxProtection.java:95: cannot find symbol    [javac] symbol  : method getAdress()    [javac] location: class com.l2jserver.gameserver.network.L2GameClient    [javac]                 _log.info("MultiBoxProtection.removeConnection(): Remove Count for: "+ client.getActiveChar().getName() +" (" + client.getAdress() + ")");    [javac]                                                                                                                                       ^    [javac] 7 errors
MultiBoxProtection.java

Code: Select all

/* * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. *  * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. *  * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */package com.l2jserver.gameserver.network;  import java.util.Arrays;import java.util.Map;import java.util.logging.Logger; import com.l2jserver.Config; import javolution.util.FastMap;  /** * @author JIV * */public class MultiBoxProtection{    protected static final Logger _log = Logger.getLogger(MultiBoxProtection.class.getName());        private Map<IpPack, Integer> map;        public static MultiBoxProtection getInstance()    {        return SingletonHolder._instance;    }        public MultiBoxProtection()    {        map = new FastMap<MultiBoxProtection.IpPack, Integer>();    }        public synchronized boolean registerNewConnection(L2GameClient client)    {        IpPack pack = new IpPack(client.getAdress(), client.getTrace());        Integer count = map.get(pack);        if (count == null)        {            count = 1;            map.put(pack, count);            if (Config.DEVELOPER)                _log.info("MultiBoxProtection.registerNewConnection(): Set Count for: "+ client.getActiveChar().getName() +" (" + client.getAdress() + ") to " + count);            return true;        }        else if (count < Config.MAX_PLAYERS_FROM_ONE_PC)        {            count++;            map.put(pack, count);            if (Config.DEVELOPER)                _log.info("MultiBoxProtection.registerNewConnection(): Increase Count for: "+ client.getActiveChar().getName() +" (" + client.getAdress() + ") to " + count);            return true;        }        else        {            count++;            map.put(pack, count);            if (Config.DEVELOPER)                _log.info("MultiBoxProtection.registerNewConnection(): Count for: "+ client.getActiveChar().getName() +" (" + client.getAdress() + ") is " + count);            return false;        }    }        public synchronized void removeConnection(L2GameClient client)    {        if (client == null)            return;                IpPack pack = new IpPack(client.getAdress(), client.getTrace());        Integer count = map.get(pack);        if (count != null && count > 1)        {            count--;            map.put(pack, count);            if (Config.DEVELOPER)                _log.info("MultiBoxProtection.removeConnection(): Decrease Count for: "+ client.getActiveChar().getName() +" (" + client.getAdress() + ") to " + count);        }        else        {            map.remove(pack);            if (Config.DEVELOPER)                _log.info("MultiBoxProtection.removeConnection(): Remove Count for: "+ client.getActiveChar().getName() +" (" + client.getAdress() + ")");        }    }        @SuppressWarnings("synthetic-access")    private static class SingletonHolder    {        protected static final MultiBoxProtection _instance = new MultiBoxProtection();    }        public final static class IpPack    {        String ip;        int[][] tracert;                public IpPack(String ip, int[][] tracert)        {            this.ip = ip;            this.tracert = tracert;        }         @Override        public int hashCode()        {            final int prime = 31;            int result = 1;            result = prime * result + ((ip == null) ? 0 : ip.hashCode());            for (int[] array: tracert)                result = prime * result + Arrays.hashCode(array);            return result;        }         @Override        public boolean equals(Object obj)        {            if (this == obj)                return true;            if (obj == null)                return false;            if (getClass() != obj.getClass())                return false;            IpPack other = (IpPack) obj;            if (ip == null)            {                if (other.ip != null)                    return false;            }            else if (!ip.equals(other.ip))                return false;            for (int i = 0 ; i < tracert.length; i++)                for (int o = 0; o < tracert[0].length; o++)                    if (tracert[i][o] != other.tracert[i][o])                        return false;            return true;        }     }}  
Can anyone help me?
Limitless
Posts: 34
Joined: Tue May 13, 2008 4:32 am

Re: client.getTrace()

Post by Limitless »

charly911 wrote:What the H*** is this?

for (int[] array: tracert)
put at the int array : the int tracert
Post Reply