Skip to content

Commit

Permalink
Wire up support for Society global chat (#3083)
Browse files Browse the repository at this point in the history
* Wire up support for Society global chat

* Update TurbineChatHandler.cs

* Update TurbineChatHandler.cs
  • Loading branch information
LtRipley36706 authored Jul 16, 2020
1 parent 54c84dc commit 053ef0f
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 24 deletions.
13 changes: 13 additions & 0 deletions Source/ACE.Entity/Enum/FactionBits.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;

namespace ACE.Entity.Enum
{
[Flags]
public enum FactionBits
{
None = 0x0,
CelestialHand = 0x1,
EldrytchWeb = 0x2,
RadiantBlood = 0x4
}
}
75 changes: 57 additions & 18 deletions Source/ACE.Server/Network/Handlers/TurbineChatHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,47 +55,86 @@ public static void TurbineChatReceived(ClientMessage clientMessage, Session sess
clientMessage.Payload.ReadUInt32(); // Always 0
var chatType = (ChatType)clientMessage.Payload.ReadUInt32();

if (channelID == TurbineChatChannel.Society)
if (channelID == TurbineChatChannel.Society) // shouldn't ever be hit
{
ChatPacket.SendServerMessage(session, "You do not belong to a society.", ChatMessageType.Broadcast); // I don't know if this is how it was done on the live servers
return;
}

var gameMessageTurbineChat = new GameMessageTurbineChat(ChatNetworkBlobType.NETBLOB_EVENT_BINARY, channelID, session.Player.Name, message, senderID, chatType);

var allegiance = AllegianceManager.FindAllegiance(channelID);
if (allegiance != null)
if (channelID > TurbineChatChannel.SocietyRadiantBlood) // Channel must be an allegiance channel
{
// is sender booted / gagged?
if (allegiance.IsFiltered(session.Player.Guid)) return;
var allegiance = AllegianceManager.FindAllegiance(channelID);
if (allegiance != null)
{
// is sender booted / gagged?
if (allegiance.IsFiltered(session.Player.Guid)) return;

// iterate through all allegiance members
foreach (var member in allegiance.Members.Keys)
{
// is this allegiance member online?
var online = PlayerManager.GetOnlinePlayer(member);
if (online == null)
continue;

// is this member booted / gagged?
if (allegiance.IsFiltered(member) || online.SquelchManager.Squelches.Contains(session.Player, ChatMessageType.Allegiance)) continue;

// does this player have allegiance chat filtered?
if (!online.GetCharacterOption(CharacterOption.ListenToAllegianceChat)) continue;

online.Session.Network.EnqueueSend(gameMessageTurbineChat);
}

session.Network.EnqueueSend(new GameMessageTurbineChat(ChatNetworkBlobType.NETBLOB_RESPONSE_BINARY, contextId, null, null, 0, chatType));
}
}
else if (channelID > TurbineChatChannel.Society) // Channel must be a society restricted channel
{
//var senderSociety = session.Player.Society;

//var adjustedChatType = senderSociety switch
//{
// FactionBits.CelestialHand => ChatType.SocietyCelHan,
// FactionBits.EldrytchWeb => ChatType.SocietyEldWeb,
// FactionBits.RadiantBlood => ChatType.SocietyRadBlo,
// _ => ChatType.Society
//};

//gameMessageTurbineChat = new GameMessageTurbineChat(ChatNetworkBlobType.NETBLOB_EVENT_BINARY, channelID, session.Player.Name, message, senderID, adjustedChatType);

// iterate through all allegiance members
foreach (var member in allegiance.Members.Keys)
foreach (var recipient in PlayerManager.GetAllOnline())
{
// is this allegiance member online?
var online = PlayerManager.GetOnlinePlayer(member);
if (online == null)
// handle filters
if (session.Player.Society != recipient.Society)
continue;

// is this member booted / gagged?
if (allegiance.IsFiltered(member) || online.SquelchManager.Squelches.Contains(session.Player, ChatMessageType.Allegiance)) continue;
if (!recipient.GetCharacterOption(CharacterOption.ListenToSocietyChat))
continue;

// does this player have allegiance chat filtered?
if (!online.GetCharacterOption(CharacterOption.ListenToAllegianceChat)) continue;
if (recipient.SquelchManager.Squelches.Contains(session.Player, ChatMessageType.AllChannels))
continue;

online.Session.Network.EnqueueSend(gameMessageTurbineChat);
recipient.Session.Network.EnqueueSend(gameMessageTurbineChat);
}

session.Network.EnqueueSend(new GameMessageTurbineChat(ChatNetworkBlobType.NETBLOB_RESPONSE_BINARY, contextId, null, null, 0, chatType));
}
else if (channelID == TurbineChatChannel.Olthoi) // Channel must be the Olthoi play channel
{
// todo: olthoi play chat (ha! yeah right...)
}
else
else // Channel must be available to all players
{
foreach (var recipient in PlayerManager.GetAllOnline())
{
// handle filters
if (channelID == TurbineChatChannel.General && !recipient.GetCharacterOption(CharacterOption.ListenToGeneralChat) ||
channelID == TurbineChatChannel.Trade && !recipient.GetCharacterOption(CharacterOption.ListenToTradeChat) ||
channelID == TurbineChatChannel.LFG && !recipient.GetCharacterOption(CharacterOption.ListenToLFGChat) ||
channelID == TurbineChatChannel.Roleplay && !recipient.GetCharacterOption(CharacterOption.ListenToRoleplayChat) ||
channelID == TurbineChatChannel.Society && !recipient.GetCharacterOption(CharacterOption.ListenToSocietyChat))
channelID == TurbineChatChannel.Roleplay && !recipient.GetCharacterOption(CharacterOption.ListenToRoleplayChat))
continue;

if (recipient.SquelchManager.Squelches.Contains(session.Player, ChatMessageType.AllChannels))
Expand Down
56 changes: 56 additions & 0 deletions Source/ACE.Server/WorldObjects/Creature_Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,5 +299,61 @@ public string KillQuest3
get => GetProperty(PropertyString.KillQuest3);
set { if (value == null) RemoveProperty(PropertyString.KillQuest3); else SetProperty(PropertyString.KillQuest3, value); }
}

public int? Faction1Bits
{
get => GetProperty(PropertyInt.Faction1Bits);
set { if (!value.HasValue) RemoveProperty(PropertyInt.Faction1Bits); else SetProperty(PropertyInt.Faction1Bits, value.Value); }
}

public int? Faction2Bits
{
get => GetProperty(PropertyInt.Faction2Bits);
set { if (!value.HasValue) RemoveProperty(PropertyInt.Faction2Bits); else SetProperty(PropertyInt.Faction2Bits, value.Value); }
}

public int? Faction3Bits
{
get => GetProperty(PropertyInt.Faction3Bits);
set { if (!value.HasValue) RemoveProperty(PropertyInt.Faction3Bits); else SetProperty(PropertyInt.Faction3Bits, value.Value); }
}

public int? Hatred1Bits
{
get => GetProperty(PropertyInt.Hatred1Bits);
set { if (!value.HasValue) RemoveProperty(PropertyInt.Hatred1Bits); else SetProperty(PropertyInt.Hatred1Bits, value.Value); }
}

public int? Hatred2Bits
{
get => GetProperty(PropertyInt.Hatred2Bits);
set { if (!value.HasValue) RemoveProperty(PropertyInt.Hatred2Bits); else SetProperty(PropertyInt.Hatred2Bits, value.Value); }
}

public int? Hatred3Bits
{
get => GetProperty(PropertyInt.Hatred3Bits);
set { if (!value.HasValue) RemoveProperty(PropertyInt.Hatred3Bits); else SetProperty(PropertyInt.Hatred3Bits, value.Value); }
}

public int? SocietyRankCelhan
{
get => GetProperty(PropertyInt.SocietyRankCelhan);
set { if (!value.HasValue) RemoveProperty(PropertyInt.SocietyRankCelhan); else SetProperty(PropertyInt.SocietyRankCelhan, value.Value); }
}

public int? SocietyRankEldweb
{
get => GetProperty(PropertyInt.SocietyRankEldweb);
set { if (!value.HasValue) RemoveProperty(PropertyInt.SocietyRankEldweb); else SetProperty(PropertyInt.SocietyRankEldweb, value.Value); }
}

public int? SocietyRankRadblo
{
get => GetProperty(PropertyInt.SocietyRankRadblo);
set { if (!value.HasValue) RemoveProperty(PropertyInt.SocietyRankRadblo); else SetProperty(PropertyInt.SocietyRankRadblo, value.Value); }
}

public FactionBits Society => (FactionBits?)Faction1Bits ?? 0;
}
}
2 changes: 2 additions & 0 deletions Source/ACE.Server/WorldObjects/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ public void LogOut_Inner(bool clientSessionTerminatedAbruptly = false)
LeaveTurbineChatChannel("Roleplay");
if (GetCharacterOption(CharacterOption.ListenToAllegianceChat) && Allegiance != null)
LeaveTurbineChatChannel("Allegiance");
if (GetCharacterOption(CharacterOption.ListenToSocietyChat) && Society != FactionBits.None)
LeaveTurbineChatChannel("Society");
}
}

Expand Down
42 changes: 36 additions & 6 deletions Source/ACE.Server/WorldObjects/Player_Networking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public void PlayerEnterWorld()
JoinTurbineChatChannel("LFG");
if (GetCharacterOption(CharacterOption.ListenToRoleplayChat))
JoinTurbineChatChannel("Roleplay");
if (GetCharacterOption(CharacterOption.ListenToSocietyChat) && Society != FactionBits.None)
JoinTurbineChatChannel("Society");
}

// check if vassals earned XP while offline
Expand Down Expand Up @@ -116,17 +118,34 @@ public void SendTurbineChatChannels(bool breakAllegiance = false)
{
var allegianceChannel = Allegiance != null && !breakAllegiance ? Allegiance.Biota.Id : 0u;

//todo: society chat channel
var societyChannel = Society switch
{
FactionBits.CelestialHand => TurbineChatChannel.SocietyCelestialHand,
FactionBits.EldrytchWeb => TurbineChatChannel.SocietyEldrytchWeb,
FactionBits.RadiantBlood => TurbineChatChannel.SocietyRadiantBlood,
_ => 0u
};

Session.Network.EnqueueSend(new GameEventSetTurbineChatChannels(Session, allegianceChannel));
Session.Network.EnqueueSend(new GameEventSetTurbineChatChannels(Session, allegianceChannel, societyChannel));
}

public void JoinTurbineChatChannel(string channelName)
{
if (channelName == "Allegiance" && Allegiance == null)
return;
else if (channelName == "Society") //&& Society == null) // todo: society
return;
else if (channelName == "Society")
{
if (Society == FactionBits.None)
return;

channelName = Society switch
{
FactionBits.CelestialHand => "Celestial Hand",
FactionBits.EldrytchWeb => "Eldrytch Web",
FactionBits.RadiantBlood => "Radiant Blood",
_ => channelName
};
}
else if (channelName == "Olthoi") //todo: olthoi play
return;

Expand All @@ -139,8 +158,19 @@ public void LeaveTurbineChatChannel(string channelName, bool breakAllegiance = f
{
if (channelName == "Allegiance" && !breakAllegiance && Allegiance == null)
return;
else if (channelName == "Society") //&& Society == null) // todo: society
return;
else if (channelName == "Society")
{
if (Society == FactionBits.None)
return;

channelName = Society switch
{
FactionBits.CelestialHand => "Celestial Hand",
FactionBits.EldrytchWeb => "Eldrytch Web",
FactionBits.RadiantBlood => "Radiant Blood",
_ => channelName
};
}
else if (channelName == "Olthoi") //todo: olthoi play
return;

Expand Down

0 comments on commit 053ef0f

Please sign in to comment.