Some Features :D

    Share

    micr0

    Posts : 72
    Join date : 2013-01-23
    Age : 23
    Location : Bulgaria

    Some Features :D

    Post  micr0 on 9th April 2013, 07:47

    Protocol Version
    WeightLimit option Fani request click me

    Code:
    ### Eclipse Workspace Patch 1.0
    #P Lisvus_GameServer
    Index: java/net/sf/l2j/Config.java
    ===================================================================
    --- java/net/sf/l2j/Config.java   (revision 367)
    +++ java/net/sf/l2j/Config.java   (working copy)
    @@ -24,8 +24,10 @@
     import java.io.InputStream;
     import java.io.OutputStream;
     import java.math.BigInteger;
    +import java.util.ArrayList;
     import java.util.List;
     import java.util.Properties;
    +import java.util.logging.Level;
     import java.util.logging.Logger;
     
     import javolution.util.FastList;
    @@ -158,6 +160,8 @@
     
        /** Alternative gameing - magic dmg failures */
        public static boolean ALT_GAME_MAGICFAILURES;
    +   
    +   public static double ALT_WEIGHT_LIMIT;
     
        /** Alternative gaming - player must be in a castle-owning clan or ally to sign up for Dawn. */
        public static boolean ALT_GAME_REQUIRE_CASTLE_DAWN;
    @@ -582,10 +586,7 @@
        public static boolean ALLOW_WYVERN_UPGRADER;
     
        // protocol revision
    -    /** Minimal protocol revision */
    -    public static int MIN_PROTOCOL_REVISION;
    -    /** Maximal protocol revision */
    -    public static int MAX_PROTOCOL_REVISION;
    +   public static List<Integer> PROTOCOL_LIST;
     
        // random animation interval
        /** Minimal time between 2 animations of a NPC */
    @@ -1143,13 +1144,19 @@
                    MAX_CHARACTERS_NUMBER_PER_ACCOUNT = Integer.parseInt(serverSettings.getProperty("CharMaxNumber", "7"));
                    MAXIMUM_ONLINE_USERS        = Integer.parseInt(serverSettings.getProperty("MaximumOnlineUsers", "100"));
                   
    -                MIN_PROTOCOL_REVISION  = Integer.parseInt(serverSettings.getProperty("MinProtocolRevision", "660"));
    -                MAX_PROTOCOL_REVISION  = Integer.parseInt(serverSettings.getProperty("MaxProtocolRevision", "665"));
    -               
    -                if (MIN_PROTOCOL_REVISION > MAX_PROTOCOL_REVISION)
    -                {
    -                    throw new Error("MinProtocolRevision is bigger than MaxProtocolRevision in server configuration file.");
    -                }
    +            String[] protocols = serverSettings.getProperty("AllowedProtocolRevisions", "655;656").split(";");
    +            PROTOCOL_LIST = new ArrayList<>(protocols.length);
    +            for (String protocol : protocols)
    +            {
    +               try
    +               {
    +                  PROTOCOL_LIST.add(Integer.parseInt(protocol.trim()));
    +               }
    +               catch (NumberFormatException e)
    +               {
    +                  _log.log(Level.WARNING, "Wrong config protocol version: " + protocol + ". Skipped.");
    +               }
    +            }
                }
                catch (Exception e)
                {
    @@ -1591,7 +1598,8 @@
                    ALT_GAME_DELEVEL            = Boolean.parseBoolean(altSettings.getProperty("Delevel", "true"));
                        Boost_EXP_COMMAND          = Boolean.parseBoolean(altSettings.getProperty("SpExpCommand", "False"));
                       ALT_GAME_MAGICFAILURES      = Boolean.parseBoolean(altSettings.getProperty("MagicFailures", "false"));
    -               ALT_GAME_MOB_ATTACK_AI      = Boolean.parseBoolean(altSettings.getProperty("AltGameMobAttackAI", "false"));
    +            ALT_WEIGHT_LIMIT = Double.parseDouble(altSettings.getProperty("AltWeightLimit", "1"));
    +            ALT_GAME_MOB_ATTACK_AI = Boolean.parseBoolean(altSettings.getProperty("AltGameMobAttackAI", "false"));
                    ALT_GAME_EXPONENT_XP        = Float.parseFloat(altSettings.getProperty("AltGameExponentXp", "0."));
                    ALT_GAME_EXPONENT_SP        = Float.parseFloat(altSettings.getProperty("AltGameExponentSp", "0."));
                        NPC_BUFFER_ENABLED          = Boolean.valueOf(altSettings.getProperty("NPCBufferEnabled", "False"));
    Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 367)
    +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
    @@ -170,6 +170,7 @@
     import net.sf.l2j.gameserver.serverpackets.TradeStart;
     import net.sf.l2j.gameserver.serverpackets.UserInfo;
     import net.sf.l2j.gameserver.serverpackets.ValidateLocation;
    +import net.sf.l2j.gameserver.skills.BaseStats;
     import net.sf.l2j.gameserver.skills.Formulas;
     import net.sf.l2j.gameserver.skills.Stats;
     import net.sf.l2j.gameserver.templates.L2Armor;
    @@ -1902,24 +1903,18 @@
        }
     
        /**
    -    * Return the max weight that the L2PcInstance can load.<BR><BR>
    -    */
    -    public int getMaxLoad()
    -    {
    -        int con = getCON();
    +    * Return the max weight that the L2PcInstance can load.<BR>
    +    * <BR>
    +    * @return
    +    */
    +   public int getMaxLoad()
    +   {
    +      // Weight Limit = (CON Modifier*69000) * Skills
    +      // Source http://l2p.bravehost.com/weightlimit.html (May 2007)
    +      double baseLoad = Math.floor(BaseStats.CON.calcBonus(this) * 69000 * Config.ALT_WEIGHT_LIMIT);
    +      return (int) calcStat(Stats.MAX_LOAD, baseLoad, this, null);
    +   }
     
    -        if (con < 1)
    -            return 31000;
    -
    -        if (con > 59)
    -            return 176000;
    -
    -
    -        double baseLoad = Math.pow(1.029993928, con)*30495.627366;
    -
    -        return (int)calcStat(Stats.MAX_LOAD, baseLoad, this, null);
    -    }
    -
        public int getExpertisePenalty()
        {
            return _expertisePenalty;
    @@ -1941,7 +1936,7 @@
        {
            if (getMaxLoad() > 0)
            {
    -            int weightproc = getCurrentLoad() * 1000 / getMaxLoad();
    +         long weightproc = (long) ((getCurrentLoad() - calcStat(Stats.MAX_LOAD, 1, this, null)) * 1000 / getMaxLoad());
                int newWeightPenalty;
                if (weightproc < 500 || _dietMode)
                    newWeightPenalty = 0;
    Index: java/net/sf/l2j/loginserver/ClientThread.java
    ===================================================================
    --- java/net/sf/l2j/loginserver/ClientThread.java   (revision 367)
    +++ java/net/sf/l2j/loginserver/ClientThread.java   (working copy)
    @@ -147,9 +147,8 @@
                    checksumOk = _crypt.checksum(decrypt);
     
                    if (!checksumOk)
    -                {
    -
    -                    _log.warning("Client is not using latest Authentication method. (Min is " + Config.MIN_PROTOCOL_REVISION + ")");
    +                {
    +               _log.warning("Client is not using latest Authentication method. (Min is " + Config.PROTOCOL_LIST + ")");
                        break;
                    }
     
    Index: java/config/server.properties
    ===================================================================
    --- java/config/server.properties   (revision 367)
    +++ java/config/server.properties   (working copy)
    @@ -64,8 +64,8 @@
     # Define how many players are allowed to play simultaneously on your server.
     MaximumOnlineUsers=100
     
    -
    -# Minimum and maximum protocol revision that server allow to connect.
    -# You must keep MinProtocolRevision <= MaxProtocolRevision.
    -MinProtocolRevision = 656
    -MaxProtocolRevision = 665
    +# Numbers of protocol revisions that server allows to connect.
    +# Delimiter is ;
    +# WARNING: <u><b><font color="red">Changing the protocol revision may result in incompatible communication and many errors in game!</font></b></u>
    +# Default: 655;656
    +AllowedProtocolRevisions = 655;656
    Index: java/config/altsettings.properties
    ===================================================================
    --- java/config/altsettings.properties   (revision 367)
    +++ java/config/altsettings.properties   (working copy)
    @@ -20,6 +20,10 @@
     # If XP loss (and deleveling) is enabled, default is 'true'
     Delevel = True
     
    +# Weight limit multiplier. Example: Setting this to 5 will give players 5x the normal weight limit.
    +# Default: 1
    +AltWeightLimit = 1
    +
     # If disabled, magic dmg has always 100% chance of success, default is 'true'
     MagicFailures = True
     
    Index: java/net/sf/l2j/gameserver/clientpackets/ProtocolVersion.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/clientpackets/ProtocolVersion.java   (revision 367)
    +++ java/net/sf/l2j/gameserver/clientpackets/ProtocolVersion.java   (working copy)
    @@ -28,84 +28,78 @@
     
     /**
      * This class ...
    - *
      * @version $Revision: 1.5.2.8.2.8 $ $Date: 2005/04/02 10:43:04 $
      */
     public class ProtocolVersion extends ClientBasePacket
     {
    -    private static final String _C__00_PROTOCOLVERSION = "[C] 00 ProtocolVersion";
    -    static Logger _log = Logger.getLogger(ProtocolVersion.class.getName());
    -
    -    private final long _version;
    -
    -    /**
    -    * packet type id 0x00
    -    * format:   cd
    -    * 
    -    * @param rawPacket
    -    */
    -    public ProtocolVersion(ByteBuffer buf, ClientThread client)
    -    {
    -        super(buf, client);
    -        _version  = readD();
    -        // ignore the rest
    -        while (buf.hasRemaining())
    -            buf.get();
    -    }
    -
    -    /** urgent messages, execute immediately */
    -    public TaskPriority getPriority()
    -    {
    -        return TaskPriority.PR_HIGH;
    -    }
    -
    -    @Override
    -    public void runImpl()
    -    {
    -        // this packet is never encrypted
    -        if (_version == -2)
    -        {
    -            if (Config.DEBUG)
    -                _log.info("Ping received");
    -
    -            // this is just a ping attempt from the new C2 client
    -            getConnection().close();
    -            return;
    -        }
    -
    -
    -        if (_version < Config.MIN_PROTOCOL_REVISION || _version > Config.MAX_PROTOCOL_REVISION)
    -        {
    -            _log.info("Client: "+getClient().toString()+" -> Protocol Revision: " + _version + " is invalid. Minimum is "+Config.MIN_PROTOCOL_REVISION+" and Maximum is "+Config.MAX_PROTOCOL_REVISION+" are supported. Closing connection.");
    -            _log.warning("Wrong Protocol Version "+_version);
    -
    -
    -            getClient().setProtocolOk(false);
    -
    -        }
    -
    -        else
    -        {
    -            getClient().setRevision((int)_version);
    -            if (Config.DEBUG)
    -                _log.fine("Client Protocol Revision is ok:"+_version);
    -
    -            getClient().setProtocolOk(true);
    -
    -
    -        }
    -
    -        sendPacket(new KeyPacket(getConnection()));
    -
    -        getConnection().activateCryptKey();
    -
    -    }
    -
    -    /* (non-Javadoc)
    -    * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
    -    */
    -    public String getType()
    -    {
    -        return _C__00_PROTOCOLVERSION;
    -    }
    +   private static final String _C__00_PROTOCOLVERSION = "[C] 00 ProtocolVersion";
    +   static Logger _log = Logger.getLogger(ProtocolVersion.class.getName());
    +   
    +   private final long _version;
    +   
    +   /**
    +    * packet type id 0x00 format: cd
    +    * @param buf
    +    * @param client
    +    */
    +   public ProtocolVersion(ByteBuffer buf, ClientThread client)
    +   {
    +      super(buf, client);
    +      _version = readD();
    +      // ignore the rest
    +      while (buf.hasRemaining())
    +         buf.get();
    +   }
    +   
    +   /**
    +    * urgent messages, execute immediately
    +    * @return
    +    */
    +   @Override
    +   public TaskPriority getPriority()
    +   {
    +      return TaskPriority.PR_HIGH;
    +   }
    +   
    +   @Override
    +   public void runImpl()
    +   {
    +      // this packet is never encrypted
    +      if (_version == -2)
    +      {
    +         if (Config.DEBUG)
    +            _log.info("Ping received");
    +         
    +         // this is just a ping attempt from the new C2 client
    +         getConnection().close();
    +         return;
    +      }
    +      
    +      else if (!Config.PROTOCOL_LIST.contains(_version))
    +      {
    +         _log.warning("Wrong Protocol Version " + _version);
    +         getClient().setProtocolOk(false);
    +      }
    +      else
    +      {
    +         getClient().setRevision((int) _version);
    +         if (Config.DEBUG)
    +            _log.fine("Client Protocol Revision is ok:" + _version);
    +         getClient().setProtocolOk(true);
    +      }
    +      
    +      sendPacket(new KeyPacket(getConnection()));
    +      getConnection().activateCryptKey();
    +      
    +   }
    +   
    +   /*
    +    * (non-Javadoc)
    +    * @see net.sf.l2j.gameserver.clientpackets.ClientBasePacket#getType()
    +    */
    +   @Override
    +   public String getType()
    +   {
    +      return _C__00_PROTOCOLVERSION;
    +   }
     }
    Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PetInstance.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/actor/instance/L2PetInstance.java   (revision 367)
    +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PetInstance.java   (working copy)
    @@ -57,6 +57,7 @@
     import net.sf.l2j.gameserver.serverpackets.StopMove;
     import net.sf.l2j.gameserver.serverpackets.SystemMessage;
     import net.sf.l2j.gameserver.serverpackets.ValidateLocation;
    +import net.sf.l2j.gameserver.skills.Stats;
     import net.sf.l2j.gameserver.taskmanager.DecayTaskManager;
     import net.sf.l2j.gameserver.templates.L2Item;
     import net.sf.l2j.gameserver.templates.L2NpcTemplate;
    @@ -1095,7 +1096,7 @@
            int maxLoad = getMaxLoad();
            if (maxLoad > 0)
            {
    -            int weightproc = getCurrentLoad() * 1000 / maxLoad;
    +         long weightproc = (long) ((getCurrentLoad() - calcStat(Stats.MAX_LOAD, 1, this, null)) * 1000 / maxLoad);
                int newWeightPenalty;
                if (weightproc < 500 || getOwner().getDietMode())
                    newWeightPenalty = 0;

      Current date/time is 28th July 2017, 18:03