Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -1,8 +1,8 @@
[*] [*]
charset=utf-8 charset=utf-8
end_of_line=lf end_of_line=crlf
trim_trailing_whitespace=true trim_trailing_whitespace=true
insert_final_newline=true insert_final_newline=true
indent_style=space indent_style=space
indent_size=4 indent_size=2

View file

@ -1,33 +1,33 @@
ModernUO ModernUO
===== =====
### Contacts ### Contacts
[Join Discord Channel](https://discord.gg/VdyCpjQ) [Join Discord Channel](https://discord.gg/VdyCpjQ)
### Goals ### Goals
- See [Goals](./GOALS.md) - See [Goals](./GOALS.md)
### Requirements ### Requirements
- .NET Framework 4.7 or Mono 5.10+ - .NET Framework 4.7 or Mono 5.10+
- zlib (Linux only) - zlib (Linux only)
- [DotNetCompilerPlatform](https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform) v2.0+ (Windows Only) - [DotNetCompilerPlatform](https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform) v2.0+ (Windows Only)
### Building using Visual Studio (Recommended) ### Building using Visual Studio (Recommended)
- Build `Server` project - Build `Server` project
- Building with Visual Studio for Windows will install `DotNetCompilerPlatform` automatically. - Building with Visual Studio for Windows will install `DotNetCompilerPlatform` automatically.
### Building for Windows (Without Visual Studio) ### Building for Windows (Without Visual Studio)
`C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc /optimize /unsafe /t:exe /out:RunUO.exe /win32icon:Server\runuo.ico /d:NEWTIMERS /d:NEWPARENT /recurse:Server\\*.cs` `C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc /optimize /unsafe /t:exe /out:RunUO.exe /win32icon:Server\runuo.ico /d:NEWTIMERS /recurse:Server\\*.cs`
- DotNetCompilerPlatform must be installed with the `csc.exe` file in the `roslyn` folder at the root of the repository. - DotNetCompilerPlatform must be installed with the `csc.exe` file in the `roslyn` folder at the root of the repository.
### Building for Mac/Linux (Without Visual Studio) ### Building for Mac/Linux (Without Visual Studio)
`mcs -optimize+ -unsafe -t:exe -out:RunUO.exe -win32icon:Server/runuo.ico -nowarn:219,414 -d:NEWTIMERS -d:NEWPARENT -d:MONO -reference:System.Drawing -recurse:Server/*.cs` `mcs -optimize+ -unsafe -t:exe -out:RunUO.exe -win32icon:Server/runuo.ico -nowarn:219,414 -d:NEWTIMERS -d:MONO -recurse:"Server/*".cs`
### Running on Mac/Linux (MONO) ### Running on Mac/Linux (MONO)
`mono RunUO.exe` `mono RunUO.exe`
### Troubleshooting / FAQ ### Troubleshooting / FAQ
#### Scripts fail to compile on Windows #### Scripts fail to compile on Windows
This is usually caused nuget packages not being installed. Install the required packages and rebuild the Server project. This is usually caused nuget packages not being installed. Install the required packages and rebuild the Server project.
Note: The required nuget packages can be set to automatically restore on build with this [setting](https://docs.microsoft.com/en-us/nuget/consume-packages/media/restore-01-autorestoreoptions.png) Note: The required nuget packages can be set to automatically restore on build with this [setting](https://docs.microsoft.com/en-us/nuget/consume-packages/media/restore-01-autorestoreoptions.png)

View file

@ -1,10 +0,0 @@
<?xml version="1.0"?>
<configuration>
<runtime>
<gcServer enabled="true" />
</runtime>
<!--
MONO/Linux users will need to uncomment and modify the following line:
-->
<!--<dllmap dll="libz" target="/lib/x86_64-linux-gnu/libz.so.1" />-->
</configuration>

View file

@ -72,20 +72,14 @@ namespace Server.Accounting
/// <summary> /// <summary>
/// List of account comments. Type of contained objects is AccountComment. /// List of account comments. Type of contained objects is AccountComment.
/// </summary> /// </summary>
public List<AccountComment> Comments public List<AccountComment> Comments => m_Comments ?? (m_Comments = new List<AccountComment>());
{
get { if ( m_Comments == null ) m_Comments = new List<AccountComment>(); return m_Comments; }
}
/// <summary> /// <summary>
/// List of account tags. Type of contained objects is AccountTag. /// List of account tags. Type of contained objects is AccountTag.
/// </summary> /// </summary>
public List<AccountTag> Tags public List<AccountTag> Tags => m_Tags ?? (m_Tags = new List<AccountTag>());
{
get { if ( m_Tags == null ) m_Tags = new List<AccountTag>(); return m_Tags; }
}
/// <summary> /// <summary>
/// Account username. Case insensitive validation. /// Account username. Case insensitive validation.
/// </summary> /// </summary>
public string Username { get; set; } public string Username { get; set; }
@ -136,10 +130,7 @@ namespace Server.Accounting
if ( !isBanned ) if ( !isBanned )
return false; return false;
DateTime banTime; if ( GetBanTags( out DateTime banTime, out TimeSpan banDuration ) )
TimeSpan banDuration;
if ( GetBanTags( out banTime, out banDuration ) )
{ {
if ( banDuration != TimeSpan.MaxValue && DateTime.UtcNow >= ( banTime + banDuration ) ) if ( banDuration != TimeSpan.MaxValue && DateTime.UtcNow >= ( banTime + banDuration ) )
{ {
@ -164,11 +155,8 @@ namespace Server.Accounting
{ {
SetFlag( 1, !value ); SetFlag( 1, !value );
if ( m_YoungTimer != null ) m_YoungTimer?.Stop();
{ m_YoungTimer = null;
m_YoungTimer.Stop();
m_YoungTimer = null;
}
} }
} }
@ -704,9 +692,7 @@ namespace Server.Accounting
{ {
if ( count < list.Length ) if ( count < list.Length )
{ {
IPAddress address; if ( IPAddress.TryParse( Utility.GetText( ip, null ), out IPAddress address ) )
if ( IPAddress.TryParse( Utility.GetText( ip, null ), out address ) )
{ {
list[count] = Utility.Intern( address ); list[count] = Utility.Intern( address );
count++; count++;
@ -848,7 +834,7 @@ namespace Server.Accounting
{ {
Mobile m = this[i]; Mobile m = this[i];
if ( m != null && m.AccessLevel >= level ) if ( m?.AccessLevel >= level )
hasAccess = true; hasAccess = true;
} }
} }
@ -991,7 +977,7 @@ namespace Server.Accounting
{ {
Mobile m = m_Mobiles[i]; Mobile m = m_Mobiles[i];
if ( m != null && !m.Deleted ) if (m?.Deleted == false)
{ {
xml.WriteStartElement( "char" ); xml.WriteStartElement( "char" );
xml.WriteAttributeString( "index", i.ToString() ); xml.WriteAttributeString( "index", i.ToString() );
@ -1002,7 +988,7 @@ namespace Server.Accounting
xml.WriteEndElement(); xml.WriteEndElement();
if ( m_Comments != null && m_Comments.Count > 0 ) if (m_Comments?.Count > 0)
{ {
xml.WriteStartElement( "comments" ); xml.WriteStartElement( "comments" );
@ -1012,7 +998,7 @@ namespace Server.Accounting
xml.WriteEndElement(); xml.WriteEndElement();
} }
if ( m_Tags != null && m_Tags.Count > 0 ) if (m_Tags?.Count > 0)
{ {
xml.WriteStartElement( "tags" ); xml.WriteStartElement( "tags" );
@ -1103,7 +1089,7 @@ namespace Server.Accounting
{ {
Mobile m = m_Mobiles[index]; Mobile m = m_Mobiles[index];
if ( m != null && m.Deleted ) if (m?.Deleted == true)
{ {
m.Account = null; m.Account = null;
m_Mobiles[index] = m = null; m_Mobiles[index] = m = null;

View file

@ -303,4 +303,4 @@ namespace Server
#endregion #endregion
} }
} }

View file

@ -190,7 +190,7 @@ namespace Server.Commands
if (!IsConstructible(ctor, from.AccessLevel)) if (!IsConstructible(ctor, from.AccessLevel))
continue; continue;
int totalParams = 0; int totalParams = 0;
// Handle optional constructors // Handle optional constructors
@ -250,7 +250,7 @@ namespace Server.Commands
if (IsParsable(type)) return ParseParsable(type, value); if (IsParsable(type)) return ParseParsable(type, value);
object obj = value; object obj = value;
if (value != null && value.StartsWith("0x")) if (value?.StartsWith("0x") == true)
{ {
if (IsSignedNumeric(type)) if (IsSignedNumeric(type))
obj = Convert.ToInt64(value.Substring(2), 16); obj = Convert.ToInt64(value.Substring(2), 16);
@ -262,7 +262,7 @@ namespace Server.Commands
if (obj == null && !type.IsValueType) if (obj == null && !type.IsValueType)
return null; return null;
return Convert.ChangeType(obj, type); return Convert.ChangeType(obj, type);
} }
catch catch
@ -455,7 +455,7 @@ namespace Server.Commands
private static void Internal_OnCommand(CommandEventArgs e, bool outline) private static void Internal_OnCommand(CommandEventArgs e, bool outline)
{ {
Mobile from = e.Mobile; Mobile from = e.Mobile;
if (e.Length >= 1) if (e.Length >= 1)
BoundingBoxPicker.Begin(from, (map, start, end) => BoundingBoxPicker.Begin(from, (map, start, end) =>
TileBox_Callback(from, map, start, end, new TileState(TileZType.Start, 0, e.Arguments, outline))); TileBox_Callback(from, map, start, end, new TileState(TileZType.Start, 0, e.Arguments, outline)));
@ -511,7 +511,7 @@ namespace Server.Commands
private static void InternalZ_OnCommand(CommandEventArgs e, bool outline) private static void InternalZ_OnCommand(CommandEventArgs e, bool outline)
{ {
Mobile from = e.Mobile; Mobile from = e.Mobile;
if (e.Length >= 2) if (e.Length >= 2)
{ {
string[] subArgs = new string[e.Length - 1]; string[] subArgs = new string[e.Length - 1];
@ -532,7 +532,7 @@ namespace Server.Commands
private static void InternalAvg_OnCommand(CommandEventArgs e, bool outline) private static void InternalAvg_OnCommand(CommandEventArgs e, bool outline)
{ {
Mobile from = e.Mobile; Mobile from = e.Mobile;
if (e.Length >= 1) if (e.Length >= 1)
BoundingBoxPicker.Begin(from, (map, start, end) => BoundingBoxPicker.Begin(from, (map, start, end) =>
TileBox_Callback(from, map, start, end, new TileState(TileZType.MapAverage, 0, e.Arguments, outline))); TileBox_Callback(from, map, start, end, new TileState(TileZType.MapAverage, 0, e.Arguments, outline)));
@ -701,4 +701,4 @@ namespace Server.Commands
} }
} }
} }
} }

View file

@ -1,5 +1,4 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Server.Commands.Generic; using Server.Commands.Generic;
@ -308,7 +307,7 @@ namespace Server.Commands
for (int i = m_Batch.BatchCommands.Count - 1; i >= 0; --i) for (int i = m_Batch.BatchCommands.Count - 1; i >= 0; --i)
{ {
BatchCommand sc = (BatchCommand)m_Batch.BatchCommands[i]; BatchCommand sc = m_Batch.BatchCommands[i];
entry = info.GetTextEntry(1 + i * 2); entry = info.GetTextEntry(1 + i * 2);

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using Server.Engines.Quests.Haven; using Server.Engines.Quests.Haven;
using Server.Engines.Quests.Necro; using Server.Engines.Quests.Necro;
using Server.Items; using Server.Items;
@ -429,7 +430,7 @@ namespace Server.Commands
int indexOf = m_Params[i].IndexOf('='); int indexOf = m_Params[i].IndexOf('=');
if (indexOf >= 0) if (indexOf >= 0)
sp.AddEntry(m_Params[i].Substring(++indexOf), 100, 1); sp.AddEntry(m_Params[i].Substring(++indexOf));
} }
else if (m_Params[i].StartsWith("MinDelay")) else if (m_Params[i].StartsWith("MinDelay"))
{ {
@ -901,12 +902,11 @@ namespace Server.Commands
{ {
eable = map.GetItemsInRange(new Point3D(x, y, z), 0); eable = map.GetItemsInRange(new Point3D(x, y, z), 0);
foreach (Item item in eable) if (eable.Any(item => item.Z == z && item.ItemID == itemID))
if (item.Z == z && item.ItemID == itemID) {
{ eable.Free();
eable.Free(); return true;
return true; }
}
} }
eable.Free(); eable.Free();
@ -989,7 +989,7 @@ namespace Server.Commands
{ {
List<DecorationList> list = new List<DecorationList>(); List<DecorationList> list = new List<DecorationList>();
DecorationList v; DecorationList v;
while ((v = Read(ip)) != null) while ((v = Read(ip)) != null)
list.Add(v); list.Add(v);
@ -1066,11 +1066,9 @@ namespace Server.Commands
{ {
public DecorationEntry(string line) public DecorationEntry(string line)
{ {
string x, y, z; Pop(out string x, ref line);
Pop(out string y, ref line);
Pop(out x, ref line); Pop(out string z, ref line);
Pop(out y, ref line);
Pop(out z, ref line);
Location = new Point3D(Utility.ToInt32(x), Utility.ToInt32(y), Utility.ToInt32(z)); Location = new Point3D(Utility.ToInt32(x), Utility.ToInt32(y), Utility.ToInt32(z));
Extra = line; Extra = line;
@ -1096,4 +1094,4 @@ namespace Server.Commands
} }
} }
} }
} }

View file

@ -2,6 +2,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using Server.Engines.Quests.Haven; using Server.Engines.Quests.Haven;
using Server.Engines.Quests.Necro; using Server.Engines.Quests.Necro;
using Server.Items; using Server.Items;
@ -427,7 +428,7 @@ namespace Server.Commands
int indexOf = m_Params[i].IndexOf('='); int indexOf = m_Params[i].IndexOf('=');
if (indexOf >= 0) if (indexOf >= 0)
sp.AddEntry(m_Params[i].Substring(++indexOf), 100, 1); sp.AddEntry(m_Params[i].Substring(++indexOf));
} }
else if (m_Params[i].StartsWith("MinDelay")) else if (m_Params[i].StartsWith("MinDelay"))
{ {
@ -899,12 +900,11 @@ namespace Server.Commands
{ {
eable = map.GetItemsInRange(new Point3D(x, y, z), 0); eable = map.GetItemsInRange(new Point3D(x, y, z), 0);
foreach (Item item in eable) if (eable.Any(item => item.Z == z && item.ItemID == itemID))
if (item.Z == z && item.ItemID == itemID) {
{ eable.Free();
eable.Free(); return true;
return true; }
}
} }
eable.Free(); eable.Free();
@ -1064,11 +1064,9 @@ namespace Server.Commands
{ {
public DecorationEntryMag(string line) public DecorationEntryMag(string line)
{ {
string x, y, z; Pop(out string x, ref line);
Pop(out string y, ref line);
Pop(out x, ref line); Pop(out string z, ref line);
Pop(out y, ref line);
Pop(out z, ref line);
Location = new Point3D(Utility.ToInt32(x), Utility.ToInt32(y), Utility.ToInt32(z)); Location = new Point3D(Utility.ToInt32(x), Utility.ToInt32(y), Utility.ToInt32(z));
Extra = line; Extra = line;
@ -1094,4 +1092,4 @@ namespace Server.Commands
} }
} }
} }
} }

View file

@ -229,11 +229,9 @@ namespace Server.Commands
StringBuilder nameBuilder = new StringBuilder(rootType); StringBuilder nameBuilder = new StringBuilder(rootType);
StringBuilder fnamBuilder = new StringBuilder("docs/types/" + SanitizeType(rootType)); StringBuilder fnamBuilder = new StringBuilder("docs/types/" + SanitizeType(rootType));
StringBuilder linkBuilder; StringBuilder linkBuilder;
if (DontLink(type)) //if ( DontLink( rootType ) ) linkBuilder = DontLink(type) ?
linkBuilder = new StringBuilder("<font color=\"blue\">" + rootType + "</font>"); new StringBuilder("<font color=\"blue\">" + rootType + "</font>") :
else new StringBuilder("<a href=\"" + "@directory@" + rootType + "-T-.html\">" + rootType + "</a>");
linkBuilder =
new StringBuilder("<a href=\"" + "@directory@" + rootType + "-T-.html\">" + rootType + "</a>");
nameBuilder.Append("&lt;"); nameBuilder.Append("&lt;");
fnamBuilder.Append("-"); fnamBuilder.Append("-");
@ -272,10 +270,7 @@ namespace Server.Commands
} }
} }
if (name == null) typeName = name ?? type.Name;
typeName = type.Name;
else
typeName = name;
if (fnam == null) fileName = "docs/types/" + SanitizeType(type.Name) + ".html"; if (fnam == null) fileName = "docs/types/" + SanitizeType(type.Name) + ".html";
else fileName = fnam + ".html"; else fileName = fnam + ".html";
@ -300,7 +295,8 @@ namespace Server.Commands
{ {
bool anonymousType = name.Contains("<"); bool anonymousType = name.Contains("<");
StringBuilder sb = new StringBuilder(name); StringBuilder sb = new StringBuilder(name);
for (int i = 0; i < ReplaceChars.Length; ++i) sb.Replace(ReplaceChars[i], '-'); for (int i = 0; i < ReplaceChars.Length; ++i)
sb.Replace(ReplaceChars[i], '-');
if (anonymousType) return "(Anonymous-Type)" + sb; if (anonymousType) return "(Anonymous-Type)" + sb;
return sb.ToString(); return sb.ToString();
@ -418,7 +414,7 @@ namespace Server.Commands
MethodInfo getMethod = prop.GetGetMethod(); MethodInfo getMethod = prop.GetGetMethod();
MethodInfo setMethod = prop.GetGetMethod(); MethodInfo setMethod = prop.GetGetMethod();
return getMethod != null && getMethod.IsStatic || setMethod != null && setMethod.IsStatic; return getMethod?.IsStatic == true || setMethod?.IsStatic == true;
} }
return false; return false;
@ -426,13 +422,7 @@ namespace Server.Commands
private string GetNameFrom(ConstructorInfo ctor, PropertyInfo prop, MethodInfo method) private string GetNameFrom(ConstructorInfo ctor, PropertyInfo prop, MethodInfo method)
{ {
if (ctor != null) return ctor?.DeclaringType?.Name ?? prop?.Name ?? method?.Name ?? "";
return ctor.DeclaringType?.Name ?? "";
if (prop != null)
return prop.Name;
if (method != null)
return method.Name;
return "";
} }
} }
@ -440,14 +430,8 @@ namespace Server.Commands
{ {
public int Compare(TypeInfo x, TypeInfo y) public int Compare(TypeInfo x, TypeInfo y)
{ {
if (x == null && y == null) return x == null && y == null ? 0 : x == null ? -1 : y == null ? 1 :
return 0; x.TypeName.CompareTo(y.TypeName);
if (x == null)
return -1;
if (y == null)
return 1;
return x.TypeName.CompareTo(y.TypeName);
} }
} }
@ -2463,7 +2447,7 @@ namespace Server.Commands
int extendCount = 0; int extendCount = 0;
if (baseType != null && baseType != typeof(object) && baseType != typeof(ValueType) && !baseType.IsPrimitive) if (baseType != typeof(object) && baseType != typeof(ValueType) && baseType?.IsPrimitive == false)
{ {
typeHtml.Write(" : "); typeHtml.Write(" : ");
@ -2575,7 +2559,7 @@ namespace Server.Commands
MethodInfo getMethod = pi.GetGetMethod(); MethodInfo getMethod = pi.GetGetMethod();
MethodInfo setMethod = pi.GetSetMethod(); MethodInfo setMethod = pi.GetSetMethod();
if (getMethod != null && getMethod.IsStatic || setMethod != null && setMethod.IsStatic) if (getMethod?.IsStatic == true || setMethod?.IsStatic == true)
html.Write(StaticString); html.Write(StaticString);
html.Write(GetPair(pi.PropertyType, pi.Name, false)); html.Write(GetPair(pi.PropertyType, pi.Name, false));

View file

@ -175,7 +175,7 @@ namespace Server.Commands
ConstructorInfo ctor = type.GetConstructor(Type.EmptyTypes); ConstructorInfo ctor = type.GetConstructor(Type.EmptyTypes);
return ctor != null && ctor.IsDefined(typeofConstructible, false); return ctor?.IsDefined(typeofConstructible, false) == true;
} }
private static void AddTypes(Assembly asm, List<Type> types) private static void AddTypes(Assembly asm, List<Type> types)
@ -399,4 +399,4 @@ namespace Server.Commands
return list.ToArray(); return list.ToArray();
} }
} }
} }

View file

@ -105,7 +105,7 @@ namespace Server.Commands.Generic
PropertyInfo[] chain = Properties.GetPropertyInfoChain(m_From, obj.GetType(), m_Columns[i], PropertyInfo[] chain = Properties.GetPropertyInfoChain(m_From, obj.GetType(), m_Columns[i],
PropertyAccess.Read, ref failReason); PropertyAccess.Read, ref failReason);
if (chain != null && chain.Length > 0) if (chain?.Length > 0)
{ {
m_Columns[i] = ""; m_Columns[i] = "";
@ -565,4 +565,4 @@ namespace Server.Commands.Generic
} }
} }
} }
} }

View file

@ -90,93 +90,93 @@ namespace Server.Commands.Generic
public void Acquire(TypeBuilder typeBuilder, ILGenerator il, string fieldName) public void Acquire(TypeBuilder typeBuilder, ILGenerator il, string fieldName)
{ {
if (Value is string toParse) if (!(Value is string toParse))
{ return;
if (!Type.IsValueType && toParse == "null")
{
Value = null;
}
else if (Type == typeof(string))
{
if (toParse == @"@""null""")
toParse = "null";
Value = toParse; if (!Type.IsValueType && toParse == "null")
} {
else if (Type.IsEnum) Value = null;
}
else if (Type == typeof(string))
{
if (toParse == @"@""null""")
toParse = "null";
Value = toParse;
}
else if (Type.IsEnum)
{
Value = Enum.Parse(Type, toParse, true);
}
else
{
MethodInfo parseMethod;
object[] parseArgs;
MethodInfo parseNumber = Type.GetMethod(
"Parse",
BindingFlags.Public | BindingFlags.Static,
null,
new[] { typeof(string), typeof(NumberStyles) },
null
);
if (parseNumber != null)
{ {
Value = Enum.Parse(Type, toParse, true); NumberStyles style = NumberStyles.Integer;
if (Insensitive.StartsWith(toParse, "0x"))
{
style = NumberStyles.HexNumber;
toParse = toParse.Substring(2);
}
parseMethod = parseNumber;
parseArgs = new object[] { toParse, style };
} }
else else
{ {
MethodInfo parseMethod; MethodInfo parseGeneral = Type.GetMethod(
object[] parseArgs;
MethodInfo parseNumber = Type.GetMethod(
"Parse", "Parse",
BindingFlags.Public | BindingFlags.Static, BindingFlags.Public | BindingFlags.Static,
null, null,
new[] { typeof(string), typeof(NumberStyles) }, new[] { typeof(string) },
null null
); );
if (parseNumber != null) parseMethod = parseGeneral;
{ parseArgs = new object[] { toParse };
NumberStyles style = NumberStyles.Integer; }
if (Insensitive.StartsWith(toParse, "0x")) if (parseMethod != null)
{ {
style = NumberStyles.HexNumber; Value = parseMethod.Invoke(null, parseArgs);
toParse = toParse.Substring(2);
}
parseMethod = parseNumber; if (!Type.IsPrimitive)
parseArgs = new object[] { toParse, style };
}
else
{ {
MethodInfo parseGeneral = Type.GetMethod( Field = typeBuilder.DefineField(
"Parse", fieldName,
BindingFlags.Public | BindingFlags.Static, Type,
null, FieldAttributes.Private | FieldAttributes.InitOnly
new[] { typeof(string) },
null
); );
parseMethod = parseGeneral; il.Emit(OpCodes.Ldarg_0);
parseArgs = new object[] { toParse };
} il.Emit(OpCodes.Ldstr, toParse);
if (parseMethod != null) if (parseArgs.Length == 2) // dirty evil hack :-(
{ il.Emit(OpCodes.Ldc_I4, (int)parseArgs[1]);
Value = parseMethod.Invoke(null, parseArgs);
il.Emit(OpCodes.Call, parseMethod);
if (!Type.IsPrimitive) il.Emit(OpCodes.Stfld, Field);
{
Field = typeBuilder.DefineField(
fieldName,
Type,
FieldAttributes.Private | FieldAttributes.InitOnly
);
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldstr, toParse);
if (parseArgs.Length == 2) // dirty evil hack :-(
il.Emit(OpCodes.Ldc_I4, (int)parseArgs[1]);
il.Emit(OpCodes.Call, parseMethod);
il.Emit(OpCodes.Stfld, Field);
}
}
else
{
throw new InvalidOperationException(
$"Unable to convert string \"{Value}\" into type '{Type}'."
);
} }
} }
else
{
throw new InvalidOperationException(
$"Unable to convert string \"{Value}\" into type '{Type}'."
);
}
} }
} }
} }
@ -542,4 +542,4 @@ namespace Server.Commands.Generic
return (IConditional)Activator.CreateInstance(conditionalType); return (IConditional)Activator.CreateInstance(conditionalType);
} }
} }
} }

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace Server.Commands.Generic namespace Server.Commands.Generic
{ {
@ -36,28 +37,15 @@ namespace Server.Commands.Generic
if (!CheckObjectTypes(from, command, ext, out bool items, out bool mobiles)) if (!CheckObjectTypes(from, command, ext, out bool items, out bool mobiles))
return; return;
IPooledEnumerable<IEntity> eable; if (!(items || mobiles))
if (items || mobiles)
eable = map.GetObjectsInBounds(rect, items, mobiles);
else
return; return;
eable.Free(); IPooledEnumerable<IEntity> eable = map.GetObjectsInBounds(rect, items, mobiles);
List<object> objs = new List<object>(); List<object> objs = eable.Where(obj => !mobiles || !(obj is Mobile) || BaseCommand.IsAccessible(from, obj))
.Where(obj => ext.IsValid(obj)).Cast<object>().ToList();
foreach (IEntity obj in eable)
{
if (mobiles && obj is Mobile && !BaseCommand.IsAccessible(from, obj))
continue;
if (ext.IsValid(obj))
objs.Add(obj);
}
eable.Free(); eable.Free();
ext.Filter(objs); ext.Filter(objs);
RunCommand(from, objs, command, args); RunCommand(from, objs, command, args);
@ -68,4 +56,4 @@ namespace Server.Commands.Generic
} }
} }
} }
} }

View file

@ -299,7 +299,7 @@ namespace Server.Commands
for (int i = 0; i < pets.Count; ++i) for (int i = 0; i < pets.Count; ++i)
{ {
Mobile pet = (Mobile)pets[i]; Mobile pet = pets[i];
if (pet is IMount mount) if (pet is IMount mount)
mount.Rider = null; // make sure it's dismounted mount.Rider = null; // make sure it's dismounted
@ -410,18 +410,20 @@ namespace Server.Commands
private static bool FixMap(ref Map map, ref Point3D loc, Item item) private static bool FixMap(ref Map map, ref Point3D loc, Item item)
{ {
return map == null || map == Map.Internal && item.RootParent is Mobile m && FixMap(ref map, ref loc, m); return map != null && map != Map.Internal || item.RootParent is Mobile m && FixMap(ref map, ref loc, m);
} }
private static bool FixMap(ref Map map, ref Point3D loc, Mobile m) private static bool FixMap(ref Map map, ref Point3D loc, Mobile m)
{ {
if (map == null || map == Map.Internal) bool validMap = map != null && map != Map.Internal;
if (!validMap)
{ {
map = m.LogoutMap; map = m.LogoutMap;
loc = m.LogoutLocation; loc = m.LogoutLocation;
} }
return map != null && map != Map.Internal; return validMap;
} }
[Usage("Go [name | serial | (x y [z]) | (deg min (N | S) deg min (E | W))]")] [Usage("Go [name | serial | (x y [z]) | (deg min (N | S) deg min (E | W))]")]
@ -676,7 +678,7 @@ namespace Server.Commands
{ {
Mobile m = state.Mobile; Mobile m = state.Mobile;
if (m != null && m.AccessLevel >= ac) if (m?.AccessLevel >= ac)
m.SendMessage(hue, message); m.SendMessage(hue, message);
} }
} }
@ -957,4 +959,4 @@ namespace Server.Commands
} }
} }
} }
} }

View file

@ -337,12 +337,7 @@ namespace Server.Commands
public class CommandInfoGump : Gump public class CommandInfoGump : Gump
{ {
public CommandInfoGump(CommandInfo info) public CommandInfoGump(CommandInfo info, int width = 320, int height = 200)
: this(info, 320, 200)
{
}
public CommandInfoGump(CommandInfo info, int width, int height)
: base(300, 50) : base(300, 50)
{ {
AddPage(0); AddPage(0);
@ -352,7 +347,7 @@ namespace Server.Commands
//AddImageTiled( 10, 10, width - 20, 20, 2624 ); //AddImageTiled( 10, 10, width - 20, 20, 2624 );
//AddAlphaRegion( 10, 10, width - 20, 20 ); //AddAlphaRegion( 10, 10, width - 20, 20 );
//AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor, false, false ); //AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor, false, false );
AddHtml(10, 10, width - 20, 20, Color(Center(info.Name), 0xFF0000), false, false); AddHtml(10, 10, width - 20, 20, Color(Center(info.Name), 0xFF0000));
//AddImageTiled( 10, 40, width - 20, height - 80, 2624 ); //AddImageTiled( 10, 40, width - 20, height - 80, 2624 );
//AddAlphaRegion( 10, 40, width - 20, height - 80 ); //AddAlphaRegion( 10, 40, width - 20, height - 80 );
@ -365,7 +360,7 @@ namespace Server.Commands
string[] aliases = info.Aliases; string[] aliases = info.Aliases;
if (aliases != null && aliases.Length != 0) if (aliases?.Length > 0)
{ {
sb.Append($"Alias{(aliases.Length == 1 ? "" : "es")}: "); sb.Append($"Alias{(aliases.Length == 1 ? "" : "es")}: ");
@ -404,4 +399,4 @@ namespace Server.Commands
} }
} }
} }
} }

View file

@ -1,5 +1,4 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;

View file

@ -16,7 +16,7 @@ namespace Server.Commands
ReadWrite = Read | Write ReadWrite = Read | Write
} }
public class Properties public static class Properties
{ {
private static Type typeofCPA = typeof(CPA); private static Type typeofCPA = typeof(CPA);
@ -174,10 +174,7 @@ namespace Server.Commands
{ {
PropertyInfo[] chain = GetPropertyInfoChain(from, obj.GetType(), propertyName, access, ref failReason); PropertyInfo[] chain = GetPropertyInfoChain(from, obj.GetType(), propertyName, access, ref failReason);
if (chain == null) return chain == null ? null : GetPropertyInfo(ref obj, chain, ref failReason);
return null;
return GetPropertyInfo(ref obj, chain, ref failReason);
} }
public static PropertyInfo GetPropertyInfo(ref object obj, PropertyInfo[] chain, ref string failReason) public static PropertyInfo GetPropertyInfo(ref object obj, PropertyInfo[] chain, ref string failReason)
@ -216,21 +213,19 @@ namespace Server.Commands
PropertyInfo p = GetPropertyInfo(ref o, chain, ref failReason); PropertyInfo p = GetPropertyInfo(ref o, chain, ref failReason);
if (p == null) return p == null ? failReason : InternalGetValue(o, p, chain);
return failReason;
return InternalGetValue(o, p, chain);
} }
public static string IncreaseValue(Mobile from, object o, string[] args) public static string IncreaseValue(Mobile from, object o, string[] args)
{ {
Type type = o.GetType(); // Type type = o.GetType();
object[] realObjs = new object[args.Length / 2]; object[] realObjs = new object[args.Length / 2];
PropertyInfo[] realProps = new PropertyInfo[args.Length / 2]; PropertyInfo[] realProps = new PropertyInfo[args.Length / 2];
int[] realValues = new int[args.Length / 2]; int[] realValues = new int[args.Length / 2];
bool positive = false, negative = false; bool positive = false;
bool negative = false;
for (int i = 0; i < realProps.Length; ++i) for (int i = 0; i < realProps.Length; ++i)
{ {
@ -315,9 +310,9 @@ namespace Server.Commands
if (value == null) if (value == null)
toString = "null"; toString = "null";
else if (IsNumeric(type)) else if (IsNumeric(type))
toString = string.Format("{0} (0x{0:X})", value); toString = $"{value} (0x{value:X})";
else if (IsChar(type)) else if (IsChar(type))
toString = string.Format("'{0}' ({1} [0x{1:X}])", value, (int)value); toString = $"'{value}' ({(int)value} [0x{(int)value:X}])";
else if (IsString(type)) else if (IsString(type))
toString = (string)value == "null" ? @"@""null""" : $"\"{value}\""; toString = (string)value == "null" ? @"@""null""" : $"\"{value}\"";
else if (IsText(type)) else if (IsText(type))
@ -348,10 +343,7 @@ namespace Server.Commands
string failReason = ""; string failReason = "";
PropertyInfo p = GetPropertyInfo(from, ref o, name, PropertyAccess.Write, ref failReason); PropertyInfo p = GetPropertyInfo(from, ref o, name, PropertyAccess.Write, ref failReason);
if (p == null) return p == null ? failReason : InternalSetValue(from, logObject, o, p, name, value, true);
return failReason;
return InternalSetValue(from, logObject, o, p, name, value, true);
} }
private static bool IsSerial(Type t) private static bool IsSerial(Type t)
@ -524,10 +516,7 @@ namespace Server.Commands
object toSet = null; object toSet = null;
string result = ConstructFromString(p.PropertyType, o, value, ref toSet); string result = ConstructFromString(p.PropertyType, o, value, ref toSet);
if (result != null) return result ?? SetDirect(from, logobj, o, p, pname, toSet, shouldLog);
return result;
return SetDirect(from, logobj, o, p, pname, toSet, shouldLog);
} }
public static string InternalSetValue(object o, PropertyInfo p, string value) public static string InternalSetValue(object o, PropertyInfo p, string value)
@ -535,10 +524,7 @@ namespace Server.Commands
object toSet = null; object toSet = null;
string result = ConstructFromString(p.PropertyType, o, value, ref toSet); string result = ConstructFromString(p.PropertyType, o, value, ref toSet);
if (result != null) return result ?? SetDirect(o, p, toSet);
return result;
return SetDirect(o, p, toSet);
} }
private class PropsTarget : Target private class PropsTarget : Target
@ -639,18 +625,14 @@ namespace Server
public abstract class ClearanceException : AccessException public abstract class ClearanceException : AccessException
{ {
protected AccessLevel m_NeededAccess;
protected AccessLevel m_PlayerAccess;
public ClearanceException(Property property, AccessLevel playerAccess, AccessLevel neededAccess, string accessType) public ClearanceException(Property property, AccessLevel playerAccess, AccessLevel neededAccess, string accessType)
: base(property, : base(property,
$"You must be at least {Mobile.GetAccessLevelName(neededAccess)} to {accessType} this property.") $"You must be at least {Mobile.GetAccessLevelName(neededAccess)} to {accessType} this property.")
{ {
} }
public AccessLevel PlayerAccess => m_PlayerAccess; public AccessLevel PlayerAccess{ get; set; }
public AccessLevel NeededAccess{ get; set; }
public AccessLevel NeededAccess => m_NeededAccess;
} }
public sealed class ReadAccessException : ClearanceException public sealed class ReadAccessException : ClearanceException
@ -801,4 +783,4 @@ namespace Server
return prop; return prop;
} }
} }
} }

View file

@ -81,7 +81,7 @@ namespace Server.Commands
break; // Tokuno Islands break; // Tokuno Islands
} }
for (int j = 0; maps != null && j < maps.Length; ++j) for (int j = 0; maps?.Length >= j; ++j)
Add_Static(e.m_ItemID, e.m_Location, maps[j], e.m_Text); Add_Static(e.m_ItemID, e.m_Location, maps[j], e.m_Text);
} }
@ -145,4 +145,4 @@ namespace Server.Commands
} }
} }
} }
} }

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Server.Commands; using Server.Commands;

View file

@ -15,10 +15,10 @@ namespace Server.ContextMenus
public override void OnClick() public override void OnClick()
{ {
if (m_Food.Deleted || !m_Food.Movable || !m_From.CheckAlive() || !m_Food.CheckItemUse(m_From)) if (m_Food?.Deleted != false || !m_Food.Movable || !m_From.CheckAlive() || !m_Food.CheckItemUse(m_From))
return; return;
m_Food.Eat(m_From); m_Food.Eat(m_From);
} }
} }
} }

View file

@ -94,33 +94,31 @@ namespace Server.Engines.BulkOrders
AddImage(5, 424, 10460); AddImage(5, 424, 10460);
AddImage(585, 424, 10460); AddImage(585, 424, 10460);
AddHtmlLocalized(270, 32, 200, 32, 1062223, LabelColor, false, false); // Filter Preference AddHtmlLocalized(270, 32, 200, 32, 1062223, LabelColor); // Filter Preference
AddHtmlLocalized(26, 64, 120, 32, 1062228, LabelColor, false, false); // Bulk Order Type AddHtmlLocalized(26, 64, 120, 32, 1062228, LabelColor); // Bulk Order Type
AddFilterList(25, 96, m_XOffsets_Type, 40, m_TypeFilters, m_XWidths_Small, f.Type, 0); AddFilterList(25, 96, m_XOffsets_Type, 40, m_TypeFilters, m_XWidths_Small, f.Type, 0);
AddHtmlLocalized(320, 64, 50, 32, 1062215, LabelColor, false, false); // Quality AddHtmlLocalized(320, 64, 50, 32, 1062215, LabelColor); // Quality
AddFilterList(320, 96, m_XOffsets_Quality, 40, m_QualityFilters, m_XWidths_Small, f.Quality, 1); AddFilterList(320, 96, m_XOffsets_Quality, 40, m_QualityFilters, m_XWidths_Small, f.Quality, 1);
AddHtmlLocalized(26, 160, 120, 32, 1062232, LabelColor, false, false); // Material Type AddHtmlLocalized(26, 160, 120, 32, 1062232, LabelColor); // Material Type
AddFilterList(25, 192, m_XOffsets_Material, 40, m_MaterialFilters, m_XWidths_Large, f.Material, 2); AddFilterList(25, 192, m_XOffsets_Material, 40, m_MaterialFilters, m_XWidths_Large, f.Material, 2);
AddHtmlLocalized(26, 320, 120, 32, 1062217, LabelColor, false, false); // Amount AddHtmlLocalized(26, 320, 120, 32, 1062217, LabelColor); // Amount
AddFilterList(25, 352, m_XOffsets_Amount, 40, m_AmountFilters, m_XWidths_Small, f.Quantity, 3); AddFilterList(25, 352, m_XOffsets_Amount, 40, m_AmountFilters, m_XWidths_Small, f.Quantity, 3);
AddHtmlLocalized(75, 416, 120, 32, 1062477, from.UseOwnFilter ? LabelColor : 16927, false, AddHtmlLocalized(75, 416, 120, 32, 1062477, from.UseOwnFilter ? LabelColor : 16927); // Set Book Filter
false); // Set Book Filter AddButton(40, 416, 4005, 4007, 1);
AddButton(40, 416, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(235, 416, 120, 32, 1062478, from.UseOwnFilter ? 16927 : LabelColor, false, AddHtmlLocalized(235, 416, 120, 32, 1062478, from.UseOwnFilter ? 16927 : LabelColor); // Set Your Filter
false); // Set Your Filter AddButton(200, 416, 4005, 4007, 2);
AddButton(200, 416, 4005, 4007, 2, GumpButtonType.Reply, 0);
AddHtmlLocalized(405, 416, 120, 32, 1062231, LabelColor, false, false); // Clear Filter AddHtmlLocalized(405, 416, 120, 32, 1062231, LabelColor); // Clear Filter
AddButton(370, 416, 4005, 4007, 3, GumpButtonType.Reply, 0); AddButton(370, 416, 4005, 4007, 3);
AddHtmlLocalized(540, 416, 50, 32, 1011046, LabelColor, false, false); // APPLY AddHtmlLocalized(540, 416, 50, 32, 1011046, LabelColor); // APPLY
AddButton(505, 416, 4017, 4018, 0, GumpButtonType.Reply, 0); AddButton(505, 416, 4017, 4018, 0);
} }
private void AddFilterList(int x, int y, int[] xOffsets, int yOffset, int[,] filters, int[] xWidths, int filterValue, private void AddFilterList(int x, int y, int[] xOffsets, int yOffset, int[,] filters, int[] xWidths, int filterValue,
@ -139,9 +137,9 @@ namespace Server.Engines.BulkOrders
isSelected = filterValue == 0; isSelected = filterValue == 0;
AddHtmlLocalized(x + 35 + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset, AddHtmlLocalized(x + 35 + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset,
xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor, false, false); xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor);
AddButton(x + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset, 4005, 4007, AddButton(x + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset, 4005, 4007,
4 + filterIndex + i * 4, GumpButtonType.Reply, 0); 4 + filterIndex + i * 4);
} }
} }
@ -221,4 +219,4 @@ namespace Server.Engines.BulkOrders
} }
} }
} }
} }

View file

@ -56,7 +56,7 @@ namespace Server.Engines.BulkOrders
{ {
VendorItem vi = pv.GetVendorItem(book); VendorItem vi = pv.GetVendorItem(book);
canBuy = vi != null && !vi.IsForSale; canBuy = vi?.IsForSale == false;
} }
int width = 600; int width = 600;
@ -103,45 +103,45 @@ namespace Server.Engines.BulkOrders
AddImage(5, 424, 10460); AddImage(5, 424, 10460);
AddImage(width - 15, 424, 10460); AddImage(width - 15, 424, 10460);
AddHtmlLocalized(canPrice ? 266 : 224, 32, 200, 32, 1062220, LabelColor, false, false); // Bulk Order Book AddHtmlLocalized(canPrice ? 266 : 224, 32, 200, 32, 1062220, LabelColor); // Bulk Order Book
AddHtmlLocalized(63, 64, 200, 32, 1062213, LabelColor, false, false); // Type AddHtmlLocalized(63, 64, 200, 32, 1062213, LabelColor); // Type
AddHtmlLocalized(147, 64, 200, 32, 1062214, LabelColor, false, false); // Item AddHtmlLocalized(147, 64, 200, 32, 1062214, LabelColor); // Item
AddHtmlLocalized(246, 64, 200, 32, 1062215, LabelColor, false, false); // Quality AddHtmlLocalized(246, 64, 200, 32, 1062215, LabelColor); // Quality
AddHtmlLocalized(336, 64, 200, 32, 1062216, LabelColor, false, false); // Material AddHtmlLocalized(336, 64, 200, 32, 1062216, LabelColor); // Material
AddHtmlLocalized(429, 64, 200, 32, 1062217, LabelColor, false, false); // Amount AddHtmlLocalized(429, 64, 200, 32, 1062217, LabelColor); // Amount
AddButton(35, 32, 4005, 4007, 1, GumpButtonType.Reply, 0); AddButton(35, 32, 4005, 4007, 1);
AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor, false, false); // Set Filter AddHtmlLocalized(70, 32, 200, 32, 1062476, LabelColor); // Set Filter
BOBFilter f = from.UseOwnFilter ? from.BOBFilter : book.Filter; BOBFilter f = from.UseOwnFilter ? from.BOBFilter : book.Filter;
if (f.IsDefault) if (f.IsDefault)
AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927, false, false); // Using No Filter AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927); // Using No Filter
else if (from.UseOwnFilter) else if (from.UseOwnFilter)
AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927, false, false); // Using Your Filter AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927); // Using Your Filter
else else
AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927, false, false); // Using Book Filter AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927); // Using Book Filter
AddButton(375, 416, 4017, 4018, 0, GumpButtonType.Reply, 0); AddButton(375, 416, 4017, 4018, 0);
AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor, false, false); // EXIT AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor); // EXIT
if (canDrop) if (canDrop)
AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor, false, false); // Drop AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor); // Drop
if (canPrice) if (canPrice)
{ {
AddHtmlLocalized(516, 64, 200, 32, 1062218, LabelColor, false, false); // Price AddHtmlLocalized(516, 64, 200, 32, 1062218, LabelColor); // Price
if (canBuy) if (canBuy)
{ {
AddHtmlLocalized(576, 64, 200, 32, 1062219, LabelColor, false, false); // Buy AddHtmlLocalized(576, 64, 200, 32, 1062219, LabelColor); // Buy
} }
else else
{ {
AddHtmlLocalized(576, 64, 200, 32, 1062227, LabelColor, false, false); // Set AddHtmlLocalized(576, 64, 200, 32, 1062227, LabelColor); // Set
AddButton(450, 416, 4005, 4007, 4, GumpButtonType.Reply, 0); AddButton(450, 416, 4005, 4007, 4);
AddHtml(485, 416, 120, 20, "<BASEFONT COLOR=#FFFFFF>Price all</FONT>", false, false); AddHtml(485, 416, 120, 20, "<BASEFONT COLOR=#FFFFFF>Price all</FONT>");
} }
} }
@ -149,14 +149,14 @@ namespace Server.Engines.BulkOrders
if (page > 0) if (page > 0)
{ {
AddButton(75, 416, 4014, 4016, 2, GumpButtonType.Reply, 0); AddButton(75, 416, 4014, 4016, 2);
AddHtmlLocalized(110, 416, 150, 20, 1011067, LabelColor, false, false); // Previous page AddHtmlLocalized(110, 416, 150, 20, 1011067, LabelColor); // Previous page
} }
if (GetIndexForPage(page + 1) < list.Count) if (GetIndexForPage(page + 1) < list.Count)
{ {
AddButton(225, 416, 4005, 4007, 3, GumpButtonType.Reply, 0); AddButton(225, 416, 4005, 4007, 3);
AddHtmlLocalized(260, 416, 150, 20, 1011066, LabelColor, false, false); // Next page AddHtmlLocalized(260, 416, 150, 20, 1011066, LabelColor); // Next page
} }
for (int i = index; i < index + count && i >= 0 && i < list.Count; ++i) for (int i = index; i < index + count && i >= 0 && i < list.Count; ++i)
@ -171,31 +171,31 @@ namespace Server.Engines.BulkOrders
int y = 96 + tableIndex * 32; int y = 96 + tableIndex * 32;
if (canDrop) if (canDrop)
AddButton(35, y + 2, 5602, 5606, 5 + i * 2, GumpButtonType.Reply, 0); AddButton(35, y + 2, 5602, 5606, 5 + i * 2);
if (canDrop || canBuy && entry.Price > 0) if (canDrop || canBuy && entry.Price > 0)
{ {
AddButton(579, y + 2, 2117, 2118, 6 + i * 2, GumpButtonType.Reply, 0); AddButton(579, y + 2, 2117, 2118, 6 + i * 2);
AddLabel(495, y, 1152, entry.Price.ToString()); AddLabel(495, y, 1152, entry.Price.ToString());
} }
AddHtmlLocalized(61, y, 50, 32, 1062225, LabelColor, false, false); // Large AddHtmlLocalized(61, y, 50, 32, 1062225, LabelColor); // Large
for (int j = 0; j < largeEntry.Entries.Length; ++j) for (int j = 0; j < largeEntry.Entries.Length; ++j)
{ {
BOBLargeSubEntry sub = largeEntry.Entries[j]; BOBLargeSubEntry sub = largeEntry.Entries[j];
AddHtmlLocalized(103, y, 130, 32, sub.Number, LabelColor, false, false); AddHtmlLocalized(103, y, 130, 32, sub.Number, LabelColor);
if (entry.RequireExceptional) if (entry.RequireExceptional)
AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor, false, false); // exceptional AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor); // exceptional
else else
AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor, false, false); // normal AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor); // normal
object name = GetMaterialName(entry.Material, entry.DeedType, sub.ItemType); object name = GetMaterialName(entry.Material, entry.DeedType, sub.ItemType);
if (name is int intName) if (name is int intName)
AddHtmlLocalized(316, y, 100, 20, intName, LabelColor, false, false); AddHtmlLocalized(316, y, 100, 20, intName, LabelColor);
else else
AddLabel(316, y, 1152, name.ToString()); AddLabel(316, y, 1152, name.ToString());
@ -212,27 +212,27 @@ namespace Server.Engines.BulkOrders
int y = 96 + tableIndex++ * 32; int y = 96 + tableIndex++ * 32;
if (canDrop) if (canDrop)
AddButton(35, y + 2, 5602, 5606, 5 + i * 2, GumpButtonType.Reply, 0); AddButton(35, y + 2, 5602, 5606, 5 + i * 2);
if (canDrop || canBuy && smallEntry.Price > 0) if (canDrop || canBuy && smallEntry.Price > 0)
{ {
AddButton(579, y + 2, 2117, 2118, 6 + i * 2, GumpButtonType.Reply, 0); AddButton(579, y + 2, 2117, 2118, 6 + i * 2);
AddLabel(495, y, 1152, smallEntry.Price.ToString()); AddLabel(495, y, 1152, smallEntry.Price.ToString());
} }
AddHtmlLocalized(61, y, 50, 32, 1062224, LabelColor, false, false); // Small AddHtmlLocalized(61, y, 50, 32, 1062224, LabelColor); // Small
AddHtmlLocalized(103, y, 130, 32, smallEntry.Number, LabelColor, false, false); AddHtmlLocalized(103, y, 130, 32, smallEntry.Number, LabelColor);
if (smallEntry.RequireExceptional) if (smallEntry.RequireExceptional)
AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor, false, false); // exceptional AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor); // exceptional
else else
AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor, false, false); // normal AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor); // normal
object name = GetMaterialName(smallEntry.Material, smallEntry.DeedType, smallEntry.ItemType); object name = GetMaterialName(smallEntry.Material, smallEntry.DeedType, smallEntry.ItemType);
if (name is int intName) if (name is int intName)
AddHtmlLocalized(316, y, 100, 20, intName, LabelColor, false, false); AddHtmlLocalized(316, y, 100, 20, intName, LabelColor);
else else
AddLabel(316, y, 1152, name.ToString()); AddLabel(316, y, 1152, name.ToString());
@ -242,11 +242,11 @@ namespace Server.Engines.BulkOrders
} }
public bool CheckFilter(IBOBEntry entry) public bool CheckFilter(IBOBEntry entry)
{ {
if (entry is BOBLargeEntry largeEntry) if (entry is BOBLargeEntry largeEntry)
return CheckFilter(entry.Material, entry.AmountMax, true, entry.RequireExceptional, entry.DeedType, return CheckFilter(entry.Material, entry.AmountMax, true, entry.RequireExceptional, entry.DeedType,
largeEntry.Entries.Length > 0 ? largeEntry.Entries[0].ItemType : null); largeEntry.Entries.Length > 0 ? largeEntry.Entries[0].ItemType : null);
if (entry is BOBSmallEntry smallEntry) if (entry is BOBSmallEntry smallEntry)
return CheckFilter(entry.Material, entry.AmountMax, false, entry.RequireExceptional, return CheckFilter(entry.Material, entry.AmountMax, false, entry.RequireExceptional,
entry.DeedType, smallEntry.ItemType); entry.DeedType, smallEntry.ItemType);
@ -355,7 +355,7 @@ namespace Server.Engines.BulkOrders
int count = 0; int count = 0;
int page = 0; int page = 0;
int i; int i;
List<IBOBEntry> list = m_List; List<IBOBEntry> list = m_List;
for (i = 0; i < index && i < list.Count; i++) for (i = 0; i < index && i < list.Count; i++)
{ {
@ -510,8 +510,8 @@ namespace Server.Engines.BulkOrders
Item item = bobEntry.Reconstruct(); Item item = bobEntry.Reconstruct();
Container pack = m_From.Backpack; Container pack = m_From.Backpack;
if (pack == null || !pack.CheckHold(m_From, item, true, true, 0, if (pack?.CheckHold(m_From, item, true, true, 0,
item.PileWeight + item.TotalWeight)) item.PileWeight + item.TotalWeight) != true)
{ {
m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page)); m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
@ -558,26 +558,26 @@ namespace Server.Engines.BulkOrders
{ {
VendorItem vi = pv.GetVendorItem(m_Book); VendorItem vi = pv.GetVendorItem(m_Book);
if (vi != null && !vi.IsForSale) if (vi?.IsForSale != false)
{ return;
int sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
int price = bobEntry.Price;
if (price == 0) int sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
int price = bobEntry.Price;
if (price == 0)
{
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
}
else
{
if (m_Book.Entries.Count > 0)
{ {
m_From.SendLocalizedMessage(1062382); // The deed selected is not available. m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price));
} }
else else
{ {
if (m_Book.Entries.Count > 0) m_From.SendLocalizedMessage(1062381); // The book is emptz
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is emptz
}
} }
} }
} }
@ -625,7 +625,7 @@ namespace Server.Engines.BulkOrders
if (!m_Book.Entries.Contains(entry)) if (!m_Book.Entries.Contains(entry))
continue; continue;
entry.Price = price; entry.Price = price;
} }
@ -644,4 +644,4 @@ namespace Server.Engines.BulkOrders
} }
} }
} }
} }

View file

@ -67,7 +67,7 @@ namespace Server.Engines.BulkOrders
else if (DeedType == BODType.Tailor) else if (DeedType == BODType.Tailor)
bod = new LargeTailorBOD(AmountMax, RequireExceptional, Material, ReconstructEntries()); bod = new LargeTailorBOD(AmountMax, RequireExceptional, Material, ReconstructEntries());
for (int i = 0; bod != null && i < bod.Entries.Length; ++i) for (int i = 0; bod?.Entries.Length >= i; ++i)
bod.Entries[i].Owner = bod; bod.Entries[i].Owner = bod;
return bod; return bod;
@ -103,4 +103,4 @@ namespace Server.Engines.BulkOrders
Entries[i].Serialize(writer); Entries[i].Serialize(writer);
} }
} }
} }

View file

@ -25,17 +25,17 @@ namespace Server.Engines.BulkOrders
AddBackground(100, 10, 300, 150, 5054); AddBackground(100, 10, 300, 150, 5054);
AddHtmlLocalized(125, 20, 250, 24, 1019070, false, false); // You have agreed to purchase: AddHtmlLocalized(125, 20, 250, 24, 1019070); // You have agreed to purchase:
AddHtmlLocalized(125, 45, 250, 24, 1045151, false, false); // a bulk order deed AddHtmlLocalized(125, 45, 250, 24, 1045151); // a bulk order deed
AddHtmlLocalized(125, 70, 250, 24, 1019071, false, false); // for the amount of: AddHtmlLocalized(125, 70, 250, 24, 1019071); // for the amount of:
AddLabel(125, 95, 0, price.ToString()); AddLabel(125, 95, 0, price.ToString());
AddButton(250, 130, 4005, 4007, 1, GumpButtonType.Reply, 0); AddButton(250, 130, 4005, 4007, 1);
AddHtmlLocalized(282, 130, 100, 24, 1011012, false, false); // CANCEL AddHtmlLocalized(282, 130, 100, 24, 1011012); // CANCEL
AddButton(120, 130, 4005, 4007, 2, GumpButtonType.Reply, 0); AddButton(120, 130, 4005, 4007, 2);
AddHtmlLocalized(152, 130, 100, 24, 1011036, false, false); // OKAY AddHtmlLocalized(152, 130, 100, 24, 1011036); // OKAY
} }
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
@ -57,12 +57,12 @@ namespace Server.Engines.BulkOrders
pv.SayTo(m_From, 1062382); // The deed selected is not available. pv.SayTo(m_From, 1062382); // The deed selected is not available.
return; return;
} }
int price = 0; int price = 0;
VendorItem vi = pv.GetVendorItem(m_Book); VendorItem vi = pv.GetVendorItem(m_Book);
if (vi != null && !vi.IsForSale) if (vi?.IsForSale == false)
price = m_Entry.Price; price = m_Entry.Price;
if (price != m_Price) if (price != m_Price)
@ -79,13 +79,13 @@ namespace Server.Engines.BulkOrders
} }
Item item = m_Entry.Reconstruct(); Item item = m_Entry.Reconstruct();
pv.Say(m_From.Name); pv.Say(m_From.Name);
Container pack = m_From.Backpack; Container pack = m_From.Backpack;
if (pack == null || !pack.CheckHold(m_From, item, true, true, 0, if (pack?.CheckHold(m_From, item, true, true, 0,
item.PileWeight + item.TotalWeight)) item.PileWeight + item.TotalWeight) != true)
{ {
pv.SayTo(m_From, 503204); // You do not have room in your backpack for this pv.SayTo(m_From, 503204); // You do not have room in your backpack for this
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page)); m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
@ -120,4 +120,4 @@ namespace Server.Engines.BulkOrders
} }
} }
} }
} }

View file

@ -70,9 +70,9 @@ namespace Server.Engines.BulkOrders
{ {
SecureTrade trade = cont.Trade; SecureTrade trade = cont.Trade;
if ( trade != null && trade.From.Mobile == from ) if (trade?.From.Mobile == from )
trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.To.Mobile, this ) ); trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.To.Mobile, this ) );
else if ( trade != null && trade.To.Mobile == from ) else if (trade?.To.Mobile == from )
trade.From.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.From.Mobile, this ) ); trade.From.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.From.Mobile, this ) );
} }
} }
@ -159,9 +159,9 @@ namespace Server.Engines.BulkOrders
{ {
base.Serialize( writer ); base.Serialize( writer );
writer.Write( (int) 2 ); // version writer.Write( 2 ); // version
writer.Write( (int) ItemCount ); writer.Write( ItemCount );
writer.Write( (int) Level ); writer.Write( (int) Level );
@ -169,7 +169,7 @@ namespace Server.Engines.BulkOrders
Filter.Serialize( writer ); Filter.Serialize( writer );
writer.WriteEncodedInt( (int) Entries.Count ); writer.WriteEncodedInt( Entries.Count );
for ( int i = 0; i < Entries.Count; ++i ) for ( int i = 0; i < Entries.Count; ++i )
{ {

View file

@ -218,13 +218,13 @@ namespace Server.Engines.BulkOrders
{ {
base.Serialize( writer ); base.Serialize( writer );
writer.Write( (int) 0 ); // version writer.Write( 0 ); // version
writer.Write( m_AmountMax ); writer.Write( m_AmountMax );
writer.Write( m_RequireExceptional ); writer.Write( m_RequireExceptional );
writer.Write( (int) m_Material ); writer.Write( (int) m_Material );
writer.Write( (int) m_Entries.Length ); writer.Write( m_Entries.Length );
for ( int i = 0; i < m_Entries.Length; ++i ) for ( int i = 0; i < m_Entries.Length; ++i )
m_Entries[i].Serialize( writer ); m_Entries[i].Serialize( writer );

View file

@ -30,48 +30,45 @@ namespace Server.Engines.BulkOrders
AddImage(20, 225 + entries.Length * 24, 10460); AddImage(20, 225 + entries.Length * 24, 10460);
AddImage(430, 225 + entries.Length * 24, 10460); AddImage(430, 225 + entries.Length * 24, 10460);
AddHtmlLocalized(180, 25, 120, 20, 1045134, 0x7FFF, false, false); // A large bulk order AddHtmlLocalized(180, 25, 120, 20, 1045134, 0x7FFF); // A large bulk order
AddHtmlLocalized(40, 48, 350, 20, 1045135, 0x7FFF, false, AddHtmlLocalized(40, 48, 350, 20, 1045135, 0x7FFF); // Ah! Thanks for the goods! Would you help me out?
false); // Ah! Thanks for the goods! Would you help me out?
AddHtmlLocalized(40, 72, 210, 20, 1045138, 0x7FFF, false, false); // Amount to make: AddHtmlLocalized(40, 72, 210, 20, 1045138, 0x7FFF); // Amount to make:
AddLabel(250, 72, 1152, deed.AmountMax.ToString()); AddLabel(250, 72, 1152, deed.AmountMax.ToString());
AddHtmlLocalized(40, 96, 120, 20, 1045137, 0x7FFF, false, false); // Items requested: AddHtmlLocalized(40, 96, 120, 20, 1045137, 0x7FFF); // Items requested:
int y = 120; int y = 120;
for (int i = 0; i < entries.Length; ++i, y += 24) for (int i = 0; i < entries.Length; ++i, y += 24)
AddHtmlLocalized(40, y, 210, 20, entries[i].Details.Number, 0x7FFF, false, false); AddHtmlLocalized(40, y, 210, 20, entries[i].Details.Number, 0x7FFF);
if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) if (deed.RequireExceptional || deed.Material != BulkMaterialType.None)
{ {
AddHtmlLocalized(40, y, 210, 20, 1045140, 0x7FFF, false, false); // Special requirements to meet: AddHtmlLocalized(40, y, 210, 20, 1045140, 0x7FFF); // Special requirements to meet:
y += 24; y += 24;
if (deed.RequireExceptional) if (deed.RequireExceptional)
{ {
AddHtmlLocalized(40, y, 350, 20, 1045141, 0x7FFF, false, false); // All items must be exceptional. AddHtmlLocalized(40, y, 350, 20, 1045141, 0x7FFF); // All items must be exceptional.
y += 24; y += 24;
} }
if (deed.Material != BulkMaterialType.None) if (deed.Material != BulkMaterialType.None)
{ {
AddHtmlLocalized(40, y, 350, 20, GetMaterialNumberFor(deed.Material), 0x7FFF, false, AddHtmlLocalized(40, y, 350, 20, GetMaterialNumberFor(deed.Material), 0x7FFF); // All items must be made with x material.
false); // All items must be made with x material.
y += 24; y += 24;
} }
} }
AddHtmlLocalized(40, 192 + entries.Length * 24, 350, 20, 1045139, 0x7FFF, false, AddHtmlLocalized(40, 192 + entries.Length * 24, 350, 20, 1045139, 0x7FFF); // Do you want to accept this order?
false); // Do you want to accept this order?
AddButton(100, 216 + entries.Length * 24, 4005, 4007, 1, GumpButtonType.Reply, 0); AddButton(100, 216 + entries.Length * 24, 4005, 4007, 1);
AddHtmlLocalized(135, 216 + entries.Length * 24, 120, 20, 1006044, 0x7FFF, false, false); // Ok AddHtmlLocalized(135, 216 + entries.Length * 24, 120, 20, 1006044, 0x7FFF); // Ok
AddButton(275, 216 + entries.Length * 24, 4005, 4007, 0, GumpButtonType.Reply, 0); AddButton(275, 216 + entries.Length * 24, 4005, 4007, 0);
AddHtmlLocalized(310, 216 + entries.Length * 24, 120, 20, 1011012, 0x7FFF, false, false); // CANCEL AddHtmlLocalized(310, 216 + entries.Length * 24, 120, 20, 1011012, 0x7FFF); // CANCEL
} }
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
@ -104,4 +101,4 @@ namespace Server.Engines.BulkOrders
return 0; return 0;
} }
} }
} }

View file

@ -30,13 +30,13 @@ namespace Server.Engines.BulkOrders
AddImage(45, 221 + entries.Length * 24, 10460); AddImage(45, 221 + entries.Length * 24, 10460);
AddImage(480, 221 + entries.Length * 24, 10460); AddImage(480, 221 + entries.Length * 24, 10460);
AddHtmlLocalized(225, 25, 120, 20, 1045134, 0x7FFF, false, false); // A large bulk order AddHtmlLocalized(225, 25, 120, 20, 1045134, 0x7FFF); // A large bulk order
AddHtmlLocalized(75, 48, 250, 20, 1045138, 0x7FFF, false, false); // Amount to make: AddHtmlLocalized(75, 48, 250, 20, 1045138, 0x7FFF); // Amount to make:
AddLabel(275, 48, 1152, deed.AmountMax.ToString()); AddLabel(275, 48, 1152, deed.AmountMax.ToString());
AddHtmlLocalized(75, 72, 120, 20, 1045137, 0x7FFF, false, false); // Items requested: AddHtmlLocalized(75, 72, 120, 20, 1045137, 0x7FFF); // Items requested:
AddHtmlLocalized(275, 76, 200, 20, 1045153, 0x7FFF, false, false); // Amount finished: AddHtmlLocalized(275, 76, 200, 20, 1045153, 0x7FFF); // Amount finished:
int y = 96; int y = 96;
@ -45,7 +45,7 @@ namespace Server.Engines.BulkOrders
LargeBulkEntry entry = entries[i]; LargeBulkEntry entry = entries[i];
SmallBulkEntry details = entry.Details; SmallBulkEntry details = entry.Details;
AddHtmlLocalized(75, y, 210, 20, details.Number, 0x7FFF, false, false); AddHtmlLocalized(75, y, 210, 20, details.Number, 0x7FFF);
AddLabel(275, y, 0x480, entry.Amount.ToString()); AddLabel(275, y, 0x480, entry.Amount.ToString());
y += 24; y += 24;
@ -53,26 +53,24 @@ namespace Server.Engines.BulkOrders
if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) if (deed.RequireExceptional || deed.Material != BulkMaterialType.None)
{ {
AddHtmlLocalized(75, y, 200, 20, 1045140, 0x7FFF, false, false); // Special requirements to meet: AddHtmlLocalized(75, y, 200, 20, 1045140, 0x7FFF); // Special requirements to meet:
y += 24; y += 24;
} }
if (deed.RequireExceptional) if (deed.RequireExceptional)
{ {
AddHtmlLocalized(75, y, 300, 20, 1045141, 0x7FFF, false, false); // All items must be exceptional. AddHtmlLocalized(75, y, 300, 20, 1045141, 0x7FFF); // All items must be exceptional.
y += 24; y += 24;
} }
if (deed.Material != BulkMaterialType.None) if (deed.Material != BulkMaterialType.None)
AddHtmlLocalized(75, y, 300, 20, GetMaterialNumberFor(deed.Material), 0x7FFF, false, AddHtmlLocalized(75, y, 300, 20, GetMaterialNumberFor(deed.Material), 0x7FFF); // All items must be made with x material.
false); // All items must be made with x material.
AddButton(125, 168 + entries.Length * 24, 4005, 4007, 2, GumpButtonType.Reply, 0); AddButton(125, 168 + entries.Length * 24, 4005, 4007, 2);
AddHtmlLocalized(160, 168 + entries.Length * 24, 300, 20, 1045155, 0x7FFF, false, AddHtmlLocalized(160, 168 + entries.Length * 24, 300, 20, 1045155, 0x7FFF); // Combine this deed with another deed.
false); // Combine this deed with another deed.
AddButton(125, 192 + entries.Length * 24, 4005, 4007, 1, GumpButtonType.Reply, 0); AddButton(125, 192 + entries.Length * 24, 4005, 4007, 1);
AddHtmlLocalized(160, 192 + entries.Length * 24, 120, 20, 1011441, 0x7FFF, false, false); // EXIT AddHtmlLocalized(160, 192 + entries.Length * 24, 120, 20, 1011441, 0x7FFF); // EXIT
} }
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
@ -97,4 +95,4 @@ namespace Server.Engines.BulkOrders
return 0; return 0;
} }
} }
} }

View file

@ -29,11 +29,7 @@ namespace Server.Engines.BulkOrders
public sealed class RewardItem public sealed class RewardItem
{ {
public RewardItem(int weight, ConstructCallback constructor) : this(weight, constructor, 0) public RewardItem(int weight, ConstructCallback constructor, int type = 0)
{
}
public RewardItem(int weight, ConstructCallback constructor, int type)
{ {
Weight = weight; Weight = weight;
Constructor = constructor; Constructor = constructor;
@ -583,7 +579,7 @@ namespace Server.Engines.BulkOrders
{ {
Groups = new[] Groups = new[]
{ {
new RewardGroup(0, new RewardItem(1, Cloth, 0)), new RewardGroup(0, new RewardItem(1, Cloth)),
new RewardGroup(50, new RewardItem(1, Cloth, 1)), new RewardGroup(50, new RewardItem(1, Cloth, 1)),
new RewardGroup(100, new RewardItem(1, Cloth, 2)), new RewardGroup(100, new RewardItem(1, Cloth, 2)),
new RewardGroup(150, new RewardItem(9, Cloth, 3), new RewardItem(1, Sandals)), new RewardGroup(150, new RewardItem(9, Cloth, 3), new RewardItem(1, Sandals)),
@ -745,4 +741,4 @@ namespace Server.Engines.BulkOrders
#endregion #endregion
} }
} }

View file

@ -28,36 +28,35 @@ namespace Server.Engines.BulkOrders
AddImage(20, 249, 10460); AddImage(20, 249, 10460);
AddImage(430, 249, 10460); AddImage(430, 249, 10460);
AddHtmlLocalized(190, 25, 120, 20, 1045133, 0x7FFF, false, false); // A bulk order AddHtmlLocalized(190, 25, 120, 20, 1045133, 0x7FFF); // A bulk order
AddHtmlLocalized(40, 48, 350, 20, 1045135, 0x7FFF, false, AddHtmlLocalized(40, 48, 350, 20, 1045135, 0x7FFF); // Ah! Thanks for the goods! Would you help me out?
false); // Ah! Thanks for the goods! Would you help me out?
AddHtmlLocalized(40, 72, 210, 20, 1045138, 0x7FFF, false, false); // Amount to make: AddHtmlLocalized(40, 72, 210, 20, 1045138, 0x7FFF); // Amount to make:
AddLabel(250, 72, 1152, deed.AmountMax.ToString()); AddLabel(250, 72, 1152, deed.AmountMax.ToString());
AddHtmlLocalized(40, 96, 120, 20, 1045136, 0x7FFF, false, false); // Item requested: AddHtmlLocalized(40, 96, 120, 20, 1045136, 0x7FFF); // Item requested:
AddItem(385, 96, deed.Graphic); AddItem(385, 96, deed.Graphic);
AddHtmlLocalized(40, 120, 210, 20, deed.Number, 0xFFFFFF, false, false); AddHtmlLocalized(40, 120, 210, 20, deed.Number, 0xFFFFFF);
if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) if (deed.RequireExceptional || deed.Material != BulkMaterialType.None)
{ {
AddHtmlLocalized(40, 144, 210, 20, 1045140, 0x7FFF, false, false); // Special requirements to meet: AddHtmlLocalized(40, 144, 210, 20, 1045140, 0x7FFF); // Special requirements to meet:
if (deed.RequireExceptional) if (deed.RequireExceptional)
AddHtmlLocalized(40, 168, 350, 20, 1045141, 0x7FFF, false, false); // All items must be exceptional. AddHtmlLocalized(40, 168, 350, 20, 1045141, 0x7FFF); // All items must be exceptional.
if (deed.Material != BulkMaterialType.None) if (deed.Material != BulkMaterialType.None)
AddHtmlLocalized(40, deed.RequireExceptional ? 192 : 168, 350, 20, GetMaterialNumberFor(deed.Material), AddHtmlLocalized(40, deed.RequireExceptional ? 192 : 168, 350, 20, GetMaterialNumberFor(deed.Material),
0x7FFF, false, false); // All items must be made with x material. 0x7FFF); // All items must be made with x material.
} }
AddHtmlLocalized(40, 216, 350, 20, 1045139, 0x7FFF, false, false); // Do you want to accept this order? AddHtmlLocalized(40, 216, 350, 20, 1045139, 0x7FFF); // Do you want to accept this order?
AddButton(100, 240, 4005, 4007, 1, GumpButtonType.Reply, 0); AddButton(100, 240, 4005, 4007, 1);
AddHtmlLocalized(135, 240, 120, 20, 1006044, 0x7FFF, false, false); // Ok AddHtmlLocalized(135, 240, 120, 20, 1006044, 0x7FFF); // Ok
AddButton(275, 240, 4005, 4007, 0, GumpButtonType.Reply, 0); AddButton(275, 240, 4005, 4007, 0);
AddHtmlLocalized(310, 240, 120, 20, 1011012, 0x7FFF, false, false); // CANCEL AddHtmlLocalized(310, 240, 120, 20, 1011012, 0x7FFF); // CANCEL
} }
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
@ -90,4 +89,4 @@ namespace Server.Engines.BulkOrders
return 0; return 0;
} }
} }
} }

View file

@ -27,34 +27,34 @@ namespace Server.Engines.BulkOrders
AddImage(45, 245, 10460); AddImage(45, 245, 10460);
AddImage(480, 245, 10460); AddImage(480, 245, 10460);
AddHtmlLocalized(225, 25, 120, 20, 1045133, 0x7FFF, false, false); // A bulk order AddHtmlLocalized(225, 25, 120, 20, 1045133, 0x7FFF); // A bulk order
AddHtmlLocalized(75, 48, 250, 20, 1045138, 0x7FFF, false, false); // Amount to make: AddHtmlLocalized(75, 48, 250, 20, 1045138, 0x7FFF); // Amount to make:
AddLabel(275, 48, 1152, deed.AmountMax.ToString()); AddLabel(275, 48, 1152, deed.AmountMax.ToString());
AddHtmlLocalized(275, 76, 200, 20, 1045153, 0x7FFF, false, false); // Amount finished: AddHtmlLocalized(275, 76, 200, 20, 1045153, 0x7FFF); // Amount finished:
AddHtmlLocalized(75, 72, 120, 20, 1045136, 0x7FFF, false, false); // Item requested: AddHtmlLocalized(75, 72, 120, 20, 1045136, 0x7FFF); // Item requested:
AddItem(410, 72, deed.Graphic); AddItem(410, 72, deed.Graphic);
AddHtmlLocalized(75, 96, 210, 20, deed.Number, 0x7FFF, false, false); AddHtmlLocalized(75, 96, 210, 20, deed.Number, 0x7FFF);
AddLabel(275, 96, 0x480, deed.AmountCur.ToString()); AddLabel(275, 96, 0x480, deed.AmountCur.ToString());
if (deed.RequireExceptional || deed.Material != BulkMaterialType.None) if (deed.RequireExceptional || deed.Material != BulkMaterialType.None)
AddHtmlLocalized(75, 120, 200, 20, 1045140, 0x7FFF, false, false); // Special requirements to meet: AddHtmlLocalized(75, 120, 200, 20, 1045140, 0x7FFF); // Special requirements to meet:
if (deed.RequireExceptional) if (deed.RequireExceptional)
AddHtmlLocalized(75, 144, 300, 20, 1045141, 0x7FFF, false, false); // All items must be exceptional. AddHtmlLocalized(75, 144, 300, 20, 1045141, 0x7FFF); // All items must be exceptional.
if (deed.Material != BulkMaterialType.None) if (deed.Material != BulkMaterialType.None)
AddHtmlLocalized(75, deed.RequireExceptional ? 168 : 144, 300, 20, GetMaterialNumberFor(deed.Material), AddHtmlLocalized(75, deed.RequireExceptional ? 168 : 144, 300, 20, GetMaterialNumberFor(deed.Material),
0x7FFF, false, false); // All items must be made with x material. 0x7FFF); // All items must be made with x material.
AddButton(125, 192, 4005, 4007, 2, GumpButtonType.Reply, 0); AddButton(125, 192, 4005, 4007, 2);
AddHtmlLocalized(160, 192, 300, 20, 1045154, 0x7FFF, false, false); // Combine this deed with the item requested. AddHtmlLocalized(160, 192, 300, 20, 1045154, 0x7FFF); // Combine this deed with the item requested.
AddButton(125, 216, 4005, 4007, 1, GumpButtonType.Reply, 0); AddButton(125, 216, 4005, 4007, 1);
AddHtmlLocalized(160, 216, 120, 20, 1011441, 0x7FFF, false, false); // EXIT AddHtmlLocalized(160, 216, 120, 20, 1011441, 0x7FFF); // EXIT
} }
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
@ -79,4 +79,4 @@ namespace Server.Engines.BulkOrders
return 0; return 0;
} }
} }
} }

View file

@ -78,10 +78,11 @@ namespace Server.Engines.BulkOrders
list.Add( new SmallBulkEntry( type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic ) ); list.Add( new SmallBulkEntry( type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic ) );
} }
} }
catch catch
{ {
} // ignored
} }
}
} }
} }

View file

@ -61,7 +61,7 @@ namespace Server.Engines.CannedEvil
if (Deleted) if (Deleted)
return; return;
if (m_Skull != null && m_Skull.Deleted) if (m_Skull?.Deleted == true)
Skull = null; Skull = null;
if (from.Map != Map || !from.InRange(GetWorldLocation(), 3)) if (from.Map != Map || !from.InRange(GetWorldLocation(), 3))
@ -88,7 +88,7 @@ namespace Server.Engines.CannedEvil
if (Deleted) if (Deleted)
return; return;
if (m_Skull != null && m_Skull.Deleted) if (m_Skull?.Deleted == true)
Skull = null; Skull = null;
if (from.Map != Map || !from.InRange(GetWorldLocation(), 3)) if (from.Map != Map || !from.InRange(GetWorldLocation(), 3))
@ -181,4 +181,4 @@ namespace Server.Engines.CannedEvil
} }
} }
} }
} }

View file

@ -86,7 +86,7 @@ namespace Server.Engines.CannedEvil
public bool Validate(ChampionSkullBrazier brazier) public bool Validate(ChampionSkullBrazier brazier)
{ {
return brazier?.Skull != null && !brazier.Skull.Deleted; return brazier?.Skull?.Deleted == false;
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)
@ -125,4 +125,4 @@ namespace Server.Engines.CannedEvil
} }
} }
} }
} }

View file

@ -348,7 +348,7 @@ namespace Server.Engines.CannedEvil
} }
else else
{ {
if (killer.Corpse != null && !killer.Corpse.Deleted) if (killer?.Corpse.Deleted == false)
killer.Corpse.DropItem(scroll); killer.Corpse.DropItem(scroll);
else else
killer.AddToBackpack(scroll); killer.AddToBackpack(scroll);
@ -421,7 +421,8 @@ namespace Server.Engines.CannedEvil
{ {
m_Altar.Hue = 0; m_Altar.Hue = 0;
if (!Core.ML || Map == Map.Felucca) new StarRoomGate(true, m_Altar.Location, m_Altar.Map); if (!Core.ML || Map == Map.Felucca)
new StarRoomGate(m_Altar.Location, m_Altar.Map, true);
} }
Champion = null; Champion = null;
@ -440,7 +441,9 @@ namespace Server.Engines.CannedEvil
if (m.Deleted) if (m.Deleted)
{ {
if (m.Corpse != null && !m.Corpse.Deleted) ((Corpse)m.Corpse).BeginDecay(TimeSpan.FromMinutes(1)); if (m.Corpse?.Deleted == false)
((Corpse)m.Corpse).BeginDecay(TimeSpan.FromMinutes(1));
m_Creatures.RemoveAt(i); m_Creatures.RemoveAt(i);
--i; --i;
++m_Kills; ++m_Kills;
@ -574,6 +577,7 @@ namespace Server.Engines.CannedEvil
} }
catch catch
{ {
// ignored
} }
Champion?.MoveToWorld(new Point3D(X, Y, Z - 15), Map); Champion?.MoveToWorld(new Point3D(X, Y, Z - 15), Map);
@ -919,7 +923,7 @@ namespace Server.Engines.CannedEvil
m_Creatures.Clear(); m_Creatures.Clear();
} }
if (Champion != null && !Champion.Player) if (Champion?.Player == false)
Champion.Delete(); Champion.Delete();
Stop(); Stop();
@ -950,7 +954,7 @@ namespace Server.Engines.CannedEvil
public void RegisterDamage(Mobile from, int amount) public void RegisterDamage(Mobile from, int amount)
{ {
if (from == null || !from.Player) if (from?.Player != true)
return; return;
m_DamageEntries[from] = amount + (m_DamageEntries.TryGetValue(from, out int value) ? value : 0); m_DamageEntries[from] = amount + (m_DamageEntries.TryGetValue(from, out int value) ? value : 0);
@ -997,7 +1001,7 @@ namespace Server.Engines.CannedEvil
Container pack = to.Backpack; Container pack = to.Backpack;
if (pack == null || !pack.TryDropItem(to, artifact, false)) if (pack?.TryDropItem(to, artifact, false) != true)
artifact.Delete(); artifact.Delete();
else else
to.SendLocalizedMessage( to.SendLocalizedMessage(
@ -1006,8 +1010,8 @@ namespace Server.Engines.CannedEvil
public bool IsEligible(Mobile m, Item Artifact) public bool IsEligible(Mobile m, Item Artifact)
{ {
return m.Player && m.Alive && m.Region != null && m.Region == m_Region && m.Backpack != null && return m.Player && m.Alive && m.Region != null && m.Region == m_Region &&
m.Backpack.CheckHold(m, Artifact, false); m.Backpack?.CheckHold(m, Artifact, false) == true;
} }
public override void Serialize(GenericWriter writer) public override void Serialize(GenericWriter writer)

View file

@ -9,19 +9,14 @@ namespace Server.Items
private Timer m_Timer; private Timer m_Timer;
[Constructible] [Constructible]
public StarRoomGate() : this(false) public StarRoomGate(Point3D loc, Map map, bool decays) : this(decays)
{
}
[Constructible]
public StarRoomGate(bool decays, Point3D loc, Map map) : this(decays)
{ {
MoveToWorld(loc, map); MoveToWorld(loc, map);
Effects.PlaySound(loc, map, 0x20E); Effects.PlaySound(loc, map, 0x20E);
} }
[Constructible] [Constructible]
public StarRoomGate(bool decays) : base(new Point3D(5143, 1774, 0), Map.Felucca) public StarRoomGate(bool decays = false) : base(new Point3D(5143, 1774, 0), Map.Felucca)
{ {
Dispellable = false; Dispellable = false;
ItemID = 0x1FD4; ItemID = 0x1FD4;
@ -101,4 +96,4 @@ namespace Server.Items
} }
} }
} }
} }

View file

@ -116,21 +116,15 @@ namespace Server.Engines.Chat
public bool ValidateAccess(ChatUser from, ChatUser target) public bool ValidateAccess(ChatUser from, ChatUser target)
{ {
if (from != null && target != null && from.Mobile.AccessLevel < target.Mobile.AccessLevel) if (from == null || target == null || from.Mobile.AccessLevel >= target.Mobile.AccessLevel)
{ return true;
from.Mobile.SendMessage("Your access level is too low to do this.");
return false; from.Mobile.SendMessage("Your access level is too low to do this.");
} return false;
return true;
} }
public bool AddUser(ChatUser user) public bool AddUser(ChatUser user, string password = null)
{
return AddUser(user, null);
}
public bool AddUser(ChatUser user, string password)
{ {
if (Contains(user)) if (Contains(user))
{ {
@ -188,12 +182,7 @@ namespace Server.Engines.Chat
} }
} }
public void AdBan(ChatUser user) public void AddBan(ChatUser user, ChatUser moderator = null)
{
AddBan(user, null);
}
public void AddBan(ChatUser user, ChatUser moderator)
{ {
if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user)) if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user))
return; return;
@ -210,12 +199,7 @@ namespace Server.Engines.Chat
m_Banned.Remove(user); m_Banned.Remove(user);
} }
public void Kick(ChatUser user) public void Kick(ChatUser user, ChatUser moderator = null)
{
Kick(user, null);
}
public void Kick(ChatUser user, ChatUser moderator)
{ {
Kick(user, moderator, false); Kick(user, moderator, false);
} }
@ -248,12 +232,7 @@ namespace Server.Engines.Chat
moderator?.SendMessage(62, user.Username); // You are banning %1 from this conference. moderator?.SendMessage(62, user.Username); // You are banning %1 from this conference.
} }
public void AddVoiced(ChatUser user) public void AddVoiced(ChatUser user, ChatUser moderator = null)
{
AddVoiced(user, null);
}
public void AddVoiced(ChatUser user, ChatUser moderator)
{ {
if (!ValidateModerator(moderator)) if (!ValidateModerator(moderator))
return; return;
@ -291,12 +270,7 @@ namespace Server.Engines.Chat
} }
} }
public void AddModerator(ChatUser user) public void AddModerator(ChatUser user, ChatUser moderator = null)
{
AddModerator(user, null);
}
public void AddModerator(ChatUser user, ChatUser moderator)
{ {
if (!ValidateModerator(moderator)) if (!ValidateModerator(moderator))
return; return;
@ -316,12 +290,7 @@ namespace Server.Engines.Chat
SendCommand(ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username); SendCommand(ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username);
} }
public void RemoveModerator(ChatUser user) public void RemoveModerator(ChatUser user, ChatUser moderator = null)
{
RemoveModerator(user, null);
}
public void RemoveModerator(ChatUser user, ChatUser moderator)
{ {
if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user)) if (!ValidateModerator(moderator) || !ValidateAccess(moderator, user))
return; return;
@ -338,32 +307,12 @@ namespace Server.Engines.Chat
} }
} }
public void SendMessage(int number) public void SendMessage(int number, string param1 = null)
{ {
SendMessage(number, null, null, null); SendMessage(number, null, param1);
} }
public void SendMessage(int number, string param1) public void SendMessage(int number, ChatUser initiator, string param1 = null, string param2 = null)
{
SendMessage(number, null, param1, null);
}
public void SendMessage(int number, string param1, string param2)
{
SendMessage(number, null, param1, param2);
}
public void SendMessage(int number, ChatUser initiator)
{
SendMessage(number, initiator, null, null);
}
public void SendMessage(int number, ChatUser initiator, string param1)
{
SendMessage(number, initiator, param1, null);
}
public void SendMessage(int number, ChatUser initiator, string param1, string param2)
{ {
for (int i = 0; i < m_Users.Count; ++i) for (int i = 0; i < m_Users.Count; ++i)
{ {
@ -395,32 +344,12 @@ namespace Server.Engines.Chat
} }
} }
public void SendCommand(ChatCommand command) public void SendCommand(ChatCommand command, string param1 = null, string param2 = null)
{
SendCommand(command, null, null, null);
}
public void SendCommand(ChatCommand command, string param1)
{
SendCommand(command, null, param1, null);
}
public void SendCommand(ChatCommand command, string param1, string param2)
{ {
SendCommand(command, null, param1, param2); SendCommand(command, null, param1, param2);
} }
public void SendCommand(ChatCommand command, ChatUser initiator) public void SendCommand(ChatCommand command, ChatUser initiator, string param1 = null, string param2 = null)
{
SendCommand(command, initiator, null, null);
}
public void SendCommand(ChatCommand command, ChatUser initiator, string param1)
{
SendCommand(command, initiator, param1, null);
}
public void SendCommand(ChatCommand command, ChatUser initiator, string param1, string param2)
{ {
for (int i = 0; i < m_Users.Count; ++i) for (int i = 0; i < m_Users.Count; ++i)
{ {
@ -457,12 +386,7 @@ namespace Server.Engines.Chat
} }
} }
public static Channel AddChannel(string name) public static Channel AddChannel(string name, string password = null)
{
return AddChannel(name, null);
}
public static Channel AddChannel(string name, string password)
{ {
Channel channel = FindChannelByName(name); Channel channel = FindChannelByName(name);
@ -521,4 +445,4 @@ namespace Server.Engines.Chat
AddChannel(name).AlwaysAvailable = true; AddChannel(name).AlwaysAvailable = true;
} }
} }
} }

View file

@ -16,17 +16,7 @@ namespace Server.Engines.Chat
PacketHandlers.Register(0xB3, 0, true, ChatAction); PacketHandlers.Register(0xB3, 0, true, ChatAction);
} }
public static void SendCommandTo(Mobile to, ChatCommand type) public static void SendCommandTo(Mobile to, ChatCommand type, string param1 = null, string param2 = null)
{
SendCommandTo(to, type, null, null);
}
public static void SendCommandTo(Mobile to, ChatCommand type, string param1)
{
SendCommandTo(to, type, param1, null);
}
public static void SendCommandTo(Mobile to, ChatCommand type, string param1, string param2)
{ {
to?.Send(new ChatMessagePacket(null, (int)type + 20, param1, param2)); to?.Send(new ChatMessagePacket(null, (int)type + 20, param1, param2));
} }

View file

@ -180,7 +180,7 @@ namespace Server.Engines.Chat
password = password?.Trim(); password = password?.Trim();
if (password != null && password.Length == 0) if (password?.Length == 0)
password = null; password = null;
Channel joined = Channel.FindChannelByName(name); Channel joined = Channel.FindChannelByName(name);
@ -217,7 +217,7 @@ namespace Server.Engines.Chat
password = password?.Trim(); password = password?.Trim();
if (password != null && password.Length == 0) if (password?.Length == 0)
password = null; password = null;
Channel.AddChannel(name, password).AddUser(from, password); Channel.AddChannel(name, password).AddUser(from, password);
@ -355,4 +355,4 @@ namespace Server.Engines.Chat
channel.VoiceRestricted = !channel.VoiceRestricted; channel.VoiceRestricted = !channel.VoiceRestricted;
} }
} }
} }

View file

@ -49,17 +49,12 @@ namespace Server.Engines.Chat
public bool IgnorePrivateMessage{ get; set; } public bool IgnorePrivateMessage{ get; set; }
public bool IsModerator => CurrentChannel != null && CurrentChannel.IsModerator(this); public bool IsModerator => CurrentChannel?.IsModerator(this) == true;
public char GetColorCharacter() public char GetColorCharacter()
{ {
if (CurrentChannel != null && CurrentChannel.IsModerator(this)) return IsModerator ? ModeratorColorCharacter :
return ModeratorColorCharacter; CurrentChannel?.IsVoiced(this) == true ? VoicedColorCharacter : NormalColorCharacter;
if (CurrentChannel != null && CurrentChannel.IsVoiced(this))
return VoicedColorCharacter;
return NormalColorCharacter;
} }
public bool CheckOnline() public bool CheckOnline()
@ -71,17 +66,7 @@ namespace Server.Engines.Chat
return false; return false;
} }
public void SendMessage(int number) public void SendMessage(int number, string param1 = null, string param2 = null)
{
SendMessage(number, null, null);
}
public void SendMessage(int number, string param1)
{
SendMessage(number, param1, null);
}
public void SendMessage(int number, string param1, string param2)
{ {
if (Mobile.NetState != null) if (Mobile.NetState != null)
Mobile.Send(new ChatMessagePacket(Mobile, number, param1, param2)); Mobile.Send(new ChatMessagePacket(Mobile, number, param1, param2));
@ -135,28 +120,28 @@ namespace Server.Engines.Chat
{ {
ChatUser user = GetChatUser(from); ChatUser user = GetChatUser(from);
if (user == null) if (user != null)
return user;
user = new ChatUser(from);
m_Users.Add(user);
m_Table[from] = user;
Channel.SendChannelsTo(user);
List<Channel> list = Channel.Channels;
for (int i = 0; i < list.Count; ++i)
{ {
user = new ChatUser(from); Channel c = list[i];
m_Users.Add(user); if (c.AddUser(user))
m_Table[from] = user; break;
Channel.SendChannelsTo(user);
List<Channel> list = Channel.Channels;
for (int i = 0; i < list.Count; ++i)
{
Channel c = list[i];
if (c.AddUser(user))
break;
}
//ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
} }
//ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
return user; return user;
} }
@ -205,32 +190,12 @@ namespace Server.Engines.Chat
return null; return null;
} }
public static void GlobalSendCommand(ChatCommand command) public static void GlobalSendCommand(ChatCommand command, string param1, string param2 = null)
{
GlobalSendCommand(command, null, null, null);
}
public static void GlobalSendCommand(ChatCommand command, string param1)
{
GlobalSendCommand(command, null, param1, null);
}
public static void GlobalSendCommand(ChatCommand command, string param1, string param2)
{ {
GlobalSendCommand(command, null, param1, param2); GlobalSendCommand(command, null, param1, param2);
} }
public static void GlobalSendCommand(ChatCommand command, ChatUser initiator) public static void GlobalSendCommand(ChatCommand command, ChatUser initiator = null, string param1 = null, string param2 = null)
{
GlobalSendCommand(command, initiator, null, null);
}
public static void GlobalSendCommand(ChatCommand command, ChatUser initiator, string param1)
{
GlobalSendCommand(command, initiator, param1, null);
}
public static void GlobalSendCommand(ChatCommand command, ChatUser initiator, string param1, string param2)
{ {
for (int i = 0; i < m_Users.Count; ++i) for (int i = 0; i < m_Users.Count; ++i)
{ {
@ -244,4 +209,4 @@ namespace Server.Engines.Chat
} }
} }
} }
} }

View file

@ -44,11 +44,11 @@ namespace Server.Engines.ConPVP
AddImage(215, -43, 0xEE40); AddImage(215, -43, 0xEE40);
//AddImage( 330, 141, 0x8BA ); //AddImage( 330, 141, 0x8BA );
AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32), false, false); AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32));
AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32), false, false); AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32));
AddHtml(22, 22 - 1, 294, 20, Color(Center("Duel Challenge"), BlackColor32), false, false); AddHtml(22, 22 - 1, 294, 20, Color(Center("Duel Challenge"), BlackColor32));
AddHtml(22, 22 + 1, 294, 20, Color(Center("Duel Challenge"), BlackColor32), false, false); AddHtml(22, 22 + 1, 294, 20, Color(Center("Duel Challenge"), BlackColor32));
AddHtml(22, 22, 294, 20, Color(Center("Duel Challenge"), LabelColor32), false, false); AddHtml(22, 22, 294, 20, Color(Center("Duel Challenge"), LabelColor32));
string fmt; string fmt;
@ -57,37 +57,37 @@ namespace Server.Engines.ConPVP
else else
fmt = "You have been challenged to a duel from {0}. Do you accept?"; fmt = "You have been challenged to a duel from {0}. Do you accept?";
AddHtml(22 - 1, 50, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32), false, false); AddHtml(22 - 1, 50, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32));
AddHtml(22 + 1, 50, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32), false, false); AddHtml(22 + 1, 50, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32));
AddHtml(22, 50 - 1, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32), false, false); AddHtml(22, 50 - 1, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32));
AddHtml(22, 50 + 1, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32), false, false); AddHtml(22, 50 + 1, 294, 40, Color(string.Format(fmt, challenger.Name), BlackColor32));
AddHtml(22, 50, 294, 40, Color(string.Format(fmt, challenger.Name), 0xB0C868), false, false); AddHtml(22, 50, 294, 40, Color(string.Format(fmt, challenger.Name), 0xB0C868));
AddImageTiled(32, 88, 264, 1, 9107); AddImageTiled(32, 88, 264, 1, 9107);
AddImageTiled(42, 90, 264, 1, 9157); AddImageTiled(42, 90, 264, 1, 9157);
AddRadio(24, 100, 9727, 9730, true, 1); AddRadio(24, 100, 9727, 9730, true, 1);
AddHtml(60 - 1, 105, 250, 20, Color("Yes, I will fight this duel.", BlackColor32), false, false); AddHtml(60 - 1, 105, 250, 20, Color("Yes, I will fight this duel.", BlackColor32));
AddHtml(60 + 1, 105, 250, 20, Color("Yes, I will fight this duel.", BlackColor32), false, false); AddHtml(60 + 1, 105, 250, 20, Color("Yes, I will fight this duel.", BlackColor32));
AddHtml(60, 105 - 1, 250, 20, Color("Yes, I will fight this duel.", BlackColor32), false, false); AddHtml(60, 105 - 1, 250, 20, Color("Yes, I will fight this duel.", BlackColor32));
AddHtml(60, 105 + 1, 250, 20, Color("Yes, I will fight this duel.", BlackColor32), false, false); AddHtml(60, 105 + 1, 250, 20, Color("Yes, I will fight this duel.", BlackColor32));
AddHtml(60, 105, 250, 20, Color("Yes, I will fight this duel.", LabelColor32), false, false); AddHtml(60, 105, 250, 20, Color("Yes, I will fight this duel.", LabelColor32));
AddRadio(24, 135, 9727, 9730, false, 2); AddRadio(24, 135, 9727, 9730, false, 2);
AddHtml(60 - 1, 140, 250, 20, Color("No, I do not wish to fight.", BlackColor32), false, false); AddHtml(60 - 1, 140, 250, 20, Color("No, I do not wish to fight.", BlackColor32));
AddHtml(60 + 1, 140, 250, 20, Color("No, I do not wish to fight.", BlackColor32), false, false); AddHtml(60 + 1, 140, 250, 20, Color("No, I do not wish to fight.", BlackColor32));
AddHtml(60, 140 - 1, 250, 20, Color("No, I do not wish to fight.", BlackColor32), false, false); AddHtml(60, 140 - 1, 250, 20, Color("No, I do not wish to fight.", BlackColor32));
AddHtml(60, 140 + 1, 250, 20, Color("No, I do not wish to fight.", BlackColor32), false, false); AddHtml(60, 140 + 1, 250, 20, Color("No, I do not wish to fight.", BlackColor32));
AddHtml(60, 140, 250, 20, Color("No, I do not wish to fight.", LabelColor32), false, false); AddHtml(60, 140, 250, 20, Color("No, I do not wish to fight.", LabelColor32));
AddRadio(24, 170, 9727, 9730, false, 3); AddRadio(24, 170, 9727, 9730, false, 3);
AddHtml(60 - 1, 175, 250, 20, Color("No, knave. Do not ask again.", BlackColor32), false, false); AddHtml(60 - 1, 175, 250, 20, Color("No, knave. Do not ask again.", BlackColor32));
AddHtml(60 + 1, 175, 250, 20, Color("No, knave. Do not ask again.", BlackColor32), false, false); AddHtml(60 + 1, 175, 250, 20, Color("No, knave. Do not ask again.", BlackColor32));
AddHtml(60, 175 - 1, 250, 20, Color("No, knave. Do not ask again.", BlackColor32), false, false); AddHtml(60, 175 - 1, 250, 20, Color("No, knave. Do not ask again.", BlackColor32));
AddHtml(60, 175 + 1, 250, 20, Color("No, knave. Do not ask again.", BlackColor32), false, false); AddHtml(60, 175 + 1, 250, 20, Color("No, knave. Do not ask again.", BlackColor32));
AddHtml(60, 175, 250, 20, Color("No, knave. Do not ask again.", LabelColor32), false, false); AddHtml(60, 175, 250, 20, Color("No, knave. Do not ask again.", LabelColor32));
AddButton(314, 173, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(314, 173, 247, 248, 1);
Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject); Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject);
} }

View file

@ -86,13 +86,9 @@ namespace Server.Engines.ConPVP
[PropertyObject] [PropertyObject]
public class ArenaStartPoints public class ArenaStartPoints
{ {
public ArenaStartPoints() : this(new Point3D[8]) public ArenaStartPoints(Point3D[] points = null)
{ {
} Points = points ?? new Point3D[8];
public ArenaStartPoints(Point3D[] points)
{
Points = points;
} }
public ArenaStartPoints(GenericReader reader) public ArenaStartPoints(GenericReader reader)
@ -407,7 +403,8 @@ namespace Server.Engines.ConPVP
set set
{ {
m_GateOut = value; m_GateOut = value;
if (Teleporter != null) Teleporter.Location = m_GateOut; if (Teleporter != null)
Teleporter.Location = m_GateOut;
} }
} }
@ -664,7 +661,7 @@ namespace Server.Engines.ConPVP
{ {
ArenaController controller = allControllers[i]; ArenaController controller = allControllers[i];
if (controller != null && !controller.Deleted && controller.Arena != null && controller.IsPrivate && if (controller?.Deleted == false && controller.Arena != null && controller.IsPrivate &&
controller.Map == first.Map && first.InRange(controller, 24)) controller.Map == first.Map && first.InRange(controller, 24))
{ {
BaseHouse house = BaseHouse.FindHouseAt(controller); BaseHouse house = BaseHouse.FindHouseAt(controller);
@ -832,4 +829,4 @@ namespace Server.Engines.ConPVP
#endregion #endregion
} }
} }

View file

@ -48,11 +48,7 @@ namespace Server.Engines.ConPVP
private bool m_Yielding; private bool m_Yielding;
public DuelContext(Mobile initiator, RulesetLayout layout) : this(initiator, layout, true) public DuelContext(Mobile initiator, RulesetLayout layout, bool addNew = true)
{
}
public DuelContext(Mobile initiator, RulesetLayout layout, bool addNew)
{ {
Initiator = initiator; Initiator = initiator;
Participants = new List<Participant>(); Participants = new List<Participant>();
@ -123,13 +119,8 @@ namespace Server.Engines.ConPVP
public static bool AllowSpecialMove(Mobile from, string name, SpecialMove move) public static bool AllowSpecialMove(Mobile from, string name, SpecialMove move)
{ {
if (!(from is PlayerMobile pm))
return true;
DuelContext dc = pm.DuelContext;
// No DuelContext, or InstaAllowSpecialMove // No DuelContext, or InstaAllowSpecialMove
return dc?.InstAllowSpecialMove(from, name, move) != false; return (from as PlayerMobile)?.DuelContext?.InstAllowSpecialMove(from, name, move) != false;
} }
public bool InstAllowSpecialMove(Mobile from, string name, SpecialMove move) public bool InstAllowSpecialMove(Mobile from, string name, SpecialMove move)
@ -139,7 +130,7 @@ namespace Server.Engines.ConPVP
DuelPlayer pl = Find(from); DuelPlayer pl = Find(from);
if (pl == null || pl.Eliminated) if (pl?.Eliminated != false)
return true; return true;
if (CantDoAnything(from)) if (CantDoAnything(from))
@ -165,9 +156,7 @@ namespace Server.Engines.ConPVP
if (!StartedBeginCountdown) if (!StartedBeginCountdown)
return true; return true;
DuelPlayer pl = Find(from); if (Find(from)?.Eliminated != false)
if (pl?.Eliminated != false)
return true; return true;
if (CantDoAnything(from)) if (CantDoAnything(from))
@ -256,7 +245,7 @@ namespace Server.Engines.ConPVP
DuelPlayer pl = Find(from); DuelPlayer pl = Find(from);
if (pl == null || pl.Eliminated) if (pl?.Eliminated != false)
return true; return true;
if (item is Dagger || CheckItemEquip(from, item)) if (item is Dagger || CheckItemEquip(from, item))
@ -350,7 +339,7 @@ namespace Server.Engines.ConPVP
DuelPlayer pl = Find(from); DuelPlayer pl = Find(from);
if (pl == null || pl.Eliminated) if (pl?.Eliminated != false)
return true; return true;
if (CantDoAnything(from)) if (CantDoAnything(from))
@ -373,7 +362,7 @@ namespace Server.Engines.ConPVP
DuelPlayer pl = Find(from); DuelPlayer pl = Find(from);
if (pl == null || pl.Eliminated) if (pl?.Eliminated != false)
return true; return true;
if (!(item is BaseRefreshPotion)) if (!(item is BaseRefreshPotion))
@ -507,7 +496,7 @@ namespace Server.Engines.ConPVP
DuelPlayer pl = Find(mob); DuelPlayer pl = Find(mob);
if (pl == null || pl.Eliminated) if (pl?.Eliminated != false)
return; return;
if (mob.Map == Map.Internal) if (mob.Map == Map.Internal)
@ -533,30 +522,27 @@ namespace Server.Engines.ConPVP
DuelPlayer pl = Find(mob); DuelPlayer pl = Find(mob);
if (pl != null && !pl.Eliminated) if (pl?.Eliminated == true || m_EventGame != null && !m_EventGame.OnDeath(mob, corpse))
return;
pl.Eliminated = true;
if (mob.Poison != null)
mob.Poison = null;
Requip(mob, corpse);
DelayBounce(TimeSpan.FromSeconds(4.0), mob, corpse);
Participant winner = CheckCompletion();
if (winner != null)
{ {
if (m_EventGame != null && !m_EventGame.OnDeath(mob, corpse)) Finish(winner);
return; }
else if (!m_Yielding)
pl.Eliminated = true; {
mob.LocalOverheadMessage(MessageType.Regular, 0x22, false, "You have been defeated.");
if (mob.Poison != null) mob.NonlocalOverheadMessage(MessageType.Regular, 0x22, false, $"{mob.Name} has been defeated.");
mob.Poison = null;
Requip(mob, corpse);
DelayBounce(TimeSpan.FromSeconds(4.0), mob, corpse);
Participant winner = CheckCompletion();
if (winner != null)
{
Finish(winner);
}
else if (!m_Yielding)
{
mob.LocalOverheadMessage(MessageType.Regular, 0x22, false, "You have been defeated.");
mob.NonlocalOverheadMessage(MessageType.Regular, 0x22, false, $"{mob.Name} has been defeated.");
}
} }
} }
@ -564,7 +550,7 @@ namespace Server.Engines.ConPVP
{ {
for (int i = 0; i < Participants.Count; ++i) for (int i = 0; i < Participants.Count; ++i)
{ {
Participant p = (Participant)Participants[i]; Participant p = Participants[i];
if (p.HasOpenSlot) if (p.HasOpenSlot)
return false; return false;
@ -609,7 +595,7 @@ namespace Server.Engines.ConPVP
Mobile killer = from.FindMostRecentDamager(false); Mobile killer = from.FindMostRecentDamager(false);
if (killer != null && killer.Player) if (killer?.Player == true)
killer.AddToBackpack(new Head(m_Tournament == null ? HeadType.Duel : HeadType.Tournament, from.Name)); killer.AddToBackpack(new Head(m_Tournament == null ? HeadType.Duel : HeadType.Tournament, from.Name));
} }
@ -671,7 +657,7 @@ namespace Server.Engines.ConPVP
{ {
DuelPlayer pl = winner.Players[i]; DuelPlayer pl = winner.Players[i];
if (pl != null && !pl.Eliminated) if (pl?.Eliminated == false)
DelayBounce(TimeSpan.FromSeconds(8.0), pl.Mobile, null); DelayBounce(TimeSpan.FromSeconds(8.0), pl.Mobile, null);
} }
@ -688,7 +674,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < Participants.Count; ++i) for (int i = 0; i < Participants.Count; ++i)
{ {
Participant loser = (Participant)Participants[i]; Participant loser = Participants[i];
if (loser != winner) if (loser != winner)
{ {
@ -714,8 +700,8 @@ namespace Server.Engines.ConPVP
if (IsOneVsOne) if (IsOneVsOne)
{ {
DuelPlayer dp1 = ((Participant)Participants[0]).Players[0]; DuelPlayer dp1 = Participants[0].Players[0];
DuelPlayer dp2 = ((Participant)Participants[1]).Players[0]; DuelPlayer dp2 = Participants[1].Players[0];
if (dp1 != null && dp2 != null) if (dp1 != null && dp2 != null)
{ {
@ -797,7 +783,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < Participants.Count; ++i) for (int i = 0; i < Participants.Count; ++i)
{ {
Participant p = (Participant)Participants[i]; Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j) for (int j = 0; j < p.Players.Length; ++j)
{ {
@ -828,7 +814,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < Participants.Count; ++i) for (int i = 0; i < Participants.Count; ++i)
{ {
Participant oldPart = (Participant)Participants[i]; Participant oldPart = Participants[i];
Participant newPart = new Participant(dc, oldPart.Players.Length); Participant newPart = new Participant(dc, oldPart.Players.Length);
for (int j = 0; j < oldPart.Players.Length; ++j) for (int j = 0; j < oldPart.Players.Length; ++j)
@ -858,7 +844,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < Participants.Count; ++i) for (int i = 0; i < Participants.Count; ++i)
{ {
Participant p = (Participant)Participants[i]; Participant p = Participants[i];
DuelPlayer pl = p.Find(mob); DuelPlayer pl = p.Find(mob);
if (pl != null) if (pl != null)
@ -873,7 +859,7 @@ namespace Server.Engines.ConPVP
DuelPlayer pl1 = Find(m1); DuelPlayer pl1 = Find(m1);
DuelPlayer pl2 = Find(m2); DuelPlayer pl2 = Find(m2);
return pl1 != null && pl2 != null && pl1.Participant == pl2.Participant; return pl1 != null && pl1.Participant == pl2?.Participant;
} }
public Participant CheckCompletion() public Participant CheckCompletion()
@ -885,7 +871,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < Participants.Count; ++i) for (int i = 0; i < Participants.Count; ++i)
{ {
Participant p = (Participant)Participants[i]; Participant p = Participants[i];
if (p.Eliminated) if (p.Eliminated)
{ {
@ -900,10 +886,7 @@ namespace Server.Engines.ConPVP
} }
} }
if (hasWinner) return hasWinner ? winner ?? Participants[0] : null;
return winner ?? (Participant)Participants[0];
return null;
} }
public void StartCountdown(int count, CountdownCallback cb) public void StartCountdown(int count, CountdownCallback cb)
@ -953,13 +936,13 @@ namespace Server.Engines.ConPVP
{ {
for (int i = 0; i < Participants.Count; ++i) for (int i = 0; i < Participants.Count; ++i)
{ {
Participant p = (Participant)Participants[i]; Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j) for (int j = 0; j < p.Players.Length; ++j)
{ {
DuelPlayer pl = p.Players[j]; DuelPlayer pl = p.Players[j];
if (pl == null || pl.Eliminated) if (pl?.Eliminated != false)
continue; continue;
pl.Mobile.SendSound(0x1E1); pl.Mobile.SendSound(0x1E1);
@ -984,13 +967,13 @@ namespace Server.Engines.ConPVP
{ {
for (int i = 0; i < Participants.Count; ++i) for (int i = 0; i < Participants.Count; ++i)
{ {
Participant p = (Participant)Participants[i]; Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j) for (int j = 0; j < p.Players.Length; ++j)
{ {
DuelPlayer pl = p.Players[j]; DuelPlayer pl = p.Players[j];
if (pl == null || pl.Eliminated) if (pl?.Eliminated != false)
continue; continue;
pl.Mobile.SendSound(0x1E1); pl.Mobile.SendSound(0x1E1);
@ -1065,7 +1048,7 @@ namespace Server.Engines.ConPVP
{ {
DuelPlayer pl = p.Players[j]; DuelPlayer pl = p.Players[j];
if (pl != null && !pl.Eliminated) if (pl?.Eliminated == false)
DelayBounce(TimeSpan.FromSeconds(8.0), pl.Mobile, null); DelayBounce(TimeSpan.FromSeconds(8.0), pl.Mobile, null);
} }
@ -1511,7 +1494,7 @@ namespace Server.Engines.ConPVP
} }
} }
} }
public void CloseAllGumps(DuelPlayer pl) public void CloseAllGumps(DuelPlayer pl)
{ {
pl.Mobile.CloseGump<BeginGump>(); pl.Mobile.CloseGump<BeginGump>();
@ -1527,7 +1510,7 @@ namespace Server.Engines.ConPVP
{ {
for (int i = 0; i < Participants.Count; ++i) for (int i = 0; i < Participants.Count; ++i)
{ {
Participant p = (Participant)Participants[i]; Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j) for (int j = 0; j < p.Players.Length; ++j)
{ {
@ -1546,7 +1529,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < Participants.Count; ++i) for (int i = 0; i < Participants.Count; ++i)
{ {
Participant p = (Participant)Participants[i]; Participant p = Participants[i];
for (int j = 0; j < p.Players.Length; ++j) for (int j = 0; j < p.Players.Length; ++j)
{ {
@ -1571,7 +1554,7 @@ namespace Server.Engines.ConPVP
else else
mob.SendMessage(0x22, "{0} has rejected the {1}.", rejector.Name, Rematch ? "rematch" : page); mob.SendMessage(0x22, "{0} has rejected the {1}.", rejector.Name, Rematch ? "rematch" : page);
} }
// Close all of them? // Close all of them?
mob.CloseGump<DuelContextGump>(); mob.CloseGump<DuelContextGump>();
mob.CloseGump<ReadyUpGump>(); mob.CloseGump<ReadyUpGump>();
@ -1851,9 +1834,9 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < ruleset.Flavors.Count; ++i) for (int i = 0; i < ruleset.Flavors.Count; ++i)
{ {
defs.Or(((Ruleset)ruleset.Flavors[i]).Options); defs.Or(ruleset.Flavors[i].Options);
mob.SendMessage(" + {0}", ((Ruleset)ruleset.Flavors[i]).Title); mob.SendMessage(" + {0}", ruleset.Flavors[i].Title);
} }
} }
else else
@ -2084,10 +2067,7 @@ namespace Server.Engines.ConPVP
} }
} }
Arena arena = m_OverrideArena; Arena arena = m_OverrideArena ?? Arena.FindArena(players);
if (arena == null)
arena = Arena.FindArena(players);
if (arena == null) if (arena == null)
{ {
@ -2482,7 +2462,7 @@ namespace Server.Engines.ConPVP
} }
else else
{ {
if (m_Teleporter != null && !m_Teleporter.Deleted) if (m_Teleporter?.Deleted == false)
m_Teleporter.Register(m); m_Teleporter.Register(m);
base.UseGate(m); base.UseGate(m);
@ -2512,4 +2492,4 @@ namespace Server.Engines.ConPVP
} }
} }
} }
} }

View file

@ -15,12 +15,7 @@ namespace Server.Engines.ConPVP
public class DuelTeleporterAddon : BaseAddon public class DuelTeleporterAddon : BaseAddon
{ {
[Constructible] [Constructible]
public DuelTeleporterAddon() : this(DuelTeleporterType.Squares) public DuelTeleporterAddon(DuelTeleporterType type = DuelTeleporterType.Squares)
{
}
[Constructible]
public DuelTeleporterAddon(DuelTeleporterType type)
{ {
int itemID = (int)type; int itemID = (int)type;
@ -91,4 +86,4 @@ namespace Server.Engines.ConPVP
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -49,7 +49,7 @@ namespace Server.Engines.ConPVP
public DuelContext Context{ get; set; } public DuelContext Context{ get; set; }
public bool InProgress => Context != null && Context.Registered; public bool InProgress => Context?.Registered == true;
public void Start(Arena arena, Tournament tourney) public void Start(Arena arena, Tournament tourney)
{ {
@ -120,4 +120,4 @@ namespace Server.Engines.ConPVP
} }
} }
} }
} }

View file

@ -47,7 +47,7 @@ namespace Server.Engines.ConPVP
defs = new BitArray(basedef.Options); defs = new BitArray(basedef.Options);
for (int i = 0; i < ruleset.Flavors.Count; ++i) for (int i = 0; i < ruleset.Flavors.Count; ++i)
defs.Or(((Ruleset)ruleset.Flavors[i]).Options); defs.Or(ruleset.Flavors[i].Options);
height += ruleset.Flavors.Count * 18; height += ruleset.Flavors.Count * 18;
} }
@ -194,7 +194,7 @@ namespace Server.Engines.ConPVP
y += 20; y += 20;
for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18) for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
AddBorderedText(35, y, 190, 20, $" + {((Ruleset)ruleset.Flavors[i]).Title}", LabelColor32, BlackColor32); AddBorderedText(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}", LabelColor32, BlackColor32);
y += 4; y += 4;
@ -243,7 +243,7 @@ namespace Server.Engines.ConPVP
y += 35; y += 35;
y -= 3; y -= 3;
AddButton(314, y, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(314, y, 247, 248, 1);
Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject); Timer.DelayCall(TimeSpan.FromSeconds(15.0), AutoReject);
} }
@ -270,9 +270,9 @@ namespace Server.Engines.ConPVP
private void AddColoredText(int x, int y, int width, int height, string text, int color) private void AddColoredText(int x, int y, int width, int height, string text, int color)
{ {
if (color == 0) if (color == 0)
AddHtml(x, y, width, height, text, false, false); AddHtml(x, y, width, height, text);
else else
AddHtml(x, y, width, height, Color(text, color), false, false); AddHtml(x, y, width, height, Color(text, color));
} }
public void AutoReject() public void AutoReject()
@ -379,4 +379,4 @@ namespace Server.Engines.ConPVP
} }
} }
} }
} }

View file

@ -105,18 +105,13 @@ namespace Server.Engines.ConPVP
AddColumnHeader(325, "Participants"); AddColumnHeader(325, "Participants");
AddColumnHeader(40, "Obs"); AddColumnHeader(40, "Obs");
AddButton(499 + 40 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(499 + 40 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1);
AddButton(499 + 40 - 12 - 63, height - 12 - 24, 241, 242, 2, GumpButtonType.Reply, 0); AddButton(499 + 40 - 12 - 63, height - 12 - 24, 241, 242, 2);
for (int i = 0; i < list.Count; ++i) for (int i = 0; i < list.Count; ++i)
{ {
Arena ar = list[i]; Arena ar = list[i];
string name = ar.Name;
if (name == null)
name = "(no name)";
int x = 12; int x = 12;
int y = 32 + i * 31; int y = 32 + i * 31;
@ -125,7 +120,7 @@ namespace Server.Engines.ConPVP
AddRadio(x + 3, y + 1, 9727, 9730, false, i); AddRadio(x + 3, y + 1, 9727, 9730, false, i);
x += 35; x += 35;
AddBorderedText(x + 5, y + 5, 115 - 5, name, color, 0); AddBorderedText(x + 5, y + 5, 115 - 5, ar.Name ?? "(no name)", color, 0);
x += 115; x += 115;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -271,9 +266,9 @@ namespace Server.Engines.ConPVP
private void AddColoredText(int x, int y, int width, string text, int color) private void AddColoredText(int x, int y, int width, string text, int color)
{ {
if (color == 0) if (color == 0)
AddHtml(x, y, width, 20, text, false, false); AddHtml(x, y, width, 20, text);
else else
AddHtml(x, y, width, 20, Color(text, color), false, false); AddHtml(x, y, width, 20, Color(text, color));
} }
private void AddColumnHeader(int width, string name) private void AddColumnHeader(int width, string name)
@ -287,4 +282,4 @@ namespace Server.Engines.ConPVP
m_ColumnX += width; m_ColumnX += width;
} }
} }
} }

View file

@ -20,32 +20,32 @@ namespace Server.Engines.ConPVP
AddImage(215, -43, 0xEE40); AddImage(215, -43, 0xEE40);
AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Countdown"), BlackColor32), false, false); AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Countdown"), BlackColor32));
AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Countdown"), BlackColor32), false, false); AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Countdown"), BlackColor32));
AddHtml(22, 22 - 1, 294, 20, Color(Center("Duel Countdown"), BlackColor32), false, false); AddHtml(22, 22 - 1, 294, 20, Color(Center("Duel Countdown"), BlackColor32));
AddHtml(22, 22 + 1, 294, 20, Color(Center("Duel Countdown"), BlackColor32), false, false); AddHtml(22, 22 + 1, 294, 20, Color(Center("Duel Countdown"), BlackColor32));
AddHtml(22, 22, 294, 20, Color(Center("Duel Countdown"), LabelColor32), false, false); AddHtml(22, 22, 294, 20, Color(Center("Duel Countdown"), LabelColor32));
AddHtml(22 - 1, 50, 294, 80, AddHtml(22 - 1, 50, 294, 80,
Color( Color(
"The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.",
BlackColor32), false, false); BlackColor32));
AddHtml(22 + 1, 50, 294, 80, AddHtml(22 + 1, 50, 294, 80,
Color( Color(
"The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.",
BlackColor32), false, false); BlackColor32));
AddHtml(22, 50 - 1, 294, 80, AddHtml(22, 50 - 1, 294, 80,
Color( Color(
"The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.",
BlackColor32), false, false); BlackColor32));
AddHtml(22, 50 + 1, 294, 80, AddHtml(22, 50 + 1, 294, 80,
Color( Color(
"The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.",
BlackColor32), false, false); BlackColor32));
AddHtml(22, 50, 294, 80, AddHtml(22, 50, 294, 80,
Color( Color(
"The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.", "The arranged duel is about to begin. During this countdown period you may not cast spells and you may not move. This message will close automatically when the period ends.",
0xFFCC66), false, false); 0xFFCC66));
/*AddImageTiled( 32, 128, 264, 1, 9107 ); /*AddImageTiled( 32, 128, 264, 1, 9107 );
AddImageTiled( 42, 130, 264, 1, 9157 ); AddImageTiled( 42, 130, 264, 1, 9157 );
@ -56,7 +56,7 @@ namespace Server.Engines.ConPVP
AddHtml( 60, 140+1, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#{2:X6}>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", BlackColor32 ), BlackColor32 ), false, false ); AddHtml( 60, 140+1, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#{2:X6}>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", BlackColor32 ), BlackColor32 ), false, false );
AddHtml( 60, 140, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#FF6666>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", 0x66AACC ), 0x66AACC ), false, false );*/ AddHtml( 60, 140, 250, 20, Color( String.Format( "Duel will begin in <BASEFONT COLOR=#FF6666>{0} <BASEFONT COLOR=#{2:X6}>second{1}.", count, count==1?"":"s", 0x66AACC ), 0x66AACC ), false, false );*/
AddButton(314 - 50, 157 - offset, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(314 - 50, 157 - offset, 247, 248, 1);
} }
public string Center(string text) public string Center(string text)
@ -69,4 +69,4 @@ namespace Server.Engines.ConPVP
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>"; return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
} }
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -26,7 +26,7 @@ namespace Server.Engines.ConPVP
AddBackground(0, 0, 300, height, 9250); AddBackground(0, 0, 300, height, 9250);
AddBackground(10, 10, 280, height - 20, 0xDAC); AddBackground(10, 10, 280, height - 20, 0xDAC);
AddHtml(35, 25, 230, 20, Center("Duel Setup"), false, false); AddHtml(35, 25, 230, 20, Center("Duel Setup"));
int x = 35; int x = 35;
int y = 47; int y = 47;
@ -38,12 +38,12 @@ namespace Server.Engines.ConPVP
AddGoldenButtonLabeled(x, y, 3, "Add Participant"); AddGoldenButtonLabeled(x, y, 3, "Add Participant");
y += 30; y += 30;
AddHtml(35, y, 230, 20, Center("Participants"), false, false); AddHtml(35, y, 230, 20, Center("Participants"));
y += 22; y += 22;
for (int i = 0; i < context.Participants.Count; ++i) for (int i = 0; i < context.Participants.Count; ++i)
{ {
Participant p = (Participant)context.Participants[i]; Participant p = context.Participants[i];
AddGoldenButtonLabeled(x, y, 4 + i, AddGoldenButtonLabeled(x, y, 4 + i,
string.Format(p.Count == 1 ? "Player {0}: {3}" : "Team {0}: {1}/{2}: {3}", 1 + i, p.FilledSlots, p.Count, string.Format(p.Count == 1 ? "Player {0}: {3}" : "Team {0}: {1}/{2}: {3}", 1 + i, p.FilledSlots, p.Count,
@ -63,14 +63,14 @@ namespace Server.Engines.ConPVP
public void AddGoldenButton(int x, int y, int bid) public void AddGoldenButton(int x, int y, int bid)
{ {
AddButton(x, y, 0xD2, 0xD2, bid, GumpButtonType.Reply, 0); AddButton(x, y, 0xD2, 0xD2, bid);
AddButton(x + 3, y + 3, 0xD8, 0xD8, bid, GumpButtonType.Reply, 0); AddButton(x + 3, y + 3, 0xD8, 0xD8, bid);
} }
public void AddGoldenButtonLabeled(int x, int y, int bid, string text) public void AddGoldenButtonLabeled(int x, int y, int bid, string text)
{ {
AddGoldenButton(x, y, bid); AddGoldenButton(x, y, bid);
AddHtml(x + 25, y, 200, 20, text, false, false); AddHtml(x + 25, y, 200, 20, text);
} }
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
@ -129,11 +129,11 @@ namespace Server.Engines.ConPVP
index -= 4; index -= 4;
if (index >= 0 && index < Context.Participants.Count) if (index >= 0 && index < Context.Participants.Count)
From.SendGump(new ParticipantGump(From, Context, (Participant)Context.Participants[index])); From.SendGump(new ParticipantGump(From, Context, Context.Participants[index]));
break; break;
} }
} }
} }
} }
} }

View file

@ -103,18 +103,18 @@ namespace Server.Engines.ConPVP
AddAlphaRegion(10, 10, 479, height - 20); AddAlphaRegion(10, 10, 479, height - 20);
if (page > 0) if (page > 0)
AddButton(446, height - 12 - 2 - 16, 0x15E3, 0x15E7, 1, GumpButtonType.Reply, 0); AddButton(446, height - 12 - 2 - 16, 0x15E3, 0x15E7, 1);
else else
AddImage(446, height - 12 - 2 - 16, 0x2626); AddImage(446, height - 12 - 2 - 16, 0x2626);
if ((page + 1) * 15 < lc) if ((page + 1) * 15 < lc)
AddButton(466, height - 12 - 2 - 16, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0); AddButton(466, height - 12 - 2 - 16, 0x15E1, 0x15E5, 2);
else else
AddImage(466, height - 12 - 2 - 16, 0x2622); AddImage(466, height - 12 - 2 - 16, 0x2622);
AddHtml(16, height - 12 - 2 - 18, 400, 20, AddHtml(16, height - 12 - 2 - 18, 400, 20,
Color(string.Format("Top {3} of {0:N0} duelists, page {1} of {2}", m_List.Count, page + 1, (lc + 14) / 15, lc), Color(string.Format("Top {3} of {0:N0} duelists, page {1} of {2}", m_List.Count, page + 1, (lc + 14) / 15, lc),
0xFFC000), false, false); 0xFFC000));
AddColumnHeader(75, "Rank"); AddColumnHeader(75, "Rank");
AddColumnHeader(115, "Level"); AddColumnHeader(115, "Level");
@ -231,9 +231,9 @@ namespace Server.Engines.ConPVP
private void AddColoredText(int x, int y, int width, string text, int color) private void AddColoredText(int x, int y, int width, string text, int color)
{ {
if (color == 0) if (color == 0)
AddHtml(x, y, width, 20, text, false, false); AddHtml(x, y, width, 20, text);
else else
AddHtml(x, y, width, 20, Color(text, color), false, false); AddHtml(x, y, width, 20, Color(text, color));
} }
private void AddColumnHeader(int width, string name) private void AddColumnHeader(int width, string name)
@ -245,4 +245,4 @@ namespace Server.Engines.ConPVP
m_ColumnX += width; m_ColumnX += width;
} }
} }
} }

View file

@ -29,16 +29,16 @@ namespace Server.Engines.ConPVP
AddBackground(0, 0, 300, height, 9250); AddBackground(0, 0, 300, height, 9250);
AddBackground(10, 10, 280, height - 20, 0xDAC); AddBackground(10, 10, 280, height - 20, 0xDAC);
AddButton(240, 25, 0xFB1, 0xFB3, 3, GumpButtonType.Reply, 0); AddButton(240, 25, 0xFB1, 0xFB3, 3);
//AddButton( 223, 54, 0x265A, 0x265A, 4, GumpButtonType.Reply, 0 ); //AddButton( 223, 54, 0x265A, 0x265A, 4, );
AddHtml(35, 25, 230, 20, Center("Participant Setup"), false, false); AddHtml(35, 25, 230, 20, Center("Participant Setup"));
int x = 35; int x = 35;
int y = 47; int y = 47;
AddHtml(x, y, 200, 20, $"Team Size: {p.Players.Length}", false, false); AddHtml(x, y, 200, 20, $"Team Size: {p.Players.Length}");
y += 22; y += 22;
AddGoldenButtonLabeled(x + 20, y, 1, "Increase"); AddGoldenButtonLabeled(x + 20, y, 1, "Increase");
@ -46,7 +46,7 @@ namespace Server.Engines.ConPVP
AddGoldenButtonLabeled(x + 20, y, 2, "Decrease"); AddGoldenButtonLabeled(x + 20, y, 2, "Decrease");
y += 30; y += 30;
AddHtml(35, y, 230, 20, Center("Players"), false, false); AddHtml(35, y, 230, 20, Center("Players"));
y += 22; y += 22;
for (int i = 0; i < p.Players.Length; ++i) for (int i = 0; i < p.Players.Length; ++i)
@ -71,14 +71,14 @@ namespace Server.Engines.ConPVP
public void AddGoldenButton(int x, int y, int bid) public void AddGoldenButton(int x, int y, int bid)
{ {
AddButton(x, y, 0xD2, 0xD2, bid, GumpButtonType.Reply, 0); AddButton(x, y, 0xD2, 0xD2, bid);
AddButton(x + 3, y + 3, 0xD8, 0xD8, bid, GumpButtonType.Reply, 0); AddButton(x + 3, y + 3, 0xD8, 0xD8, bid);
} }
public void AddGoldenButtonLabeled(int x, int y, int bid, string text) public void AddGoldenButtonLabeled(int x, int y, int bid, string text)
{ {
AddGoldenButton(x, y, bid); AddGoldenButton(x, y, bid);
AddHtml(x + 25, y, 200, 20, text, false, false); AddHtml(x + 25, y, 200, 20, text);
} }
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
@ -250,4 +250,4 @@ namespace Server.Engines.ConPVP
} }
} }
} }
} }

View file

@ -26,7 +26,7 @@ namespace Server.Engines.ConPVP
AddBackground(0, 0, 260, height, 9250); AddBackground(0, 0, 260, height, 9250);
AddBackground(10, 10, 240, height - 20, 0xDAC); AddBackground(10, 10, 240, height - 20, 0xDAC);
AddHtml(35, 25, 190, 20, Center("Rules"), false, false); AddHtml(35, 25, 190, 20, Center("Rules"));
int y = 25 + 20; int y = 25 + 20;
@ -34,37 +34,37 @@ namespace Server.Engines.ConPVP
{ {
Ruleset cur = m_Defaults[i]; Ruleset cur = m_Defaults[i];
AddHtml(35 + 14, y, 176, 20, cur.Title, false, false); AddHtml(35 + 14, y, 176, 20, cur.Title);
if (ruleset.Base == cur && !ruleset.Changed) if (ruleset.Base == cur && !ruleset.Changed)
AddImage(35, y + 4, 0x939); AddImage(35, y + 4, 0x939);
else if (ruleset.Base == cur) else if (ruleset.Base == cur)
AddButton(35, y + 4, 0x93A, 0x939, 2 + i, GumpButtonType.Reply, 0); AddButton(35, y + 4, 0x93A, 0x939, 2 + i);
else else
AddButton(35, y + 4, 0x938, 0x939, 2 + i, GumpButtonType.Reply, 0); AddButton(35, y + 4, 0x938, 0x939, 2 + i);
y += 22; y += 22;
} }
AddHtml(35 + 14, y, 176, 20, "Custom", false, false); AddHtml(35 + 14, y, 176, 20, "Custom");
AddButton(35, y + 4, ruleset.Changed ? 0x939 : 0x938, 0x939, 1, GumpButtonType.Reply, 0); AddButton(35, y + 4, ruleset.Changed ? 0x939 : 0x938, 0x939, 1);
y += 22; y += 22;
y += 6; y += 6;
AddHtml(35, y, 190, 20, Center("Flavors"), false, false); AddHtml(35, y, 190, 20, Center("Flavors"));
y += 20; y += 20;
for (int i = 0; i < m_Flavors.Length; ++i) for (int i = 0; i < m_Flavors.Length; ++i)
{ {
Ruleset cur = m_Flavors[i]; Ruleset cur = m_Flavors[i];
AddHtml(35 + 14, y, 176, 20, cur.Title, false, false); AddHtml(35 + 14, y, 176, 20, cur.Title);
if (ruleset.Flavors.Contains(cur)) if (ruleset.Flavors.Contains(cur))
AddButton(35, y + 4, 0x939, 0x938, 2 + m_Defaults.Length + i, GumpButtonType.Reply, 0); AddButton(35, y + 4, 0x939, 0x938, 2 + m_Defaults.Length + i);
else else
AddButton(35, y + 4, 0x938, 0x939, 2 + m_Defaults.Length + i, GumpButtonType.Reply, 0); AddButton(35, y + 4, 0x938, 0x939, 2 + m_Defaults.Length + i);
y += 22; y += 22;
} }
@ -77,7 +77,7 @@ namespace Server.Engines.ConPVP
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
{ {
if (m_Context != null && !m_Context.Registered) if (m_Context?.Registered == false)
return; return;
switch (info.ButtonID) switch (info.ButtonID)
@ -123,4 +123,4 @@ namespace Server.Engines.ConPVP
} }
} }
} }
} }

View file

@ -22,7 +22,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < parts.Count; ++i) for (int i = 0; i < parts.Count; ++i)
{ {
Participant p = (Participant)parts[i]; Participant p = parts[i];
height += 4; height += 4;
@ -44,19 +44,19 @@ namespace Server.Engines.ConPVP
if (count == -1) if (count == -1)
{ {
AddHtml(35, 25, 190, 20, Center("Ready"), false, false); AddHtml(35, 25, 190, 20, Center("Ready"));
} }
else else
{ {
AddHtml(35, 25, 190, 20, Center("Starting"), false, false); AddHtml(35, 25, 190, 20, Center("Starting"));
AddHtml(35, 25, 190, 20, "<DIV ALIGN=RIGHT>" + count, false, false); AddHtml(35, 25, 190, 20, "<DIV ALIGN=RIGHT>" + count);
} }
int y = 25 + 20; int y = 25 + 20;
for (int i = 0; i < parts.Count; ++i) for (int i = 0; i < parts.Count; ++i)
{ {
Participant p = (Participant)parts[i]; Participant p = parts[i];
y += 4; y += 4;
@ -66,7 +66,7 @@ namespace Server.Engines.ConPVP
if (p.Players.Length > 1) if (p.Players.Length > 1)
{ {
AddHtml(35 + 14, y, 176, 20, $"Participant #{i + 1}", false, false); AddHtml(35 + 14, y, 176, 20, $"Participant #{i + 1}");
y += 22; y += 22;
offset = 10; offset = 10;
} }
@ -75,7 +75,7 @@ namespace Server.Engines.ConPVP
{ {
DuelPlayer pl = p.Players[j]; DuelPlayer pl = p.Players[j];
if (pl != null && pl.Ready) if (pl?.Ready == true)
{ {
AddImage(35 + offset, y + 4, 0x939); AddImage(35 + offset, y + 4, 0x939);
} }
@ -87,7 +87,7 @@ namespace Server.Engines.ConPVP
string name = pl == null ? "(Empty)" : pl.Mobile.Name; string name = pl == null ? "(Empty)" : pl.Mobile.Name;
AddHtml(35 + offset + 14, y, 166, 20, name, false, false); AddHtml(35 + offset + 14, y, 166, 20, name);
y += 22; y += 22;
} }
@ -106,4 +106,4 @@ namespace Server.Engines.ConPVP
{ {
} }
} }
} }

View file

@ -26,10 +26,10 @@ namespace Server.Engines.ConPVP
AddBackground(0, 0, 210, height, 9250); AddBackground(0, 0, 210, height, 9250);
AddBackground(10, 10, 190, height - 20, 0xDAC); AddBackground(10, 10, 190, height - 20, 0xDAC);
AddHtml(35, 25, 140, 20, Center("Rematch?"), false, false); AddHtml(35, 25, 140, 20, Center("Rematch?"));
AddButton(35, 55, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(35, 55, 247, 248, 1);
AddButton(115, 55, 242, 241, 2, GumpButtonType.Reply, 0); AddButton(115, 55, 242, 241, 2);
} }
else else
{ {
@ -58,7 +58,7 @@ namespace Server.Engines.ConPVP
AddBackground(0, 0, 260, height, 9250); AddBackground(0, 0, 260, height, 9250);
AddBackground(10, 10, 240, height - 20, 0xDAC); AddBackground(10, 10, 240, height - 20, 0xDAC);
AddHtml(35, 25, 190, 20, Center("Participants"), false, false); AddHtml(35, 25, 190, 20, Center("Participants"));
int y = 20 + 25; int y = 20 + 25;
@ -72,7 +72,7 @@ namespace Server.Engines.ConPVP
if (p.Players.Length > 1) if (p.Players.Length > 1)
{ {
AddHtml(35, y, 176, 20, $"Team #{i + 1}", false, false); AddHtml(35, y, 176, 20, $"Team #{i + 1}");
y += 22; y += 22;
offset = 10; offset = 10;
} }
@ -83,7 +83,7 @@ namespace Server.Engines.ConPVP
string name = pl == null ? "(Empty)" : pl.Mobile.Name; string name = pl == null ? "(Empty)" : pl.Mobile.Name;
AddHtml(35 + offset, y, 166, 20, name, false, false); AddHtml(35 + offset, y, 166, 20, name);
y += 22; y += 22;
} }
@ -91,12 +91,12 @@ namespace Server.Engines.ConPVP
y += 8; y += 8;
AddHtml(35, y, 176, 20, "Continue?", false, false); AddHtml(35, y, 176, 20, "Continue?");
y -= 2; y -= 2;
AddButton(102, y, 247, 248, 0, GumpButtonType.Page, 2); AddButton(102, y, 247, 248, 0, GumpButtonType.Page, 2);
AddButton(169, y, 242, 241, 2, GumpButtonType.Reply, 0); AddButton(169, y, 242, 241, 2);
#endregion #endregion
@ -118,7 +118,7 @@ namespace Server.Engines.ConPVP
defs = new BitArray(basedef.Options); defs = new BitArray(basedef.Options);
for (int i = 0; i < ruleset.Flavors.Count; ++i) for (int i = 0; i < ruleset.Flavors.Count; ++i)
defs.Or(((Ruleset)ruleset.Flavors[i]).Options); defs.Or(ruleset.Flavors[i].Options);
height += ruleset.Flavors.Count * 18; height += ruleset.Flavors.Count * 18;
} }
@ -140,20 +140,20 @@ namespace Server.Engines.ConPVP
AddBackground(0, 0, 260, height, 9250); AddBackground(0, 0, 260, height, 9250);
AddBackground(10, 10, 240, height - 20, 0xDAC); AddBackground(10, 10, 240, height - 20, 0xDAC);
AddHtml(35, 25, 190, 20, Center("Rules"), false, false); AddHtml(35, 25, 190, 20, Center("Rules"));
AddHtml(35, 50, 190, 20, $"Set: {basedef.Title}", false, false); AddHtml(35, 50, 190, 20, $"Set: {basedef.Title}");
y = 70; y = 70;
for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18) for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
AddHtml(35, y, 190, 20, $" + {((Ruleset)ruleset.Flavors[i]).Title}", false, false); AddHtml(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}");
y += 4; y += 4;
if (changes > 0) if (changes > 0)
{ {
AddHtml(35, y, 190, 20, "Modifications:", false, false); AddHtml(35, y, 190, 20, "Modifications:");
y += 20; y += 20;
for (int i = 0; i < opts.Length; ++i) for (int i = 0; i < opts.Length; ++i)
@ -164,7 +164,7 @@ namespace Server.Engines.ConPVP
if (name != null) // sanity if (name != null) // sanity
{ {
AddImage(35, y, opts[i] ? 0xD3 : 0xD2); AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
AddHtml(60, y, 165, 22, name, false, false); AddHtml(60, y, 165, 22, name);
} }
y += 22; y += 22;
@ -172,18 +172,18 @@ namespace Server.Engines.ConPVP
} }
else else
{ {
AddHtml(35, y, 190, 20, "Modifications: None", false, false); AddHtml(35, y, 190, 20, "Modifications: None");
y += 20; y += 20;
} }
y += 8; y += 8;
AddHtml(35, y, 176, 20, "Continue?", false, false); AddHtml(35, y, 176, 20, "Continue?");
y -= 2; y -= 2;
AddButton(102, y, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(102, y, 247, 248, 1);
AddButton(169, y, 242, 241, 3, GumpButtonType.Reply, 0); AddButton(169, y, 242, 241, 3);
#endregion #endregion
} }
@ -196,8 +196,8 @@ namespace Server.Engines.ConPVP
public void AddGoldenButton(int x, int y, int bid) public void AddGoldenButton(int x, int y, int bid)
{ {
AddButton(x, y, 0xD2, 0xD2, bid, GumpButtonType.Reply, 0); AddButton(x, y, 0xD2, 0xD2, bid);
AddButton(x + 3, y + 3, 0xD8, 0xD8, bid, GumpButtonType.Reply, 0); AddButton(x + 3, y + 3, 0xD8, 0xD8, bid);
} }
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
@ -230,4 +230,4 @@ namespace Server.Engines.ConPVP
} }
} }
} }
} }

View file

@ -45,7 +45,7 @@ namespace Server.Engines.ConPVP
AddBackground(0, 0, 260, height, 9250); AddBackground(0, 0, 260, height, 9250);
AddBackground(10, 10, 240, height - 20, 0xDAC); AddBackground(10, 10, 240, height - 20, 0xDAC);
AddHtml(35, 25, 190, 20, Center(page.Title), false, false); AddHtml(35, 25, 190, 20, Center(page.Title));
int x = 35; int x = 35;
int y = 47; int y = 47;
@ -53,7 +53,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < page.Children.Length; ++i) for (int i = 0; i < page.Children.Length; ++i)
{ {
AddGoldenButton(x, y, 1 + i); AddGoldenButton(x, y, 1 + i);
AddHtml(x + 25, y, 250, 22, page.Children[i].Title, false, false); AddHtml(x + 25, y, 250, 22, page.Children[i].Title);
y += 22; y += 22;
} }
@ -67,7 +67,7 @@ namespace Server.Engines.ConPVP
else else
AddCheck(x, y, 0xD2, 0xD3, enabled, i); AddCheck(x, y, 0xD2, 0xD3, enabled, i);
AddHtml(x + 25, y, 250, 22, page.Options[i], false, false); AddHtml(x + 25, y, 250, 22, page.Options[i]);
y += 22; y += 22;
} }
@ -80,13 +80,13 @@ namespace Server.Engines.ConPVP
public void AddGoldenButton(int x, int y, int bid) public void AddGoldenButton(int x, int y, int bid)
{ {
AddButton(x, y, 0xD2, 0xD2, bid, GumpButtonType.Reply, 0); AddButton(x, y, 0xD2, 0xD2, bid);
AddButton(x + 3, y + 3, 0xD8, 0xD8, bid, GumpButtonType.Reply, 0); AddButton(x + 3, y + 3, 0xD8, 0xD8, bid);
} }
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
{ {
if (m_DuelContext != null && !m_DuelContext.Registered) if (m_DuelContext?.Registered == false)
return; return;
if (!m_ReadOnly) if (!m_ReadOnly)
@ -127,4 +127,4 @@ namespace Server.Engines.ConPVP
} }
} }
} }
} }

View file

@ -19,7 +19,7 @@ namespace Server.Engines.ConPVP
Match_Info, Match_Info,
Player_Info Player_Info
} }
public class TournamentBracketGump : Gump public class TournamentBracketGump : Gump
{ {
private const int BlackColor32 = 0x000008; private const int BlackColor32 = 0x000008;
@ -86,7 +86,7 @@ namespace Server.Engines.ConPVP
sb.Append(" Tournament Bracket"); sb.Append(" Tournament Bracket");
AddHtml(25, 35, 250, 20, Center(sb.ToString()), false, false); AddHtml(25, 35, 250, 20, Center(sb.ToString()));
AddRightArrow(25, 53, ToButtonID(0, 4), "Rules"); AddRightArrow(25, 53, ToButtonID(0, 4), "Rules");
AddRightArrow(25, 71, ToButtonID(0, 1), "Participants"); AddRightArrow(25, 71, ToButtonID(0, 1), "Participants");
@ -117,7 +117,7 @@ namespace Server.Engines.ConPVP
text = "The tournament will begin shortly."; text = "The tournament will begin shortly.";
} }
AddHtml(25, 92, 250, 40, text, false, false); AddHtml(25, 92, 250, 40, text);
} }
else else
{ {
@ -138,7 +138,7 @@ namespace Server.Engines.ConPVP
defs = new BitArray(basedef.Options); defs = new BitArray(basedef.Options);
for (int i = 0; i < ruleset.Flavors.Count; ++i) for (int i = 0; i < ruleset.Flavors.Count; ++i)
defs.Or(((Ruleset)ruleset.Flavors[i]).Options); defs.Or(ruleset.Flavors[i].Options);
} }
else else
{ {
@ -158,7 +158,7 @@ namespace Server.Engines.ConPVP
60 + 18 + 20 + 20 + 20 + 8 + 20 + ruleset.Flavors.Count * 18 + 4 + 20 + changes * 22 + 6, 9380); 60 + 18 + 20 + 20 + 20 + 8 + 20 + ruleset.Flavors.Count * 18 + 4 + 20 + changes * 22 + 6, 9380);
AddLeftArrow(25, 11, ToButtonID(0, 0)); AddLeftArrow(25, 11, ToButtonID(0, 0));
AddHtml(25, 35, 250, 20, Center("Rules"), false, false); AddHtml(25, 35, 250, 20, Center("Rules"));
int y = 53; int y = 53;
@ -177,7 +177,7 @@ namespace Server.Engines.ConPVP
break; break;
} }
AddHtml(35, y, 190, 20, $"Grouping: {groupText}", false, false); AddHtml(35, y, 190, 20, $"Grouping: {groupText}");
y += 20; y += 20;
string tieText = null; string tieText = null;
@ -201,7 +201,7 @@ namespace Server.Engines.ConPVP
break; break;
} }
AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}", false, false); AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}");
y += 20; y += 20;
string sdText = "Off"; string sdText = "Off";
@ -216,22 +216,22 @@ namespace Server.Engines.ConPVP
sdText = $"{sdText} (all rounds)"; sdText = $"{sdText} (all rounds)";
} }
AddHtml(35, y, 240, 20, $"Sudden Death: {sdText}", false, false); AddHtml(35, y, 240, 20, $"Sudden Death: {sdText}");
y += 20; y += 20;
y += 8; y += 8;
AddHtml(35, y, 190, 20, $"Ruleset: {basedef.Title}", false, false); AddHtml(35, y, 190, 20, $"Ruleset: {basedef.Title}");
y += 20; y += 20;
for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18) for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18)
AddHtml(35, y, 190, 20, $" + {((Ruleset)ruleset.Flavors[i]).Title}", false, false); AddHtml(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}");
y += 4; y += 4;
if (changes > 0) if (changes > 0)
{ {
AddHtml(35, y, 190, 20, "Modifications:", false, false); AddHtml(35, y, 190, 20, "Modifications:");
y += 20; y += 20;
for (int i = 0; i < opts.Length; ++i) for (int i = 0; i < opts.Length; ++i)
@ -242,7 +242,7 @@ namespace Server.Engines.ConPVP
if (name != null) // sanity if (name != null) // sanity
{ {
AddImage(35, y, opts[i] ? 0xD3 : 0xD2); AddImage(35, y, opts[i] ? 0xD3 : 0xD2);
AddHtml(60, y, 165, 22, name, false, false); AddHtml(60, y, 165, 22, name);
} }
y += 22; y += 22;
@ -250,7 +250,7 @@ namespace Server.Engines.ConPVP
} }
else else
{ {
AddHtml(35, y, 190, 20, "Modifications: None", false, false); AddHtml(35, y, 190, 20, "Modifications: None");
} }
break; break;
@ -265,8 +265,7 @@ namespace Server.Engines.ConPVP
: new List<TourneyParticipant>(tourney.Participants); : new List<TourneyParticipant>(tourney.Participants);
AddLeftArrow(25, 11, ToButtonID(0, 0)); AddLeftArrow(25, 11, ToButtonID(0, 0));
AddHtml(25, 35, 250, 20, Center($"{pList.Count} Participant{(pList.Count == 1 ? "" : "s")}"), false, AddHtml(25, 35, 250, 20, Center($"{pList.Count} Participant{(pList.Count == 1 ? "" : "s")}"));
false);
StartPage(out int index, out int count, out int y, 12); StartPage(out int index, out int count, out int y, 12);
@ -293,11 +292,11 @@ namespace Server.Engines.ConPVP
AddBackground(0, 0, 300, 60 + 18 + 20 + part.Players.Count * 18 + 20 + 20 + 160, 9380); AddBackground(0, 0, 300, 60 + 18 + 20 + part.Players.Count * 18 + 20 + 20 + 160, 9380);
AddLeftArrow(25, 11, ToButtonID(0, 1)); AddLeftArrow(25, 11, ToButtonID(0, 1));
AddHtml(25, 35, 250, 20, Center("Participants"), false, false); AddHtml(25, 35, 250, 20, Center("Participants"));
int y = 53; int y = 53;
AddHtml(25, y, 200, 20, part.Players.Count == 1 ? "Players" : "Team", false, false); AddHtml(25, y, 200, 20, part.Players.Count == 1 ? "Players" : "Team");
y += 20; y += 20;
for (int i = 0; i < part.Players.Count; ++i) for (int i = 0; i < part.Players.Count; ++i)
@ -314,10 +313,10 @@ namespace Server.Engines.ConPVP
} }
AddHtml(25, y, 200, 20, AddHtml(25, y, 200, 20,
$"Free Advances: {(part.FreeAdvances == 0 ? "None" : part.FreeAdvances.ToString())}", false, false); $"Free Advances: {(part.FreeAdvances == 0 ? "None" : part.FreeAdvances.ToString())}");
y += 20; y += 20;
AddHtml(25, y, 200, 20, "Log:", false, false); AddHtml(25, y, 200, 20, "Log:");
y += 20; y += 20;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -343,7 +342,7 @@ namespace Server.Engines.ConPVP
AddBackground(0, 0, 300, 300, 9380); AddBackground(0, 0, 300, 300, 9380);
AddLeftArrow(25, 11, ToButtonID(0, 3)); AddLeftArrow(25, 11, ToButtonID(0, 3));
AddHtml(25, 35, 250, 20, Center("Participants"), false, false); AddHtml(25, 35, 250, 20, Center("Participants"));
if (!(obj is Mobile mob)) if (!(obj is Mobile mob))
break; break;
@ -351,16 +350,13 @@ namespace Server.Engines.ConPVP
Ladder ladder = Ladder.Instance; Ladder ladder = Ladder.Instance;
LadderEntry entry = ladder?.Find(mob); LadderEntry entry = ladder?.Find(mob);
AddHtml(25, 53, 250, 20, $"Name: {mob.Name}", false, false); AddHtml(25, 53, 250, 20, $"Name: {mob.Name}");
AddHtml(25, 73, 250, 20, AddHtml(25, 73, 250, 20,
$"Guild: {(mob.Guild == null ? "None" : mob.Guild.Name + " [" + mob.Guild.Abbreviation + "]")}", $"Guild: {(mob.Guild == null ? "None" : mob.Guild.Name + " [" + mob.Guild.Abbreviation + "]")}");
false, false); AddHtml(25, 93, 250, 20, $"Rank: {(entry == null ? "N/A" : LadderGump.Rank(entry.Index + 1))}");
AddHtml(25, 93, 250, 20, $"Rank: {(entry == null ? "N/A" : LadderGump.Rank(entry.Index + 1))}", false, AddHtml(25, 113, 250, 20, $"Level: {(entry == null ? 0 : Ladder.GetLevel(entry.Experience))}");
false); AddHtml(25, 133, 250, 20, $"Wins: {entry?.Wins ?? 0:N0}");
AddHtml(25, 113, 250, 20, $"Level: {(entry == null ? 0 : Ladder.GetLevel(entry.Experience))}", false, AddHtml(25, 153, 250, 20, $"Losses: {entry?.Losses ?? 0:N0}");
false);
AddHtml(25, 133, 250, 20, $"Wins: {entry?.Wins ?? 0:N0}", false, false);
AddHtml(25, 153, 250, 20, $"Losses: {entry?.Losses ?? 0:N0}", false, false);
break; break;
} }
@ -370,7 +366,7 @@ namespace Server.Engines.ConPVP
AddBackground(0, 0, 300, 300, 9380); AddBackground(0, 0, 300, 300, 9380);
AddLeftArrow(25, 11, ToButtonID(0, 0)); AddLeftArrow(25, 11, ToButtonID(0, 0));
AddHtml(25, 35, 250, 20, Center("Rounds"), false, false); AddHtml(25, 35, 250, 20, Center("Rounds"));
// List<PyramidLevel> levelsList = m_List != null // List<PyramidLevel> levelsList = m_List != null
// ? Utility.CastListCovariant<object, PyramidLevel>(m_List) // ? Utility.CastListCovariant<object, PyramidLevel>(m_List)
@ -389,11 +385,11 @@ namespace Server.Engines.ConPVP
AddBackground(0, 0, 300, 300, 9380); AddBackground(0, 0, 300, 300, 9380);
AddLeftArrow(25, 11, ToButtonID(0, 2)); AddLeftArrow(25, 11, ToButtonID(0, 2));
AddHtml(25, 35, 250, 20, Center("Rounds"), false, false); AddHtml(25, 35, 250, 20, Center("Rounds"));
if (!(m_Object is PyramidLevel level)) if (!(m_Object is PyramidLevel level))
break; break;
List<TourneyMatch> matchesList = m_List != null List<TourneyMatch> matchesList = m_List != null
? Utility.CastListCovariant<object, TourneyMatch>(m_List) ? Utility.CastListCovariant<object, TourneyMatch>(m_List)
: new List<TourneyMatch>(level.Matches); : new List<TourneyMatch>(level.Matches);
@ -401,7 +397,7 @@ namespace Server.Engines.ConPVP
AddRightArrow(25, 53, ToButtonID(5, 0), AddRightArrow(25, 53, ToButtonID(5, 0),
$"Free Advance: {(level.FreeAdvance == null ? "None" : level.FreeAdvance.NameList)}"); $"Free Advance: {(level.FreeAdvance == null ? "None" : level.FreeAdvance.NameList)}");
AddHtml(25, 73, 200, 20, $"{matchesList.Count} Match{(matchesList.Count == 1 ? "" : "es")}", false, false); AddHtml(25, 73, 200, 20, $"{matchesList.Count} Match{(matchesList.Count == 1 ? "" : "es")}");
StartPage(out int index, out int count, out int y, 10); StartPage(out int index, out int count, out int y, 10);
@ -529,14 +525,12 @@ namespace Server.Engines.ConPVP
AddBackground(0, 0, 300, 60 + 18 + 20 + 20 + 20 + ct * 18 + 6, 9380); AddBackground(0, 0, 300, 60 + 18 + 20 + 20 + 20 + ct * 18 + 6, 9380);
AddLeftArrow(25, 11, ToButtonID(0, 5)); AddLeftArrow(25, 11, ToButtonID(0, 5));
AddHtml(25, 35, 250, 20, Center("Rounds"), false, false); AddHtml(25, 35, 250, 20, Center("Rounds"));
AddHtml(25, 53, 250, 20, $"Winner: {(match.Winner == null ? "N/A" : match.Winner.NameList)}", false, AddHtml(25, 53, 250, 20, $"Winner: {(match.Winner == null ? "N/A" : match.Winner.NameList)}");
false);
AddHtml(25, 73, 250, 20, AddHtml(25, 73, 250, 20,
$"State: {(match.InProgress ? "In progress" : match.Context != null ? "Complete" : "Waiting")}", $"State: {(match.InProgress ? "In progress" : match.Context != null ? "Complete" : "Waiting")}");
false, false); AddHtml(25, 93, 250, 20, "Participants:");
AddHtml(25, 93, 250, 20, "Participants:", false, false);
if (m_Tournament.TourneyType == TourneyType.Standard) if (m_Tournament.TourneyType == TourneyType.Standard)
for (int i = 0; i < match.Participants.Count; ++i) for (int i = 0; i < match.Participants.Count; ++i)
@ -613,7 +607,7 @@ namespace Server.Engines.ConPVP
} }
} }
else if (m_Tournament.TourneyType == TourneyType.FreeForAll) else if (m_Tournament.TourneyType == TourneyType.FreeForAll)
AddHtml(25, 113, 250, 20, "Free For All", false, false); AddHtml(25, 113, 250, 20, "Free For All");
break; break;
} }
@ -642,17 +636,17 @@ namespace Server.Engines.ConPVP
private void AddColoredText(int x, int y, int width, int height, string text, int color) private void AddColoredText(int x, int y, int width, int height, string text, int color)
{ {
if (color == 0) if (color == 0)
AddHtml(x, y, width, height, text, false, false); AddHtml(x, y, width, height, text);
else else
AddHtml(x, y, width, height, Color(text, color), false, false); AddHtml(x, y, width, height, Color(text, color));
} }
public void AddRightArrow(int x, int y, int bid, string text) public void AddRightArrow(int x, int y, int bid, string text)
{ {
AddButton(x, y, 0x15E1, 0x15E5, bid, GumpButtonType.Reply, 0); AddButton(x, y, 0x15E1, 0x15E5, bid);
if (text != null) if (text != null)
AddHtml(x + 20, y - 1, 230, 20, text, false, false); AddHtml(x + 20, y - 1, 230, 20, text);
} }
public void AddRightArrow(int x, int y, int bid) public void AddRightArrow(int x, int y, int bid)
@ -662,10 +656,10 @@ namespace Server.Engines.ConPVP
public void AddLeftArrow(int x, int y, int bid, string text) public void AddLeftArrow(int x, int y, int bid, string text)
{ {
AddButton(x, y, 0x15E3, 0x15E7, bid, GumpButtonType.Reply, 0); AddButton(x, y, 0x15E3, 0x15E7, bid);
if (text != null) if (text != null)
AddHtml(x + 20, y - 1, 230, 20, text, false, false); AddHtml(x + 20, y - 1, 230, 20, text);
} }
public void AddLeftArrow(int x, int y, int bid) public void AddLeftArrow(int x, int y, int bid)
@ -859,4 +853,4 @@ namespace Server.Engines.ConPVP
} }
} }
} }
} }

View file

@ -52,7 +52,7 @@ namespace Server.Engines.ConPVP
get get
{ {
for (int i = 0; i < Players.Length; ++i) for (int i = 0; i < Players.Length; ++i)
if (Players[i] != null && !Players[i].Eliminated) if (Players[i]?.Eliminated == false)
return false; return false;
return true; return true;
@ -96,7 +96,7 @@ namespace Server.Engines.ConPVP
} }
for (int i = 0; i < Players.Length; ++i) for (int i = 0; i < Players.Length; ++i)
if (Players[i] != null && Players[i].Mobile == mob) if (Players[i]?.Mobile == mob)
return Players[i]; return Players[i];
return null; return null;
@ -228,4 +228,4 @@ namespace Server.Engines.ConPVP
public Participant Participant{ get; set; } public Participant Participant{ get; set; }
} }
} }

View file

@ -198,8 +198,8 @@ namespace Server.Engines.ConPVP
AddColumnHeader(35, null); AddColumnHeader(35, null);
AddColumnHeader(115, "Arena"); AddColumnHeader(115, "Arena");
AddButton(499 + 40 - 365 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(499 + 40 - 365 - 12 - 63 - 4 - 63, height - 12 - 24, 247, 248, 1);
AddButton(499 + 40 - 365 - 12 - 63, height - 12 - 24, 241, 242, 2, GumpButtonType.Reply, 0); AddButton(499 + 40 - 365 - 12 - 63, height - 12 - 24, 241, 242, 2);
for (int i = 0; i < arenas.Count; ++i) for (int i = 0; i < arenas.Count; ++i)
{ {
@ -258,9 +258,9 @@ namespace Server.Engines.ConPVP
private void AddColoredText(int x, int y, int width, string text, int color) private void AddColoredText(int x, int y, int width, string text, int color)
{ {
if (color == 0) if (color == 0)
AddHtml(x, y, width, 20, text, false, false); AddHtml(x, y, width, 20, text);
else else
AddHtml(x, y, width, 20, Color(text, color), false, false); AddHtml(x, y, width, 20, Color(text, color));
} }
private void AddColumnHeader(int width, string name) private void AddColumnHeader(int width, string name)

View file

@ -47,7 +47,7 @@ namespace Server.Engines.ConPVP
{ {
if (m_Root != null) if (m_Root != null)
return m_Root; return m_Root;
List<RulesetLayout> entries = new List<RulesetLayout> List<RulesetLayout> entries = new List<RulesetLayout>
{ {
new RulesetLayout("Spells", new RulesetLayout("Spells",
@ -761,4 +761,4 @@ namespace Server.Engines.ConPVP
return TotalLength; return TotalLength;
} }
} }
} }

View file

@ -21,10 +21,7 @@ namespace Server.Engines.ConPVP
public override bool AllowHousing(Mobile from, Point3D p) public override bool AllowHousing(Mobile from, Point3D p)
{ {
if (from.AccessLevel < AccessLevel.GameMaster) return from.AccessLevel >= AccessLevel.GameMaster && base.AllowHousing(from, p);
return false;
return base.AllowHousing(from, p);
} }
public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation) public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation)
@ -35,12 +32,11 @@ namespace Server.Engines.ConPVP
return false; return false;
} }
PlayerMobile pm = m as PlayerMobile; PlayerMobile pm = m as PlayerMobile ??
(m is BaseCreature bc && bc.Summoned ?
bc.SummonMaster as PlayerMobile : null);
if (pm == null && m is BaseCreature bc && bc.Summoned) if (pm?.DuelContext?.StartedBeginCountdown == true)
pm = bc.SummonMaster as PlayerMobile;
if (pm?.DuelContext != null && pm.DuelContext.StartedBeginCountdown)
return true; return true;
if (DuelContext.CheckCombat(m)) if (DuelContext.CheckCombat(m))
@ -67,4 +63,4 @@ namespace Server.Engines.ConPVP
return false; return false;
} }
} }
} }

View file

@ -247,7 +247,7 @@ namespace Server.Engines.ConPVP
sb.Append(remaining.Count == 2 ? "between " : "among "); sb.Append(remaining.Count == 2 ? "between " : "among ");
sb.Append(remaining.Count); sb.Append(remaining.Count);
sb.Append(remaining[0].Players.Count == 1 ? " players: " : " teams: "); sb.Append(remaining[0].Players.Count == 1 ? " players: " : " teams: ");
bool hasAppended = false; bool hasAppended = false;
@ -370,9 +370,7 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < part.Context.Participants.Count; ++i) for (int i = 0; i < part.Context.Participants.Count; ++i)
{ {
Participant check = part.Context.Participants[i]; if (part.Context.Participants[i]?.Eliminated == false)
if (check != null && !check.Eliminated)
++rem; ++rem;
} }
@ -559,7 +557,7 @@ namespace Server.Engines.ConPVP
{ {
Mobile mob = players[i]; Mobile mob = players[i];
if (mob == null || mob.Deleted) if (mob?.Deleted != false)
continue; continue;
Item item = new Trophy(title, rank); Item item = new Trophy(title, rank);
@ -762,7 +760,7 @@ namespace Server.Engines.ConPVP
if (!match.InProgress) if (!match.InProgress)
for (int j = 0; j < Arenas.Count; ++j) for (int j = 0; j < Arenas.Count; ++j)
{ {
Arena arena = (Arena)Arenas[j]; Arena arena = Arenas[j];
if (!arena.IsOccupied) if (!arena.IsOccupied)
{ {
@ -794,7 +792,7 @@ namespace Server.Engines.ConPVP
if (!bad) if (!bad)
continue; continue;
for (int j = 0; j < part.Players.Count; ++j) for (int j = 0; j < part.Players.Count; ++j)
part.Players[j].SendMessage("You have been disqualified from the tournament."); part.Players[j].SendMessage("You have been disqualified from the tournament.");
@ -882,7 +880,7 @@ namespace Server.Engines.ConPVP
Undefeated.Clear(); Undefeated.Clear();
break; break;
} }
} }
if (Undefeated.Count > 1) if (Undefeated.Count > 1)
@ -895,7 +893,7 @@ namespace Server.Engines.ConPVP
public void Alert(params string[] alerts) public void Alert(params string[] alerts)
{ {
for (int i = 0; i < Arenas.Count; ++i) for (int i = 0; i < Arenas.Count; ++i)
Alert((Arena)Arenas[i], alerts); Alert(Arenas[i], alerts);
} }
public void Alert(Arena arena, params string[] alerts) public void Alert(Arena arena, params string[] alerts)
@ -909,4 +907,4 @@ namespace Server.Engines.ConPVP
} }
} }
} }
} }

View file

@ -34,7 +34,7 @@ namespace Server.Engines.ConPVP
{ {
TournamentController controller = m_Instances[i]; TournamentController controller = m_Instances[i];
if (controller != null && !controller.Deleted && controller.Tournament != null && if (controller?.Deleted == false && controller.Tournament != null &&
controller.Tournament.Stage != TournamentStage.Inactive) controller.Tournament.Stage != TournamentStage.Inactive)
return true; return true;
} }
@ -140,4 +140,4 @@ namespace Server.Engines.ConPVP
} }
} }
} }
} }

View file

@ -70,7 +70,8 @@ namespace Server.Engines.ConPVP
{ {
Faction fac = Faction.Find(mob); Faction fac = Faction.Find(mob);
if (fac != null) index = fac.Definition.Sort; if (fac != null)
index = fac.Definition.Sort;
} }
else if (partsPerMatch == 2) else if (partsPerMatch == 2)
{ {
@ -186,4 +187,4 @@ namespace Server.Engines.ConPVP
public List<TourneyMatch> Matches{ get; set; } = new List<TourneyMatch>(); public List<TourneyMatch> Matches{ get; set; } = new List<TourneyMatch>();
public TourneyParticipant FreeAdvance{ get; set; } public TourneyParticipant FreeAdvance{ get; set; }
} }
} }

View file

@ -17,16 +17,7 @@ namespace Server.Engines.Craft
private CraftPage m_Page; private CraftPage m_Page;
private BaseTool m_Tool; private BaseTool m_Tool;
/*public CraftGump( Mobile from, CraftSystem craftSystem, BaseTool tool ): this( from, craftSystem, -1, -1, tool, null ) public CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page = CraftPage.None) : base(40, 40)
{
}*/
public CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice) : this(from, craftSystem, tool,
notice, CraftPage.None)
{
}
private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(40, 40)
{ {
m_From = from; m_From = from;
m_CraftSystem = craftSystem; m_CraftSystem = craftSystem;
@ -50,57 +41,56 @@ namespace Server.Engines.Craft
AddAlphaRegion(10, 10, 510, 417); AddAlphaRegion(10, 10, 510, 417);
if (craftSystem.GumpTitleNumber > 0) if (craftSystem.GumpTitleNumber > 0)
AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false); AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor);
else else
AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false); AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString);
AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false); // <CENTER>CATEGORIES</CENTER> AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor); // <CENTER>CATEGORIES</CENTER>
AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER> AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor); // <CENTER>SELECTIONS</CENTER>
AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER> AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor); // <CENTER>NOTICES</CENTER>
AddButton(15, 402, 4017, 4019, 0, GumpButtonType.Reply, 0); AddButton(15, 402, 4017, 4019, 0);
AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor, false, false); // EXIT AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor); // EXIT
AddButton(270, 402, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0); AddButton(270, 402, 4005, 4007, GetButtonID(6, 2));
AddHtmlLocalized(305, 405, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST AddHtmlLocalized(305, 405, 150, 18, 1044013, LabelColor); // MAKE LAST
// Mark option // Mark option
if (craftSystem.MarkOption) if (craftSystem.MarkOption)
{ {
AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0); AddButton(270, 362, 4005, 4007, GetButtonID(6, 6));
AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor); // MARK ITEM
false, false); // MARK ITEM
} }
// **************************************** // ****************************************
// Resmelt option // Resmelt option
if (craftSystem.Resmelt) if (craftSystem.Resmelt)
{ {
AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0); AddButton(15, 342, 4005, 4007, GetButtonID(6, 1));
AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor); // SMELT ITEM
} }
// **************************************** // ****************************************
// Repair option // Repair option
if (craftSystem.Repair) if (craftSystem.Repair)
{ {
AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0); AddButton(270, 342, 4005, 4007, GetButtonID(6, 5));
AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor); // REPAIR ITEM
} }
// **************************************** // ****************************************
// Enhance option // Enhance option
if (craftSystem.CanEnhance) if (craftSystem.CanEnhance)
{ {
AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0); AddButton(270, 382, 4005, 4007, GetButtonID(6, 8));
AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor); // ENHANCE ITEM
} }
// **************************************** // ****************************************
if (notice is int noticeInt && noticeInt > 0) if (notice is int noticeInt && noticeInt > 0)
AddHtmlLocalized(170, 295, 350, 40, noticeInt, LabelColor, false, false); AddHtmlLocalized(170, 295, 350, 40, noticeInt, LabelColor);
else if (notice is string) else if (notice is string)
AddHtml(170, 295, 350, 40, $"<BASEFONT COLOR=#{FontColor:X6}>{notice}</BASEFONT>", false, false); AddHtml(170, 295, 350, 40, $"<BASEFONT COLOR=#{FontColor:X6}>{notice}</BASEFONT>");
// If the system has more than one resource // If the system has more than one resource
if (craftSystem.CraftSubRes.Init) if (craftSystem.CraftSubRes.Init)
@ -131,10 +121,10 @@ namespace Server.Engines.Craft
resourceCount += items[i].Amount; resourceCount += items[i].Amount;
} }
AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0); AddButton(15, 362, 4005, 4007, GetButtonID(6, 0));
if (nameNumber > 0) if (nameNumber > 0)
AddHtmlLocalized(50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); AddHtmlLocalized(50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor);
else else
AddLabel(50, 362, LabelHue, $"{nameString} ({resourceCount} Available)"); AddLabel(50, 362, LabelHue, $"{nameString} ({resourceCount} Available)");
} }
@ -169,10 +159,10 @@ namespace Server.Engines.Craft
resourceCount += items[i].Amount; resourceCount += items[i].Amount;
} }
AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0); AddButton(15, 382, 4005, 4007, GetButtonID(6, 7));
if (nameNumber > 0) if (nameNumber > 0)
AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor);
else else
AddLabel(50, 385, LabelHue, $"{nameString} ({resourceCount} Available)"); AddLabel(50, 385, LabelHue, $"{nameString} ({resourceCount} Available)");
} }
@ -184,7 +174,7 @@ namespace Server.Engines.Craft
CreateResList(false, from); CreateResList(false, from);
else if (page == CraftPage.PickResource2) else if (page == CraftPage.PickResource2)
CreateResList(true, from); CreateResList(true, from);
else if (context != null && context.LastGroupIndex > -1) else if (context?.LastGroupIndex > -1)
CreateItemList(context.LastGroupIndex); CreateItemList(context.LastGroupIndex);
} }
@ -210,9 +200,9 @@ namespace Server.Engines.Craft
CraftContext context = m_CraftSystem.GetContext(m_From); CraftContext context = m_CraftSystem.GetContext(m_From);
AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0); AddButton(220, 260, 4005, 4007, GetButtonID(6, 4));
AddHtmlLocalized(255, 263, 200, 18, context == null || !context.DoNotColor ? 1061591 : 1061590, AddHtmlLocalized(255, 263, 200, 18, context == null || !context.DoNotColor ? 1061591 : 1061590,
LabelColor, false, false); LabelColor);
} }
int resourceCount = 0; int resourceCount = 0;
@ -225,11 +215,11 @@ namespace Server.Engines.Craft
resourceCount += items[j].Amount; resourceCount += items[j].Amount;
} }
AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0); AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(5, i));
if (subResource.NameNumber > 0) if (subResource.NameNumber > 0)
AddHtmlLocalized(255, 63 + index * 20, 250, 18, subResource.NameNumber, resourceCount.ToString(), AddHtmlLocalized(255, 63 + index * 20, 250, 18, subResource.NameNumber, resourceCount.ToString(),
LabelColor, false, false); LabelColor);
else else
AddLabel(255, 60 + index * 20, LabelHue, $"{subResource.NameString} ({resourceCount})"); AddLabel(255, 60 + index * 20, LabelHue, $"{subResource.NameString} ({resourceCount})");
} }
@ -256,7 +246,7 @@ namespace Server.Engines.Craft
if (i > 0) if (i > 0)
{ {
AddButton(370, 260, 4005, 4007, 0, GumpButtonType.Page, i / 10 + 1); AddButton(370, 260, 4005, 4007, 0, GumpButtonType.Page, i / 10 + 1);
AddHtmlLocalized(405, 263, 100, 18, 1044045, LabelColor, false, false); // NEXT PAGE AddHtmlLocalized(405, 263, 100, 18, 1044045, LabelColor); // NEXT PAGE
} }
AddPage(i / 10 + 1); AddPage(i / 10 + 1);
@ -264,21 +254,21 @@ namespace Server.Engines.Craft
if (i > 0) if (i > 0)
{ {
AddButton(220, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10); AddButton(220, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
AddHtmlLocalized(255, 263, 100, 18, 1044044, LabelColor, false, false); // PREV PAGE AddHtmlLocalized(255, 263, 100, 18, 1044044, LabelColor); // PREV PAGE
} }
} }
AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(3, i), GumpButtonType.Reply, 0); AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(3, i));
if (craftItem.NameNumber > 0) if (craftItem.NameNumber > 0)
AddHtmlLocalized(255, 63 + index * 20, 220, 18, craftItem.NameNumber, LabelColor, false, false); AddHtmlLocalized(255, 63 + index * 20, 220, 18, craftItem.NameNumber, LabelColor);
else else
AddLabel(255, 60 + index * 20, LabelHue, craftItem.NameString); AddLabel(255, 60 + index * 20, LabelHue, craftItem.NameString);
AddButton(480, 60 + index * 20, 4011, 4012, GetButtonID(4, i), GumpButtonType.Reply, 0); AddButton(480, 60 + index * 20, 4011, 4012, GetButtonID(4, i));
} }
else else
AddHtmlLocalized(230, 62, 200, 22, 1044165, LabelColor, false, false); // You haven't made anything yet. AddHtmlLocalized(230, 62, 200, 22, 1044165, LabelColor); // You haven't made anything yet.
} }
public void CreateItemList(int selectedGroup) public void CreateItemList(int selectedGroup)
@ -304,7 +294,7 @@ namespace Server.Engines.Craft
if (i > 0) if (i > 0)
{ {
AddButton(370, 260, 4005, 4007, 0, GumpButtonType.Page, i / 10 + 1); AddButton(370, 260, 4005, 4007, 0, GumpButtonType.Page, i / 10 + 1);
AddHtmlLocalized(405, 263, 100, 18, 1044045, LabelColor, false, false); // NEXT PAGE AddHtmlLocalized(405, 263, 100, 18, 1044045, LabelColor); // NEXT PAGE
} }
AddPage(i / 10 + 1); AddPage(i / 10 + 1);
@ -312,18 +302,18 @@ namespace Server.Engines.Craft
if (i > 0) if (i > 0)
{ {
AddButton(220, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10); AddButton(220, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10);
AddHtmlLocalized(255, 263, 100, 18, 1044044, LabelColor, false, false); // PREV PAGE AddHtmlLocalized(255, 263, 100, 18, 1044044, LabelColor); // PREV PAGE
} }
} }
AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(1, i), GumpButtonType.Reply, 0); AddButton(220, 60 + index * 20, 4005, 4007, GetButtonID(1, i));
if (craftItem.NameNumber > 0) if (craftItem.NameNumber > 0)
AddHtmlLocalized(255, 63 + index * 20, 220, 18, craftItem.NameNumber, LabelColor, false, false); AddHtmlLocalized(255, 63 + index * 20, 220, 18, craftItem.NameNumber, LabelColor);
else else
AddLabel(255, 60 + index * 20, LabelHue, craftItem.NameString); AddLabel(255, 60 + index * 20, LabelHue, craftItem.NameString);
AddButton(480, 60 + index * 20, 4011, 4012, GetButtonID(2, i), GumpButtonType.Reply, 0); AddButton(480, 60 + index * 20, 4011, 4012, GetButtonID(2, i));
} }
} }
@ -331,17 +321,17 @@ namespace Server.Engines.Craft
{ {
CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups; CraftGroupCol craftGroupCol = m_CraftSystem.CraftGroups;
AddButton(15, 60, 4005, 4007, GetButtonID(6, 3), GumpButtonType.Reply, 0); AddButton(15, 60, 4005, 4007, GetButtonID(6, 3));
AddHtmlLocalized(50, 63, 150, 18, 1044014, LabelColor, false, false); // LAST TEN AddHtmlLocalized(50, 63, 150, 18, 1044014, LabelColor); // LAST TEN
for (int i = 0; i < craftGroupCol.Count; i++) for (int i = 0; i < craftGroupCol.Count; i++)
{ {
CraftGroup craftGroup = craftGroupCol.GetAt(i); CraftGroup craftGroup = craftGroupCol.GetAt(i);
AddButton(15, 80 + i * 20, 4005, 4007, GetButtonID(0, i), GumpButtonType.Reply, 0); AddButton(15, 80 + i * 20, 4005, 4007, GetButtonID(0, i));
if (craftGroup.NameNumber > 0) if (craftGroup.NameNumber > 0)
AddHtmlLocalized(50, 83 + i * 20, 150, 18, craftGroup.NameNumber, LabelColor, false, false); AddHtmlLocalized(50, 83 + i * 20, 150, 18, craftGroup.NameNumber, LabelColor);
else else
AddLabel(50, 80 + i * 20, LabelHue, craftGroup.NameString); AddLabel(50, 80 + i * 20, LabelHue, craftGroup.NameString);
} }
@ -608,11 +598,11 @@ namespace Server.Engines.Craft
} }
} }
private enum CraftPage public enum CraftPage
{ {
None, None,
PickResource, PickResource,
PickResource2 PickResource2
} }
} }
} }

View file

@ -53,41 +53,40 @@ namespace Server.Engines.Craft
AddImageTiled(10, 387, 510, 22, 2624); AddImageTiled(10, 387, 510, 22, 2624);
AddAlphaRegion(10, 10, 510, 399); AddAlphaRegion(10, 10, 510, 399);
AddHtmlLocalized(170, 40, 150, 20, 1044053, LabelColor, false, false); // ITEM AddHtmlLocalized(170, 40, 150, 20, 1044053, LabelColor); // ITEM
AddHtmlLocalized(10, 192, 150, 22, 1044054, LabelColor, false, false); // <CENTER>SKILLS</CENTER> AddHtmlLocalized(10, 192, 150, 22, 1044054, LabelColor); // <CENTER>SKILLS</CENTER>
AddHtmlLocalized(10, 277, 150, 22, 1044055, LabelColor, false, false); // <CENTER>MATERIALS</CENTER> AddHtmlLocalized(10, 277, 150, 22, 1044055, LabelColor); // <CENTER>MATERIALS</CENTER>
AddHtmlLocalized(10, 362, 150, 22, 1044056, LabelColor, false, false); // <CENTER>OTHER</CENTER> AddHtmlLocalized(10, 362, 150, 22, 1044056, LabelColor); // <CENTER>OTHER</CENTER>
if (craftSystem.GumpTitleNumber > 0) if (craftSystem.GumpTitleNumber > 0)
AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false); AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor);
else else
AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false); AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString);
AddButton(15, 387, 4014, 4016, 0, GumpButtonType.Reply, 0); AddButton(15, 387, 4014, 4016, 0);
AddHtmlLocalized(50, 390, 150, 18, 1044150, LabelColor, false, false); // BACK AddHtmlLocalized(50, 390, 150, 18, 1044150, LabelColor); // BACK
bool needsRecipe = craftItem.Recipe != null && from is PlayerMobile mobile && bool needsRecipe = craftItem.Recipe != null && from is PlayerMobile mobile &&
!mobile.HasRecipe(craftItem.Recipe); !mobile.HasRecipe(craftItem.Recipe);
if (needsRecipe) if (needsRecipe)
{ {
AddButton(270, 387, 4005, 4007, 0, GumpButtonType.Page, 0); AddButton(270, 387, 4005, 4007, 0, GumpButtonType.Page);
AddHtmlLocalized(305, 390, 150, 18, 1044151, GreyLabelColor, false, false); // MAKE NOW AddHtmlLocalized(305, 390, 150, 18, 1044151, GreyLabelColor); // MAKE NOW
} }
else else
{ {
AddButton(270, 387, 4005, 4007, 1, GumpButtonType.Reply, 0); AddButton(270, 387, 4005, 4007, 1);
AddHtmlLocalized(305, 390, 150, 18, 1044151, LabelColor, false, false); // MAKE NOW AddHtmlLocalized(305, 390, 150, 18, 1044151, LabelColor); // MAKE NOW
} }
if (craftItem.NameNumber > 0) if (craftItem.NameNumber > 0)
AddHtmlLocalized(330, 40, 180, 18, craftItem.NameNumber, LabelColor, false, false); AddHtmlLocalized(330, 40, 180, 18, craftItem.NameNumber, LabelColor);
else else
AddLabel(330, 40, LabelHue, craftItem.NameString); AddLabel(330, 40, LabelHue, craftItem.NameString);
if (craftItem.UseAllRes) if (craftItem.UseAllRes)
AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1048176, LabelColor, false, AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1048176, LabelColor); // Makes as many as possible at once
false); // Makes as many as possible at once
DrawItem(); DrawItem();
DrawSkill(); DrawSkill();
@ -100,15 +99,14 @@ namespace Server.Engines.Craft
if (craftItem.RequiredExpansion != Expansion.None) if (craftItem.RequiredExpansion != Expansion.None)
{ {
bool supportsEx = from.NetState != null && from.NetState.SupportsExpansion(craftItem.RequiredExpansion); bool supportsEx = from.NetState?.SupportsExpansion(craftItem.RequiredExpansion) == true;
TextDefinition.AddHtmlText(this, 170, 302 + m_OtherCount++ * 20, 310, 18, TextDefinition.AddHtmlText(this, 170, 302 + m_OtherCount++ * 20, 310, 18,
RequiredExpansionMessage(craftItem.RequiredExpansion), false, false, RequiredExpansionMessage(craftItem.RequiredExpansion), false, false,
supportsEx ? LabelColor : RedLabelColor, supportsEx ? LabelHue : RedLabelHue); supportsEx ? LabelColor : RedLabelColor, supportsEx ? LabelHue : RedLabelHue);
} }
if (needsRecipe) if (needsRecipe)
AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1073620, RedLabelColor, false, AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1073620, RedLabelColor); // You have not learned this recipe.
false); // You have not learned this recipe.
} }
private TextDefinition RequiredExpansionMessage(Expansion expansion) private TextDefinition RequiredExpansionMessage(Expansion expansion)
@ -132,8 +130,7 @@ namespace Server.Engines.Craft
if (m_CraftItem.IsMarkable(type)) if (m_CraftItem.IsMarkable(type))
{ {
AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1044059, LabelColor, false, AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1044059, LabelColor); // This item may hold its maker's mark
false); // This item may hold its maker's mark
m_ShowExceptionalChance = true; m_ShowExceptionalChance = true;
} }
} }
@ -148,8 +145,7 @@ namespace Server.Engines.Craft
if (minSkill < 0) if (minSkill < 0)
minSkill = 0; minSkill = 0;
AddHtmlLocalized(170, 132 + i * 20, 200, 18, AosSkillBonuses.GetLabel(skill.SkillToMake), LabelColor, false, AddHtmlLocalized(170, 132 + i * 20, 200, 18, AosSkillBonuses.GetLabel(skill.SkillToMake), LabelColor);
false);
AddLabel(430, 132 + i * 20, LabelHue, $"{minSkill:F1}"); AddLabel(430, 132 + i * 20, LabelHue, $"{minSkill:F1}");
} }
@ -171,7 +167,7 @@ namespace Server.Engines.Craft
else if (chance > 1.0) else if (chance > 1.0)
chance = 1.0; chance = 1.0;
AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor, false, false); // Success Chance: AddHtmlLocalized(170, 80, 250, 18, 1044057, LabelColor); // Success Chance:
AddLabel(430, 80, LabelHue, $"{chance * 100:F1}%"); AddLabel(430, 80, LabelHue, $"{chance * 100:F1}%");
if (m_ShowExceptionalChance) if (m_ShowExceptionalChance)
@ -181,7 +177,7 @@ namespace Server.Engines.Craft
else if (excepChance > 1.0) else if (excepChance > 1.0)
excepChance = 1.0; excepChance = 1.0;
AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767, false, false); // Exceptional Chance: AddHtmlLocalized(170, 100, 250, 18, 1044058, 32767); // Exceptional Chance:
AddLabel(430, 100, LabelHue, $"{excepChance * 100:F1}%"); AddLabel(430, 100, LabelHue, $"{excepChance * 100:F1}%");
} }
} }
@ -232,13 +228,12 @@ namespace Server.Engines.Craft
if (!retainedColor && m_CraftItem.RetainsColorFrom(m_CraftSystem, type)) if (!retainedColor && m_CraftItem.RetainsColorFrom(m_CraftSystem, type))
{ {
retainedColor = true; retainedColor = true;
AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1044152, LabelColor, false, AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 310, 18, 1044152, LabelColor); // * The item retains the color of this material
false); // * The item retains the color of this material
AddLabel(500, 219 + i * 20, LabelHue, "*"); AddLabel(500, 219 + i * 20, LabelHue, "*");
} }
if (nameNumber > 0) if (nameNumber > 0)
AddHtmlLocalized(170, 219 + i * 20, 310, 18, nameNumber, LabelColor, false, false); AddHtmlLocalized(170, 219 + i * 20, 310, 18, nameNumber, LabelColor);
else else
AddLabel(170, 219 + i * 20, LabelHue, nameString); AddLabel(170, 219 + i * 20, LabelHue, nameString);
@ -247,13 +242,12 @@ namespace Server.Engines.Craft
if (m_CraftItem.NameNumber == 1041267) // runebook if (m_CraftItem.NameNumber == 1041267) // runebook
{ {
AddHtmlLocalized(170, 219 + m_CraftItem.Resources.Count * 20, 310, 18, 1044447, LabelColor, false, false); AddHtmlLocalized(170, 219 + m_CraftItem.Resources.Count * 20, 310, 18, 1044447, LabelColor);
AddLabel(430, 219 + m_CraftItem.Resources.Count * 20, LabelHue, "1"); AddLabel(430, 219 + m_CraftItem.Resources.Count * 20, LabelHue, "1");
} }
if (cropScroll) if (cropScroll)
AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 360, 18, 1044379, LabelColor, false, AddHtmlLocalized(170, 302 + m_OtherCount++ * 20, 360, 18, 1044379, LabelColor); // Inscribing scrolls also requires a blank scroll and mana.
false); // Inscribing scrolls also requires a blank scroll and mana.
} }
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
@ -292,4 +286,4 @@ namespace Server.Engines.Craft
} }
} }
} }
} }

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Server.Commands; using Server.Commands;
using Server.Factions; using Server.Factions;
using Server.Items; using Server.Items;
@ -273,16 +274,12 @@ namespace Server.Engines.Craft
return false; return false;
IPooledEnumerable<Item> eable = map.GetItemsInRange(from.Location, 2); IPooledEnumerable<Item> eable = map.GetItemsInRange(from.Location, 2);
bool found = eable.Any(item => item.Z + 16 > item.Z && item.Z + 16 > item.Z && Find(item.ItemID, itemIDs));
foreach (Item item in eable)
if (item.Z + 16 > from.Z && from.Z + 16 > item.Z && Find(item.ItemID, itemIDs))
{
eable.Free();
return true;
}
eable.Free(); eable.Free();
if (found)
return true;
for (int x = -2; x <= 2; ++x) for (int x = -2; x <= 2; ++x)
for (int y = -2; y <= 2; ++y) for (int y = -2; y <= 2; ++y)
{ {
@ -758,7 +755,7 @@ namespace Server.Engines.Craft
if (from.BeginAction<CraftSystem>()) if (from.BeginAction<CraftSystem>())
{ {
if (RequiredExpansion == Expansion.None || if (RequiredExpansion == Expansion.None ||
from.NetState != null && from.NetState.SupportsExpansion(RequiredExpansion)) from.NetState?.SupportsExpansion(RequiredExpansion) == true)
{ {
bool allRequiredSkills = true; bool allRequiredSkills = true;
double chance = GetSuccessChance(from, typeRes, craftSystem, false, ref allRequiredSkills); double chance = GetSuccessChance(from, typeRes, craftSystem, false, ref allRequiredSkills);
@ -860,7 +857,7 @@ namespace Server.Engines.Craft
if (badCraft > 0) if (badCraft > 0)
{ {
if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) if (tool?.Deleted == false && tool.UsesRemaining > 0)
from.SendGump(new CraftGump(from, craftSystem, tool, badCraft)); from.SendGump(new CraftGump(from, craftSystem, tool, badCraft));
else else
from.SendLocalizedMessage(badCraft); from.SendLocalizedMessage(badCraft);
@ -876,7 +873,7 @@ namespace Server.Engines.Craft
ref checkMessage) ref checkMessage)
&& ConsumeAttributes(from, ref checkMessage, false))) && ConsumeAttributes(from, ref checkMessage, false)))
{ {
if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) if (tool?.Deleted == false && tool.UsesRemaining > 0)
from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage)); from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage));
else if (checkMessage is int messageInt && messageInt > 0) else if (checkMessage is int messageInt && messageInt > 0)
from.SendLocalizedMessage(messageInt); from.SendLocalizedMessage(messageInt);
@ -905,7 +902,7 @@ namespace Server.Engines.Craft
if (!(ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message) if (!(ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message)
&& ConsumeAttributes(from, ref message, true))) && ConsumeAttributes(from, ref message, true)))
{ {
if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) if (tool?.Deleted == false && tool.UsesRemaining > 0)
from.SendGump(new CraftGump(from, craftSystem, tool, message)); from.SendGump(new CraftGump(from, craftSystem, tool, message));
else if (message is int messageIn && messageIn > 0) else if (message is int messageIn && messageIn > 0)
from.SendLocalizedMessage(messageIn); from.SendLocalizedMessage(messageIn);
@ -992,7 +989,7 @@ namespace Server.Engines.Craft
{ {
Town town = Town.FromRegion(from.Region); Town town = Town.FromRegion(from.Region);
if (town != null && town.Owner == faction) if (town?.Owner == faction)
{ {
Container pack = from.Backpack; Container pack = from.Backpack;
@ -1013,14 +1010,14 @@ namespace Server.Engines.Craft
if (queryFactionImbue) if (queryFactionImbue)
from.SendGump(new FactionImbueGump(quality, item, from, craftSystem, tool, num, availableSilver, faction, from.SendGump(new FactionImbueGump(quality, item, from, craftSystem, tool, num, availableSilver, faction,
def)); def));
else if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) else if (tool?.Deleted == false && tool.UsesRemaining > 0)
from.SendGump(new CraftGump(from, craftSystem, tool, num)); from.SendGump(new CraftGump(from, craftSystem, tool, num));
else if (num > 0) else if (num > 0)
from.SendLocalizedMessage(num); from.SendLocalizedMessage(num);
} }
else if (!allRequiredSkills) else if (!allRequiredSkills)
{ {
if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) if (tool?.Deleted == false && tool.UsesRemaining > 0)
from.SendGump(new CraftGump(from, craftSystem, tool, 1044153)); from.SendGump(new CraftGump(from, craftSystem, tool, 1044153));
else else
from.SendLocalizedMessage(1044153); // You don't have the required skills to attempt this item. from.SendLocalizedMessage(1044153); // You don't have the required skills to attempt this item.
@ -1036,7 +1033,7 @@ namespace Server.Engines.Craft
// Not enough resource to craft it // Not enough resource to craft it
if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true)) if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true))
{ {
if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) if (tool?.Deleted == false && tool.UsesRemaining > 0)
from.SendGump(new CraftGump(from, craftSystem, tool, message)); from.SendGump(new CraftGump(from, craftSystem, tool, message));
else if (message is int messageInt && messageInt > 0) else if (message is int messageInt && messageInt > 0)
from.SendLocalizedMessage(messageInt); from.SendLocalizedMessage(messageInt);
@ -1104,7 +1101,7 @@ namespace Server.Engines.Craft
if (badCraft > 0) if (badCraft > 0)
{ {
if (m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0) if (m_Tool?.Deleted == false && m_Tool.UsesRemaining > 0)
m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, badCraft)); m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, badCraft));
else else
m_From.SendLocalizedMessage(badCraft); m_From.SendLocalizedMessage(badCraft);

View file

@ -4,14 +4,11 @@ namespace Server.Engines.Craft
{ {
public class CraftRes public class CraftRes
{ {
public CraftRes(Type type, int amount) public CraftRes(Type type, TextDefinition name, int amount, TextDefinition message = null)
{ {
ItemType = type; ItemType = type;
Amount = amount; Amount = amount;
}
public CraftRes(Type type, TextDefinition name, int amount, TextDefinition message) : this(type, amount)
{
NameNumber = name; NameNumber = name;
MessageNumber = message; MessageNumber = message;
@ -41,4 +38,4 @@ namespace Server.Engines.Craft
from.SendLocalizedMessage(502925); // You don't have the resources required to make that item. from.SendLocalizedMessage(502925); // You don't have the resources required to make that item.
} }
} }
} }

View file

@ -31,4 +31,4 @@ namespace Server.Engines.Craft
public double RequiredSkill{ get; } public double RequiredSkill{ get; }
} }
} }

View file

@ -31,13 +31,13 @@ namespace Server.Engines.Craft
AddBackground(0, 0, 220, 170, 5054); AddBackground(0, 0, 220, 170, 5054);
AddBackground(10, 10, 200, 150, 3000); AddBackground(10, 10, 200, 150, 3000);
AddHtmlLocalized(20, 20, 180, 80, 1018317, false, false); // Do you wish to place your maker's mark on this item? AddHtmlLocalized(20, 20, 180, 80, 1018317); // Do you wish to place your maker's mark on this item?
AddHtmlLocalized(55, 100, 140, 25, 1011011, false, false); // CONTINUE AddHtmlLocalized(55, 100, 140, 25, 1011011); // CONTINUE
AddButton(20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0); AddButton(20, 100, 4005, 4007, 1);
AddHtmlLocalized(55, 125, 140, 25, 1011012, false, false); // CANCEL AddHtmlLocalized(55, 125, 140, 25, 1011012); // CANCEL
AddButton(20, 125, 4005, 4007, 0, GumpButtonType.Reply, 0); AddButton(20, 125, 4005, 4007, 0);
} }
public override void OnResponse(NetState sender, RelayInfo info) public override void OnResponse(NetState sender, RelayInfo info)
@ -52,4 +52,4 @@ namespace Server.Engines.Craft
m_CraftItem.CompleteCraft(m_Quality, makersMark, m_From, m_CraftSystem, m_TypeRes, m_Tool, null); m_CraftItem.CompleteCraft(m_Quality, makersMark, m_From, m_CraftSystem, m_TypeRes, m_Tool, null);
} }
} }
} }

View file

@ -34,16 +34,7 @@ namespace Server.Engines.Craft
public int ID{ get; } public int ID{ get; }
public TextDefinition TextDefinition public TextDefinition TextDefinition => m_TD ?? (m_TD = new TextDefinition(CraftItem.NameNumber, CraftItem.NameString));
{
get
{
if (m_TD == null)
m_TD = new TextDefinition(CraftItem.NameNumber, CraftItem.NameString);
return m_TD;
}
}
public static void Initialize() public static void Initialize()
{ {

View file

@ -117,6 +117,7 @@ namespace Server.Engines.Craft
} }
catch catch
{ {
// ignored
} }
return SmeltResult.Invalid; return SmeltResult.Invalid;

View file

@ -17,16 +17,7 @@ namespace Server.Engines.Craft
public override int GumpTitleNumber => 1044001; public override int GumpTitleNumber => 1044001;
public static CraftSystem CraftSystem public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefAlchemy());
{
get
{
if (m_CraftSystem == null)
m_CraftSystem = new DefAlchemy();
return m_CraftSystem;
}
}
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item)
{ {
@ -35,8 +26,9 @@ namespace Server.Engines.Craft
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
if (tool == null || tool.Deleted || tool.UsesRemaining < 0) if (tool?.Deleted != false || tool.UsesRemaining < 0)
return 1044038; // You have worn out your tool! return 1044038; // You have worn out your tool!
if (!BaseTool.CheckAccessible(tool, from)) if (!BaseTool.CheckAccessible(tool, from))
return 1044263; // The tool must be on your person to use. return 1044263; // The tool must be on your person to use.
@ -180,4 +172,4 @@ namespace Server.Engines.Craft
} }
} }
} }
} }

View file

@ -30,16 +30,7 @@ namespace Server.Engines.Craft
public override int GumpTitleNumber => 1044002; public override int GumpTitleNumber => 1044002;
public static CraftSystem CraftSystem public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefBlacksmithy());
{
get
{
if (m_CraftSystem == null)
m_CraftSystem = new DefBlacksmithy();
return m_CraftSystem;
}
}
public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive; public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive;
@ -111,7 +102,7 @@ namespace Server.Engines.Craft
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
if (tool == null || tool.Deleted || tool.UsesRemaining < 0) if (tool?.Deleted != false || tool.UsesRemaining < 0)
return 1044038; // You have worn out your tool! return 1044038; // You have worn out your tool!
if (!BaseTool.CheckTool(tool, from)) if (!BaseTool.CheckTool(tool, from))
return 1048146; // If you have a tool equipped, you must use that tool. return 1048146; // If you have a tool equipped, you must use that tool.
@ -801,4 +792,4 @@ namespace Server.Engines.Craft
public class AnvilAttribute : Attribute public class AnvilAttribute : Attribute
{ {
} }
} }

View file

@ -15,16 +15,7 @@ namespace Server.Engines.Craft
public override int GumpTitleNumber => 1044006; public override int GumpTitleNumber => 1044006;
public static CraftSystem CraftSystem public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefBowFletching());
{
get
{
if (m_CraftSystem == null)
m_CraftSystem = new DefBowFletching();
return m_CraftSystem;
}
}
public override CraftECA ECA => CraftECA.FiftyPercentChanceMinusTenPercent; public override CraftECA ECA => CraftECA.FiftyPercentChanceMinusTenPercent;
@ -35,7 +26,7 @@ namespace Server.Engines.Craft
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
if (tool == null || tool.Deleted || tool.UsesRemaining < 0) if (tool?.Deleted != false || tool.UsesRemaining < 0)
return 1044038; // You have worn out your tool! return 1044038; // You have worn out your tool!
if (!BaseTool.CheckAccessible(tool, from)) if (!BaseTool.CheckAccessible(tool, from))
return 1044263; // The tool must be on your person to use. return 1044263; // The tool must be on your person to use.
@ -212,4 +203,4 @@ namespace Server.Engines.Craft
Repair = Core.AOS; Repair = Core.AOS;
} }
} }
} }

View file

@ -15,16 +15,7 @@ namespace Server.Engines.Craft
public override int GumpTitleNumber => 1044004; public override int GumpTitleNumber => 1044004;
public static CraftSystem CraftSystem public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefCarpentry());
{
get
{
if (m_CraftSystem == null)
m_CraftSystem = new DefCarpentry();
return m_CraftSystem;
}
}
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item)
{ {
@ -33,7 +24,7 @@ namespace Server.Engines.Craft
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
if (tool == null || tool.Deleted || tool.UsesRemaining < 0) if (tool?.Deleted != false || tool.UsesRemaining < 0)
return 1044038; // You have worn out your tool! return 1044038; // You have worn out your tool!
if (!BaseTool.CheckAccessible(tool, from)) if (!BaseTool.CheckAccessible(tool, from))
return 1044263; // The tool must be on your person to use. return 1044263; // The tool must be on your person to use.
@ -545,4 +536,4 @@ namespace Server.Engines.Craft
AddSubRes(typeof(FrostwoodLog), 1072649, 100.0, 1044041, 1072652); AddSubRes(typeof(FrostwoodLog), 1072649, 100.0, 1044041, 1072652);
} }
} }
} }

View file

@ -15,16 +15,7 @@ namespace Server.Engines.Craft
public override int GumpTitleNumber => 1044008; public override int GumpTitleNumber => 1044008;
public static CraftSystem CraftSystem public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefCartography());
{
get
{
if (m_CraftSystem == null)
m_CraftSystem = new DefCartography();
return m_CraftSystem;
}
}
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item)
{ {
@ -33,7 +24,7 @@ namespace Server.Engines.Craft
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
if (tool == null || tool.Deleted || tool.UsesRemaining < 0) if (tool?.Deleted != false || tool.UsesRemaining < 0)
return 1044038; // You have worn out your tool! return 1044038; // You have worn out your tool!
if (!BaseTool.CheckAccessible(tool, from)) if (!BaseTool.CheckAccessible(tool, from))
return 1044263; // The tool must be on your person to use. return 1044263; // The tool must be on your person to use.
@ -76,4 +67,4 @@ namespace Server.Engines.Craft
AddCraft(typeof(WorldMap), 1044448, 1015233, 39.5, 99.5, typeof(BlankMap), 1044449, 1, 1044450); AddCraft(typeof(WorldMap), 1044448, 1015233, 39.5, 99.5, typeof(BlankMap), 1044449, 1, 1044450);
} }
} }
} }

View file

@ -15,16 +15,7 @@ namespace Server.Engines.Craft
public override int GumpTitleNumber => 1044003; public override int GumpTitleNumber => 1044003;
public static CraftSystem CraftSystem public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefCooking());
{
get
{
if (m_CraftSystem == null)
m_CraftSystem = new DefCooking();
return m_CraftSystem;
}
}
public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive; public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive;
@ -35,7 +26,7 @@ namespace Server.Engines.Craft
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
if (tool == null || tool.Deleted || tool.UsesRemaining < 0) if (tool?.Deleted != false || tool.UsesRemaining < 0)
return 1044038; // You have worn out your tool! return 1044038; // You have worn out your tool!
if (!BaseTool.CheckAccessible(tool, from)) if (!BaseTool.CheckAccessible(tool, from))
return 1044263; // The tool must be on your person to use. return 1044263; // The tool must be on your person to use.
@ -292,4 +283,4 @@ namespace Server.Engines.Craft
/* End Chocolatiering */ /* End Chocolatiering */
} }
} }
} }

View file

@ -16,28 +16,16 @@ namespace Server.Engines.Craft
public override int GumpTitleNumber => 1044622; public override int GumpTitleNumber => 1044622;
public static CraftSystem CraftSystem public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefGlassblowing());
{
get
{
if (m_CraftSystem == null)
m_CraftSystem = new DefGlassblowing();
return m_CraftSystem;
}
}
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item)
{ {
if (item.ItemType == typeof(HollowPrism)) return item.ItemType == typeof(HollowPrism) ? 0.5 : 0.0;
return 0.5; // 50%
return 0.0; // 0%
} }
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
if (tool == null || tool.Deleted || tool.UsesRemaining < 0) if (tool?.Deleted != false || tool.UsesRemaining < 0)
return 1044038; // You have worn out your tool! return 1044038; // You have worn out your tool!
if (!BaseTool.CheckTool(tool, from)) if (!BaseTool.CheckTool(tool, from))
return 1048146; // If you have a tool equipped, you must use that tool. return 1048146; // If you have a tool equipped, you must use that tool.
@ -48,10 +36,7 @@ namespace Server.Engines.Craft
DefBlacksmithy.CheckAnvilAndForge(from, 2, out _, out bool forge); DefBlacksmithy.CheckAnvilAndForge(from, 2, out _, out bool forge);
if (forge) return forge ? 0 : 1044628; // You must be near a forge to blow glass.
return 0;
return 1044628; // You must be near a forge to blow glass.
} }
public override void PlayCraftEffect(Mobile from) public override void PlayCraftEffect(Mobile from)
@ -128,4 +113,4 @@ namespace Server.Engines.Craft
} }
} }
} }
} }

View file

@ -36,16 +36,7 @@ namespace Server.Engines.Craft
public override int GumpTitleNumber => 1044009; public override int GumpTitleNumber => 1044009;
public static CraftSystem CraftSystem public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefInscription());
{
get
{
if (m_CraftSystem == null)
m_CraftSystem = new DefInscription();
return m_CraftSystem;
}
}
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item)
{ {
@ -54,7 +45,7 @@ namespace Server.Engines.Craft
public override int CanCraft(Mobile from, BaseTool tool, Type typeItem) public override int CanCraft(Mobile from, BaseTool tool, Type typeItem)
{ {
if (tool == null || tool.Deleted || tool.UsesRemaining < 0) if (tool?.Deleted != false || tool.UsesRemaining < 0)
return 1044038; // You have worn out your tool! return 1044038; // You have worn out your tool!
if (!BaseTool.CheckAccessible(tool, from)) if (!BaseTool.CheckAccessible(tool, from))
return 1044263; // The tool must be on your person to use. return 1044263; // The tool must be on your person to use.
@ -65,9 +56,7 @@ namespace Server.Engines.Craft
if (o is SpellScroll scroll) if (o is SpellScroll scroll)
{ {
Spellbook book = Spellbook.Find(from, scroll.SpellID); bool hasSpell = Spellbook.Find(from, scroll.SpellID)?.HasSpell(scroll.SpellID) == true;
bool hasSpell = book != null && book.HasSpell(scroll.SpellID);
scroll.Delete(); scroll.Delete();
@ -121,7 +110,6 @@ namespace Server.Engines.Craft
switch (m_Circle) switch (m_Circle)
{ {
default: default:
case 0:
minSkill = -25.0; minSkill = -25.0;
maxSkill = 25.0; maxSkill = 25.0;
break; break;
@ -409,4 +397,4 @@ namespace Server.Engines.Craft
SpidersSilk SpidersSilk
} }
} }
} }

View file

@ -16,16 +16,7 @@ namespace Server.Engines.Craft
public override int GumpTitleNumber => 1044500; public override int GumpTitleNumber => 1044500;
public static CraftSystem CraftSystem public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefMasonry());
{
get
{
if (m_CraftSystem == null)
m_CraftSystem = new DefMasonry();
return m_CraftSystem;
}
}
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item)
{ {
@ -39,7 +30,7 @@ namespace Server.Engines.Craft
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
if (tool == null || tool.Deleted || tool.UsesRemaining < 0) if (tool?.Deleted != false || tool.UsesRemaining < 0)
return 1044038; // You have worn out your tool! return 1044038; // You have worn out your tool!
if (!BaseTool.CheckTool(tool, from)) if (!BaseTool.CheckTool(tool, from))
return 1048146; // If you have a tool equipped, you must use that tool. return 1048146; // If you have a tool equipped, you must use that tool.
@ -139,4 +130,4 @@ namespace Server.Engines.Craft
} }
} }
} }
} }

View file

@ -23,16 +23,7 @@ namespace Server.Engines.Craft
public override int GumpTitleNumber => 1044005; public override int GumpTitleNumber => 1044005;
public static CraftSystem CraftSystem public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefTailoring());
{
get
{
if (m_CraftSystem == null)
m_CraftSystem = new DefTailoring();
return m_CraftSystem;
}
}
public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive; public override CraftECA ECA => CraftECA.ChanceMinusSixtyToFourtyFive;
@ -43,7 +34,7 @@ namespace Server.Engines.Craft
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
if (tool == null || tool.Deleted || tool.UsesRemaining < 0) if (tool?.Deleted != false || tool.UsesRemaining < 0)
return 1044038; // You have worn out your tool! return 1044038; // You have worn out your tool!
if (!BaseTool.CheckAccessible(tool, from)) if (!BaseTool.CheckAccessible(tool, from))
return 1044263; // The tool must be on your person to use. return 1044263; // The tool must be on your person to use.
@ -427,4 +418,4 @@ namespace Server.Engines.Craft
CanEnhance = Core.AOS; CanEnhance = Core.AOS;
} }
} }
} }

View file

@ -31,16 +31,7 @@ namespace Server.Engines.Craft
public override int GumpTitleNumber => 1044007; public override int GumpTitleNumber => 1044007;
public static CraftSystem CraftSystem public static CraftSystem CraftSystem => m_CraftSystem ?? (m_CraftSystem = new DefTinkering());
{
get
{
if (m_CraftSystem == null)
m_CraftSystem = new DefTinkering();
return m_CraftSystem;
}
}
public override double GetChanceAtMin(CraftItem item) public override double GetChanceAtMin(CraftItem item)
{ {
@ -52,7 +43,7 @@ namespace Server.Engines.Craft
public override int CanCraft(Mobile from, BaseTool tool, Type itemType) public override int CanCraft(Mobile from, BaseTool tool, Type itemType)
{ {
if (tool == null || tool.Deleted || tool.UsesRemaining < 0) if (tool?.Deleted != false || tool.UsesRemaining < 0)
return 1044038; // You have worn out your tool! return 1044038; // You have worn out your tool!
if (!BaseTool.CheckAccessible(tool, from)) if (!BaseTool.CheckAccessible(tool, from))
return 1044263; // The tool must be on your person to use. return 1044263; // The tool must be on your person to use.
@ -507,7 +498,7 @@ namespace Server.Engines.Craft
Mobile from = m_TrapCraft.From; Mobile from = m_TrapCraft.From;
BaseTool tool = m_TrapCraft.Tool; BaseTool tool = m_TrapCraft.Tool;
if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) if (tool?.Deleted == false && tool.UsesRemaining > 0)
from.SendGump(new CraftGump(from, m_TrapCraft.CraftSystem, tool, message)); from.SendGump(new CraftGump(from, m_TrapCraft.CraftSystem, tool, message));
else if (message > 0) else if (message > 0)
from.SendLocalizedMessage(message); from.SendLocalizedMessage(message);
@ -547,4 +538,4 @@ namespace Server.Engines.Craft
public override TrapType TrapType => TrapType.ExplosionTrap; public override TrapType TrapType => TrapType.ExplosionTrap;
} }
} }

View file

@ -27,12 +27,7 @@ namespace Server.Engines.Doom
private Timer m_Timer; private Timer m_Timer;
[Constructible] [Constructible]
public GauntletSpawner() : this(null) public GauntletSpawner(string typeName = null) : base(0x36FE)
{
}
[Constructible]
public GauntletSpawner(string typeName) : base(0x36FE)
{ {
Visible = false; Visible = false;
Movable = false; Movable = false;
@ -334,7 +329,7 @@ namespace Server.Engines.Doom
{ {
State = GauntletSpawnerState.InSequence; State = GauntletSpawnerState.InSequence;
if (Sequence != null && !Sequence.Deleted) if (Sequence?.Deleted == false)
Sequence.RecurseReset(); Sequence.RecurseReset();
} }
} }
@ -353,7 +348,7 @@ namespace Server.Engines.Doom
{ {
State = GauntletSpawnerState.Completed; State = GauntletSpawnerState.Completed;
if (Sequence != null && !Sequence.Deleted) if (Sequence?.Deleted == false)
{ {
if (Sequence.State == GauntletSpawnerState.Completed) if (Sequence.State == GauntletSpawnerState.Completed)
RecurseReset(); RecurseReset();
@ -428,7 +423,7 @@ namespace Server.Engines.Doom
public static void CreateTeleporter(int xFrom, int yFrom, int xTo, int yTo) public static void CreateTeleporter(int xFrom, int yFrom, int xTo, int yTo)
{ {
Static telePad = new Static(0x1822); Static telePad = new Static(0x1822);
Teleporter teleItem = new Teleporter(new Point3D(xTo, yTo, -1), Map.Malas, false); Teleporter teleItem = new Teleporter(new Point3D(xTo, yTo, -1), Map.Malas);
telePad.Hue = 0x482; telePad.Hue = 0x482;
telePad.MoveToWorld(new Point3D(xFrom, yFrom, -1), Map.Malas); telePad.MoveToWorld(new Point3D(xFrom, yFrom, -1), Map.Malas);
@ -652,4 +647,4 @@ namespace Server.Engines.Doom
{ {
} }
} }
} }

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Server.Commands; using Server.Commands;
using Server.Mobiles; using Server.Mobiles;
using Server.Network; using Server.Network;
@ -181,12 +182,11 @@ namespace Server.Engines.Doom
[Description("Generates lamp room and lever puzzle in doom.")] [Description("Generates lamp room and lever puzzle in doom.")]
public static void GenLampPuzzle_OnCommand(CommandEventArgs e) public static void GenLampPuzzle_OnCommand(CommandEventArgs e)
{ {
foreach (Item item in Map.Malas.GetItemsInRange(lp_Center, 0)) if (Map.Malas.GetItemsInRange(lp_Center, 0).OfType<LeverPuzzleController>().Any())
if (item is LeverPuzzleController) {
{ e.Mobile.SendMessage("Lamp room puzzle already exists: please delete the existing controller first ...");
e.Mobile.SendMessage("Lamp room puzzle already exists: please delete the existing controller first ..."); return;
return; }
}
e.Mobile.SendMessage("Generating Lamp Room puzzle..."); e.Mobile.SendMessage("Generating Lamp Room puzzle...");
new LeverPuzzleController().MoveToWorld(lp_Center, Map.Malas); new LeverPuzzleController().MoveToWorld(lp_Center, Map.Malas);
@ -199,10 +199,11 @@ namespace Server.Engines.Doom
public static Item AddLeverPuzzlePart(int[] Loc, Item newitem) public static Item AddLeverPuzzlePart(int[] Loc, Item newitem)
{ {
if (newitem == null || newitem.Deleted) if (newitem?.Deleted != false)
installed = false; installed = false;
else else
newitem.MoveToWorld(new Point3D(Loc[0], Loc[1], Loc[2]), Map.Malas); newitem.MoveToWorld(new Point3D(Loc[0], Loc[1], Loc[2]), Map.Malas);
return newitem; return newitem;
} }
@ -220,16 +221,17 @@ namespace Server.Engines.Doom
m_LampRoom?.Unregister(); m_LampRoom?.Unregister();
if (m_Tiles != null) if (m_Tiles != null)
foreach (Region region in m_Tiles) foreach (LeverPuzzleRegion region in m_Tiles)
region.Unregister(); region.Unregister();
if (m_Box != null && !m_Box.Deleted) m_Box.Delete(); if (m_Box?.Deleted == false)
m_Box.Delete();
} }
public static void NukeItemList(List<Item> list) public static void NukeItemList(List<Item> list)
{ {
if (list != null && list.Count != 0) if (list?.Count > 0)
foreach (Item item in list) foreach (Item item in list)
if (item != null && !item.Deleted) if (item?.Deleted == false)
item.Delete(); item.Delete();
} }
@ -244,31 +246,29 @@ namespace Server.Engines.Doom
public virtual LeverPuzzleStatue GetStatue(int index) public virtual LeverPuzzleStatue GetStatue(int index)
{ {
LeverPuzzleStatue statue = (LeverPuzzleStatue)m_Statues[index]; LeverPuzzleStatue statue = (LeverPuzzleStatue)m_Statues[index];
return statue?.Deleted == false ? statue : null;
if (statue != null && !statue.Deleted) return statue;
return null;
} }
public virtual LeverPuzzleLever GetLever(int index) public virtual LeverPuzzleLever GetLever(int index)
{ {
LeverPuzzleLever lever = (LeverPuzzleLever)m_Levers[index]; LeverPuzzleLever lever = (LeverPuzzleLever)m_Levers[index];
if (lever != null && !lever.Deleted) return lever; return lever?.Deleted == false ? lever : null;
return null;
} }
public virtual void PuzzleStatus(int message, string fstring) public virtual void PuzzleStatus(int message, string fstring = null)
{ {
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
Item s; Item s;
if ((s = GetStatue(i)) != null) s.PublicOverheadMessage(MessageType.Regular, 0x3B2, message, fstring); if ((s = GetStatue(i)) != null)
s.PublicOverheadMessage(MessageType.Regular, 0x3B2, message, fstring);
} }
} }
public virtual void ResetPuzzle() public virtual void ResetPuzzle()
{ {
PuzzleStatus(1062053, null); PuzzleStatus(1062053);
ResetLevers(); ResetLevers();
} }
@ -289,8 +289,8 @@ namespace Server.Engines.Doom
public virtual void KillTimers() public virtual void KillTimers()
{ {
if (l_Timer != null && l_Timer.Running) l_Timer.Stop(); if (l_Timer?.Running == true) l_Timer.Stop();
if (m_Timer != null && m_Timer.Running) m_Timer.Stop(); if (m_Timer?.Running == true) m_Timer.Stop();
} }
public virtual void RemoveSuccessful() public virtual void RemoveSuccessful()
@ -300,8 +300,7 @@ namespace Server.Engines.Doom
public virtual void LeverPulled(ushort code) public virtual void LeverPulled(ushort code)
{ {
int Correct = 0; int correct = 0;
Mobile m_Player;
KillTimers(); KillTimers();
@ -315,20 +314,21 @@ namespace Server.Engines.Doom
if (!CircleComplete) if (!CircleComplete)
{ {
PuzzleStatus(1050004, null); // The circle is the key... PuzzleStatus(1050004); // The circle is the key...
} }
else else
{ {
Mobile player;
if (TheirKey == MyKey) if (TheirKey == MyKey)
{ {
GenKey(); GenKey();
if ((Successful = m_Player = GetOccupant(0)) != null) if ((Successful = player = GetOccupant(0)) != null)
{ {
SendLocationEffect(lp_Center, 0x1153, 0, 60, 1); SendLocationEffect(lp_Center, 0x1153, 0, 60, 1);
PlaySounds(lp_Center, cs1); PlaySounds(lp_Center, cs1);
Effects.SendBoltEffect(m_Player, true); Effects.SendBoltEffect(player, true);
m_Player.MoveToWorld(lr_Enter, Map.Malas); player.MoveToWorld(lr_Enter, Map.Malas);
m_Timer = new LampRoomTimer(this); m_Timer = new LampRoomTimer(this);
m_Timer.Start(); m_Timer.Start();
@ -339,16 +339,13 @@ namespace Server.Engines.Doom
{ {
for (int i = 0; i < 16; i++) /* Count matching SET bits, ie correct codes */ for (int i = 0; i < 16; i++) /* Count matching SET bits, ie correct codes */
if (((MyKey >> i) & 1) == 1 && ((TheirKey >> i) & 1) == 1) if (((MyKey >> i) & 1) == 1 && ((TheirKey >> i) & 1) == 1)
Correct++; correct++;
PuzzleStatus(Statue_Msg[Correct], Correct > 0 ? Correct.ToString() : null); PuzzleStatus(Statue_Msg[correct], correct > 0 ? correct.ToString() : null);
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
if ((m_Player = GetOccupant(i)) != null) if ((player = GetOccupant(i)) != null)
{ new RockTimer(player, this).Start();
Timer smash = new RockTimer(m_Player, this);
smash.Start();
}
} }
} }
@ -357,33 +354,25 @@ namespace Server.Engines.Doom
public virtual void GenKey() /* Shuffle & build key */ public virtual void GenKey() /* Shuffle & build key */
{ {
ushort tmp;
int n, i;
ushort[] CA = { 1, 2, 4, 8 }; ushort[] CA = { 1, 2, 4, 8 };
for (i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
n = (n = Utility.Random(0, 3)) == i ? n & ~i : n; /* if (i==n) { return pointless; } */ int n = (n = Utility.Random(0, 3)) == i ? n & ~i : n;
tmp = CA[i]; ushort tmp = CA[i];
CA[i] = CA[n]; CA[i] = CA[n];
CA[n] = tmp; CA[n] = tmp;
} }
for (i = 0; i < 4; MyKey = (ushort)(CA[i++] | (MyKey <<= 4))) for (int i = 0; i < 4; MyKey = (ushort)(CA[i++] | (MyKey <<= 4)))
{ {
} }
} }
private static bool IsValidDamagable(Mobile m) private static bool IsValidDamagable(Mobile m)
{ {
if (m != null && !m.Deleted) return m?.Deleted == false &&
{ (m.Player && m.Alive ||
if (m.Player && m.Alive) m is BaseCreature bc && (bc.Controlled || bc.Summoned) && !bc.IsDeadBondedPet);
return true;
return m is BaseCreature bc && (bc.Controlled || bc.Summoned) && !bc.IsDeadBondedPet;
}
return false;
} }
public static void MoveMobileOut(Mobile m) public static void MoveMobileOut(Mobile m)
@ -391,7 +380,7 @@ namespace Server.Engines.Doom
if (m != null) if (m != null)
{ {
if (m is PlayerMobile && !m.Alive) if (m is PlayerMobile && !m.Alive)
if (m.Corpse != null && !m.Corpse.Deleted) if (m.Corpse?.Deleted == false)
m.Corpse.MoveToWorld(lr_Exit, Map.Malas); m.Corpse.MoveToWorld(lr_Exit, Map.Malas);
BaseCreature.TeleportPets(m, lr_Exit, Map.Malas); BaseCreature.TeleportPets(m, lr_Exit, Map.Malas);
m.Location = lr_Exit; m.Location = lr_Exit;
@ -401,7 +390,7 @@ namespace Server.Engines.Doom
public static bool AniSafe(Mobile m) public static bool AniSafe(Mobile m)
{ {
return m != null && !TransformationSpellHelper.UnderTransformation(m) && m.BodyMod == 0 && m.Alive; return m?.BodyMod == 0 && m.Alive && !TransformationSpellHelper.UnderTransformation(m);
} }
public static IEntity ZAdjustedIEFromMobile(Mobile m, int ZDelta) public static IEntity ZAdjustedIEFromMobile(Mobile m, int ZDelta)
@ -411,7 +400,7 @@ namespace Server.Engines.Doom
public static void DoDamage(Mobile m, int min, int max, bool poison) public static void DoDamage(Mobile m, int min, int max, bool poison)
{ {
if (m != null && !m.Deleted && m.Alive) if (m?.Deleted == false && m.Alive)
{ {
int damage = Utility.Random(min, max); int damage = Utility.Random(min, max);
AOS.Damage(m, damage, poison ? 0 : 100, 0, 0, poison ? 100 : 0, 0); AOS.Damage(m, damage, poison ? 0 : 100, 0, 0, poison ? 100 : 0, 0);
@ -559,8 +548,8 @@ namespace Server.Engines.Doom
{ {
IEntity m_IEntity = new Entity(Serial.Zero, RandomPointIn(m_Player.Location, 10), m_Player.Map); IEntity m_IEntity = new Entity(Serial.Zero, RandomPointIn(m_Player.Location, 10), m_Player.Map);
List<Mobile> mobiles = new List<Mobile>(); List<Mobile> mobiles = m_IEntity.Map.GetMobilesInRange(m_IEntity.Location, 2).ToList();
foreach (Mobile m in m_IEntity.Map.GetMobilesInRange(m_IEntity.Location, 2)) mobiles.Add(m);
for (int k = 0; k < mobiles.Count; k++) for (int k = 0; k < mobiles.Count; k++)
if (IsValidDamagable(mobiles[k]) && mobiles[k] != m_Player) if (IsValidDamagable(mobiles[k]) && mobiles[k] != m_Player)
{ {
@ -615,7 +604,7 @@ namespace Server.Engines.Doom
if (ticks >= 71 || m_Controller.m_LampRoom.GetPlayerCount() == 0) if (ticks >= 71 || m_Controller.m_LampRoom.GetPlayerCount() == 0)
{ {
foreach (Mobile mobile in mobiles) foreach (Mobile mobile in mobiles)
if (mobile != null && !mobile.Deleted && !mobile.IsDeadBondedPet) if (mobile?.Deleted == false && !mobile.IsDeadBondedPet)
mobile.Kill(); mobile.Kill();
m_Controller.Enabled = true; m_Controller.Enabled = true;
Stop(); Stop();
@ -637,7 +626,8 @@ namespace Server.Engines.Doom
DoDamage(mobile, 15, 20, true); DoDamage(mobile, 15, 20, true);
} }
if (Utility.Random((int)(level & ~0xfffffffc), 3) == 3) mobile.ApplyPoison(mobile, PA2[level]); if (Utility.Random((int)(level & ~0xfffffffc), 3) == 3)
mobile.ApplyPoison(mobile, PA2[level]);
if (ticks % 12 == 0 && level > 0 && mobile.Player) if (ticks % 12 == 0 && level > 0 && mobile.Player)
mobile.SendLocalizedMessage(PA[level][0], null, PA[level][1]); mobile.SendLocalizedMessage(PA[level][0], null, PA[level][1]);
} }
@ -648,4 +638,4 @@ namespace Server.Engines.Doom
} }
} }
} }
} }

View file

@ -32,7 +32,7 @@ namespace Server.Engines.Doom
{ {
m_Wanderer = new WandererOfTheVoid(); m_Wanderer = new WandererOfTheVoid();
m_Wanderer.MoveToWorld(LeverPuzzleController.lr_Enter, Map.Malas); m_Wanderer.MoveToWorld(LeverPuzzleController.lr_Enter, Map.Malas);
m_Wanderer.PublicOverheadMessage(MessageType.Regular, 0x3B2, 1060002, ""); // I am the guardian of... m_Wanderer.PublicOverheadMessage(MessageType.Regular, 0x3B2, 1060002); // I am the guardian of...
Timer.DelayCall(TimeSpan.FromSeconds(5.0), CallBackMessage); Timer.DelayCall(TimeSpan.FromSeconds(5.0), CallBackMessage);
} }
} }
@ -44,7 +44,7 @@ namespace Server.Engines.Doom
public override void OnAfterDelete() public override void OnAfterDelete()
{ {
if (m_Controller != null && !m_Controller.Deleted) if (m_Controller?.Deleted == false)
m_Controller.Delete(); m_Controller.Delete();
} }
@ -80,7 +80,7 @@ namespace Server.Engines.Doom
public override void OnAfterDelete() public override void OnAfterDelete()
{ {
if (m_Controller != null && !m_Controller.Deleted) if (m_Controller?.Deleted == false)
m_Controller.Delete(); m_Controller.Delete();
} }
@ -134,7 +134,7 @@ namespace Server.Engines.Doom
public override void OnAfterDelete() public override void OnAfterDelete()
{ {
if (m_Controller != null && !m_Controller.Deleted) if (m_Controller?.Deleted == false)
m_Controller.Delete(); m_Controller.Delete();
} }
@ -202,4 +202,4 @@ namespace Server.Engines.Doom
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

View file

@ -5,12 +5,12 @@ namespace Server.Engines.Doom
{ {
public class LampRoomRegion : BaseRegion public class LampRoomRegion : BaseRegion
{ {
private LeverPuzzleController Controller; private LeverPuzzleController m_Controller;
public LampRoomRegion(LeverPuzzleController controller) public LampRoomRegion(LeverPuzzleController controller)
: base(null, Map.Malas, Find(LeverPuzzleController.lr_Enter, Map.Malas), LeverPuzzleController.lr_Rect) : base(null, Map.Malas, Find(LeverPuzzleController.lr_Enter, Map.Malas), LeverPuzzleController.lr_Rect)
{ {
Controller = controller; m_Controller = controller;
Register(); Register();
} }
@ -38,13 +38,13 @@ namespace Server.Engines.Doom
if (m.AccessLevel > AccessLevel.Player) if (m.AccessLevel > AccessLevel.Player)
return; return;
if (Controller.Successful != null) if (m_Controller.Successful != null)
{ {
if (m is PlayerMobile) if (m is PlayerMobile)
{ {
if (m == Controller.Successful) return; if (m == m_Controller.Successful) return;
} }
else if (m is BaseCreature bc && (bc.Controlled && bc.ControlMaster == Controller.Successful || else if (m is BaseCreature bc && (bc.Controlled && bc.ControlMaster == m_Controller.Successful ||
bc.Summoned)) bc.Summoned))
{ {
return; return;
@ -57,49 +57,36 @@ namespace Server.Engines.Doom
public override void OnExit(Mobile m) public override void OnExit(Mobile m)
{ {
if (m != null && m == Controller.Successful) if (m != null && m == m_Controller.Successful)
Controller.RemoveSuccessful(); m_Controller.RemoveSuccessful();
} }
public override void OnDeath(Mobile m) public override void OnDeath(Mobile m)
{ {
if (m != null && !m.Deleted && !(m is WandererOfTheVoid)) if (m?.Deleted != false || m is WandererOfTheVoid)
{ return;
Timer kick = new LeverPuzzleController.LampRoomKickTimer(m); Timer kick = new LeverPuzzleController.LampRoomKickTimer(m);
kick.Start(); kick.Start();
}
} }
public override bool OnSkillUse(Mobile m, int Skill) /* just in case */ public override bool OnSkillUse(Mobile m, int Skill) /* just in case */
{ {
if (Controller.Successful == null || m.AccessLevel == AccessLevel.Player && m != Controller.Successful) return m_Controller.Successful != null && (m.AccessLevel != AccessLevel.Player || m == m_Controller.Successful);
return false;
return true;
} }
} }
public class LeverPuzzleRegion : BaseRegion public class LeverPuzzleRegion : BaseRegion
{ {
private LeverPuzzleController Controller;
public Mobile m_Occupant; public Mobile m_Occupant;
public LeverPuzzleRegion(LeverPuzzleController controller, int[] loc) public LeverPuzzleRegion(LeverPuzzleController controller, int[] loc)
: base(null, Map.Malas, Find(LeverPuzzleController.lr_Enter, Map.Malas), new Rectangle2D(loc[0], loc[1], 1, 1)) : base(null, Map.Malas, Find(LeverPuzzleController.lr_Enter, Map.Malas), new Rectangle2D(loc[0], loc[1], 1, 1))
{ {
Controller = controller;
Register(); Register();
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public Mobile Occupant public Mobile Occupant => m_Occupant?.Alive == true ? m_Occupant : null;
{
get
{
if (m_Occupant != null && m_Occupant.Alive)
return m_Occupant;
return null;
}
}
public override void OnEnter(Mobile m) public override void OnEnter(Mobile m)
{ {
@ -113,4 +100,4 @@ namespace Server.Engines.Doom
m_Occupant = null; m_Occupant = null;
} }
} }
} }

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Linq;
using Server.Ethics.Evil; using Server.Ethics.Evil;
using Server.Ethics.Hero; using Server.Ethics.Hero;
using Server.Items; using Server.Items;
@ -126,16 +127,7 @@ namespace Server.Ethics
if (!Insensitive.Equals(ethic.Definition.JoinPhrase.String, e.Speech)) if (!Insensitive.Equals(ethic.Definition.JoinPhrase.String, e.Speech))
continue; continue;
bool isNearAnkh = false; if (!e.Mobile.GetItemsInRange(2).Any(item => item is AnkhNorth || item is AnkhWest))
foreach (Item item in e.Mobile.GetItemsInRange(2))
if (item is AnkhNorth || item is AnkhWest)
{
isNearAnkh = true;
break;
}
if (!isNearAnkh)
continue; continue;
pl = new Player(ethic, e.Mobile); pl = new Player(ethic, e.Mobile);
@ -239,4 +231,4 @@ namespace Server.Ethics
m_Players[i].Serialize(writer); m_Players[i].Serialize(writer);
} }
} }
} }

View file

@ -8,7 +8,7 @@ namespace Server.Ethics
{ {
Movable = false; Movable = false;
if (Instance == null || Instance.Deleted) if (Instance?.Deleted != false)
Instance = this; Instance = this;
else else
base.Delete(); base.Delete();
@ -56,4 +56,4 @@ namespace Server.Ethics
{ {
} }
} }
} }

View file

@ -104,7 +104,7 @@ namespace Server.Ethics
Player pl = pm.EthicPlayer; Player pl = pm.EthicPlayer;
if (pl != null && !pl.Ethic.IsEligible(pl.Mobile)) if (pl?.Ethic.IsEligible(pl.Mobile) == false)
pm.EthicPlayer = pl = null; pm.EthicPlayer = pl = null;
return pl; return pl;
@ -157,4 +157,4 @@ namespace Server.Ethics
writer.WriteDeltaTime(m_Shield); writer.WriteDeltaTime(m_Shield);
} }
} }
} }

View file

@ -18,7 +18,7 @@ namespace Server.Ethics.Evil
public override void BeginInvoke(Player from) public override void BeginInvoke(Player from)
{ {
if (from.Familiar != null && from.Familiar.Deleted) if (from.Familiar?.Deleted == true)
from.Familiar = null; from.Familiar = null;
if (from.Familiar != null) if (from.Familiar != null)
@ -43,4 +43,4 @@ namespace Server.Ethics.Evil
} }
} }
} }
} }

View file

@ -18,7 +18,7 @@ namespace Server.Ethics.Evil
public override void BeginInvoke(Player from) public override void BeginInvoke(Player from)
{ {
if (from.Steed != null && from.Steed.Deleted) if (from.Steed?.Deleted == true)
from.Steed = null; from.Steed = null;
if (from.Steed != null) if (from.Steed != null)
@ -43,4 +43,4 @@ namespace Server.Ethics.Evil
} }
} }
} }
} }

View file

@ -18,7 +18,7 @@ namespace Server.Ethics.Hero
public override void BeginInvoke(Player from) public override void BeginInvoke(Player from)
{ {
if (from.Steed != null && from.Steed.Deleted) if (from.Steed?.Deleted == true)
from.Steed = null; from.Steed = null;
if (from.Steed != null) if (from.Steed != null)
@ -43,4 +43,4 @@ namespace Server.Ethics.Hero
} }
} }
} }
} }

View file

@ -18,7 +18,7 @@ namespace Server.Ethics.Hero
public override void BeginInvoke(Player from) public override void BeginInvoke(Player from)
{ {
if (from.Familiar != null && from.Familiar.Deleted) if (from.Familiar?.Deleted == true)
from.Familiar = null; from.Familiar = null;
if (from.Familiar != null) if (from.Familiar != null)
@ -43,4 +43,4 @@ namespace Server.Ethics.Hero
} }
} }
} }
} }

View file

@ -550,4 +550,4 @@ namespace Server.Factions
Campaign, Campaign,
Election Election
} }
} }

Some files were not shown because too many files have changed in this diff Show more