From 2a47b926eda7a53a3db2d5c7af3daf0e006f5f35 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Fri, 21 May 2021 21:42:08 +0000 Subject: [PATCH] RelationChanged packet related adjustments. Contributed by iDesy. --- .../gameserver/cache/RelationCache.java | 6 +-- .../model/actor/instance/PlayerInstance.java | 20 +++++---- .../gameserver/model/siege/Siege.java | 4 +- .../serverpackets/RelationChanged.java | 43 +++++++++---------- .../l2jmobius/gameserver/util/Broadcast.java | 2 +- .../gameserver/cache/RelationCache.java | 6 +-- .../model/actor/instance/PlayerInstance.java | 20 +++++---- .../gameserver/model/siege/Siege.java | 4 +- .../serverpackets/RelationChanged.java | 35 ++++++++------- .../l2jmobius/gameserver/util/Broadcast.java | 2 +- 10 files changed, 72 insertions(+), 70 deletions(-) diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/cache/RelationCache.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/cache/RelationCache.java index 91d5ea7d55..ab9195847b 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/cache/RelationCache.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/cache/RelationCache.java @@ -21,16 +21,16 @@ package org.l2jmobius.gameserver.cache; */ public final class RelationCache { - private final int _relation; + private final long _relation; private final boolean _isAutoAttackable; - public RelationCache(int relation, boolean isAutoAttackable) + public RelationCache(long relation, boolean isAutoAttackable) { _relation = relation; _isAutoAttackable = isAutoAttackable; } - public int getRelation() + public long getRelation() { return _relation; } diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 4d278d44b5..e7842a9eb1 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -987,12 +987,12 @@ public class PlayerInstance extends Playable return _chars; } - public int getRelation(PlayerInstance target) + public long getRelation(PlayerInstance target) { final Clan clan = getClan(); final Party party = getParty(); final Clan targetClan = target.getClan(); - int result = 0; + long result = 0; if (clan != null) { result |= RelationChanged.RELATION_CLAN_MEMBER; @@ -1094,12 +1094,14 @@ public class PlayerInstance extends Playable case DECLARATION: case BLOOD_DECLARATION: { - result |= RelationChanged.RELATION_DECLARED_WAR; + if (war.getAttackerClanId() == target.getClanId()) + { + result |= RelationChanged.RELATION_DECLARED_WAR; + } break; } case MUTUAL: { - result |= RelationChanged.RELATION_DECLARED_WAR; result |= RelationChanged.RELATION_MUTUAL_WAR; break; } @@ -1796,7 +1798,7 @@ public class PlayerInstance extends Playable return; } - final int relation = getRelation(player); + final long relation = getRelation(player); final boolean isAutoAttackable = isAutoAttackable(player); final RelationCache oldrelation = getKnownRelations().get(player.getObjectId()); if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) @@ -4089,7 +4091,7 @@ public class PlayerInstance extends Playable } // Update relation. - final int relation = getRelation(player); + final long relation = getRelation(player); final boolean isAutoAttackable = isAutoAttackable(player); final RelationCache oldrelation = getKnownRelations().get(player.getObjectId()); if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) @@ -6361,7 +6363,7 @@ public class PlayerInstance extends Playable return; } - final int relation = getRelation(player); + final long relation = getRelation(player); final boolean isAutoAttackable = isAutoAttackable(player); final RelationCache oldrelation = getKnownRelations().get(player.getObjectId()); if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) @@ -12397,7 +12399,7 @@ public class PlayerInstance extends Playable player.sendPacket(new CharInfo(this, isInvisible() && player.canOverrideCond(PlayerCondOverride.SEE_ALL_PLAYERS))); } - final int relation1 = getRelation(player); + final long relation1 = getRelation(player); final RelationChanged rc1 = new RelationChanged(); rc1.addRelation(this, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP)); if (hasSummon()) @@ -12413,7 +12415,7 @@ public class PlayerInstance extends Playable } player.sendPacket(rc1); - final int relation2 = player.getRelation(this); + final long relation2 = player.getRelation(this); final RelationChanged rc2 = new RelationChanged(); rc2.addRelation(player, relation2, !player.isInsideZone(ZoneId.PEACE)); if (player.hasSummon()) diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/Siege.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/Siege.java index a207a925f4..b5bbaf4a6b 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/Siege.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/siege/Siege.java @@ -594,7 +594,7 @@ public class Siege implements Siegable return; } - final int relation = member.getRelation(player); + final long relation = member.getRelation(player); final boolean isAutoAttackable = member.isAutoAttackable(player); final RelationCache oldrelation = member.getKnownRelations().get(player.getObjectId()); if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) @@ -654,7 +654,7 @@ public class Siege implements Siegable return; } - final int relation = member.getRelation(player); + final long relation = member.getRelation(player); final boolean isAutoAttackable = member.isAutoAttackable(player); final RelationCache oldrelation = member.getKnownRelations().get(player.getObjectId()); if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/RelationChanged.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/RelationChanged.java index af84573e63..709dee7ed0 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/RelationChanged.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/RelationChanged.java @@ -29,33 +29,32 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; public class RelationChanged implements IClientOutgoingPacket { // TODO: Enum - public static final int RELATION_PARTY1 = 0x00001; // party member - public static final int RELATION_PARTY2 = 0x00002; // party member - public static final int RELATION_PARTY3 = 0x00004; // party member - public static final int RELATION_PARTY4 = 0x00008; // party member (for information, see PlayerInstance.getRelation()) - public static final int RELATION_PARTYLEADER = 0x00010; // true if is party leader - public static final int RELATION_HAS_PARTY = 0x00020; // true if is in party - public static final int RELATION_CLAN_MEMBER = 0x00040; // true if is in clan - public static final int RELATION_LEADER = 0x00080; // true if is clan leader - public static final int RELATION_CLAN_MATE = 0x00100; // true if is in same clan - public static final int RELATION_INSIEGE = 0x00200; // true if in siege - public static final int RELATION_ATTACKER = 0x00400; // true when attacker - public static final int RELATION_ALLY = 0x00800; // blue siege icon, cannot have if red - public static final int RELATION_ENEMY = 0x01000; // true when red icon, doesn't matter with blue - public static final int RELATION_DECLARED_WAR = 0x04000; // single sword - public static final int RELATION_MUTUAL_WAR = 0x08000; // double swords + public static final int RELATION_PARTY1 = 0x1; // party member + public static final int RELATION_PARTY2 = 0x2; // party member + public static final int RELATION_PARTY3 = 0x4; // party member + public static final int RELATION_PARTY4 = 0x8; // party member (for information, see PlayerInstance.getRelation()) + public static final int RELATION_PARTYLEADER = 0x10; // true if is party leader + public static final int RELATION_HAS_PARTY = 0x20; // true if is in party + public static final int RELATION_CLAN_MEMBER = 0x40; // true if is in clan + public static final int RELATION_LEADER = 0x100; // true if is clan leader + public static final int RELATION_CLAN_MATE = 0x200; // true if is in same clan + public static final int RELATION_INSIEGE = 0x400; // true if in siege + public static final int RELATION_ATTACKER = 0x800; // true when attacker + public static final int RELATION_ALLY = 0x4000; // blue siege icon, cannot have if red + public static final int RELATION_ENEMY = 0x8000; // true when red icon, doesn't matter with blue public static final int RELATION_ALLY_MEMBER = 0x10000; // clan is in alliance public static final int RELATION_TERRITORY_WAR = 0x80000; // show Territory War icon - + public static final long RELATION_DECLARED_WAR = 0x40000000L; // double swords + public static final long RELATION_MUTUAL_WAR = 0x4E200000L; // single sword // Masks - public static final byte SEND_ONE = 0x00; public static final byte SEND_DEFAULT = 0x01; + public static final byte SEND_ONE = 0x02; public static final byte SEND_MULTI = 0x04; protected static class Relation { int _objId; - int _relation; + long _relation; int _autoAttackable; int _reputation; int _pvpFlag; @@ -65,7 +64,7 @@ public class RelationChanged implements IClientOutgoingPacket private final List _multi; private byte _mask = 0x00; - public RelationChanged(Playable activeChar, int relation, boolean autoattackable) + public RelationChanged(Playable activeChar, long relation, boolean autoattackable) { _mask |= SEND_ONE; _singled = new Relation(); @@ -83,7 +82,7 @@ public class RelationChanged implements IClientOutgoingPacket _multi = new LinkedList<>(); } - public void addRelation(Playable activeChar, int relation, boolean autoattackable) + public void addRelation(Playable activeChar, long relation, boolean autoattackable) { if (activeChar.isInvisible()) { @@ -124,9 +123,9 @@ public class RelationChanged implements IClientOutgoingPacket { packet.writeD(relation._objId); - if ((_mask & SEND_DEFAULT) == 0) + if ((_mask & SEND_DEFAULT) != SEND_DEFAULT) { - packet.writeD(relation._relation); + packet.writeQ(relation._relation); packet.writeC(relation._autoAttackable); packet.writeD(relation._reputation); packet.writeC(relation._pvpFlag); diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/Broadcast.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/Broadcast.java index e06c7046db..9bd624d486 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/Broadcast.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/util/Broadcast.java @@ -82,7 +82,7 @@ public class Broadcast player.sendPacket(mov); if ((mov instanceof CharInfo) && (creature.isPlayer())) { - final int relation = ((PlayerInstance) creature).getRelation(player); + final long relation = ((PlayerInstance) creature).getRelation(player); final boolean isAutoAttackable = creature.isAutoAttackable(player); final RelationCache oldrelation = creature.getKnownRelations().get(player.getObjectId()); if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/cache/RelationCache.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/cache/RelationCache.java index 91d5ea7d55..ab9195847b 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/cache/RelationCache.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/cache/RelationCache.java @@ -21,16 +21,16 @@ package org.l2jmobius.gameserver.cache; */ public final class RelationCache { - private final int _relation; + private final long _relation; private final boolean _isAutoAttackable; - public RelationCache(int relation, boolean isAutoAttackable) + public RelationCache(long relation, boolean isAutoAttackable) { _relation = relation; _isAutoAttackable = isAutoAttackable; } - public int getRelation() + public long getRelation() { return _relation; } diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 9b0ff2a15e..c8c4bb2d90 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1010,12 +1010,12 @@ public class PlayerInstance extends Playable return _chars; } - public int getRelation(PlayerInstance target) + public long getRelation(PlayerInstance target) { final Clan clan = getClan(); final Party party = getParty(); final Clan targetClan = target.getClan(); - int result = 0; + long result = 0; if (clan != null) { result |= RelationChanged.RELATION_CLAN_MEMBER; @@ -1117,12 +1117,14 @@ public class PlayerInstance extends Playable case DECLARATION: case BLOOD_DECLARATION: { - result |= RelationChanged.RELATION_DECLARED_WAR; + if (war.getAttackerClanId() == target.getClanId()) + { + result |= RelationChanged.RELATION_DECLARED_WAR; + } break; } case MUTUAL: { - result |= RelationChanged.RELATION_DECLARED_WAR; result |= RelationChanged.RELATION_MUTUAL_WAR; break; } @@ -1819,7 +1821,7 @@ public class PlayerInstance extends Playable return; } - final int relation = getRelation(player); + final long relation = getRelation(player); final boolean isAutoAttackable = isAutoAttackable(player); final RelationCache oldrelation = getKnownRelations().get(player.getObjectId()); if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) @@ -4131,7 +4133,7 @@ public class PlayerInstance extends Playable } // Update relation. - final int relation = getRelation(player); + final long relation = getRelation(player); final boolean isAutoAttackable = isAutoAttackable(player); final RelationCache oldrelation = getKnownRelations().get(player.getObjectId()); if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) @@ -6385,7 +6387,7 @@ public class PlayerInstance extends Playable return; } - final int relation = getRelation(player); + final long relation = getRelation(player); final boolean isAutoAttackable = isAutoAttackable(player); final RelationCache oldrelation = getKnownRelations().get(player.getObjectId()); if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) @@ -12385,7 +12387,7 @@ public class PlayerInstance extends Playable player.sendPacket(new CharInfo(this, isInvisible() && player.canOverrideCond(PlayerCondOverride.SEE_ALL_PLAYERS))); } - final int relation1 = getRelation(player); + final long relation1 = getRelation(player); final RelationChanged rc1 = new RelationChanged(); rc1.addRelation(this, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP)); if (hasSummon()) @@ -12401,7 +12403,7 @@ public class PlayerInstance extends Playable } player.sendPacket(rc1); - final int relation2 = player.getRelation(this); + final long relation2 = player.getRelation(this); final RelationChanged rc2 = new RelationChanged(); rc2.addRelation(player, relation2, !player.isInsideZone(ZoneId.PEACE)); if (player.hasSummon()) diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/siege/Siege.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/siege/Siege.java index a20374a251..1839b6539e 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/siege/Siege.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/model/siege/Siege.java @@ -594,7 +594,7 @@ public class Siege implements Siegable return; } - final int relation = member.getRelation(player); + final long relation = member.getRelation(player); final boolean isAutoAttackable = member.isAutoAttackable(player); final RelationCache oldrelation = member.getKnownRelations().get(player.getObjectId()); if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) @@ -654,7 +654,7 @@ public class Siege implements Siegable return; } - final int relation = member.getRelation(player); + final long relation = member.getRelation(player); final boolean isAutoAttackable = member.isAutoAttackable(player); final RelationCache oldrelation = member.getKnownRelations().get(player.getObjectId()); if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/serverpackets/RelationChanged.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/serverpackets/RelationChanged.java index fbaf467336..96ba66e687 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/serverpackets/RelationChanged.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/network/serverpackets/RelationChanged.java @@ -29,27 +29,26 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; public class RelationChanged implements IClientOutgoingPacket { // TODO: Enum - public static final int RELATION_PARTY1 = 0x00001; // party member - public static final int RELATION_PARTY2 = 0x00002; // party member - public static final int RELATION_PARTY3 = 0x00004; // party member - public static final int RELATION_PARTY4 = 0x00008; // party member (for information, see PlayerInstance.getRelation()) - public static final int RELATION_PARTYLEADER = 0x00010; // true if is party leader - public static final int RELATION_HAS_PARTY = 0x00020; // true if is in party - public static final int RELATION_CLAN_MEMBER = 0x00040; // true if is in clan - public static final int RELATION_LEADER = 0x00100; // true if is clan leader - public static final int RELATION_CLAN_MATE = 0x00200; // true if is in same clan - public static final int RELATION_INSIEGE = 0x00400; // true if in siege - public static final int RELATION_ATTACKER = 0x00800; // true when attacker - public static final int RELATION_ALLY = 0x04000; // blue siege icon, cannot have if red - public static final int RELATION_ENEMY = 0x08000; // true when red icon, doesn't matter with blue - public static final long RELATION_DECLARED_WAR = 0x040000000L; // single sword 1310720000L - public static final long RELATION_MUTUAL_WAR = 1310720000L; // double swords 0x040000000L + public static final int RELATION_PARTY1 = 0x1; // party member + public static final int RELATION_PARTY2 = 0x2; // party member + public static final int RELATION_PARTY3 = 0x4; // party member + public static final int RELATION_PARTY4 = 0x8; // party member (for information, see PlayerInstance.getRelation()) + public static final int RELATION_PARTYLEADER = 0x10; // true if is party leader + public static final int RELATION_HAS_PARTY = 0x20; // true if is in party + public static final int RELATION_CLAN_MEMBER = 0x40; // true if is in clan + public static final int RELATION_LEADER = 0x100; // true if is clan leader + public static final int RELATION_CLAN_MATE = 0x200; // true if is in same clan + public static final int RELATION_INSIEGE = 0x400; // true if in siege + public static final int RELATION_ATTACKER = 0x800; // true when attacker + public static final int RELATION_ALLY = 0x4000; // blue siege icon, cannot have if red + public static final int RELATION_ENEMY = 0x8000; // true when red icon, doesn't matter with blue public static final int RELATION_ALLY_MEMBER = 0x10000; // clan is in alliance public static final int RELATION_TERRITORY_WAR = 0x80000; // show Territory War icon - + public static final long RELATION_DECLARED_WAR = 0x40000000L; // single sword 0x4E200000L + public static final long RELATION_MUTUAL_WAR = 0x4E200000L; // double swords 0x40000000L // Masks - public static final byte SEND_ONE = 0x02; public static final byte SEND_DEFAULT = 0x01; + public static final byte SEND_ONE = 0x02; public static final byte SEND_MULTI = 0x04; protected static class Relation @@ -87,9 +86,9 @@ public class RelationChanged implements IClientOutgoingPacket { if (activeChar.isInvisible()) { - // throw new IllegalArgumentException("Cannot add invisible character to multi relation packet"); return; } + final Relation r = new Relation(); r._objId = activeChar.getObjectId(); r._relation = relation; diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/util/Broadcast.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/util/Broadcast.java index e06c7046db..9bd624d486 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/util/Broadcast.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/util/Broadcast.java @@ -82,7 +82,7 @@ public class Broadcast player.sendPacket(mov); if ((mov instanceof CharInfo) && (creature.isPlayer())) { - final int relation = ((PlayerInstance) creature).getRelation(player); + final long relation = ((PlayerInstance) creature).getRelation(player); final boolean isAutoAttackable = creature.isAutoAttackable(player); final RelationCache oldrelation = creature.getKnownRelations().get(player.getObjectId()); if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))