Skip to content

Commit 814345d

Browse files
fix: (Day) 1850 - Fix issue where you could kick players from an inst… (AscensionGameDev#1851)
* fix: (Day) 1850 - Fix issue where you could kick players from an instance to get past the party size limit * fix: also kick on intentional leave * remove MapInstanceType.Party --------- Co-authored-by: Robbie Lodico <[email protected]>
1 parent aa62096 commit 814345d

File tree

4 files changed

+70
-37
lines changed

4 files changed

+70
-37
lines changed

Intersect (Core)/Config/InstancingOptions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public partial class InstancingOptions
3434
/// </summary>
3535
public bool LoseExpOnInstanceDeath { get; set; } = false;
3636

37+
public bool BlockPartyInvitesInInstance { get; set; } = false;
38+
39+
public bool KickPartyMembersOnKick { get; set; } = true;
40+
3741
[OnDeserialized]
3842
internal void OnDeserializedMethod(StreamingContext context)
3943
{

Intersect.Server.Core/Entities/Player.cs

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ public ulong PlayTimeSeconds
182182
[NotMapped, JsonIgnore]
183183
public int MapAutorunEvents { get; private set; }
184184

185+
[NotMapped, JsonIgnore]
186+
public bool InOpenInstance => InstanceType != MapInstanceType.Personal && InstanceType != MapInstanceType.Shared;
187+
185188
/// <summary>
186189
/// References the in-memory copy of the guild for this player, reference this instead of the Guild property below.
187190
/// </summary>
@@ -4899,13 +4902,25 @@ public void CancelTrade()
48994902
//Parties
49004903
public void InviteToParty(Player fromPlayer)
49014904
{
4905+
if (fromPlayer == null)
4906+
{
4907+
return;
4908+
}
4909+
49024910
if (Party.Count != 0)
49034911
{
49044912
PacketSender.SendChatMsg(fromPlayer, Strings.Parties.inparty.ToString(Name), ChatMessageType.Party, CustomColors.Alerts.Error);
49054913

49064914
return;
49074915
}
49084916

4917+
if (Options.Instance.Instancing.BlockPartyInvitesInInstance && (!InOpenInstance || !fromPlayer.InOpenInstance))
4918+
{
4919+
PacketSender.SendChatMsg(fromPlayer, Strings.Parties.InInstance, ChatMessageType.Party, CustomColors.Alerts.Error);
4920+
4921+
return;
4922+
}
4923+
49094924
if (fromPlayer.PartyRequests.ContainsKey(this))
49104925
{
49114926
fromPlayer.PartyRequests.Remove(this);
@@ -4991,6 +5006,13 @@ public void KickParty(Guid target)
49915006
oldMember.Party = new List<Player>();
49925007
PacketSender.SendParty(oldMember);
49935008
PacketSender.SendChatMsg(oldMember, Strings.Parties.kicked, ChatMessageType.Party, CustomColors.Alerts.Error);
5009+
5010+
// Kick the player out of your shared instance!
5011+
if (Options.Instance.Instancing.KickPartyMembersOnKick && oldMember.InstanceType == MapInstanceType.Shared)
5012+
{
5013+
oldMember.WarpToLastOverworldLocation(false);
5014+
}
5015+
49945016
Party.Remove(oldMember);
49955017

49965018
if (Party.Count > 1) //Need atleast 2 party members to function
@@ -5021,36 +5043,40 @@ public void KickParty(Guid target)
50215043

50225044
public void LeaveParty()
50235045
{
5024-
if (Party.Count > 0 && Party.Contains(this))
5046+
if (Options.Instance.Instancing.KickPartyMembersOnKick && InstanceType == MapInstanceType.Shared)
5047+
{
5048+
WarpToLastOverworldLocation(false);
5049+
}
5050+
5051+
Party ??= new List<Player>();
5052+
if (Party.Count < 1 || !Party.Contains(this))
50255053
{
5026-
var oldMember = this;
5027-
Party.Remove(this);
5054+
return;
5055+
}
50285056

5029-
if (Party.Count > 1) //Need atleast 2 party members to function
5030-
{
5031-
//Update all members of the party with the new list
5032-
for (var i = 0; i < Party.Count; i++)
5033-
{
5034-
Party[i].Party = Party;
5035-
PacketSender.SendParty(Party[i]);
5036-
PacketSender.SendChatMsg(
5037-
Party[i], Strings.Parties.memberleft.ToString(oldMember.Name), ChatMessageType.Party, CustomColors.Alerts.Error
5038-
);
5039-
}
5040-
}
5041-
else if (Party.Count > 0) //Check if anyone is left on their own
5042-
{
5043-
var remainder = Party[0];
5044-
remainder.Party.Clear();
5045-
PacketSender.SendParty(remainder);
5046-
PacketSender.SendChatMsg(remainder, Strings.Parties.disbanded, ChatMessageType.Party, CustomColors.Alerts.Error);
5047-
}
5057+
var currentParty = Party.ToList();
5058+
currentParty.Remove(this);
50485059

5049-
PacketSender.SendChatMsg(this, Strings.Parties.left, ChatMessageType.Party, CustomColors.Alerts.Error);
5060+
string partyMessage = currentParty.Count > 1
5061+
? Strings.Parties.memberleft.ToString(Name)
5062+
: Strings.Parties.disbanded;
5063+
5064+
// Update all members of the party with the new list
5065+
foreach (var partyMember in currentParty)
5066+
{
5067+
partyMember.Party = currentParty.ToList();
5068+
PacketSender.SendParty(partyMember);
5069+
PacketSender.SendChatMsg(
5070+
partyMember,
5071+
partyMessage,
5072+
ChatMessageType.Party,
5073+
CustomColors.Alerts.Error
5074+
);
50505075
}
50515076

50525077
Party = new List<Player>();
50535078
PacketSender.SendParty(this);
5079+
PacketSender.SendChatMsg(this, Strings.Parties.left, ChatMessageType.Party, CustomColors.Alerts.Error);
50545080
}
50555081

50565082
public bool InParty(Player member)

Intersect.Server.Core/Localization/Strings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,9 @@ public sealed partial class PartiesNamespace : LocaleNamespace
11311131
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
11321132
public readonly LocalizedString disbanded = @"The party has been disbanded.";
11331133

1134+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
1135+
public readonly LocalizedString InInstance = @"You cannot invite someone to a party while in an instance!";
1136+
11341137
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
11351138
public readonly LocalizedString inparty = @"{00} is already in a party!";
11361139

Intersect.sln

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Client", "Interse
99
EndProject
1010
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Client.Framework", "Intersect.Client.Framework\Intersect.Client.Framework.csproj", "{40973F13-3339-4548-9008-FF76A0C8CD79}"
1111
EndProject
12-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Editor", "Intersect.Editor\Intersect.Editor.csproj", "{5AC53DF1-8152-466D-B7D0-238657F013F7}"
13-
EndProject
12+
#Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Editor", "Intersect.Editor\Intersect.Editor.csproj", "{5AC53DF1-8152-466D-B7D0-238657F013F7}"
13+
#EndProject
1414
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Network", "Intersect.Network\Intersect.Network.csproj", "{E8F288CB-51DF-4D9D-A3B3-A61BD4FD3F45}"
1515
EndProject
1616
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Server", "Intersect.Server\Intersect.Server.csproj", "{9FFC7331-87BE-403B-82A0-B86D3CCE7C53}"
@@ -23,8 +23,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Tests.Client", "I
2323
EndProject
2424
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Tests.Client.Framework", "Intersect.Tests.Client.Framework\Intersect.Tests.Client.Framework.csproj", "{83033560-06F2-4155-9956-E4F0F06DC113}"
2525
EndProject
26-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Tests.Editor", "Intersect.Tests.Editor\Intersect.Tests.Editor.csproj", "{3E8FC79E-D0B3-4554-9ABD-BD6DCBFBEE5D}"
27-
EndProject
26+
#Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Tests.Editor", "Intersect.Tests.Editor\Intersect.Tests.Editor.csproj", "{3E8FC79E-D0B3-4554-9ABD-BD6DCBFBEE5D}"
27+
#EndProject
2828
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Tests.Network", "Intersect.Tests.Network\Intersect.Tests.Network.csproj", "{E66A4B60-E79C-4222-A702-94D3CC7A2377}"
2929
EndProject
3030
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Intersect.Tests.Server", "Intersect.Tests.Server\Intersect.Tests.Server.csproj", "{F55A208D-6E20-462F-A204-EF13BCCF67D8}"
@@ -106,12 +106,12 @@ Global
106106
{40973F13-3339-4548-9008-FF76A0C8CD79}.NoFody|Any CPU.Build.0 = Debug|Any CPU
107107
{40973F13-3339-4548-9008-FF76A0C8CD79}.Release|Any CPU.ActiveCfg = Release|Any CPU
108108
{40973F13-3339-4548-9008-FF76A0C8CD79}.Release|Any CPU.Build.0 = Release|Any CPU
109-
{5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
110-
{5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
111-
{5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU
112-
{5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.Build.0 = Debug|Any CPU
113-
{5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
114-
{5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.Build.0 = Release|Any CPU
109+
#{5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
110+
#{5AC53DF1-8152-466D-B7D0-238657F013F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
111+
#{5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU
112+
#{5AC53DF1-8152-466D-B7D0-238657F013F7}.NoFody|Any CPU.Build.0 = Debug|Any CPU
113+
#{5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
114+
#{5AC53DF1-8152-466D-B7D0-238657F013F7}.Release|Any CPU.Build.0 = Release|Any CPU
115115
{E8F288CB-51DF-4D9D-A3B3-A61BD4FD3F45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
116116
{E8F288CB-51DF-4D9D-A3B3-A61BD4FD3F45}.Debug|Any CPU.Build.0 = Debug|Any CPU
117117
{E8F288CB-51DF-4D9D-A3B3-A61BD4FD3F45}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU
@@ -139,9 +139,9 @@ Global
139139
{83033560-06F2-4155-9956-E4F0F06DC113}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
140140
{83033560-06F2-4155-9956-E4F0F06DC113}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU
141141
{83033560-06F2-4155-9956-E4F0F06DC113}.Release|Any CPU.ActiveCfg = Release|Any CPU
142-
{3E8FC79E-D0B3-4554-9ABD-BD6DCBFBEE5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
143-
{3E8FC79E-D0B3-4554-9ABD-BD6DCBFBEE5D}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU
144-
{3E8FC79E-D0B3-4554-9ABD-BD6DCBFBEE5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
142+
#{3E8FC79E-D0B3-4554-9ABD-BD6DCBFBEE5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
143+
#{3E8FC79E-D0B3-4554-9ABD-BD6DCBFBEE5D}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU
144+
#{3E8FC79E-D0B3-4554-9ABD-BD6DCBFBEE5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
145145
{E66A4B60-E79C-4222-A702-94D3CC7A2377}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
146146
{E66A4B60-E79C-4222-A702-94D3CC7A2377}.NoFody|Any CPU.ActiveCfg = Debug|Any CPU
147147
{E66A4B60-E79C-4222-A702-94D3CC7A2377}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -186,7 +186,7 @@ Global
186186
{4030D4D5-9DC6-496D-9763-9A41DD1DECBE} = {91D46B09-C92B-450B-AEC2-C7A6EE0F8E3B}
187187
{49599C25-3C71-4EE5-98C9-957EE20F7DE7} = {91D46B09-C92B-450B-AEC2-C7A6EE0F8E3B}
188188
{83033560-06F2-4155-9956-E4F0F06DC113} = {91D46B09-C92B-450B-AEC2-C7A6EE0F8E3B}
189-
{3E8FC79E-D0B3-4554-9ABD-BD6DCBFBEE5D} = {91D46B09-C92B-450B-AEC2-C7A6EE0F8E3B}
189+
#{3E8FC79E-D0B3-4554-9ABD-BD6DCBFBEE5D} = {91D46B09-C92B-450B-AEC2-C7A6EE0F8E3B}
190190
{E66A4B60-E79C-4222-A702-94D3CC7A2377} = {91D46B09-C92B-450B-AEC2-C7A6EE0F8E3B}
191191
{F55A208D-6E20-462F-A204-EF13BCCF67D8} = {91D46B09-C92B-450B-AEC2-C7A6EE0F8E3B}
192192
{BAD9DA5F-4FA5-42A3-A58A-A7B880573121} = {0C9FAC99-60FC-4063-A15F-7A200096F67C}

0 commit comments

Comments
 (0)