Previous commit for older branches.

This commit is contained in:
MobiusDevelopment
2021-05-21 23:17:20 +00:00
parent 2a47b926ed
commit 80d9daf414
42 changed files with 452 additions and 431 deletions

View File

@@ -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;
}

View File

@@ -971,12 +971,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;
@@ -1078,12 +1078,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;
}
@@ -1780,7 +1782,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))
@@ -4073,7 +4075,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))
@@ -6345,7 +6347,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))
@@ -12372,7 +12374,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())
@@ -12388,7 +12390,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())

View File

@@ -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))

View File

@@ -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; // single sword
public static final long RELATION_MUTUAL_WAR = 0x4E200000L; // double swords?
// 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<Relation> _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,13 +82,13 @@ 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())
{
// throw new IllegalArgumentException("Cannot add invisible character to multi relation packet");
return;
}
final Relation r = new Relation();
r._objId = activeChar.getObjectId();
r._relation = relation;
@@ -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);

View File

@@ -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))