Updates Packets & Randomizer (#43)

* Fixes a bug with the main loop. Removes unnecessary optimizations for RDRand.

* WIP - Rewriting packets.

* Cleanup and updates README

* Converts more packets

* Fixes header

* Converts Effects packets.

* Forgot the send command

* Adds the start of containers packets.

* Adds message packets with caching

* Extends the send methods

* Starts to add Acquire methods

* Converted the packets

* Cleanup

* Cleanup

* Adds more packets

* Adds more packets

* Fixes clearing arrays from pool. Adds Mobile Incoming

* Converts more packets.

* Moves more packets

* Moves more packets

* Test compression

* Merges

* Migrating to an idiomatic syntax that also supports compression, and proxying.

* Optimize the stack alloc. Changes attributes

* Converted container packets

* Visual Studio doesn't auto save files. I am still getting used to subpar IDEs.

* Adds static packet caching. Will profile later. Converts more packets

* Fixes packets and changes how compression is configured

* WIP - Adds basics for Gumps. Not finished though.

* Fix file

* Fixes formatting

* Changed SpanWriter to be more idiomatic.

* Fixes Span vs RawSpan and missing stackallocs

* Converts over some more gumps

* WIP - Deletes 32bit support.

* Drops RDRand32 support.

* Fixes gump compilation

* Converting gump components

* Removes old huffman compression function

* Revert signature for backwards compatibility

* WIP - Converting more gump components

* Creates ArraySet for the strings. Updates AppendTo to reference that.

* Converts the maining gump components

* Cleans up gump components

* Cleans up directives

* Cleans up ArraySet and moves it. Adds null-coalescing-assignment

* Cleanup, Target Packets, and C# 8 changes.

* Removed OPL Packet

* World packets

* Fixing packet uses

* Cleans up code. Fixes packet uses in various places.

* More cleanup for packets

* Code cleanup

* Converts more packet uses and cleans up more code

* More code cleanup

* Finishes fixing the packets in Item

* Updates secure trade packets

* Updates core and gets it to compile.

* Moved packets to scripts. Fixed account handler use of packets

* Code cleanup

* Updates chat packets

* Code cleanuo

* Adds party packets, but need to implement them.

* Party packets WIP

* Finishes party packets

* Rearrange movement namespaces and classes

* Finishes plant packets

* Code Formatting

* Fixes moving effects

* Code cleanup, eliminates equipinfo

* Adds more packets. Fixes bugs with various packets.

* Finishes mahjon packets

* Fixes mahjong packet

* Code cleanup

* Finishes mahjong packets

* Adds Map packets

* Add multifacet maps and charts

* Cleans up some packets with UTF8

* Optimizes packets

* Cleans up more packets. Moves the MessageHelper

* Removes assistant support. Removes extended protocol. Incorporates MapUO packets as normal packets.

* Updates protocol extensions packet receiver

* Fixes a few bugs. Fixes a few more packets.

* Code cleanup and fixing more packets

* Fixes packet effects

* Cleaned up more code

* Buff Icon cleanup

* Removed unused constructors

* Code Cleanup. Adds BoatHS Packets

* Moves house files. Updates house foundation packets.

* Deployment cleanup

* Fixes:

* Code cleanup

* More code cleanup

* More code cleanup

* Cleaned up BaseHouse

* Enforces styling

* Converts foreach to linq where possible.

* Dont need that

* Goals/Readme updates

* Removes 32bit support at the highest level. Turns on HRT by default.

* Code cleanup. Fixes extended features packet.

* Fixes various bugs

* Code cleanup

* Code cleanup

* Code cleanup. Fixes gump X/Y assignment.

* Code cleanup using |= operator

* More code cleanup

* Cleanup

* Fixes spacing issues. Thanks Visual Studio. You suck.

* Compiler error

* Fixes NPE from RunUO 2.7

* Renames ScriptCompiler to AssemblyHandler. Fixes packets. Updates README

* Fixes more packets. Stupid trailing nulls.

* Fixes various bugs.

* Fixes for gumps

* Fixes more gump stuff. Going to split it out later since it is getting insane

* Recoded the gump writing

* WIP

* *Added output path of scripts project to dev branch
*Activated debugging in code
This commit is contained in:
Kamron Batman 2019-11-11 03:40:16 -08:00 committed by 3HMonkey
parent 7aa8fd3df1
commit 179cb50557
588 changed files with 10843 additions and 16177 deletions

View file

@ -16,7 +16,7 @@ namespace Server.Gumps
{
public enum AdminGumpPage
{
Information_General,
Information_General = 0,
Information_Perf,
Administer,
Clients,
@ -39,7 +39,8 @@ namespace Server.Gumps
AccountDetails_Tags,
AccountDetails_ChangePassword,
AccountDetails_ChangeAccess,
FirewallInfo
FirewallInfo,
Invalid = -1
}
public class AdminGump : Gump
@ -587,8 +588,7 @@ namespace Server.Gumps
}
case AdminGumpPage.Accounts:
{
if (m_List == null)
m_List = new List<object>();
m_List ??= new List<object>();
List<Account> rads = state as List<Account>;
@ -1182,11 +1182,10 @@ namespace Server.Gumps
if (totalBytes > 1000000)
return $"{(double)totalBytes / 1048576:F1} MB";
if (totalBytes > 1000)
return $"{(double)totalBytes / 1024:F1} KB";
return $"{totalBytes} Bytes";
}
public static string FormatByteAmount(long totalBytes) =>
totalBytes > 1000000000 ? $"{(double)totalBytes / 1073741824:F1} GB" :
totalBytes > 1000000 ? $"{(double)totalBytes / 1048576:F1} MB" :
totalBytes > 1000 ? $"{(double)totalBytes / 1024:F1} KB" : $"{totalBytes} Bytes";
public static void Initialize()
{
@ -1525,7 +1524,7 @@ namespace Server.Gumps
{
IPAddress[] ips = a.LoginIPs;
if (ips.Length != 0 && ip == ips[0] && AccountHandler.IPTable.ContainsKey(ips[0]))
if (ips.Length != 0 && ip.Equals(ips[0]) && AccountHandler.IPTable.ContainsKey(ips[0]))
--AccountHandler.IPTable[ip];
List<IPAddress> newList = new List<IPAddress>(ips);
@ -1608,30 +1607,19 @@ namespace Server.Gumps
{
case 0:
{
AdminGumpPage page;
switch (index)
AdminGumpPage page = index switch
{
case 0:
page = AdminGumpPage.Information_General;
break;
case 1:
page = AdminGumpPage.Administer;
break;
case 2:
page = AdminGumpPage.Clients;
break;
case 3:
page = AdminGumpPage.Accounts;
break;
case 4:
page = AdminGumpPage.Firewall;
break;
case 5:
page = AdminGumpPage.Information_Perf;
break;
default: return;
}
0 => AdminGumpPage.Information_General,
1 => AdminGumpPage.Administer,
2 => AdminGumpPage.Clients,
3 => AdminGumpPage.Accounts,
4 => AdminGumpPage.Firewall,
5 => AdminGumpPage.Information_Perf,
_ => AdminGumpPage.Invalid,
};
if (page == AdminGumpPage.Invalid)
return;
from.SendGump(new AdminGump(from, page));
break;
@ -1951,12 +1939,7 @@ namespace Server.Gumps
hasAccess = true;
else
for (int j = 0; !hasAccess && j < a.Length; ++j)
{
Mobile m = a[j];
if (m?.AccessLevel >= level)
hasAccess = true;
}
hasAccess |= a[j]?.AccessLevel >= level;
if (!hasAccess)
{
@ -2500,11 +2483,7 @@ namespace Server.Gumps
}
case 31: // View all inactive accounts
{
List<object> results = new List<object>();
foreach (Account acct in Accounts.GetAccounts())
if (acct.Inactive)
results.Add(acct);
List<object> results = Accounts.GetAccounts().Cast<Account>().Where(acct => acct.Inactive).Cast<object>().ToList();
if (results.Count == 1)
from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null,
@ -2517,11 +2496,7 @@ namespace Server.Gumps
}
case 32: // View all banned accounts
{
List<object> results = new List<object>();
foreach (Account acct in Accounts.GetAccounts())
if (acct.Banned)
results.Add(acct);
List<object> results = Accounts.GetAccounts().Cast<Account>().Where(acct => acct.Banned).Cast<object>().ToList();
if (results.Count == 1)
from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null,
@ -2552,8 +2527,7 @@ namespace Server.Gumps
bool hasHouse = false;
for (int i = 0; i < acct.Length && !hasHouse; ++i)
if (acct[i] != null && BaseHouse.HasHouse(acct[i]))
hasHouse = true;
hasHouse |= acct[i] != null && BaseHouse.HasHouse(acct[i]);
if (!hasHouse)
newRads.Add(acct);
@ -2972,8 +2946,7 @@ namespace Server.Gumps
if (check.AccessLevel > accessLevel)
accessLevel = check.AccessLevel;
if (check.NetState != null)
online = true;
online |= check.NetState != null;
}
}

View file

@ -50,14 +50,14 @@ namespace Server.Gumps
public virtual int LabelNumber // Are you sure you wish to select this?
=> 1074975;
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == (int)Buttons.Confirm)
{
if (info.IsSwitched((int)Buttons.Break))
Confirm(state.Mobile);
Confirm(sender.Mobile);
else
Refuse(state.Mobile);
Refuse(sender.Mobile);
}
}

View file

@ -110,7 +110,7 @@ namespace Server.Gumps
public override string Caption => Title;
public static CAGCategory Root => m_Root ?? (m_Root = Load("Data/objects.xml"));
public static CAGCategory Root => m_Root ??= Load("Data/objects.xml");
public override void OnClick(Mobile from, int page)
{
@ -184,7 +184,8 @@ namespace Server.Gumps
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
private static bool PrevLabel = false, NextLabel = false;
private static bool PrevLabel = false;
private static bool NextLabel = false;
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
private static readonly int PrevLabelOffsetY = 0;
@ -333,7 +334,7 @@ namespace Server.Gumps
}
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = m_Owner;

View file

@ -128,13 +128,13 @@ namespace Server.Gumps
to.SendGump(new ClientGump(to, m_State, te == null ? "" : te.Text));
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_State == null)
return;
Mobile focus = m_State.Mobile;
Mobile from = state.Mobile;
Mobile from = sender.Mobile;
if (focus == null)
{

View file

@ -1,7 +1,6 @@
using System.Collections.Generic;
using Server.Accounting;
using Server.Network;
using Server.Prompts;
using Server.Targeting;
namespace Server.Gumps
@ -78,12 +77,12 @@ namespace Server.Gumps
from.SendGump(new CommentsGump((Account)m.Account));
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 0x7F)
{
state.Mobile.SendMessage("Enter the text for the account comment (or press [Esc] to cancel):");
state.Mobile.Prompt = new CommentPrompt(m_Acct);
sender.Mobile.SendMessage("Enter the text for the account comment (or press [Esc] to cancel):");
sender.Mobile.Prompt = new CommentPrompt(m_Acct);
}
}

View file

@ -46,7 +46,7 @@ namespace Server.Gumps
AddHtmlLocalized(240, 250, 170, 20, 1011012, 0x7FFF); // CANCEL
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1 && !m_House.Deleted)
{
@ -100,7 +100,7 @@ namespace Server.Gumps
}
else
{
Item toGive = null;
Item toGive;
if (m_House.IsAosRules)
{

View file

@ -187,9 +187,9 @@ namespace Server.Gumps
from.SendGump(new GoGump(0, from, tree, branch));
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = state.Mobile;
Mobile from = sender.Mobile;
switch (info.ButtonID)
{

View file

@ -20,7 +20,7 @@ namespace Server.Gumps
AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadMember(m_Mobile, m_Guild))
return;
@ -38,7 +38,7 @@ namespace Server.Gumps
Mobile m = m_List[index];
if (m?.Deleted == false)
state.Mobile.GuildFealty = m;
sender.Mobile.GuildFealty = m;
}
}
}

View file

@ -20,7 +20,7 @@ namespace Server.Gumps
AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadLeader(m_Mobile, m_Guild))
return;

View file

@ -1,5 +1,4 @@
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{

View file

@ -20,7 +20,7 @@ namespace Server.Gumps
AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadLeader(m_Mobile, m_Guild))
return;

View file

@ -21,7 +21,7 @@ namespace Server.Gumps
AddHtmlLocalized(335, 400, 100, 35, 1013077); // Refuse
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadLeader(m_Mobile, m_Guild))
return;

View file

@ -17,7 +17,7 @@ namespace Server.Gumps
AddHtmlLocalized(55, 400, 300, 35, 1011120); // Return to the main menu.
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadMember(m_Mobile, m_Guild))
return;

View file

@ -41,7 +41,7 @@ namespace Server.Gumps
AddHtmlLocalized(335, 360, 150, 30, 1011012); // CANCEL
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (Guild.NewGuildSystem && !BaseGuildGump.IsLeader(m_Mobile, m_Guild) ||
!Guild.NewGuildSystem && GuildGump.BadLeader(m_Mobile, m_Guild))

View file

@ -41,7 +41,7 @@ namespace Server.Gumps
AddHtml(55, 220, 300, 20, website);
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadMember(m_Mobile, m_Guild))
return;

View file

@ -1,5 +1,4 @@
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{

View file

@ -20,7 +20,7 @@ namespace Server.Gumps
AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadLeader(m_Mobile, m_Guild))
return;

View file

@ -23,7 +23,7 @@ namespace Server.Gumps
AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadLeader(m_Mobile, m_Guild))
return;

View file

@ -1,6 +1,5 @@
using System.Collections.Generic;
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{

View file

@ -20,7 +20,7 @@ namespace Server.Gumps
AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadLeader(m_Mobile, m_Guild))
return;

View file

@ -1,5 +1,4 @@
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{

View file

@ -20,7 +20,7 @@ namespace Server.Gumps
AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadLeader(m_Mobile, m_Guild))
return;

View file

@ -20,7 +20,7 @@ namespace Server.Gumps
AddHtmlLocalized(335, 400, 100, 35, 1011012); // CANCEL
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadLeader(m_Mobile, m_Guild))
return;

View file

@ -17,7 +17,7 @@ namespace Server.Gumps
AddHtmlLocalized(55, 400, 300, 35, 1011120); // Return to the main menu.
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadMember(m_Mobile, m_Guild))
return;

View file

@ -1,5 +1,4 @@
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{

View file

@ -63,7 +63,7 @@ namespace Server.Gumps
AddHtmlLocalized(55, 400, 400, 35, 1011104); // Return to the previous menu.
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadLeader(m_Mobile, m_Guild))
return;

View file

@ -86,7 +86,7 @@ namespace Server.Gumps
}
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadMember(m_Mobile, m_Guild))
return;

View file

@ -1,5 +1,4 @@
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{

View file

@ -82,7 +82,7 @@ namespace Server.Gumps
AddHtmlLocalized(335, 360, 100, 30, 1011441); // EXIT
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (GuildGump.BadLeader(m_Mobile, m_Guild))
return;

View file

@ -1,3 +1,4 @@
using System.Linq;
using Server.Gumps;
using Server.Misc;
using Server.Mobiles;
@ -40,9 +41,7 @@ namespace Server.Guilds
public override void OnResponse(NetState sender, RelayInfo info)
{
PlayerMobile pm = sender.Mobile as PlayerMobile;
if (!IsMember(pm, guild))
if (!(sender.Mobile is PlayerMobile pm &&IsMember(pm, guild)))
return;
switch (info.ButtonID)
@ -85,30 +84,12 @@ namespace Server.Guilds
s = s.ToLower();
for (int i = 0; i < s.Length; ++i)
{
char c = s[i];
if ((c < 'a' || c > 'z') && (c < '0' || c > '9'))
{
bool except = false;
for (int j = 0; !except && j < exceptions.Length; j++)
if (c == exceptions[j])
except = true;
if (!except)
return false;
}
}
if (s.Any(c => (c < 'a' || c > 'z') && (c < '0' || c > '9') && exceptions.All(exception => exception != c)))
return false;
string[] disallowed = ProfanityProtection.Disallowed;
for (int i = 0; i < disallowed.Length; i++)
if (s.IndexOf(disallowed[i]) != -1)
return false;
return true;
return disallowed.All(t => s.IndexOf(t) == -1);
}
public void AddHtmlText(int x, int y, int width, int height, TextDefinition text, bool back, bool scroll)

View file

@ -108,9 +108,7 @@ namespace Server.Guilds
if (PendingWar)
{
if (war.WarRequester)
{
number = 1063027; // <div align=center>You have challenged this guild to war!</div>
}
else
{
number = 1062969; // <div align=center>This guild has challenged you to war!</div>
@ -211,9 +209,7 @@ namespace Server.Guilds
if (war?.WarRequester == false && activeWar == null)
{
if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
{
pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars.
}
else if (alliance != null && alliance.Leader != guild)
{
pm.SendLocalizedMessage(1063239,
@ -276,9 +272,7 @@ namespace Server.Guilds
if (war?.WarRequester == false && activeWar == null)
{
if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
{
pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars.
}
else if (alliance != null && alliance.Leader != guild)
{
pm.SendLocalizedMessage(1063239,
@ -287,9 +281,7 @@ namespace Server.Guilds
alliance.Leader.Name); // You need to negotiate via ~1_val~ instead.
}
else
{
pm.SendGump(new WarDeclarationGump(pm, guild, otherGuild));
}
}
break;
@ -299,9 +291,7 @@ namespace Server.Guilds
if (war != null)
{
if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
{
pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars.
}
else if (alliance != null && alliance.Leader != guild)
{
pm.SendLocalizedMessage(1063239,
@ -324,9 +314,7 @@ namespace Server.Guilds
case 8: //Surrender
{
if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
{
pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars.
}
else if (alliance != null && alliance.Leader != guild)
{
pm.SendLocalizedMessage(1063239,
@ -384,9 +372,7 @@ namespace Server.Guilds
if (war == null && activeWar == null)
{
if (!playerRank.GetFlag(RankFlags.ControlWarStatus))
{
pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars.
}
else if (alliance != null && alliance.Leader != guild)
{
pm.SendLocalizedMessage(1063239,
@ -402,9 +388,7 @@ namespace Server.Guilds
otherAlliance.Leader.Name); // You need to negotiate via ~1_val~ instead.
}
else
{
pm.SendGump(new WarDeclarationGump(pm, guild, m_Other));
}
}
break;
@ -419,14 +403,10 @@ namespace Server.Guilds
if (alliance == null)
{
if (!playerRank.GetFlag(RankFlags.AllianceControl))
{
pm.SendLocalizedMessage(1070747); // You don't have permission to create an alliance.
}
else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader))
{
pm.SendLocalizedMessage(
1070758); // You cannot propose an alliance to a guild with a different faction allegiance.
}
else if (otherAlliance != null)
{
if (otherAlliance.IsPendingMember(m_Other))
@ -436,13 +416,9 @@ namespace Server.Guilds
pm.SendLocalizedMessage(1063426, m_Other.Name); // ~1_val~ already belongs to an alliance.
}
else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0)
{
pm.SendLocalizedMessage(1063427, m_Other.Name); // ~1_val~ is currently involved in a guild war.
}
else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0)
{
pm.SendLocalizedMessage(1063427, guild.Name); // ~1_val~ is currently involved in a guild war.
}
else
{
pm.SendLocalizedMessage(1063439); // Enter a name for the new alliance:
@ -457,14 +433,10 @@ namespace Server.Guilds
else
{
if (!playerRank.GetFlag(RankFlags.AllianceControl))
{
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
}
else if (alliance.Leader != guild)
{
pm.SendLocalizedMessage(1063239,
$"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance.
}
else if (otherAlliance != null)
{
if (otherAlliance.IsPendingMember(m_Other))
@ -474,23 +446,15 @@ namespace Server.Guilds
pm.SendLocalizedMessage(1063426, m_Other.Name); // ~1_val~ already belongs to an alliance.
}
else if (alliance.IsPendingMember(guild))
{
pm.SendLocalizedMessage(1063416,
guild.Name); // ~1_val~ is currently considering another alliance proposal.
}
else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0)
{
pm.SendLocalizedMessage(1063427, m_Other.Name); // ~1_val~ is currently involved in a guild war.
}
else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0)
{
pm.SendLocalizedMessage(1063427, guild.Name); // ~1_val~ is currently involved in a guild war.
}
else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader))
{
pm.SendLocalizedMessage(
1070758); // You cannot propose an alliance to a guild with a different faction allegiance.
}
else
{
pm.SendLocalizedMessage(1070750,
@ -517,9 +481,7 @@ namespace Server.Guilds
case 11: //Leave Alliance
{
if (!playerRank.GetFlag(RankFlags.AllianceControl))
{
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
}
else if (alliance?.IsMember(guild) == true)
{
guild.Alliance = null; //Calls alliance.Removeguild
@ -535,14 +497,10 @@ namespace Server.Guilds
case 12: //Remove Guild from alliance
{
if (!playerRank.GetFlag(RankFlags.AllianceControl))
{
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
}
else if (alliance != null && alliance.Leader != guild)
{
pm.SendLocalizedMessage(1063239,
$"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance.
}
else if (alliance?.IsMember(guild) == true && alliance.IsMember(m_Other))
{
m_Other.Alliance = null;
@ -557,14 +515,10 @@ namespace Server.Guilds
case 13: //Promote to Alliance leader
{
if (!playerRank.GetFlag(RankFlags.AllianceControl))
{
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
}
else if (alliance != null && alliance.Leader != guild)
{
pm.SendLocalizedMessage(1063239,
$"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance.
}
else if (alliance?.IsMember(guild) == true && alliance.IsMember(m_Other))
{
pm.SendLocalizedMessage(1063434,
@ -578,9 +532,7 @@ namespace Server.Guilds
case 14: //Withdraw Request
{
if (!playerRank.GetFlag(RankFlags.AllianceControl))
{
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
}
else if (alliance != null && alliance.Leader == guild && alliance.IsPendingMember(m_Other))
{
m_Other.Alliance = null;
@ -592,9 +544,7 @@ namespace Server.Guilds
case 15: //Deny Alliance Request
{
if (!playerRank.GetFlag(RankFlags.AllianceControl))
{
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
}
else if (alliance != null && otherAlliance != null && alliance.Leader == m_Other &&
otherAlliance.IsPendingMember(guild))
{
@ -609,9 +559,7 @@ namespace Server.Guilds
case 16: //Accept Alliance Request
{
if (!playerRank.GetFlag(RankFlags.AllianceControl))
{
pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance.
}
else if (otherAlliance != null && otherAlliance.Leader == m_Other &&
otherAlliance.IsPendingMember(guild))
{
@ -640,20 +588,15 @@ namespace Server.Guilds
if (!IsMember(from, guild) || alliance != null)
return;
RankDefinition playerRank = pm.GuildRank;
if (!playerRank.GetFlag(RankFlags.AllianceControl))
{
pm.SendLocalizedMessage(1070747); // You don't have permission to create an alliance.
}
else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader))
{
//Notes about this: OSI only cares/checks when proposing, you can change your faction all you want later.
pm.SendLocalizedMessage(
1070758); // You cannot propose an alliance to a guild with a different faction allegiance.
}
else if (otherAlliance != null)
{
if (otherAlliance.IsPendingMember(m_Other))
@ -663,30 +606,20 @@ namespace Server.Guilds
pm.SendLocalizedMessage(1063426, m_Other.Name); // ~1_val~ already belongs to an alliance.
}
else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0)
{
pm.SendLocalizedMessage(1063427, m_Other.Name); // ~1_val~ is currently involved in a guild war.
}
else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0)
{
pm.SendLocalizedMessage(1063427, guild.Name); // ~1_val~ is currently involved in a guild war.
}
else
{
string name = Utility.FixHtml(text.Trim());
if (!CheckProfanity(name))
{
pm.SendLocalizedMessage(1070886); // That alliance name is not allowed.
}
else if (name.Length > Guild.NameLimit)
{
pm.SendLocalizedMessage(1070887,
Guild.NameLimit.ToString()); // An alliance name cannot exceed ~1_val~ characters in length.
}
else if (AllianceInfo.Alliances.ContainsKey(name.ToLower()))
{
pm.SendLocalizedMessage(1063428); // That alliance name is not available.
}
else
{
pm.SendLocalizedMessage(1070750,

View file

@ -1,4 +1,3 @@
using Server.Accounting;
using Server.Guilds;
using Server.Items;
using Server.Multis;
@ -32,13 +31,14 @@ namespace Server.Gumps
AddImageTiled(10, 40, 400, 200, 2624);
AddAlphaRegion(10, 40, 400, 200);
AddHtmlLocalized(10, 40, 400, 200, 1061795, 32512, false, true); /* You are about to demolish your house.
* You will be refunded the house's value directly to your bank box.
* All items in the house will remain behind and can be freely picked up by anyone.
* Once the house is demolished, anyone can attempt to place a new house on the vacant land.
* This action will not un-condemn any other houses on your account, nor will it end your 7-day waiting period (if it applies to you).
* Are you sure you wish to continue?
*/
AddHtmlLocalized(10, 40, 400, 200, 1061795, 32512, false, true);
/* You are about to demolish your house.
* You will be refunded the house's value directly to your bank box.
* All items in the house will remain behind and can be freely picked up by anyone.
* Once the house is demolished, anyone can attempt to place a new house on the vacant land.
* This action will not un-condemn any other houses on your account, nor will it end your 7-day waiting period (if it applies to you).
* Are you sure you wish to continue?
*/
AddImageTiled(10, 250, 400, 20, 2624);
AddAlphaRegion(10, 250, 400, 20);
@ -50,7 +50,7 @@ namespace Server.Gumps
AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767); // CANCEL
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1 && !m_House.Deleted)
{

View file

@ -54,12 +54,12 @@ namespace Server.Gumps
}
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_House.Deleted)
return;
Mobile from = state.Mobile;
Mobile from = sender.Mobile;
from.SendGump(new HouseGump(from, m_House));
}
@ -125,12 +125,12 @@ namespace Server.Gumps
}
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_House.Deleted)
return;
Mobile from = state.Mobile;
Mobile from = sender.Mobile;
if (m_List != null && info.ButtonID == 1) // Remove now
{

View file

@ -672,92 +672,92 @@ namespace Server.Gumps
if (e == null)
return;
int cost = e.Cost - house.Price;
int cost = e.Cost - house.Price;
if (cost > 0)
if (cost > 0)
{
if (Banker.Withdraw(from, cost))
{
if (Banker.Withdraw(from, cost))
{
from.SendLocalizedMessage(1060398,
cost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
}
else
{
from.SendLocalizedMessage(
1061624); // You do not have enough funds in your bank to cover the difference between your old house and your new one.
return;
}
from.SendLocalizedMessage(1060398,
cost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
}
else if (cost < 0)
else
{
if (Banker.Deposit(from, -cost))
from.SendLocalizedMessage(1060397,
(-cost).ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box.
else
return;
}
BaseHouse newHouse = e.ConstructHouse(from);
if (newHouse != null)
{
newHouse.Price = e.Cost;
house.MoveAllToCrate();
newHouse.Friends = new List<Mobile>(house.Friends);
newHouse.CoOwners = new List<Mobile>(house.CoOwners);
newHouse.Bans = new List<Mobile>(house.Bans);
newHouse.Access = new List<Mobile>(house.Access);
newHouse.BuiltOn = house.BuiltOn;
newHouse.LastTraded = house.LastTraded;
newHouse.Public = house.Public;
newHouse.VendorInventories.AddRange(house.VendorInventories);
house.VendorInventories.Clear();
foreach (VendorInventory inventory in newHouse.VendorInventories) inventory.House = newHouse;
newHouse.InternalizedVendors.AddRange(house.InternalizedVendors);
house.InternalizedVendors.Clear();
foreach (Mobile mobile in newHouse.InternalizedVendors)
if (mobile is PlayerVendor vendor)
vendor.House = newHouse;
else if (mobile is PlayerBarkeeper barkeeper)
barkeeper.House = newHouse;
if (house.MovingCrate != null)
{
newHouse.MovingCrate = house.MovingCrate;
newHouse.MovingCrate.House = newHouse;
house.MovingCrate = null;
}
List<Item> items = house.GetItems();
List<Mobile> mobiles = house.GetMobiles();
newHouse.MoveToWorld(
new Point3D(house.X + house.ConvertOffsetX, house.Y + house.ConvertOffsetY,
house.Z + house.ConvertOffsetZ), house.Map);
house.Delete();
foreach (Item item in items) item.Location = newHouse.BanLocation;
foreach (Mobile mobile in mobiles) mobile.Location = newHouse.BanLocation;
/* You have successfully replaced your original house with a new house.
* The value of the replaced house has been deposited into your bank box.
* All of the items in your original house have been relocated to a Moving Crate in the new house.
* Any deed-based house add-ons have been converted back into deeds.
* Vendors and barkeeps in the house, if any, have been stored in the Moving Crate as well.
* Use the <B>Get Vendor</B> context-sensitive menu option on your character to retrieve them.
* These containers can be used to re-create the vendor in a new location.
* Any barkeepers have been converted into deeds.
*/
from.SendGump(new NoticeGump(1060637, 30720, 1060012, 32512, 420, 280));
from.SendLocalizedMessage(
1061624); // You do not have enough funds in your bank to cover the difference between your old house and your new one.
return;
}
}
else if (cost < 0)
{
if (Banker.Deposit(from, -cost))
from.SendLocalizedMessage(1060397,
(-cost).ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box.
else
return;
}
BaseHouse newHouse = e.ConstructHouse(from);
if (newHouse != null)
{
newHouse.Price = e.Cost;
house.MoveAllToCrate();
newHouse.Friends = new List<Mobile>(house.Friends);
newHouse.CoOwners = new List<Mobile>(house.CoOwners);
newHouse.Bans = new List<Mobile>(house.Bans);
newHouse.Access = new List<Mobile>(house.Access);
newHouse.BuiltOn = house.BuiltOn;
newHouse.LastTraded = house.LastTraded;
newHouse.Public = house.Public;
newHouse.VendorInventories.AddRange(house.VendorInventories);
house.VendorInventories.Clear();
foreach (VendorInventory inventory in newHouse.VendorInventories) inventory.House = newHouse;
newHouse.InternalizedVendors.AddRange(house.InternalizedVendors);
house.InternalizedVendors.Clear();
foreach (Mobile mobile in newHouse.InternalizedVendors)
if (mobile is PlayerVendor vendor)
vendor.House = newHouse;
else if (mobile is PlayerBarkeeper barkeeper)
barkeeper.House = newHouse;
if (house.MovingCrate != null)
{
newHouse.MovingCrate = house.MovingCrate;
newHouse.MovingCrate.House = newHouse;
house.MovingCrate = null;
}
List<Item> items = house.GetItems();
List<Mobile> mobiles = house.GetMobiles();
newHouse.MoveToWorld(
new Point3D(house.X + house.ConvertOffsetX, house.Y + house.ConvertOffsetY,
house.Z + house.ConvertOffsetZ), house.Map);
house.Delete();
foreach (Item item in items) item.Location = newHouse.BanLocation;
foreach (Mobile mobile in mobiles) mobile.Location = newHouse.BanLocation;
/* You have successfully replaced your original house with a new house.
* The value of the replaced house has been deposited into your bank box.
* All of the items in your original house have been relocated to a Moving Crate in the new house.
* Any deed-based house add-ons have been converted back into deeds.
* Vendors and barkeeps in the house, if any, have been stored in the Moving Crate as well.
* Use the <B>Get Vendor</B> context-sensitive menu option on your character to retrieve them.
* These containers can be used to re-create the vendor in a new location.
* Any barkeepers have been converted into deeds.
*/
from.SendGump(new NoticeGump(1060637, 30720, 1060012, 32512, 420, 280));
return;
}
}
from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, house));

View file

@ -53,7 +53,7 @@ namespace Server.Gumps
AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767); // CANCEL
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1 && !m_House.Deleted)
m_House.EndConfirmTransfer(m_From, m_To);

View file

@ -33,12 +33,12 @@ namespace Server.Gumps
AddButton(110, 105, 0x819, 0x818, 0x2); // Cancel
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Pet.Deleted || !m_Pet.IsBonded || !m_Pet.IsDeadPet)
return;
Mobile from = state.Mobile;
Mobile from = sender.Mobile;
if (info.ButtonID == 1)
{

View file

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Server.HuePickers;
using Server.Items;
using Server.Mobiles;
using Server.Network;
@ -37,9 +36,9 @@ namespace Server.Gumps
AddHtmlLocalized(152, 130, 100, 24, 1011036); // OKAY
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = state.Mobile;
Mobile from = sender.Mobile;
if (!m_Vendor.CanInteractWith(from, false))
return;
@ -135,9 +134,9 @@ namespace Server.Gumps
AddLabel(300, 48, 0, ((int)(days / 12.0)).ToString());
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = state.Mobile;
Mobile from = sender.Mobile;
if (!m_Vendor.CanInteractWith(from, true))
return;
@ -476,12 +475,12 @@ namespace Server.Gumps
}
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Vendor.Deleted)
return;
Mobile from = state.Mobile;
Mobile from = sender.Mobile;
if (m_Vendor is PlayerVendor vendor && !vendor.CanInteractWith(from, true))
return;
@ -581,11 +580,11 @@ namespace Server.Gumps
if (category.Layer == Layer.Hair)
{
new PVHairHuePicker(false, m_Vendor, from).SendTo(state);
new PVHairHuePicker(false, m_Vendor, from).SendTo(sender);
}
else if (category.Layer == Layer.FacialHair)
{
new PVHairHuePicker(true, m_Vendor, from).SendTo(state);
new PVHairHuePicker(true, m_Vendor, from).SendTo(sender);
}
else
{
@ -604,7 +603,7 @@ namespace Server.Gumps
}
if (item != null)
new PVHuePicker(item, m_Vendor, from).SendTo(state);
new PVHuePicker(item, m_Vendor, from).SendTo(sender);
}
}
}

View file

@ -120,7 +120,7 @@ namespace Server.Gumps
}
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1 && info.Switches.Length > 0)
{

View file

@ -153,9 +153,7 @@ namespace Server.Gumps
if (parent != null)
{
if (m_Stack == null)
m_Stack = new Stack<StackEntry>();
m_Stack ??= new Stack<StackEntry>();
m_Stack.Push(parent);
}
@ -281,9 +279,9 @@ namespace Server.Gumps
}
}
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = state.Mobile;
Mobile from = sender.Mobile;
if (!BaseCommand.IsAccessible(from, m_Object))
{

View file

@ -127,7 +127,6 @@ namespace Server.Gumps
switch (index)
{
default:
case 0:
type = ModelBodyType.Monsters;
list = m_Monster;
break;
@ -204,24 +203,17 @@ namespace Server.Gumps
if (((Body)bodyID).IsEmpty)
continue;
List<InternalEntry> list;
switch (oldEntry.BodyType)
List<InternalEntry> list = oldEntry.BodyType switch
{
default: continue;
case ModelBodyType.Monsters:
list = m_Monster;
break;
case ModelBodyType.Animals:
list = m_Animal;
break;
case ModelBodyType.Sea:
list = m_Sea;
break;
case ModelBodyType.Human:
list = m_Human;
break;
}
ModelBodyType.Monsters => m_Monster,
ModelBodyType.Animals => m_Animal,
ModelBodyType.Sea => m_Sea,
ModelBodyType.Human => m_Human,
_ => null
};
if (list == null)
return;
int itemID = ShrinkTable.Lookup(bodyID, -1);
@ -287,7 +279,7 @@ namespace Server.Gumps
int v = Name.CompareTo(comp.Name);
if (v == 0)
Body.CompareTo(comp.Body);
v = Body.CompareTo(comp.Body);
return v;
}

View file

@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
using Server.HuePickers;
using Server.Network;
namespace Server.Gumps

View file

@ -4,7 +4,6 @@ using System.Reflection;
using Server.Commands;
using Server.Commands.Generic;
using Server.Network;
using Server.Prompts;
namespace Server.Gumps
{

View file

@ -2,7 +2,6 @@ using System.Collections.Generic;
using Server.Items;
using Server.Multis;
using Server.Network;
using Server.Prompts;
using Server.Spells.Chivalry;
using Server.Spells.Fourth;
using Server.Spells.Seventh;
@ -203,9 +202,9 @@ namespace Server.Gumps
public static bool HasSpell(Mobile from, int spellID) => Spellbook.Find(from, spellID)?.HasSpell(spellID) == true;
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = state.Mobile;
Mobile from = sender.Mobile;
if (Book.Deleted || !from.InRange(Book.GetWorldLocation(), Core.ML ? 3 : 1) || !DesignContext.Check(from))
{

View file

@ -60,7 +60,7 @@ namespace Server.Gumps
public int GetFirstID(SecureLevel level) => m_Info.Level == level ? 4006 : 4005;
public override void OnResponse(NetState state, RelayInfo info)
public override void OnResponse(NetState sender, RelayInfo info)
{
var level = info.ButtonID switch
{
@ -74,12 +74,12 @@ namespace Server.Gumps
if (m_Info.Level == level)
{
state.Mobile.SendLocalizedMessage(1061281); // Access level unchanged.
sender.Mobile.SendLocalizedMessage(1061281); // Access level unchanged.
}
else
{
m_Info.Level = level;
state.Mobile.SendLocalizedMessage(1061280); // New access level set.
sender.Mobile.SendLocalizedMessage(1061280); // New access level set.
}
}
}

View file

@ -306,7 +306,6 @@ namespace Server.Gumps
switch (sk.Lock)
{
default:
case SkillLock.Up:
buttonID1 = 0x983;
buttonID2 = 0x983;
xOffset = 6;

View file

@ -1,6 +1,5 @@
using Server.Items;
using Server.Network;
using Server.Prompts;
using Server.Mobiles;
using Server.Targeting;
using Server.Multis;