Explorar el Código

BETA: Misc fixes:
* NPE vulnerability:
* ValueSortMap, suppressed for now.
* L2Attackable
* NpcBufferTable

Zoey76 hace 13 años
padre
commit
db6d1f82b5

+ 4 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/NpcBufferTable.java

@@ -128,6 +128,10 @@ public class NpcBufferTable
 			{
 				try
 				{
+					if (con == null)
+					{
+						con = L2DatabaseFactory.getInstance().getConnection();
+					}
 					PreparedStatement statement = con.prepareStatement("SELECT `npc_id`,`skill_id`,`skill_level`,`skill_fee_id`,`skill_fee_amount`,`buff_group` FROM `custom_npc_buffer` ORDER BY `npc_id` ASC");
 					ResultSet rset = statement.executeQuery();
 					

+ 3 - 11
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Attackable.java

@@ -601,12 +601,11 @@ public class L2Attackable extends L2Npc
 			
 			int damage;
 			L2Character attacker, ddealer;
-			RewardInfo reward;
 			
 			L2PcInstance maxDealer = null;
 			int maxDamage = 0;
 			
-			// While Interating over This Map Removing Object is Not Allowed
+			// While Iterating over This Map Removing Object is Not Allowed
 			// Go through the _aggroList of the L2Attackable
 			for (AggroInfo info : getAggroList().values())
 			{
@@ -632,7 +631,7 @@ public class L2Attackable extends L2Npc
 						continue;
 					
 					// Calculate real damages (Summoners should get own damage plus summon's damage)
-					reward = rewards.get(ddealer);
+					RewardInfo reward = rewards.get(ddealer);
 					
 					if (reward == null)
 						reward = new RewardInfo(ddealer, damage);
@@ -666,15 +665,8 @@ public class L2Attackable extends L2Npc
 				float partyMul, penalty;
 				RewardInfo reward2;
 				int[] tmp;
-				
-				// TODO: Zoey76: Rewrite, bad iteration, NPE vulnerability, possible concurrent modification.
-				for (FastMap.Entry<L2Character, RewardInfo> entry = rewards.head(), end = rewards.tail(); (entry = entry.getNext()) != end;)
+				for (RewardInfo reward : rewards.values())
 				{
-					if (entry == null)
-						continue;
-					
-					reward = entry.getValue();
-					
 					if (reward == null)
 						continue;
 					

+ 4 - 1
L2J_Server_BETA/java/com/l2jserver/util/ValueSortMap.java

@@ -94,7 +94,10 @@ public class ValueSortMap
 	 * @param ascendingOrder Values will be sorted as per value of ascendingOrder
 	 * @return LinkedHashMap Sorted new LinkedHashMap
 	 */
-	@SuppressWarnings("rawtypes")
+	@SuppressWarnings({
+		"rawtypes",
+		"null"
+	})
 	private static LinkedHashMap sortMapByValue(Map inMap, Comparator comparator, Boolean ascendingOrder)
 	{
 		int iSize = inMap.size();