Browse Source

BETA: Fixing IndexOutOfBoundsException within effects.
* Reported by: LeoDetona, oscard, takhs7, Torvitas
* Reviewed by: Zoey76

Rumen Nikiforov 11 years ago
parent
commit
7ae513bf31

+ 8 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/CharEffectList.java

@@ -840,7 +840,14 @@ public final class CharEffectList
 						}
 						pos++;
 					}
-					_buffs.add(pos, effect);
+					if (pos >= _buffs.size())
+					{
+						_buffs.add(effect);
+					}
+					else
+					{
+						_buffs.add(pos, effect);
+					}
 				}
 			}
 		}

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/effects/L2Effect.java

@@ -308,7 +308,7 @@ public abstract class L2Effect implements IChanceSkillTrigger
 		if (_template.getTotalTickCount() > 0)
 		{
 			// TODO: If default abnormal time is changed to 0, the first check below must be updated as well.
-			final int period = ((_abnormalTime > 1) ? (_abnormalTime / _template.getTotalTickCount()) : _template.getTotalTickCount()) * 1000;
+			final int period = ((_abnormalTime > 1) ? Math.max(_abnormalTime / _template.getTotalTickCount(), 1) : _template.getTotalTickCount()) * 1000;
 			_currentFuture = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(new EffectTask(), delay / period, period);
 		}
 		else