Skip to content

Commit

Permalink
Reworked sign handling
Browse files Browse the repository at this point in the history
This fixes the `1` sign getting removed for alliance members if another player joined.
Also removed custom (and buggy) sign handling for leagues.
Thanks to Toby for the correct `SM_SHOW_BRAND` packet structure.
  • Loading branch information
neon-dev committed Jun 23, 2024
1 parent 1fbe91e commit a1def76
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import com.aionemu.gameserver.model.Race;
import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.model.team.common.events.ShowBrandEvent;
import com.aionemu.gameserver.model.team.common.legacy.LootGroupRules;
import com.aionemu.gameserver.model.team.common.legacy.LootRuleType;
import com.aionemu.gameserver.network.aion.AionServerPacket;
Expand All @@ -22,7 +21,7 @@
public abstract class TemporaryPlayerTeam<TM extends TeamMember<Player>> extends GeneralTeam<Player, TM> {

private LootGroupRules lootGroupRules = new LootGroupRules();
private Map<Integer, Integer> brands = new ConcurrentHashMap<>();
protected final Map<Integer, Integer> targetIdsByBrandId = new ConcurrentHashMap<>();

public TemporaryPlayerTeam(int objId, boolean autoReleaseObjectId) {
super(objId, autoReleaseObjectId);
Expand All @@ -38,17 +37,13 @@ public TemporaryPlayerTeam(int objId, boolean autoReleaseObjectId) {
*/
public abstract int getMaxExpPlayerLevel();

public void onBrand(int targetObjectId, int brandId) {
if (targetObjectId == 0) {
brands.values().removeIf(bId -> bId == brandId);
} else {
brands.put(targetObjectId, brandId);
}
onEvent(new ShowBrandEvent<>(this, targetObjectId, brandId));
public void updateBrand(int brandId, int targetObjectId) {
targetIdsByBrandId.put(brandId, targetObjectId);
sendPackets(new SM_SHOW_BRAND(brandId, targetObjectId));
}

public void sendBrands(Player member) {
brands.forEach((targetObjId, brandId) -> PacketSendUtility.sendPacket(member, new SM_SHOW_BRAND(brandId, targetObjId)));
PacketSendUtility.sendPacket(member, new SM_SHOW_BRAND(targetIdsByBrandId));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,6 @@ public static void distributeKinahInGroup(Player player, long amount) {
}
}

/**
* Show specific mark on top of player
*/
public static void showBrand(Player player, int targetObjId, int brandId) {
PlayerAlliance alliance = player.getPlayerAlliance();
if (alliance != null) {
alliance.onBrand(targetObjId, brandId);
}
}

public static final String getServiceStatus() {
return "Number of alliances: " + alliances.size();
}

public static class OfflinePlayerAllianceChecker implements Runnable {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.aionemu.gameserver.network.aion.serverpackets.SM_ABYSS_RANK_UPDATE;
import com.aionemu.gameserver.network.aion.serverpackets.SM_ALLIANCE_INFO;
import com.aionemu.gameserver.network.aion.serverpackets.SM_ALLIANCE_MEMBER_INFO;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SHOW_BRAND;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
import com.aionemu.gameserver.utils.PacketSendUtility;

Expand All @@ -27,10 +26,8 @@ public void handleEvent() {
PlayerAllianceMember invitedMember = PlayerAllianceService.addPlayerToAlliance(team, player);

SM_ALLIANCE_INFO allianceInfo = new SM_ALLIANCE_INFO(team);
SM_SHOW_BRAND allianceMark = new SM_SHOW_BRAND(0, 0, team.isInLeague());
SM_ALLIANCE_MEMBER_INFO allianceMemberInfo = new SM_ALLIANCE_MEMBER_INFO(invitedMember, PlayerAllianceEvent.JOIN);
PacketSendUtility.sendPacket(player, allianceInfo);
PacketSendUtility.sendPacket(player, allianceMark);
PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_FORCE_ENTERED_FORCE());
PacketSendUtility.sendPacket(player, allianceMemberInfo);
team.sendBrands(player);
Expand All @@ -40,7 +37,6 @@ public void handleEvent() {
PacketSendUtility.sendPacket(p, allianceMemberInfo);
PacketSendUtility.sendPacket(p, SM_SYSTEM_MESSAGE.STR_FORCE_HE_ENTERED_FORCE(player.getName()));
PacketSendUtility.sendPacket(p, allianceInfo);
PacketSendUtility.sendPacket(p, allianceMark);
PacketSendUtility.sendPacket(player, new SM_ALLIANCE_MEMBER_INFO(member, PlayerAllianceEvent.ENTER));
}
});
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,6 @@ public static void distributeKinah(Player player, long kinah) {
}
}

/**
* Show specific mark on top of player
*/
public static void showBrand(Player player, int targetObjId, int brandId) {
PlayerGroup group = player.getPlayerGroup();
if (group != null) {
group.onBrand(targetObjId, brandId);
}
}

public static void changeLeader(Player player) {
PlayerGroup group = player.getPlayerGroup();
if (group != null) {
Expand Down Expand Up @@ -208,15 +198,6 @@ public static void stopMentoring(Player player) {
}
}

public static final void cleanup() {
log.info(getServiceStatus());
groups.clear();
}

public static final String getServiceStatus() {
return "Number of groups: " + groups.size();
}

public static final PlayerGroup searchGroup(int playerObjId) {
for (PlayerGroup group : groups.values()) {
if (group.hasMember(playerObjId)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.aionemu.gameserver.model.team.common.legacy.LootGroupRules;
import com.aionemu.gameserver.network.aion.AionServerPacket;
import com.aionemu.gameserver.network.aion.serverpackets.SM_ALLIANCE_INFO;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SHOW_BRAND;
import com.aionemu.gameserver.utils.collections.Predicates;
import com.aionemu.gameserver.utils.idfactory.IDFactory;

Expand Down Expand Up @@ -151,7 +150,7 @@ public void broadcast(PlayerAlliance skippedAlliance, Player skippedPlayer) {
if (skippedPlayer != null) {
predicate = Predicates.Players.allExcept(skippedPlayer);
}
targetAlliance.sendPacket(predicate, new SM_ALLIANCE_INFO(targetAlliance, skippedAlliance), new SM_SHOW_BRAND(0, 0, true));
targetAlliance.sendPacket(predicate, new SM_ALLIANCE_INFO(targetAlliance, skippedAlliance));
}
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ public static Collection<League> getLeagues() {
return Collections.unmodifiableCollection(leagues.values());
}

public static void showBrand(Player player, int targetObjId, int brandId) {
League league = player.getPlayerAlliance().getLeague();
league.onEvent(new LeagueShowBrandEvent(league, targetObjId, brandId));
}

public static void moveAlliance(Player player, int selectedId, int targetId) {
League league = player.getPlayerAlliance().getLeague();
if (league.getLeaderObject().getLeaderObject().equals(player)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.aionemu.gameserver.model.team.common.events.AlwaysTrueTeamEvent;
import com.aionemu.gameserver.model.team.league.League;
import com.aionemu.gameserver.network.aion.serverpackets.SM_ALLIANCE_INFO;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SHOW_BRAND;

/**
* @author ATracer
Expand All @@ -20,7 +19,6 @@ public LeagueCreateEvent(League league) {
public void handleEvent() {
league.forEach(alliance -> {
alliance.sendPackets(new SM_ALLIANCE_INFO(alliance, SM_ALLIANCE_INFO.LEAGUE_ALLIANCE_ENTERED, alliance.getLeader().getName()));
alliance.sendPackets(new SM_SHOW_BRAND(0, 0, true));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.aionemu.gameserver.model.team.league.League;
import com.aionemu.gameserver.model.team.league.LeagueMember;
import com.aionemu.gameserver.network.aion.serverpackets.SM_ALLIANCE_INFO;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SHOW_BRAND;

/**
* @author Tibald
Expand Down Expand Up @@ -37,7 +36,6 @@ public void handleEvent() {
} else {
alliance.sendPackets(new SM_ALLIANCE_INFO(alliance, SM_ALLIANCE_INFO.LEAGUE_JOINED_ALLIANCE, invitedAlliance.getLeaderObject().getName()));
}
alliance.sendPackets(new SM_SHOW_BRAND(0, 0, true));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.aionemu.gameserver.model.team.league.League;
import com.aionemu.gameserver.model.team.league.LeagueService;
import com.aionemu.gameserver.network.aion.serverpackets.SM_ALLIANCE_INFO;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SHOW_BRAND;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
import com.aionemu.gameserver.utils.PacketSendUtility;

Expand Down Expand Up @@ -50,18 +49,15 @@ public void handleEvent() {
switch (reason) {
case LEAVE:
alliance.sendPackets(new SM_ALLIANCE_INFO(alliance, SM_ALLIANCE_INFO.LEAGUE_LEFT_ME, alliance.getLeaderObject().getName()));
alliance.sendPackets(new SM_SHOW_BRAND(0, 0, alliance.isInLeague()));
checkDisband();
break;
case EXPEL:
// TODO getCaptainName in team
alliance.sendPackets(new SM_ALLIANCE_INFO(alliance, SM_ALLIANCE_INFO.LEAGUE_EXPELLED, league.getLeaderObject().getLeader().getName()));
alliance.sendPackets(new SM_SHOW_BRAND(0, 0, alliance.isInLeague()));
checkDisband();
break;
case DISBAND:
alliance.sendPackets(new SM_ALLIANCE_INFO(alliance, SM_ALLIANCE_INFO.LEAGUE_DISPERSED, ""));
alliance.sendPackets(new SM_SHOW_BRAND(0, 0, alliance.isInLeague()));
break;
}
}
Expand All @@ -79,12 +75,10 @@ public void accept(PlayerAlliance leagueAlliance) {
case LEAVE:
PacketSendUtility.sendPacket(member,
new SM_ALLIANCE_INFO(leagueAlliance, SM_ALLIANCE_INFO.LEAGUE_LEFT_HIM, alliance.getLeader().getName()));
PacketSendUtility.sendPacket(member, new SM_SHOW_BRAND(0, 0, leagueAlliance.isInLeague()));
break;
case EXPEL:
// TODO may be EXPEL message only to leader
PacketSendUtility.sendPacket(member, new SM_ALLIANCE_INFO(leagueAlliance, SM_ALLIANCE_INFO.LEAGUE_EXPEL, alliance.getLeader().getName()));
PacketSendUtility.sendPacket(member, new SM_SHOW_BRAND(0, 0, leagueAlliance.isInLeague()));
break;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.aionemu.gameserver.model.team.common.legacy.LootGroupRules;
import com.aionemu.gameserver.model.team.league.League;
import com.aionemu.gameserver.network.aion.serverpackets.SM_ALLIANCE_INFO;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SHOW_BRAND;

/**
* @author Source, Neon
Expand All @@ -22,10 +21,7 @@ public LeagueLootRulesChangeEvent(League league, LootGroupRules lootGroupRules)
@Override
public void handleEvent() {
league.setLootGroupRules(lootGroupRules);
league.forEach(alliance -> {
alliance.sendPackets(new SM_ALLIANCE_INFO(alliance));
alliance.sendPackets(new SM_SHOW_BRAND(0, 0, true));
});
league.forEach(alliance -> alliance.sendPackets(new SM_ALLIANCE_INFO(alliance)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.aionemu.gameserver.model.team.league.League;
import com.aionemu.gameserver.model.team.league.LeagueMember;
import com.aionemu.gameserver.network.aion.serverpackets.SM_ALLIANCE_INFO;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SHOW_BRAND;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;

/**
Expand Down Expand Up @@ -38,7 +37,6 @@ public void handleEvent() {
targetName = target.getObject().getLeaderObject().getName();
league.forEach(alliance -> {
alliance.sendPackets(new SM_ALLIANCE_INFO(alliance));
alliance.sendPackets(new SM_SHOW_BRAND(0, 0, true));

if (alliance.getObjectId() == selectedAllianceId) {
alliance.sendPackets(SM_SYSTEM_MESSAGE.STR_UNION_CHANGE_FORCE_NUMBER_ME(targetCurrentPosition));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.util.Set;

import com.aionemu.gameserver.model.gameobjects.player.Player;
import com.aionemu.gameserver.model.team.alliance.PlayerAllianceService;
import com.aionemu.gameserver.model.team.group.PlayerGroupService;
import com.aionemu.gameserver.model.team.TemporaryPlayerTeam;
import com.aionemu.gameserver.model.team.alliance.PlayerAlliance;
import com.aionemu.gameserver.network.aion.AionClientPacket;
import com.aionemu.gameserver.network.aion.AionConnection.State;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SHOW_BRAND;
Expand Down Expand Up @@ -35,24 +35,11 @@ protected void readImpl() {
protected void runImpl() {
Player player = getConnection().getActivePlayer();

if (player.isInGroup()) {
if (player.getPlayerGroup().isLeader(player)) {
PlayerGroupService.showBrand(player, targetObjectId, brandId);
}
}
// to better times (on retail still not implemented) but we have ;)
// else if (player.isInLeague()) {
// if (player.getPlayerAlliance().getLeague().getLeader().getObject().isLeader(player)) {
// LeagueService.showBrand(player, targetObjectId, brandId);
// }
// }
else if (player.isInAlliance()) {
if (player.getPlayerAlliance().isSomeCaptain(player)) {
PlayerAllianceService.showBrand(player, targetObjectId, brandId);
}
} else {
TemporaryPlayerTeam<?> team = player.getCurrentTeam();
if (team == null) {
PacketSendUtility.sendPacket(player, new SM_SHOW_BRAND(brandId, targetObjectId));
} else if (team.isLeader(player) || team instanceof PlayerAlliance alliance && alliance.isSomeCaptain(player)) {
team.updateBrand(brandId, targetObjectId);
}
}

}
Loading

0 comments on commit a1def76

Please sign in to comment.