RelationChanged packet related adjustments.

Contributed by iDesy.
This commit is contained in:
MobiusDevelopment 2021-05-21 21:42:08 +00:00
parent d10102ecba
commit 2a47b926ed
10 changed files with 72 additions and 70 deletions

View File

@ -21,16 +21,16 @@ package org.l2jmobius.gameserver.cache;
*/ */
public final class RelationCache public final class RelationCache
{ {
private final int _relation; private final long _relation;
private final boolean _isAutoAttackable; private final boolean _isAutoAttackable;
public RelationCache(int relation, boolean isAutoAttackable) public RelationCache(long relation, boolean isAutoAttackable)
{ {
_relation = relation; _relation = relation;
_isAutoAttackable = isAutoAttackable; _isAutoAttackable = isAutoAttackable;
} }
public int getRelation() public long getRelation()
{ {
return _relation; return _relation;
} }

View File

@ -987,12 +987,12 @@ public class PlayerInstance extends Playable
return _chars; return _chars;
} }
public int getRelation(PlayerInstance target) public long getRelation(PlayerInstance target)
{ {
final Clan clan = getClan(); final Clan clan = getClan();
final Party party = getParty(); final Party party = getParty();
final Clan targetClan = target.getClan(); final Clan targetClan = target.getClan();
int result = 0; long result = 0;
if (clan != null) if (clan != null)
{ {
result |= RelationChanged.RELATION_CLAN_MEMBER; result |= RelationChanged.RELATION_CLAN_MEMBER;
@ -1094,12 +1094,14 @@ public class PlayerInstance extends Playable
case DECLARATION: case DECLARATION:
case BLOOD_DECLARATION: case BLOOD_DECLARATION:
{ {
result |= RelationChanged.RELATION_DECLARED_WAR; if (war.getAttackerClanId() == target.getClanId())
{
result |= RelationChanged.RELATION_DECLARED_WAR;
}
break; break;
} }
case MUTUAL: case MUTUAL:
{ {
result |= RelationChanged.RELATION_DECLARED_WAR;
result |= RelationChanged.RELATION_MUTUAL_WAR; result |= RelationChanged.RELATION_MUTUAL_WAR;
break; break;
} }
@ -1796,7 +1798,7 @@ public class PlayerInstance extends Playable
return; return;
} }
final int relation = getRelation(player); final long relation = getRelation(player);
final boolean isAutoAttackable = isAutoAttackable(player); final boolean isAutoAttackable = isAutoAttackable(player);
final RelationCache oldrelation = getKnownRelations().get(player.getObjectId()); final RelationCache oldrelation = getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
@ -4089,7 +4091,7 @@ public class PlayerInstance extends Playable
} }
// Update relation. // Update relation.
final int relation = getRelation(player); final long relation = getRelation(player);
final boolean isAutoAttackable = isAutoAttackable(player); final boolean isAutoAttackable = isAutoAttackable(player);
final RelationCache oldrelation = getKnownRelations().get(player.getObjectId()); final RelationCache oldrelation = getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
@ -6361,7 +6363,7 @@ public class PlayerInstance extends Playable
return; return;
} }
final int relation = getRelation(player); final long relation = getRelation(player);
final boolean isAutoAttackable = isAutoAttackable(player); final boolean isAutoAttackable = isAutoAttackable(player);
final RelationCache oldrelation = getKnownRelations().get(player.getObjectId()); final RelationCache oldrelation = getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) 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))); 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(); final RelationChanged rc1 = new RelationChanged();
rc1.addRelation(this, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP)); rc1.addRelation(this, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP));
if (hasSummon()) if (hasSummon())
@ -12413,7 +12415,7 @@ public class PlayerInstance extends Playable
} }
player.sendPacket(rc1); player.sendPacket(rc1);
final int relation2 = player.getRelation(this); final long relation2 = player.getRelation(this);
final RelationChanged rc2 = new RelationChanged(); final RelationChanged rc2 = new RelationChanged();
rc2.addRelation(player, relation2, !player.isInsideZone(ZoneId.PEACE)); rc2.addRelation(player, relation2, !player.isInsideZone(ZoneId.PEACE));
if (player.hasSummon()) if (player.hasSummon())

View File

@ -594,7 +594,7 @@ public class Siege implements Siegable
return; return;
} }
final int relation = member.getRelation(player); final long relation = member.getRelation(player);
final boolean isAutoAttackable = member.isAutoAttackable(player); final boolean isAutoAttackable = member.isAutoAttackable(player);
final RelationCache oldrelation = member.getKnownRelations().get(player.getObjectId()); final RelationCache oldrelation = member.getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
@ -654,7 +654,7 @@ public class Siege implements Siegable
return; return;
} }
final int relation = member.getRelation(player); final long relation = member.getRelation(player);
final boolean isAutoAttackable = member.isAutoAttackable(player); final boolean isAutoAttackable = member.isAutoAttackable(player);
final RelationCache oldrelation = member.getKnownRelations().get(player.getObjectId()); final RelationCache oldrelation = member.getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))

View File

@ -29,33 +29,32 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
public class RelationChanged implements IClientOutgoingPacket public class RelationChanged implements IClientOutgoingPacket
{ {
// TODO: Enum // TODO: Enum
public static final int RELATION_PARTY1 = 0x00001; // party member public static final int RELATION_PARTY1 = 0x1; // party member
public static final int RELATION_PARTY2 = 0x00002; // party member public static final int RELATION_PARTY2 = 0x2; // party member
public static final int RELATION_PARTY3 = 0x00004; // party member public static final int RELATION_PARTY3 = 0x4; // party member
public static final int RELATION_PARTY4 = 0x00008; // party member (for information, see PlayerInstance.getRelation()) public static final int RELATION_PARTY4 = 0x8; // party member (for information, see PlayerInstance.getRelation())
public static final int RELATION_PARTYLEADER = 0x00010; // true if is party leader public static final int RELATION_PARTYLEADER = 0x10; // true if is party leader
public static final int RELATION_HAS_PARTY = 0x00020; // true if is in party public static final int RELATION_HAS_PARTY = 0x20; // true if is in party
public static final int RELATION_CLAN_MEMBER = 0x00040; // true if is in clan public static final int RELATION_CLAN_MEMBER = 0x40; // true if is in clan
public static final int RELATION_LEADER = 0x00080; // true if is clan leader public static final int RELATION_LEADER = 0x100; // true if is clan leader
public static final int RELATION_CLAN_MATE = 0x00100; // true if is in same clan public static final int RELATION_CLAN_MATE = 0x200; // true if is in same clan
public static final int RELATION_INSIEGE = 0x00200; // true if in siege public static final int RELATION_INSIEGE = 0x400; // true if in siege
public static final int RELATION_ATTACKER = 0x00400; // true when attacker public static final int RELATION_ATTACKER = 0x800; // true when attacker
public static final int RELATION_ALLY = 0x00800; // blue siege icon, cannot have if red public static final int RELATION_ALLY = 0x4000; // 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_ENEMY = 0x8000; // 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_ALLY_MEMBER = 0x10000; // clan is in alliance 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 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 // Masks
public static final byte SEND_ONE = 0x00;
public static final byte SEND_DEFAULT = 0x01; public static final byte SEND_DEFAULT = 0x01;
public static final byte SEND_ONE = 0x02;
public static final byte SEND_MULTI = 0x04; public static final byte SEND_MULTI = 0x04;
protected static class Relation protected static class Relation
{ {
int _objId; int _objId;
int _relation; long _relation;
int _autoAttackable; int _autoAttackable;
int _reputation; int _reputation;
int _pvpFlag; int _pvpFlag;
@ -65,7 +64,7 @@ public class RelationChanged implements IClientOutgoingPacket
private final List<Relation> _multi; private final List<Relation> _multi;
private byte _mask = 0x00; private byte _mask = 0x00;
public RelationChanged(Playable activeChar, int relation, boolean autoattackable) public RelationChanged(Playable activeChar, long relation, boolean autoattackable)
{ {
_mask |= SEND_ONE; _mask |= SEND_ONE;
_singled = new Relation(); _singled = new Relation();
@ -83,7 +82,7 @@ public class RelationChanged implements IClientOutgoingPacket
_multi = new LinkedList<>(); _multi = new LinkedList<>();
} }
public void addRelation(Playable activeChar, int relation, boolean autoattackable) public void addRelation(Playable activeChar, long relation, boolean autoattackable)
{ {
if (activeChar.isInvisible()) if (activeChar.isInvisible())
{ {
@ -124,9 +123,9 @@ public class RelationChanged implements IClientOutgoingPacket
{ {
packet.writeD(relation._objId); 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.writeC(relation._autoAttackable);
packet.writeD(relation._reputation); packet.writeD(relation._reputation);
packet.writeC(relation._pvpFlag); packet.writeC(relation._pvpFlag);

View File

@ -82,7 +82,7 @@ public class Broadcast
player.sendPacket(mov); player.sendPacket(mov);
if ((mov instanceof CharInfo) && (creature.isPlayer())) 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 boolean isAutoAttackable = creature.isAutoAttackable(player);
final RelationCache oldrelation = creature.getKnownRelations().get(player.getObjectId()); final RelationCache oldrelation = creature.getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))

View File

@ -21,16 +21,16 @@ package org.l2jmobius.gameserver.cache;
*/ */
public final class RelationCache public final class RelationCache
{ {
private final int _relation; private final long _relation;
private final boolean _isAutoAttackable; private final boolean _isAutoAttackable;
public RelationCache(int relation, boolean isAutoAttackable) public RelationCache(long relation, boolean isAutoAttackable)
{ {
_relation = relation; _relation = relation;
_isAutoAttackable = isAutoAttackable; _isAutoAttackable = isAutoAttackable;
} }
public int getRelation() public long getRelation()
{ {
return _relation; return _relation;
} }

View File

@ -1010,12 +1010,12 @@ public class PlayerInstance extends Playable
return _chars; return _chars;
} }
public int getRelation(PlayerInstance target) public long getRelation(PlayerInstance target)
{ {
final Clan clan = getClan(); final Clan clan = getClan();
final Party party = getParty(); final Party party = getParty();
final Clan targetClan = target.getClan(); final Clan targetClan = target.getClan();
int result = 0; long result = 0;
if (clan != null) if (clan != null)
{ {
result |= RelationChanged.RELATION_CLAN_MEMBER; result |= RelationChanged.RELATION_CLAN_MEMBER;
@ -1117,12 +1117,14 @@ public class PlayerInstance extends Playable
case DECLARATION: case DECLARATION:
case BLOOD_DECLARATION: case BLOOD_DECLARATION:
{ {
result |= RelationChanged.RELATION_DECLARED_WAR; if (war.getAttackerClanId() == target.getClanId())
{
result |= RelationChanged.RELATION_DECLARED_WAR;
}
break; break;
} }
case MUTUAL: case MUTUAL:
{ {
result |= RelationChanged.RELATION_DECLARED_WAR;
result |= RelationChanged.RELATION_MUTUAL_WAR; result |= RelationChanged.RELATION_MUTUAL_WAR;
break; break;
} }
@ -1819,7 +1821,7 @@ public class PlayerInstance extends Playable
return; return;
} }
final int relation = getRelation(player); final long relation = getRelation(player);
final boolean isAutoAttackable = isAutoAttackable(player); final boolean isAutoAttackable = isAutoAttackable(player);
final RelationCache oldrelation = getKnownRelations().get(player.getObjectId()); final RelationCache oldrelation = getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
@ -4131,7 +4133,7 @@ public class PlayerInstance extends Playable
} }
// Update relation. // Update relation.
final int relation = getRelation(player); final long relation = getRelation(player);
final boolean isAutoAttackable = isAutoAttackable(player); final boolean isAutoAttackable = isAutoAttackable(player);
final RelationCache oldrelation = getKnownRelations().get(player.getObjectId()); final RelationCache oldrelation = getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
@ -6385,7 +6387,7 @@ public class PlayerInstance extends Playable
return; return;
} }
final int relation = getRelation(player); final long relation = getRelation(player);
final boolean isAutoAttackable = isAutoAttackable(player); final boolean isAutoAttackable = isAutoAttackable(player);
final RelationCache oldrelation = getKnownRelations().get(player.getObjectId()); final RelationCache oldrelation = getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) 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))); 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(); final RelationChanged rc1 = new RelationChanged();
rc1.addRelation(this, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP)); rc1.addRelation(this, relation1, !isInsideZone(ZoneId.PEACE) || !isInsideZone(ZoneId.NO_PVP));
if (hasSummon()) if (hasSummon())
@ -12401,7 +12403,7 @@ public class PlayerInstance extends Playable
} }
player.sendPacket(rc1); player.sendPacket(rc1);
final int relation2 = player.getRelation(this); final long relation2 = player.getRelation(this);
final RelationChanged rc2 = new RelationChanged(); final RelationChanged rc2 = new RelationChanged();
rc2.addRelation(player, relation2, !player.isInsideZone(ZoneId.PEACE)); rc2.addRelation(player, relation2, !player.isInsideZone(ZoneId.PEACE));
if (player.hasSummon()) if (player.hasSummon())

View File

@ -594,7 +594,7 @@ public class Siege implements Siegable
return; return;
} }
final int relation = member.getRelation(player); final long relation = member.getRelation(player);
final boolean isAutoAttackable = member.isAutoAttackable(player); final boolean isAutoAttackable = member.isAutoAttackable(player);
final RelationCache oldrelation = member.getKnownRelations().get(player.getObjectId()); final RelationCache oldrelation = member.getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
@ -654,7 +654,7 @@ public class Siege implements Siegable
return; return;
} }
final int relation = member.getRelation(player); final long relation = member.getRelation(player);
final boolean isAutoAttackable = member.isAutoAttackable(player); final boolean isAutoAttackable = member.isAutoAttackable(player);
final RelationCache oldrelation = member.getKnownRelations().get(player.getObjectId()); final RelationCache oldrelation = member.getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))

View File

@ -29,27 +29,26 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
public class RelationChanged implements IClientOutgoingPacket public class RelationChanged implements IClientOutgoingPacket
{ {
// TODO: Enum // TODO: Enum
public static final int RELATION_PARTY1 = 0x00001; // party member public static final int RELATION_PARTY1 = 0x1; // party member
public static final int RELATION_PARTY2 = 0x00002; // party member public static final int RELATION_PARTY2 = 0x2; // party member
public static final int RELATION_PARTY3 = 0x00004; // party member public static final int RELATION_PARTY3 = 0x4; // party member
public static final int RELATION_PARTY4 = 0x00008; // party member (for information, see PlayerInstance.getRelation()) public static final int RELATION_PARTY4 = 0x8; // party member (for information, see PlayerInstance.getRelation())
public static final int RELATION_PARTYLEADER = 0x00010; // true if is party leader public static final int RELATION_PARTYLEADER = 0x10; // true if is party leader
public static final int RELATION_HAS_PARTY = 0x00020; // true if is in party public static final int RELATION_HAS_PARTY = 0x20; // true if is in party
public static final int RELATION_CLAN_MEMBER = 0x00040; // true if is in clan public static final int RELATION_CLAN_MEMBER = 0x40; // true if is in clan
public static final int RELATION_LEADER = 0x00100; // true if is clan leader public static final int RELATION_LEADER = 0x100; // true if is clan leader
public static final int RELATION_CLAN_MATE = 0x00200; // true if is in same clan public static final int RELATION_CLAN_MATE = 0x200; // true if is in same clan
public static final int RELATION_INSIEGE = 0x00400; // true if in siege public static final int RELATION_INSIEGE = 0x400; // true if in siege
public static final int RELATION_ATTACKER = 0x00800; // true when attacker public static final int RELATION_ATTACKER = 0x800; // true when attacker
public static final int RELATION_ALLY = 0x04000; // blue siege icon, cannot have if red public static final int RELATION_ALLY = 0x4000; // 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 int RELATION_ENEMY = 0x8000; // 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_ALLY_MEMBER = 0x10000; // clan is in alliance 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 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 // Masks
public static final byte SEND_ONE = 0x02;
public static final byte SEND_DEFAULT = 0x01; public static final byte SEND_DEFAULT = 0x01;
public static final byte SEND_ONE = 0x02;
public static final byte SEND_MULTI = 0x04; public static final byte SEND_MULTI = 0x04;
protected static class Relation protected static class Relation
@ -87,9 +86,9 @@ public class RelationChanged implements IClientOutgoingPacket
{ {
if (activeChar.isInvisible()) if (activeChar.isInvisible())
{ {
// throw new IllegalArgumentException("Cannot add invisible character to multi relation packet");
return; return;
} }
final Relation r = new Relation(); final Relation r = new Relation();
r._objId = activeChar.getObjectId(); r._objId = activeChar.getObjectId();
r._relation = relation; r._relation = relation;

View File

@ -82,7 +82,7 @@ public class Broadcast
player.sendPacket(mov); player.sendPacket(mov);
if ((mov instanceof CharInfo) && (creature.isPlayer())) 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 boolean isAutoAttackable = creature.isAutoAttackable(player);
final RelationCache oldrelation = creature.getKnownRelations().get(player.getObjectId()); final RelationCache oldrelation = creature.getKnownRelations().get(player.getObjectId());
if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable)) if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))