Trying to prevent mass cancel actions from lagging the area.

Author: Nik
Source: http://www.l2jserver.com/forum/viewtopic.php?f=77&t=31639
This commit is contained in:
MobiusDev 2015-10-20 21:39:49 +00:00
parent 9497505950
commit 1a750ba084

View File

@ -27,12 +27,14 @@ import java.util.Queue;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.logging.Logger; import java.util.logging.Logger;
import com.l2jserver.Config; import com.l2jserver.Config;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.model.actor.L2Character; import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Summon; import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@ -96,6 +98,8 @@ public final class CharEffectList
/** Hidden buffs count, prevents iterations. */ /** Hidden buffs count, prevents iterations. */
private final AtomicInteger _hiddenBuffs = new AtomicInteger(); private final AtomicInteger _hiddenBuffs = new AtomicInteger();
private ScheduledFuture<?> _effectIconsUpdate;
/** /**
* Constructor for effect list. * Constructor for effect list.
* @param owner the creature that owns this effect list * @param owner the creature that owns this effect list
@ -1388,6 +1392,17 @@ public final class CharEffectList
return; return;
} }
// Check if the previous call hasnt finished, if so, don't send packets uselessly again.
if (_effectIconsUpdate != null)
{
if (!_effectIconsUpdate.isDone())
{
return;
}
}
// Schedule the icon update packets 500miliseconds ahead, so it can gather-up most of the changes.
_effectIconsUpdate = ThreadPoolManager.getInstance().scheduleGeneral(() ->
{
AbnormalStatusUpdate asu = null; AbnormalStatusUpdate asu = null;
PartySpelled ps = null; PartySpelled ps = null;
PartySpelled psSummon = null; PartySpelled psSummon = null;
@ -1456,7 +1471,7 @@ public final class CharEffectList
} }
} }
// Songs and dances. // Toggles.
if (hasToggles()) if (hasToggles())
{ {
for (BuffInfo info : getToggles()) for (BuffInfo info : getToggles())
@ -1511,6 +1526,9 @@ public final class CharEffectList
game.getZone().broadcastPacketToObservers(os); game.getZone().broadcastPacketToObservers(os);
} }
} }
_effectIconsUpdate = null;
}, 500);
} }
private void addIcon(BuffInfo info, AbnormalStatusUpdate asu, PartySpelled ps, PartySpelled psSummon, ExOlympiadSpelledInfo os, boolean isSummon) private void addIcon(BuffInfo info, AbnormalStatusUpdate asu, PartySpelled ps, PartySpelled psSummon, ExOlympiadSpelledInfo os, boolean isSummon)