2
0
Эх сурвалжийг харах

BETA: Misc fixes:
* NPE vulnerability:
1. L2EffectPointInstance
* Unnecessary math operations:
1. RecoBonus
* Unexpected result ([C@e0b6f5) from [4901]
1. java/com/l2jserver/gameserver/util/Util
* Out-dated GPL notice:
1. StringUtil
1. java/com/l2jserver/util/Util

'''Note:''' StringUtil should be optimized and probably merged with some utility classes.

Zoey76 13 жил өмнө
parent
commit
b723467324

+ 4 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2EffectPointInstance.java

@@ -29,7 +29,10 @@ public class L2EffectPointInstance extends L2Npc
 		setInstanceType(InstanceType.L2EffectPointInstance);
 		setIsInvul(false);
 		_owner = owner == null ? null : owner.getActingPlayer();
-		setInstanceId(owner.getInstanceId());
+		if (owner != null)
+		{
+			setInstanceId(owner.getInstanceId());
+		}
 	}
 	
 	@Override

+ 2 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/RecoBonus.java

@@ -40,8 +40,8 @@ public final class RecoBonus
 			if (activeChar.getRecomHave() == 0)
 				return 0;
 			
-			int _lvl = (int) Math.ceil(activeChar.getLevel()/10);
-			int _exp = (int) Math.ceil((Math.min(100, activeChar.getRecomHave())-1)/10);
+			int _lvl = activeChar.getLevel() / 10;
+			int _exp = (Math.min(100, activeChar.getRecomHave()) - 1) / 10;
 			
 			return _recoBonus[_lvl][_exp];
 		}

+ 5 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/util/Util.java

@@ -157,15 +157,17 @@ public final class Util
 	public static String capitalizeFirst(String str)
 	{
 		if (str == null || str.isEmpty())
+		{
 			return str;
-		
+		}
 		final char[] arr = str.toCharArray();
 		final char c = arr[0];
 		
 		if (Character.isLetter(c))
+		{
 			arr[0] = Character.toUpperCase(c);
-		
-		return arr.toString();
+		}
+		return new String(arr);
 	}
 	
 	/**

+ 8 - 15
L2J_Server_BETA/java/com/l2jserver/util/StringUtil.java

@@ -1,21 +1,14 @@
 /*
- * $Header$
+ * 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.
  * 
- * $Author: fordfrog $ $Date$ $Revision$ $Log$
+ * 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.
  * 
- * 
- * 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/>.
+ * 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.util;
 

+ 8 - 18
L2J_Server_BETA/java/com/l2jserver/util/Util.java

@@ -1,23 +1,14 @@
 /*
- * $Header: Util.java, 14-Jul-2005 03:27:51 luisantonioa Exp $
+ * 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.
  * 
- * $Author: luisantonioa $ $Date: 14-Jul-2005 03:27:51 $ $Revision: 1 $ $Log:
- * Util.java,v $ Revision 1 14-Jul-2005 03:27:51 luisantonioa Added copyright
- * notice
+ * 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.
  * 
- * 
- * 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/>.
+ * 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.util;
 
@@ -32,7 +23,6 @@ import java.nio.ByteBuffer;
  * 
  * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
  */
-
 public class Util
 {
 	/**