Player info related packets with delay locks.
This commit is contained in:
@@ -41,6 +41,7 @@ import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.concurrent.locks.StampedLock;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -723,7 +724,10 @@ public class PlayerInstance extends Playable
|
||||
private ScheduledFuture<?> _taskRentPet;
|
||||
private ScheduledFuture<?> _taskWater;
|
||||
|
||||
private ScheduledFuture<?> _skillListRefreshTask;
|
||||
/** Packet delay locks */
|
||||
private final StampedLock _skillListPacketLock = new StampedLock();
|
||||
private final StampedLock _userInfoPacketLock = new StampedLock();
|
||||
private final StampedLock _storageMaxPacketLock = new StampedLock();
|
||||
|
||||
/** Last Html Npcs, 0 = last html was not bound to an npc */
|
||||
private final int[] _htmlActionOriginObjectIds = new int[HtmlActionScope.values().length];
|
||||
@@ -2240,6 +2244,16 @@ public class PlayerInstance extends Playable
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerEquipItem(this, item), this);
|
||||
}
|
||||
|
||||
public boolean setStorageMaxCountPacketLock(boolean lock)
|
||||
{
|
||||
if (lock)
|
||||
{
|
||||
return _storageMaxPacketLock.tryWriteLock() != 0;
|
||||
}
|
||||
_storageMaxPacketLock.tryUnlockWrite();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the the PvP Kills of the PlayerInstance (Number of player killed during a PvP).
|
||||
*/
|
||||
@@ -4085,6 +4099,16 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setUserInfoPacketLock(boolean lock)
|
||||
{
|
||||
if (lock)
|
||||
{
|
||||
return _userInfoPacketLock.tryWriteLock() != 0;
|
||||
}
|
||||
_userInfoPacketLock.tryUnlockWrite();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a Server->Client packet UserInfo to this PlayerInstance and CharInfo to all PlayerInstance in its _KnownPlayers. <B><U> Concept</U> :</B> Others PlayerInstance in the detection area of the PlayerInstance are identified in <B>_knownPlayers</B>. In order to inform other players of this
|
||||
* PlayerInstance state modifications, server just need to go through _knownPlayers to send Server->Client Packet <B><U> Actions</U> :</B>
|
||||
@@ -9493,16 +9517,19 @@ public class PlayerInstance extends Playable
|
||||
return _wantsPeace;
|
||||
}
|
||||
|
||||
public boolean setSkillListPacketLock(boolean lock)
|
||||
{
|
||||
if (lock)
|
||||
{
|
||||
return _skillListPacketLock.tryWriteLock() != 0;
|
||||
}
|
||||
_skillListPacketLock.tryUnlockWrite();
|
||||
return false;
|
||||
}
|
||||
|
||||
public void sendSkillList()
|
||||
{
|
||||
if (_skillListRefreshTask == null)
|
||||
{
|
||||
_skillListRefreshTask = ThreadPool.schedule(() ->
|
||||
{
|
||||
sendSkillList(0);
|
||||
_skillListRefreshTask = null;
|
||||
}, 1000);
|
||||
}
|
||||
sendSkillList(0);
|
||||
}
|
||||
|
||||
public void sendSkillList(int lastLearnedSkillId)
|
||||
@@ -9906,8 +9933,15 @@ public class PlayerInstance extends Playable
|
||||
removeSkill(oldSkill, false, true);
|
||||
}
|
||||
|
||||
stopAllEffectsExceptThoseThatLastThroughDeath();
|
||||
stopAllEffects();
|
||||
// stopAllEffectsExceptThoseThatLastThroughDeath();
|
||||
getEffectList().stopEffects(info -> !info.getSkill().isStayAfterDeath(), true, false);
|
||||
|
||||
// stopAllEffects();
|
||||
getEffectList().stopEffects(info -> !info.getSkill().isNecessaryToggle() && !info.getSkill().isIrreplacableBuff(), true, false);
|
||||
|
||||
// Update abnormal visual effects.
|
||||
sendPacket(new ExUserInfoAbnormalVisualEffect(this));
|
||||
|
||||
stopCubics();
|
||||
|
||||
restoreRecipeBook(false);
|
||||
|
@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||
import org.l2jmobius.gameserver.model.SkillLearn;
|
||||
@@ -31,19 +32,32 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
*/
|
||||
public class AcquireSkillList implements IClientOutgoingPacket
|
||||
{
|
||||
final PlayerInstance _player;
|
||||
final List<SkillLearn> _learnable;
|
||||
private PlayerInstance _player;
|
||||
private List<SkillLearn> _learnable;
|
||||
|
||||
public AcquireSkillList(PlayerInstance player)
|
||||
{
|
||||
_player = player;
|
||||
_learnable = SkillTreesData.getInstance().getAvailableSkills(player, player.getClassId(), false, false);
|
||||
_learnable.addAll(SkillTreesData.getInstance().getNextAvailableSkills(player, player.getClassId(), false, false));
|
||||
if (player.setSkillListPacketLock(true))
|
||||
{
|
||||
_player = player;
|
||||
_learnable = SkillTreesData.getInstance().getAvailableSkills(player, player.getClassId(), false, false);
|
||||
_learnable.addAll(SkillTreesData.getInstance().getNextAvailableSkills(player, player.getClassId(), false, false));
|
||||
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
player.setSkillListPacketLock(false);
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
OutgoingPackets.ACQUIRE_SKILL_LIST.writeId(packet);
|
||||
|
||||
packet.writeH(_learnable.size());
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.stats.Stats;
|
||||
@@ -27,34 +28,49 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
*/
|
||||
public class ExStorageMaxCount implements IClientOutgoingPacket
|
||||
{
|
||||
private final int _inventory;
|
||||
private final int _warehouse;
|
||||
// private final int _freight; // Removed with 152.
|
||||
private final int _clan;
|
||||
private final int _privateSell;
|
||||
private final int _privateBuy;
|
||||
private final int _receipeD;
|
||||
private final int _recipe;
|
||||
private final int _inventoryExtraSlots;
|
||||
private final int _inventoryQuestItems;
|
||||
private PlayerInstance _player;
|
||||
private int _inventory;
|
||||
private int _warehouse;
|
||||
// private int _freight; // Removed with 152.
|
||||
private int _clan;
|
||||
private int _privateSell;
|
||||
private int _privateBuy;
|
||||
private int _receipeD;
|
||||
private int _recipe;
|
||||
private int _inventoryExtraSlots;
|
||||
private int _inventoryQuestItems;
|
||||
|
||||
public ExStorageMaxCount(PlayerInstance player)
|
||||
{
|
||||
_inventory = player.getInventoryLimit();
|
||||
_warehouse = player.getWareHouseLimit();
|
||||
// _freight = Config.ALT_FREIGHT_SLOTS; // Removed with 152.
|
||||
_privateSell = player.getPrivateSellStoreLimit();
|
||||
_privateBuy = player.getPrivateBuyStoreLimit();
|
||||
_clan = Config.WAREHOUSE_SLOTS_CLAN;
|
||||
_receipeD = player.getDwarfRecipeLimit();
|
||||
_recipe = player.getCommonRecipeLimit();
|
||||
_inventoryExtraSlots = (int) player.getStat().getValue(Stats.INVENTORY_NORMAL, 0);
|
||||
_inventoryQuestItems = Config.INVENTORY_MAXIMUM_QUEST_ITEMS;
|
||||
if (player.setStorageMaxCountPacketLock(true))
|
||||
{
|
||||
_player = player;
|
||||
_inventory = player.getInventoryLimit();
|
||||
_warehouse = player.getWareHouseLimit();
|
||||
// _freight = Config.ALT_FREIGHT_SLOTS; // Removed with 152.
|
||||
_privateSell = player.getPrivateSellStoreLimit();
|
||||
_privateBuy = player.getPrivateBuyStoreLimit();
|
||||
_clan = Config.WAREHOUSE_SLOTS_CLAN;
|
||||
_receipeD = player.getDwarfRecipeLimit();
|
||||
_recipe = player.getCommonRecipeLimit();
|
||||
_inventoryExtraSlots = (int) player.getStat().getValue(Stats.INVENTORY_NORMAL, 0);
|
||||
_inventoryQuestItems = Config.INVENTORY_MAXIMUM_QUEST_ITEMS;
|
||||
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
player.setStorageMaxCountPacketLock(false);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
OutgoingPackets.EX_STORAGE_MAX_COUNT.writeId(packet);
|
||||
|
||||
packet.writeD(_inventory);
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.data.xml.impl.ExperienceData;
|
||||
import org.l2jmobius.gameserver.enums.UserInfoType;
|
||||
@@ -33,20 +34,20 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
*/
|
||||
public class UserInfo extends AbstractMaskPacket<UserInfoType>
|
||||
{
|
||||
private final PlayerInstance _player;
|
||||
private PlayerInstance _player;
|
||||
|
||||
private final int _relation;
|
||||
private final int _runSpd;
|
||||
private final int _walkSpd;
|
||||
private final int _swimRunSpd;
|
||||
private final int _swimWalkSpd;
|
||||
private int _relation;
|
||||
private int _runSpd;
|
||||
private int _walkSpd;
|
||||
private int _swimRunSpd;
|
||||
private int _swimWalkSpd;
|
||||
private final int _flRunSpd = 0;
|
||||
private final int _flWalkSpd = 0;
|
||||
private final int _flyRunSpd;
|
||||
private final int _flyWalkSpd;
|
||||
private final double _moveMultiplier;
|
||||
private final int _enchantLevel;
|
||||
private final int _armorEnchant;
|
||||
private int _flyRunSpd;
|
||||
private int _flyWalkSpd;
|
||||
private double _moveMultiplier;
|
||||
private int _enchantLevel;
|
||||
private int _armorEnchant;
|
||||
private String _title;
|
||||
|
||||
private final byte[] _masks = new byte[]
|
||||
@@ -59,11 +60,6 @@ public class UserInfo extends AbstractMaskPacket<UserInfoType>
|
||||
private int _initSize = 5;
|
||||
|
||||
public UserInfo(PlayerInstance player)
|
||||
{
|
||||
this(player, true);
|
||||
}
|
||||
|
||||
public UserInfo(PlayerInstance player, boolean addAll)
|
||||
{
|
||||
_player = player;
|
||||
|
||||
@@ -84,9 +80,41 @@ public class UserInfo extends AbstractMaskPacket<UserInfoType>
|
||||
_title = "[Invisible]";
|
||||
}
|
||||
|
||||
if (addAll)
|
||||
addComponentType(UserInfoType.values());
|
||||
}
|
||||
|
||||
public UserInfo(PlayerInstance player, boolean addAll)
|
||||
{
|
||||
if (player.setUserInfoPacketLock(true))
|
||||
{
|
||||
addComponentType(UserInfoType.values());
|
||||
_player = player;
|
||||
|
||||
_relation = calculateRelation(player);
|
||||
_moveMultiplier = player.getMovementSpeedMultiplier();
|
||||
_runSpd = (int) Math.round(player.getRunSpeed() / _moveMultiplier);
|
||||
_walkSpd = (int) Math.round(player.getWalkSpeed() / _moveMultiplier);
|
||||
_swimRunSpd = (int) Math.round(player.getSwimRunSpeed() / _moveMultiplier);
|
||||
_swimWalkSpd = (int) Math.round(player.getSwimWalkSpeed() / _moveMultiplier);
|
||||
_flyRunSpd = player.isFlying() ? _runSpd : 0;
|
||||
_flyWalkSpd = player.isFlying() ? _walkSpd : 0;
|
||||
_enchantLevel = player.getInventory().getWeaponEnchant();
|
||||
_armorEnchant = player.getInventory().getArmorMinEnchant();
|
||||
|
||||
_title = player.getTitle();
|
||||
if (player.isGM() && player.isInvisible())
|
||||
{
|
||||
_title = "[Invisible]";
|
||||
}
|
||||
|
||||
if (addAll)
|
||||
{
|
||||
addComponentType(UserInfoType.values());
|
||||
}
|
||||
|
||||
ThreadPool.schedule(() ->
|
||||
{
|
||||
player.setUserInfoPacketLock(false);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,6 +155,11 @@ public class UserInfo extends AbstractMaskPacket<UserInfoType>
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
OutgoingPackets.USER_INFO.writeId(packet);
|
||||
|
||||
packet.writeD(_player.getObjectId());
|
||||
|
Reference in New Issue
Block a user