Skip to content

Commit

Permalink
Improve Friends Notifications (#4194)
Browse files Browse the repository at this point in the history
* Improve Friends Notifications

Friends will now send broadcast text to announce their online status as was the case in retail.

* Update Player_Networking.cs

:}

* Update Player_Networking.cs
  • Loading branch information
LtRipley36706 authored Jun 6, 2024
1 parent 575688c commit 2c459c7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Source/ACE.Server/Managers/PlayerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public static bool SwitchPlayerFromOfflineToOnline(Player player)

AllegianceManager.LoadPlayer(player);

player.SendFriendStatusUpdates();
player.SendFriendStatusUpdates(false, !player.GetAppearOffline());

return true;
}
Expand Down Expand Up @@ -426,7 +426,7 @@ public static bool SwitchPlayerFromOnlineToOffline(Player player)
playersLock.ExitWriteLock();
}

player.SendFriendStatusUpdates(false);
player.SendFriendStatusUpdates(!player.GetAppearOffline(), false);
player.HandleAllegianceOnLogout();

return true;
Expand Down
3 changes: 2 additions & 1 deletion Source/ACE.Server/WorldObjects/Player_Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ public bool GetAppearOffline()
/// </summary>
public void SetAppearOffline(bool appearOffline)
{
var previousAppearOffline = GetAppearOffline();
SetCharacterOption(CharacterOption.AppearOffline, appearOffline);
SendFriendStatusUpdates();
SendFriendStatusUpdates(!previousAppearOffline, !GetAppearOffline());
}


Expand Down
33 changes: 15 additions & 18 deletions Source/ACE.Server/WorldObjects/Player_Networking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public void SendInventoryAndWieldedItems()
foreach (var item in EquippedObjects.Values)
{
item.Wielder = this;
Session.Network.EnqueueSend(new GameMessageCreateObject(item));
Session.Network.EnqueueSend(new GameMessageCreateObject(item));
}
}

Expand All @@ -272,28 +272,25 @@ public void SendContractTrackerTable()
/// <summary>
/// Will send out GameEventFriendsListUpdate packets to everyone online that has this player as a friend.
/// </summary>
public void SendFriendStatusUpdates()
public void SendFriendStatusUpdates(bool previouslyOnline, bool isOnline)
{
var inverseFriends = PlayerManager.GetOnlineInverseFriends(Guid);
var appearOffline = GetAppearOffline();
var previouslyOnlineAndIsNowOffline = previouslyOnline && !isOnline;
var previouslyOfflineAndIsNowOnline = !previouslyOnline && isOnline;
var previouslyOfflineAndAppearOffline = !previouslyOnline && appearOffline;

foreach (var friend in inverseFriends)
if ((previouslyOfflineAndIsNowOnline && !previouslyOfflineAndAppearOffline) || previouslyOnlineAndIsNowOffline)
{
var playerFriend = new CharacterPropertiesFriendList { CharacterId = friend.Guid.Full, FriendId = Guid.Full };
friend.Session.Network.EnqueueSend(new GameEventFriendsListUpdate(friend.Session, GameEventFriendsListUpdate.FriendsUpdateTypeFlag.FriendStatusChanged, playerFriend, true, !GetAppearOffline()));
}
}
var msg = $"{Name} has {(isOnline ? "come on" : "gone off")}line.";

/// <summary>
/// Will send out GameEventFriendsListUpdate packets to everyone online that has this player as a friend.
/// </summary>
public void SendFriendStatusUpdates(bool onlineStatus)
{
var inverseFriends = PlayerManager.GetOnlineInverseFriends(Guid);
var inverseFriends = PlayerManager.GetOnlineInverseFriends(Guid);

foreach (var friend in inverseFriends)
{
var playerFriend = new CharacterPropertiesFriendList { CharacterId = friend.Guid.Full, FriendId = Guid.Full };
friend.Session.Network.EnqueueSend(new GameEventFriendsListUpdate(friend.Session, GameEventFriendsListUpdate.FriendsUpdateTypeFlag.FriendStatusChanged, playerFriend, true, onlineStatus));
foreach (var friend in inverseFriends)
{
var playerFriend = new CharacterPropertiesFriendList { CharacterId = friend.Guid.Full, FriendId = Guid.Full };
friend.Session.Network.EnqueueSend(new GameEventFriendsListUpdate(friend.Session, GameEventFriendsListUpdate.FriendsUpdateTypeFlag.FriendStatusChanged, playerFriend, true, isOnline));
friend.SendMessage(msg);
}
}
}

Expand Down

0 comments on commit 2c459c7

Please sign in to comment.