Skip to content

Commit

Permalink
Merge branch 'master' into net8
Browse files Browse the repository at this point in the history
  • Loading branch information
LtRipley36706 committed Jan 12, 2024
2 parents c40cff0 + 47298c1 commit ede7646
Show file tree
Hide file tree
Showing 17 changed files with 426 additions and 105 deletions.
2 changes: 2 additions & 0 deletions Source/ACE.Common/ACE.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<PackageReference Include="BCrypt.Net-Core" Version="1.6.0" />
<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="TimeZoneConverter" Version="6.1.0" />
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="System.Text.Json" Version="6.0.9" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 9 additions & 1 deletion Source/ACE.Common/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void Initialize(string path = @"Config.js")

var fileText = File.ReadAllText(pathToUse);

Config = JsonSerializer.Deserialize<MasterConfiguration>(fileText, new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, NumberHandling = JsonNumberHandling.AllowReadingFromString });
Config = JsonSerializer.Deserialize<MasterConfiguration>(fileText, SerializerOptions);
}
catch (Exception exception)
{
Expand All @@ -72,5 +72,13 @@ public static void Initialize(string path = @"Config.js")
throw;
}
}

public static JsonSerializerOptions SerializerOptions = new JsonSerializerOptions
{
AllowTrailingCommas = true,
NumberHandling = JsonNumberHandling.AllowReadingFromString,
ReadCommentHandling = JsonCommentHandling.Skip,
WriteIndented = true
};
}
}
14 changes: 12 additions & 2 deletions Source/ACE.Common/Cryptography/BCryptProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ public static class BCryptProvider
{
public static string HashPassword(string input, int workFactor = 10)
{
return BCrypt.Net.BCrypt.HashPassword(input, workFactor, BCrypt.Net.SaltRevision.Revision2Y);
// Force BCrypt.Net-Next to use 2y instead of the default 2a
// The older bcrypt package ACE used (BCrypt.Net-Core) defaultd to 2y
// Reference: https://stackoverflow.com/questions/49878948/hashing-password-with-2y-identifier/75114685
string salt = BCrypt.Net.BCrypt.GenerateSalt(workFactor, 'y');

return BCrypt.Net.BCrypt.HashPassword(input, salt);
}

public static bool Verify(string text, string hash)
Expand All @@ -14,7 +19,12 @@ public static bool Verify(string text, string hash)

public static int GetPasswordWorkFactor(string hash)
{
return BCrypt.Net.BCrypt.GetPasswordWorkFactor(hash);
var hashInformation = BCrypt.Net.BCrypt.InterrogateHash(hash);

if (int.TryParse(hashInformation.WorkFactor, out var workFactor))
return workFactor;

return 0;
}
}
}
6 changes: 2 additions & 4 deletions Source/ACE.Common/DerethDateTime.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;

using TimeZoneConverter;

namespace ACE.Common
{
/// <summary>
Expand Down Expand Up @@ -32,7 +30,7 @@ public class DerethDateTime
private static DateTime dayOne_RealWorld = new DateTime(1999, 4, 2, 00, 00, 00);

private static DateTime retailDayOne_RealWorld = new DateTime(1999, 11, 2, 00, 00, 00);
private static DateTime retailDayLast_RealWorld = new DateTime(2017, 1, 31, 12, 00, 00);
private static DateTime retailDayLast_RealWorld = new DateTime(2017, 1, 31, 12, 00, 00); // Eastern Standard Time

/// <summary>
/// <para>A <see cref="DerethDateTime"/> instance set to the Derethian Date, Portal Year and Time when the worlds first opened.</para>
Expand Down Expand Up @@ -1061,6 +1059,6 @@ public static DerethDateTime ConvertRealWorldToLoreDateTime(DateTime dateTime)
/// <summary>
/// Converts the <see cref="DateTime.UtcNow"/> object to a new <see cref="DerethDateTime"/> object set to EMU Standard Sync Time.
/// </summary>
public static DerethDateTime UtcNowToEMUTime => new DerethDateTime((DateTime.UtcNow - TimeZoneInfo.ConvertTimeToUtc(retailDayLast_RealWorld, TZConvert.GetTimeZoneInfo("Eastern Standard Time"))).TotalSeconds);
public static DerethDateTime UtcNowToEMUTime => new DerethDateTime((DateTime.UtcNow.AddHours(-5) - retailDayLast_RealWorld).TotalSeconds); // -5 is Eastern Standard Time UTC Offset
}
}
2 changes: 2 additions & 0 deletions Source/ACE.DatLoader/ACE.DatLoader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 0 additions & 7 deletions Source/ACE.Database/ACE.Database.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.25" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.2" />
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.Net.Primitives" Version="4.3.1" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions Source/ACE.Server/ACE.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Lib.Harmony" Version="2.3.0-prerelease.2" />
<PackageReference Include="Lib.Harmony" Version="2.3.0-prerelease.4" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Log4Net.Async.Standard" Version="3.1.0" />
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.4.0" />
<PackageReference Include="MySql.Data" Version="8.2.0" />
<PackageReference Include="MySqlConnector" Version="2.3.3" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Source/ACE.Server/Command/Handlers/DeveloperCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ public static void MoveTo(Session session, params string[] parameters)
[CommandHandler("barbershop", AccessLevel.Developer, CommandHandlerFlag.RequiresWorld, "Displays the barber ui")]
public static void BarberShop(Session session, params string[] parameters)
{
session.Player.BarberActive = true;
session.Network.EnqueueSend(new GameEventStartBarber(session));
}

Expand Down
4 changes: 2 additions & 2 deletions Source/ACE.Server/Factories/StarterGearFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.IO;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization;

using ACE.Common;
using ACE.Server.Entity;

using log4net;
Expand Down Expand Up @@ -36,7 +36,7 @@ private static StarterGearConfiguration LoadConfigFromResource()
{
var starterGearText = File.ReadAllText(starterGearFile);

config = JsonSerializer.Deserialize<StarterGearConfiguration>(starterGearText, new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, NumberHandling = JsonNumberHandling.AllowReadingFromString });
config = JsonSerializer.Deserialize<StarterGearConfiguration>(starterGearText, ConfigManager.SerializerOptions);

return config;
}
Expand Down
4 changes: 3 additions & 1 deletion Source/ACE.Server/Mods/ModContainer.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using ACE.Common;

using log4net;

using McMaster.NETCore.Plugins;
Expand Down Expand Up @@ -204,7 +206,7 @@ private bool TryCreateModInstance()

public void SaveMetadata()
{
var json = JsonSerializer.Serialize(Meta, new JsonSerializerOptions { WriteIndented = true });
var json = JsonSerializer.Serialize(Meta, ConfigManager.SerializerOptions);
var info = new FileInfo(MetadataPath);

if (!info.RetryWrite(json))
Expand Down
4 changes: 2 additions & 2 deletions Source/ACE.Server/Mods/ModManager.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using ACE.Common;
using ACE.Server.Managers;
using ACE.Server.WorldObjects;

Expand All @@ -9,7 +10,6 @@
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace ACE.Server.Mods
{
Expand Down Expand Up @@ -144,7 +144,7 @@ private static bool TryLoadModContainer(string metadataPath, out ModContainer co

try
{
var metadata = JsonSerializer.Deserialize<ModMetadata>(File.ReadAllText(metadataPath), new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, NumberHandling = JsonNumberHandling.AllowReadingFromString });
var metadata = JsonSerializer.Deserialize<ModMetadata>(File.ReadAllText(metadataPath), ConfigManager.SerializerOptions);

container = new ModContainer()
{
Expand Down
5 changes: 2 additions & 3 deletions Source/ACE.Server/Program_Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.IO.Compression;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;

using ACE.Common;
Expand Down Expand Up @@ -38,7 +37,7 @@ private static void DoOutOfBoxSetup(string configFile)
}

var fileText = File.ReadAllText(configFile);
config = JsonSerializer.Deserialize<MasterConfiguration>(fileText, new JsonSerializerOptions { ReadCommentHandling = JsonCommentHandling.Skip, NumberHandling = JsonNumberHandling.AllowReadingFromString });
config = JsonSerializer.Deserialize<MasterConfiguration>(fileText, ConfigManager.SerializerOptions);
}

Console.WriteLine("Performing setup for ACEmulator...");
Expand Down Expand Up @@ -260,7 +259,7 @@ private static void DoOutOfBoxSetup(string configFile)

Console.WriteLine("commiting configuration to disk...");

var jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
var jsonString = JsonSerializer.Serialize(config, ConfigManager.SerializerOptions);
File.WriteAllText(configFile, jsonString);


Expand Down
18 changes: 9 additions & 9 deletions Source/ACE.Server/ServerBuildInfo_Dynamic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ namespace ACE.Server
public static partial class ServerBuildInfo
{
public static string Branch = "master";
public static string Commit = "7dd702ace2dc4ed2c3da5d221bd28a8a10a37db4";
public static string Commit = "74b57b215c600e480657fc0bbeaeab9f568920d6";

public static string Version = "1.56";
public static string Build = "4466";
public static string Version = "1.57";
public static string Build = "4475";

public static int BuildYear = 2023;
public static int BuildMonth = 12;
public static int BuildDay = 29;
public static int BuildHour = 17;
public static int BuildMinute = 47;
public static int BuildSecond = 46;
public static int BuildYear = 2024;
public static int BuildMonth = 01;
public static int BuildDay = 11;
public static int BuildHour = 00;
public static int BuildMinute = 58;
public static int BuildSecond = 45;
}
}

66 changes: 1 addition & 65 deletions Source/ACE.Server/WorldObjects/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -675,71 +675,7 @@ public void SendAutonomousPosition()



public void HandleActionFinishBarber(ClientMessage message)
{
// Read the payload sent from the client...
PaletteBaseId = message.Payload.ReadUInt32();
HeadObjectDID = message.Payload.ReadUInt32();
Character.HairTexture = message.Payload.ReadUInt32();
Character.DefaultHairTexture = message.Payload.ReadUInt32();
CharacterChangesDetected = true;
EyesTextureDID = message.Payload.ReadUInt32();
DefaultEyesTextureDID = message.Payload.ReadUInt32();
NoseTextureDID = message.Payload.ReadUInt32();
DefaultNoseTextureDID = message.Payload.ReadUInt32();
MouthTextureDID = message.Payload.ReadUInt32();
DefaultMouthTextureDID = message.Payload.ReadUInt32();
SkinPaletteDID = message.Payload.ReadUInt32();
HairPaletteDID = message.Payload.ReadUInt32();
EyesPaletteDID = message.Payload.ReadUInt32();
SetupTableId = message.Payload.ReadUInt32();

uint option_bound = message.Payload.ReadUInt32(); // Supress Levitation - Empyrean Only
uint option_unk = message.Payload.ReadUInt32(); // Unknown - Possibly set aside for future use?

// Check if Character is Empyrean, and if we need to set/change/send new motion table
if (Heritage == 9)
{
// These are the motion tables for Empyrean float and not-float (one for each gender). They are hard-coded into the client.
const uint EmpyreanMaleFloatMotionDID = 0x0900020Bu;
const uint EmpyreanFemaleFloatMotionDID = 0x0900020Au;
const uint EmpyreanMaleMotionDID = 0x0900020Eu;
const uint EmpyreanFemaleMotionDID = 0x0900020Du;

// Check for the Levitation option for Empyrean. Shadow crown and Undead flames are handled by client.
if (Gender == 1) // Male
{
if (option_bound == 1 && MotionTableId != EmpyreanMaleMotionDID)
{
MotionTableId = EmpyreanMaleMotionDID;
Session.Network.EnqueueSend(new GameMessagePrivateUpdateDataID(this, PropertyDataId.MotionTable, (uint)MotionTableId));
}
else if (option_bound == 0 && MotionTableId != EmpyreanMaleFloatMotionDID)
{
MotionTableId = EmpyreanMaleFloatMotionDID;
Session.Network.EnqueueSend(new GameMessagePrivateUpdateDataID(this, PropertyDataId.MotionTable, (uint)MotionTableId));
}
}
else // Female
{
if (option_bound == 1 && MotionTableId != EmpyreanFemaleMotionDID)
{
MotionTableId = EmpyreanFemaleMotionDID;
Session.Network.EnqueueSend(new GameMessagePrivateUpdateDataID(this, PropertyDataId.MotionTable, (uint)MotionTableId));
}
else if (option_bound == 0 && MotionTableId != EmpyreanFemaleFloatMotionDID)
{
MotionTableId = EmpyreanFemaleFloatMotionDID;
Session.Network.EnqueueSend(new GameMessagePrivateUpdateDataID(this, PropertyDataId.MotionTable, (uint)MotionTableId));
}
}
}


// Broadcast updated character appearance
EnqueueBroadcast(new GameMessageObjDescEvent(this));
BarberActive = false;
}


/// <summary>
/// Sends object description if the client requests it
Expand Down
Loading

0 comments on commit ede7646

Please sign in to comment.