Modernization Fixes & Updates to Default Values (#3)

This commit is contained in:
Kamron Batman 2018-10-28 00:33:16 -07:00 • committed by GitHub
parent 445eddff68
commit dcf64091b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
768 changed files with 10507 additions and 14196 deletions

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using Server.Gumps;
using Server.Network;
@ -7,18 +6,16 @@ namespace Server.Engines.ConPVP
{
public class PreferencesController : Item
{
private Preferences m_Preferences;
[Constructible]
public PreferencesController() : base(0x1B7A)
{
Visible = false;
Movable = false;
m_Preferences = new Preferences();
Preferences = new Preferences();
if (Preferences.Instance == null)
Preferences.Instance = m_Preferences;
Preferences.Instance = Preferences;
else
Delete();
}
@ -27,18 +24,14 @@ namespace Server.Engines.ConPVP
{
}
//[CommandProperty( AccessLevel.GameMaster )]
public Preferences Preferences
{
get => m_Preferences;
set { }
}
[CommandProperty( AccessLevel.Administrator )]
public Preferences Preferences{ get; private set; }
public override string DefaultName => "preferences controller";
public override void Delete()
{
if (Preferences.Instance != m_Preferences)
if (Preferences.Instance != Preferences)
base.Delete();
}
@ -48,7 +41,7 @@ namespace Server.Engines.ConPVP
writer.Write(0);
m_Preferences.Serialize(writer);
Preferences.Serialize(writer);
}
public override void Deserialize(GenericReader reader)
@ -61,8 +54,8 @@ namespace Server.Engines.ConPVP
{
case 0:
{
m_Preferences = new Preferences(reader);
Preferences.Instance = m_Preferences;
Preferences = new Preferences(reader);
Preferences.Instance = Preferences;
break;
}
}
@ -71,12 +64,12 @@ namespace Server.Engines.ConPVP
public class Preferences
{
private Hashtable m_Table;
private Dictionary<Mobile, PreferencesEntry> m_Table;
public Preferences()
{
m_Table = new Hashtable();
Entries = new ArrayList();
m_Table = new Dictionary<Mobile, PreferencesEntry>();
Entries = new List<PreferencesEntry>();
}
public Preferences(GenericReader reader)
@ -89,12 +82,12 @@ namespace Server.Engines.ConPVP
{
int count = reader.ReadEncodedInt();
m_Table = new Hashtable(count);
Entries = new ArrayList(count);
m_Table = new Dictionary<Mobile, PreferencesEntry>(count);
Entries = new List<PreferencesEntry>(count);
for (int i = 0; i < count; ++i)
{
PreferencesEntry entry = new PreferencesEntry(reader, this, version);
PreferencesEntry entry = new PreferencesEntry(reader, version);
if (entry.Mobile != null)
{
@ -108,17 +101,17 @@ namespace Server.Engines.ConPVP
}
}
public ArrayList Entries{ get; }
public List<PreferencesEntry> Entries{ get; }
public static Preferences Instance{ get; set; }
public PreferencesEntry Find(Mobile mob)
{
PreferencesEntry entry = (PreferencesEntry)m_Table[mob];
PreferencesEntry entry = m_Table[mob];
if (entry == null)
{
m_Table[mob] = entry = new PreferencesEntry(mob, this);
m_Table[mob] = entry = new PreferencesEntry(mob);
Entries.Add(entry);
}
@ -132,25 +125,20 @@ namespace Server.Engines.ConPVP
writer.WriteEncodedInt(Entries.Count);
for (int i = 0; i < Entries.Count; ++i)
((PreferencesEntry)Entries[i]).Serialize(writer);
Entries[i].Serialize(writer);
}
}
public class PreferencesEntry
{
private Preferences m_Preferences;
public PreferencesEntry(Mobile mob, Preferences prefs)
public PreferencesEntry(Mobile mob)
{
m_Preferences = prefs;
Mobile = mob;
Disliked = new ArrayList();
Disliked = new List<string>();
}
public PreferencesEntry(GenericReader reader, Preferences prefs, int version)
public PreferencesEntry(GenericReader reader, int version)
{
m_Preferences = prefs;
switch (version)
{
case 0:
@ -159,7 +147,7 @@ namespace Server.Engines.ConPVP
int count = reader.ReadEncodedInt();
Disliked = new ArrayList(count);
Disliked = new List<string>(count);
for (int i = 0; i < count; ++i)
Disliked.Add(reader.ReadString());
@ -171,7 +159,7 @@ namespace Server.Engines.ConPVP
public Mobile Mobile{ get; }
public ArrayList Disliked{ get; }
public List<string> Disliked{ get; }
public void Serialize(GenericWriter writer)
{
@ -180,7 +168,7 @@ namespace Server.Engines.ConPVP
writer.WriteEncodedInt(Disliked.Count);
for (int i = 0; i < Disliked.Count; ++i)
writer.Write((string)Disliked[i]);
writer.Write(Disliked[i]);
}
}
@ -188,11 +176,9 @@ namespace Server.Engines.ConPVP
{
private int m_ColumnX = 12;
private PreferencesEntry m_Entry;
private Mobile m_From;
public PreferencesGump(Mobile from, Preferences prefs) : base(50, 50)
{
m_From = from;
m_Entry = prefs.Find(from);
if (m_Entry == null)
@ -221,10 +207,7 @@ namespace Server.Engines.ConPVP
{
Arena ar = arenas[i];
string name = ar.Name;
if (name == null)
name = "(no name)";
string name = ar.Name ?? "(no name)";
int x = 12;
int y = 32 + i * 31;
@ -235,7 +218,6 @@ namespace Server.Engines.ConPVP
x += 35;
AddBorderedText(x + 5, y + 5, 115 - 5, name, color, 0);
x += 115;
}
}
@ -272,12 +254,6 @@ namespace Server.Engines.ConPVP
private void AddBorderedText(int x, int y, int width, string text, int color, int borderColor)
{
/*AddColoredText( x - 1, y, width, text, borderColor );
AddColoredText( x + 1, y, width, text, borderColor );
AddColoredText( x, y - 1, width, text, borderColor );
AddColoredText( x, y + 1, width, text, borderColor );*/
/*AddColoredText( x - 1, y - 1, width, text, borderColor );
AddColoredText( x + 1, y + 1, width, text, borderColor );*/
AddColoredText(x, y, width, text, color);
}