Skip to content

Commit

Permalink
Merge pull request #1 from ZaneDubya/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
msx752 authored Nov 6, 2016
2 parents f80d15e + 3266ffb commit 1b4383b
Show file tree
Hide file tree
Showing 113 changed files with 3,461 additions and 3,124 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ UltimaXNA is an isometric massively multiplayer online role playing client that

**Getting started**

You should use [Visual Studio 2013](https://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx) to develop and compile UltimaXNA. You will also need to install [XNA for Visual Studio 2013](https://msxna.codeplex.com/releases/view/117230).
You should use [Visual Studio 2015](https://www.visualstudio.com/vs/community/) to develop and compile UltimaXNA. You will also need to install [XNA for Visual Studio 2015](https://blogs.msdn.microsoft.com/uk_faculty_connection/2015/11/02/installing-xna-with-visual-studio-2015/).

UltimaXNA does not include the Ultima Online resource files, and will not work on a computer that does not have Ultima Online installed. UltimaXNA is compatible with any Ultima Online client prior to the introduction of the UOP resource format, including Mondain's Legacy. [Download the client files for Mondain's Legacy here](http://games.mirrors.tds.net/pub/ea-games/uo/uoml_setup.exe).
UltimaXNA does not include the Ultima Online resource files, and will not work on a computer that does not have Ultima Online installed. UltimaXNA is compatible with any Ultima Online client prior to the introduction of the UOP resource format, including Mondain's Legacy. [Download the client files for Mondain's Legacy here](http://download.cnet.com/Ultima-Online-Mondain-s-Legacy-client/3000-7540_4-10432237.html).

UltimaXNA is designed to work with all server software. The recommended installation is RunUO 2.3, [which you can download here](https://code.google.com/p/runuo/downloads/list).
UltimaXNA is designed to work with all server software, but we test exclusively on RunUO 2.6, [which you can download here](https://github.com/runuo/runuo/releases). Note that you will [need to change three lines of the RunUO server scripts](https://github.com/ZaneDubya/UltimaXNA/wiki) to allow it to work with Mondain's Legacy resource files.
28 changes: 12 additions & 16 deletions dev/Configuration/UltimaOnlineSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
*
***************************************************************************/
#region usings
using System.Collections;
using System.Collections.Generic;
using UltimaXNA.Core.Configuration;
using UltimaXNA.Ultima.Data;
#endregion

namespace UltimaXNA.Configuration
Expand All @@ -25,29 +24,26 @@ public sealed class UltimaOnlineSettings : ASettingsSection

public UltimaOnlineSettings()
{
// NOTE FROM ZaneDubya: DO NOT CHANGE ClientVersion from 6.0.6.2.
// We are focusing our efforts on getting a specific version of the client working.
// Once we have this version working, we will attempt to support additional versions.
// We will not support any issues you experience after changing this value.
ClientVersion = new byte[] {6, 0, 6, 2};
PatchVersion = ClientVersion.DefaultVersion;
}

/// <summary>
/// The patch version which is sent to the server. Hardcoded to 6.0.6.2.
/// RunUO (and possibly other server software) rely on the client's reported
/// patch version to enable/disable certain packets and features. You WILL have
/// issues if you change this out of a given range of supported values.
/// The patch version which is sent to the server. RunUO (and possibly other server software)
/// rely on the client's reported patch version to enable/disable certain packets and features.
/// </summary>
public byte[] ClientVersion
public byte[] PatchVersion
{
get { return m_ClientVersion; }
get {
if (m_ClientVersion == null || m_ClientVersion.Length != 4)
return ClientVersion.DefaultVersion;
return m_ClientVersion;
}
set
{
if (value == null || value.Length != 4)
return;
// Do not remove this check. See above.
if (value[0] != 6 || value[1] != 0 || value[2] != 6 || value[3] != 2)
return;
// Note from ZaneDubya: I will not support your client if you change or remove this line:
if (!ClientVersion.EqualTo(value, ClientVersion.DefaultVersion)) return;
SetProperty(ref m_ClientVersion, value);
}
}
Expand Down
25 changes: 20 additions & 5 deletions dev/Configuration/UserInterfaceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ public class UserInterfaceSettings : ASettingsSection
private bool m_AlwaysRun;
private bool m_MenuBarDisabled;

private int m_SpeechColor;
private int m_EmoteColor;
private int m_PartyMsgColor;
private int m_GuildMsgColor;
private int m_SpeechColor = 4 * Utility.RandomValue(0, 99) * 5;
private int m_EmoteColor = 646;
private int m_PartyMsgPrivateColor = 58;
private int m_PartyMsgColor = 68;
private int m_GuildMsgColor = 70;
private bool m_IgnoreGuildMsg;
private int m_AllianceMsgColor;
private int m_AllianceMsgColor = 487;
private bool m_IgnoreAllianceMsg;
private bool m_CrimeQuery;

public UserInterfaceSettings()
{
Expand All @@ -48,6 +50,7 @@ public UserInterfaceSettings()
Mouse = new MouseProperty();
AlwaysRun = false;
MenuBarDisabled = false;
CrimeQuery = true;
}

public bool IsMaximized
Expand Down Expand Up @@ -120,6 +123,12 @@ public int EmoteColor
set { SetProperty(ref m_EmoteColor, Clamp(value, 0, HueData.HueCount - 1)); }
}

public int PartyPrivateMsgColor
{
get { return m_PartyMsgPrivateColor; }
set { SetProperty(ref m_PartyMsgPrivateColor, Clamp(value, 0, HueData.HueCount - 1)); }
}

public int PartyMsgColor
{
get { return m_PartyMsgColor; }
Expand Down Expand Up @@ -149,5 +158,11 @@ public bool IgnoreAllianceMsg
get { return m_IgnoreAllianceMsg; }
set { SetProperty(ref m_IgnoreAllianceMsg, value); }
}

public bool CrimeQuery
{
get { return m_CrimeQuery; }
set { SetProperty(ref m_CrimeQuery, value); }
}
}
}
16 changes: 11 additions & 5 deletions dev/Core/Audio/ASound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ namespace UltimaXNA.Core.Audio
abstract class ASound : IDisposable
{
public string Name { get; private set; }
public DateTime LastPlayed = DateTime.MinValue;
public static TimeSpan MinimumDelay = TimeSpan.FromSeconds(1d);

abstract protected byte[] GetBuffer();
abstract protected void OnBufferNeeded(object sender, EventArgs e);
virtual protected void AfterStop() { }
virtual protected void BeforePlay() { }

private static List<Tuple<DynamicSoundEffectInstance, double>> m_EffectInstances;
private static List<Tuple<DynamicSoundEffectInstance, double>> m_MusicInstances;
static List<Tuple<DynamicSoundEffectInstance, double>> m_EffectInstances;
static List<Tuple<DynamicSoundEffectInstance, double>> m_MusicInstances;
protected DynamicSoundEffectInstance m_ThisInstance;

protected int Frequency = 22050;
Expand Down Expand Up @@ -61,27 +63,31 @@ public void Dispose()
/// Plays the effect.
/// </summary>
/// <param name="asEffect">Set to false for music, true for sound effects.</param>
public void Play(bool asEffect, AudioEffects effect = AudioEffects.None, float volume = 1.0f)
public void Play(bool asEffect, AudioEffects effect = AudioEffects.None, float volume = 1.0f, bool spamCheck = false)
{
double now = UltimaGame.TotalMS;
CullExpiredEffects(now);

if (spamCheck && (LastPlayed + MinimumDelay > DateTime.Now))
return;

m_ThisInstance = GetNewInstance(asEffect);
if (m_ThisInstance == null)
{
this.Dispose();
Dispose();
return;
}

switch (effect)
{
case AudioEffects.PitchVariation:
float pitch = (float)Utility.RandomValue(-5, 5) * .025f;
float pitch = Utility.RandomValue(-5, 5) * .025f;
m_ThisInstance.Pitch = pitch;
break;
}

BeforePlay();
LastPlayed = DateTime.Now;

byte[] buffer = GetBuffer();
if (buffer != null && buffer.Length > 0)
Expand Down
4 changes: 2 additions & 2 deletions dev/Core/Audio/MP3Sharp/MP3Stream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public bool IsEOF
/// Creates a new stream instance using the provided filename, and the default chunk size of 4096 bytes.
/// </summary>
public MP3Stream(string fileName)
: this(new FileStream(fileName, FileMode.Open))
: this(new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
}

/// <summary>
/// Creates a new stream instance using the provided filename and chunk size.
/// </summary>
public MP3Stream(string fileName, int chunkSize)
: this(new FileStream(fileName, FileMode.Open), chunkSize)
: this(new FileStream(fileName, FileMode.Open, FileAccess.Read), chunkSize)
{
}

Expand Down
2 changes: 1 addition & 1 deletion dev/Core/Configuration/SettingsFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public SettingsFile(string filename)
m_SectionCache = new Dictionary<string, ASettingsSection>();
m_SaveTimer = new Timer
{
Interval = 1000, // save settings every 1 second
Interval = 10000, // save settings every 10 seconds
AutoReset = true
};
m_SaveTimer.Elapsed += OnTimerElapsed;
Expand Down
6 changes: 3 additions & 3 deletions dev/Core/Graphics/SpriteBatch3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace UltimaXNA.Core.Graphics
{
public class SpriteBatch3D
{
private const int MAX_VERTICES_PER_DRAW = 0x2000;
private const int MAX_VERTICES_PER_DRAW = 0x4000;
private const int INITIAL_TEXTURE_COUNT = 0x800;
private const float MAX_ACCURATE_SINGLE_FLOAT = 65536; // this number is somewhat arbitrary; it's the number at which the
// difference between two subsequent integers is +/-0.005. See http://stackoverflow.com/questions/872544/precision-of-floating-point
Expand Down Expand Up @@ -221,7 +221,7 @@ private void DrawAllVertices(Techniques first, Techniques last)
List<VertexPositionNormalTextureHue> vertexList = vertexEnumerator.Current.Value;
GraphicsDevice.Textures[0] = texture;

GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, CopyVerticesToArray(vertexList), 0, vertexList.Count, m_IndexBuffer, 0, vertexList.Count / 2);
GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, CopyVerticesToArray(vertexList), 0, Math.Min(vertexList.Count,MAX_VERTICES_PER_DRAW), m_IndexBuffer, 0, vertexList.Count / 2);
vertexList.Clear();
m_VertexListQueue.Enqueue(vertexList);
}
Expand Down Expand Up @@ -305,4 +305,4 @@ private short[] CreateIndexBuffer(int primitiveCount)
return indices;
}
}
}
}
21 changes: 7 additions & 14 deletions dev/Core/Patterns/IModule.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
using UltimaXNA.Core.Diagnostics.Tracing;

namespace UltimaXNA.Core.Patterns
{
public interface IModule
{
string Name
{
namespace UltimaXNA.Core.Patterns {
public interface IModule {
string Name {
get;
}

void Load();
void Unload();
}

public abstract class Module : IModule
{
public virtual string Name
{
public abstract class Module : IModule {
public virtual string Name {
get { return GetType().Name; }
}

public void Load()
{
public void Load() {
Tracer.Info("Loading Module {0}.", Name);
OnLoad();
}

public void Unload()
{
public void Unload() {
Tracer.Info("Unloading Module {0}.", Name);
OnUnload();
}
Expand Down
39 changes: 11 additions & 28 deletions dev/Core/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,56 +18,39 @@
using UltimaXNA.Core.Patterns;
#endregion

namespace UltimaXNA.Core
{
class PluginManager
{
private List<IModule> m_Modules = new List<IModule>();
namespace UltimaXNA.Core {
class PluginManager {
List<IModule> m_Modules = new List<IModule>();

public PluginManager(string baseAppPath)
{
public PluginManager(string baseAppPath) {
Configure(baseAppPath);
}

private void Configure(string baseAppPath)
{
void Configure(string baseAppPath) {
DirectoryInfo directory = new DirectoryInfo(Path.Combine(baseAppPath, "plugins"));

if (!directory.Exists)
{
if (!directory.Exists) {
return;
}

FileInfo[] assemblies = directory.GetFiles("*.dll");

foreach (FileInfo file in assemblies)
{
try
{
foreach (FileInfo file in assemblies) {
try {
Tracer.Info("Loading plugin {0}.", file.Name);

Assembly assembly = Assembly.LoadFile(file.FullName);
IEnumerable<Type> modules = assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IModule)));

foreach (Type module in modules)
{
foreach (Type module in modules) {
Tracer.Info("Activating module {0}.", module.FullName);

IModule instance = (IModule)Activator.CreateInstance(module);

LoadModule(instance);
}
}
catch (Exception e)
{
catch (Exception e) {
Tracer.Warn("An error occurred while trying to load plugin. [{0}]", file.FullName);
Tracer.Warn(e);
}
}
}

private void LoadModule(IModule module)
{
void LoadModule(IModule module) {
m_Modules.Add(module);
module.Load();
}
Expand Down
11 changes: 1 addition & 10 deletions dev/Core/UI/AControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,7 @@ public bool IsUncloseableWithEsc
/// </summary>
public bool IsVisible { get; set; }

private bool _isedit = true;

public bool IsEditable
{
get { return _isedit; }
set
{
_isedit = value;
}
}
public bool IsEditable { get; set; }

/// <summary>
/// A list of all the child controls that this control owns.
Expand Down
2 changes: 1 addition & 1 deletion dev/Core/UI/HTML/HtmlDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ private void LayoutElements_BreakWordAtLineEnd(List<AElement> elements, int star
width += word[i].Width;
if (width >= lineWidth)
{
elements.Insert(start + i + 1, lineend);
elements.Insert(start + i, lineend); // start + i + 1
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions dev/Core/UI/UserInterfaceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public void Update(double totalMS, double frameMS)
for (int i = 0; i < m_Controls.Count; i++)
{
AControl c = m_Controls[i];
if (!c.IsInitialized)
if (!c.IsInitialized && !c.IsDisposed)
c.Initialize();
c.Update(totalMS, frameMS);
}
Expand Down Expand Up @@ -640,7 +640,7 @@ private void ClipMouse(ref Point position)
position.X = -8;
if (position.Y < -8)
position.Y = -8;
if (position.Y >= Width + 8)
if (position.X >= Width + 8)
position.X = Width + 8;
if (position.Y >= Height + 8)
position.Y = Height + 8;
Expand Down
2 changes: 1 addition & 1 deletion dev/Data/bodytable.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
49 Monster
50 Monster
51 Monster
52 Animal
52 Monster
53 Monster
54 Monster
55 Monster
Expand Down
Loading

0 comments on commit 1b4383b

Please sign in to comment.