L2JMobius

High Five declared war symbol

kinghanker · 5 · 5184

Offline kinghanker

  • Knight
  • ***
    • Posts: 68
When we declare war with another clan the sending of server/client packages seems not to be synchronized because the war message appears in the center of the screen but the symbol about the character does not appear until relogin.

In the video below, it shows better what I'm trying to explain:


Offline DebiaN

  • Vassal
  • *
    • Posts: 9
Try it!

package org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;

Code: [Select]
public void broadcastCharInfo()
{
final CharInfo charInfo = new CharInfo(this, false);
World.getInstance().forEachVisibleObject(this, PlayerInstance.class, player ->
{
if (isVisibleFor(player))
{
if (isInvisible() && player.canOverrideCond(PlayerCondOverride.SEE_ALL_PLAYERS))
{
player.sendPacket(new CharInfo(this, true));
}
else
{
player.sendPacket(charInfo);
}
+
+ player.sendPacket(new RelationChanged(this, getRelation(player), isAutoAttackable(player)));
+ if (hasSummon())
+ {
+ player.sendPacket(new RelationChanged(_summon, getRelation(player), isAutoAttackable(player)));
+ }
}
});
}


Offline kinghanker

  • Knight
  • ***
    • Posts: 68
It works, your solution is really very simple and solves the problem, congratulations!
I had already resolved otherwise, I added a check only when declaring or canceling wars. Both ways will do.

org.l2jmobius.gameserver.model.clan.Clan.java
Code: [Select]
public void broadcastClanStatus()
{
for (PlayerInstance member : getOnlineMembers(0))
{
member.sendPacket(PledgeShowMemberListDeleteAll.STATIC_PACKET);
member.sendPacket(new PledgeShowMemberListAll(this, member));

+ World.getInstance().forEachVisibleObject(member, PlayerInstance.class, player ->
+ {
+ if (!member.isVisibleFor(player))
+ {
+ return;
+ }
+
+ player.sendPacket(new RelationChanged(member, member.getRelation(player), member.isAutoAttackable(player)));
+ if (member.hasSummon())
+ {
+ player.sendPacket(new RelationChanged(member.getSummon(), member.getRelation(player), member.isAutoAttackable(player)));
+ }
+ });
}
}
Thanks for the help!


Offline DebiaN

  • Vassal
  • *
    • Posts: 9
Good job!
Your way is better since its will be called only once broadcastClanStatus need update.


Online Mobius

  • Distinguished King
  • *****
    • Posts: 17919
I see similar code on other branches as well.
According to that code...
Code: [Select]
Index: java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java
===================================================================
--- java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java (revision 9310)
+++ java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java (working copy)
@@ -4109,6 +4109,22 @@
  {
  player.sendPacket(charInfo);
  }
+
+ // Update relation.
+ final int relation = getRelation(player);
+ final boolean isAutoAttackable = isAutoAttackable(player);
+ final RelationCache oldrelation = getKnownRelations().get(player.getObjectId());
+ if ((oldrelation == null) || (oldrelation.getRelation() != relation) || (oldrelation.isAutoAttackable() != isAutoAttackable))
+ {
+ final RelationChanged rc = new RelationChanged();
+ rc.addRelation(this, relation, isAutoAttackable);
+ if (hasSummon())
+ {
+ player.sendPacket(new RelationChanged(_summon, getRelation(player), isAutoAttackable(player)));
+ }
+ player.sendPacket(rc);
+ getKnownRelations().put(player.getObjectId(), new RelationCache(relation, isAutoAttackable));
+ }
  }
  });
  }

Fixed with https://bitbucket.org/MobiusDev/l2j_mobius/commits/312e0a046832aa80c032c388f4801656feb36ec9
Thanks :D