Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public List<IDatabaseObject> ValueList
}
catch (Exception exception)
{
Log.Warn(
LegacyLogging.Logger?.Warn(
exception,
$@"{StoredType.Name}[Count={mIdMap.Count},NullCount={mIdMap.Count(pair => pair.Value == null)}]"
);
Expand Down Expand Up @@ -363,10 +363,10 @@ internal virtual bool InternalSet(IDatabaseObject value, bool overwrite)

private static string MessageNoConstructor(Type type, params string[] constructorMessage)
{
var joinedConstructorMessage = string.Join(",", constructorMessage ?? new string[] { });
var joinedConstructorMessage = string.Join(',', constructorMessage);
var builder = new StringBuilder();
builder.AppendLine($@"No ({joinedConstructorMessage}) constructor for type '{type?.Name}'.");
builder.AppendLine(ReflectionUtils.StringifyConstructors(type));
builder.AppendLine($@"No ({joinedConstructorMessage}) constructor for type '{type.Name}'.");
builder.AppendLine(type.StringifyConstructors());

return builder.ToString();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Intersect.Collections;

public static partial class ListExtensions
{
public static IReadOnlyList<T> WrapReadOnly<T>(this IList<T> list) =>
new ReadOnlyList<T>(list);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,4 @@ public partial class ReadOnlyList<T> : IReadOnlyList<T>

public ReadOnlyList(IList<T> backingList) =>
this.backingList = backingList;
}

public static partial class ListExtensions
{
public static IReadOnlyList<T> WrapReadOnly<T>(this IList<T> list) =>
new ReadOnlyList<T>(list);
}
}
File renamed without changes.
38 changes: 38 additions & 0 deletions Framework/Intersect.Framework.Core/Compression/IAssetPacker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Intersect.Compression;

public interface IAssetPacker : IDisposable
{
/// <summary>
/// The location given at the creation of this object defining where we can find our asset packs.
/// </summary>
string PackageLocation { get; }

/// <summary>
/// A list of all packages currently being cached.
/// </summary>
List<string> CachedPackages { get; }

/// <summary>
/// A list of all files contained within the asset packs.
/// </summary>
List<string> FileList { get; }

/// <summary>
/// Retrieve an asset from the asset packages.
/// </summary>
/// <param name="fileName">The asset to retrieve.</param>
/// <returns>Returns a <see cref="MemoryStream"/> containing the requested file.</returns>
MemoryStream GetAsset(string fileName);

/// <summary>
/// Checks whether or not an asset is contained within the loaded index file. This check is case insensitive!
/// </summary>
/// <param name="fileName">The file to look for.</param>
/// <returns>Returns whether or not the file was found in the loaded Asset Packs.</returns>
bool Contains(string fileName);

/// <summary>
/// Updates our cache timers and disposes of items no longer within the caching time limit.
/// </summary>
void UpdateCache();
}
39 changes: 39 additions & 0 deletions Framework/Intersect.Framework.Core/Config/FloodThreshholds.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace Intersect.Config;

public partial class FloodThreshholds
{
/// <summary>
/// The largest a single packet should be before it's considered flooding.
/// </summary>
public int MaxPacketSize { get; set; } = 10240;

/// <summary>
/// The maximum number of packets we should receive from a cient before we consider them to be flooding.
/// </summary>
public int MaxPacketPerSec { get; set; } = 50;

/// <summary>
/// The number of packets received per second on average that we will accept before kicking the client for flooding.
/// </summary>
public int KickAvgPacketPerSec { get; set; } = 30;

public static FloodThreshholds Editor()
{
return new FloodThreshholds()
{
MaxPacketSize = int.MaxValue,
MaxPacketPerSec = int.MaxValue,
KickAvgPacketPerSec = int.MaxValue
};
}

public static FloodThreshholds NotLoggedIn()
{
return new FloodThreshholds()
{
MaxPacketSize = 10240,
MaxPacketPerSec = 5,
KickAvgPacketPerSec = 3,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ public static bool LoadFromDisk()
Instance.SmtpValid = Instance.SmtpSettings.IsValid();
Instance.SendingToClient = false;
Instance.FixAnimatedSprites();
Log.Default.Configuration.LogLevel = Instance.Logging.Level;
File.WriteAllText(configPath, JsonConvert.SerializeObject(Instance, Formatting.Indented));
Instance.SendingToClient = true;
optionsCompressed = JsonConvert.SerializeObject(Instance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,42 +76,4 @@ public partial class PacketSecurityOptions
[JsonProperty("FloodThreshholds")]
public FloodThreshholds Threshholds = FloodThreshholds.NotLoggedIn();
#endregion
}

public partial class FloodThreshholds
{
/// <summary>
/// The largest a single packet should be before it's considered flooding.
/// </summary>
public int MaxPacketSize { get; set; } = 10240;

/// <summary>
/// The maximum number of packets we should receive from a cient before we consider them to be flooding.
/// </summary>
public int MaxPacketPerSec { get; set; } = 50;

/// <summary>
/// The number of packets received per second on average that we will accept before kicking the client for flooding.
/// </summary>
public int KickAvgPacketPerSec { get; set; } = 30;

public static FloodThreshholds Editor()
{
return new FloodThreshholds()
{
MaxPacketSize = int.MaxValue,
MaxPacketPerSec = int.MaxValue,
KickAvgPacketPerSec = int.MaxValue
};
}

public static FloodThreshholds NotLoggedIn()
{
return new FloodThreshholds()
{
MaxPacketSize = 10240,
MaxPacketPerSec = 5,
KickAvgPacketPerSec = 3,
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Intersect.Enums;
using Intersect.Logging;
using Intersect.Models;
using Intersect.Utilities;
using Newtonsoft.Json;

Expand All @@ -14,6 +15,11 @@ namespace Intersect.Configuration;
/// </summary>
public sealed partial class ClientConfiguration : IConfiguration<ClientConfiguration>
{
public ClientConfiguration()
{
ConfigurationHelper.CacheName = $"{Host}.{Port}";
}

public static string ResourcesDirectory { get; set; } = "resources";

public static string DefaultPath => Path.Combine(ResourcesDirectory, "config.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace Intersect.Configuration;

public static partial class ConfigurationHelper
{
public static string CacheName { get; set; } = default!;

public static T Load<T>(T configuration, string filePath, bool failQuietly = false)
where T : IConfiguration<T>
{
Expand All @@ -27,7 +29,7 @@ public static T Load<T>(T configuration, string filePath, bool failQuietly = fal
}
catch (Exception exception)
{
Log.Error(exception);
LegacyLogging.Logger?.Error(exception);

throw;
}
Expand Down Expand Up @@ -57,7 +59,7 @@ public static T Save<T>(T configuration, string filePath, bool failQuietly = fal
}
catch (Exception exception)
{
Log.Error(exception);
LegacyLogging.Logger?.Error(exception);

throw;
}
Expand All @@ -77,7 +79,7 @@ public static T LoadSafely<T>(T configuration, string filePath = null)
}
catch (Exception exception)
{
Log.Warn(exception);
LegacyLogging.Logger?.Warn(exception);
}
finally
{
Expand All @@ -87,7 +89,7 @@ public static T LoadSafely<T>(T configuration, string filePath = null)
}
catch (Exception exception)
{
Log.Error(exception);
LegacyLogging.Logger?.Error(exception);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface IApplicationContext : IDisposable
/// <summary>
/// The application-specific logger.
/// </summary>
Logger Logger { get; }
ILogger Logger { get; }

/// <summary>
/// The network helper for the application.
Expand Down Expand Up @@ -66,5 +66,5 @@ public interface IApplicationContext : IDisposable
/// Start the application with a <see cref="LockingActionQueue"/>.
/// </summary>
/// <returns>the <see cref="LockingActionQueue"/> instance being used</returns>
LockingActionQueue StartWithActionQueue();
ILockingActionQueue StartWithActionQueue();
}
22 changes: 22 additions & 0 deletions Framework/Intersect.Framework.Core/Direction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Intersect.Enums;

public enum Direction
{
None = -1,

Up,

Down,

Left,

Right,

UpLeft,

UpRight,

DownRight,

DownLeft,
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,6 @@

namespace Intersect.Enums;

public enum Direction
{
None = -1,

Up,

Down,

Left,

Right,

UpLeft,

UpRight,

DownRight,

DownLeft,
}

public static class DirectionExtensions
{
public static Direction GetOpposite(this Direction direction) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace Intersect.Server.Utilities;

public partial class ExperienceCurve
{

public const string DEFAULT_EXPERIENCE_FORMULA = "Floor(BaseExp * Pow(Gain, Level - 1))";

public const string PARAM_BASE_EXP = "BaseExp";
Expand Down Expand Up @@ -46,7 +45,7 @@ protected virtual void Exp(FunctionArgs args)
{
if (args.Parameters == null || args.Parameters.Length < 3)
{
Log.Error("Tried to execute Exp with fewer than three arguments.");
LegacyLogging.Logger?.Error("Tried to execute Exp with fewer than three arguments.");
args.Result = 0L;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;

using Intersect.Models;

using Microsoft.EntityFrameworkCore;
Expand All @@ -21,7 +20,7 @@ public AnimationLayer()
}
}

public string Sprite { get; set; } = "";
public string Sprite { get; set; } = string.Empty;

public int FrameCount { get; set; } = 1;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Globalization;
using System.Reflection;

using Intersect.Framework.Reflection;
using Intersect.Localization;
using Intersect.Reflection;

#if !DEBUG
using Intersect.Logging;
Expand Down Expand Up @@ -48,7 +47,7 @@ public override string Format(Type stringsType, object value)
#if DEBUG
throw error;
#else
Log.Error(error);
LegacyLogging.Logger?.Error(error);
return base.Format(stringsType, value);
#endif
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Reflection;

using Intersect.Localization;
using Intersect.Logging;

#if !DEBUG
using Intersect.Logging;
Expand Down Expand Up @@ -46,7 +47,7 @@ public override string Format(Type stringsType, object value)
#if DEBUG
throw error;
#else
Log.Error(error);
LegacyLogging.Logger?.Error(error);
return base.Format(stringsType, value);
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public override string Format(Type stringsType, object value)
else
{
var lookup = DescriptorType
.GetProperties(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
.FirstOrDefault(propertyInfo => propertyInfo.PropertyType == typeof(DatabaseObjectLookup))?
.GetValue(null) as DatabaseObjectLookup;
.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
.FirstOrDefault(fieldInfo => fieldInfo.FieldType == typeof(DatabaseObjectLookup))?
.GetValue(null) as DatabaseObjectLookup;

if (lookup == default)
{
Expand Down
Loading