Skip to content

Commit

Permalink
Merge pull request #524 from sebastian-heinz/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
alborrajo authored Sep 2, 2024
2 parents dd88306 + 8c8ab0e commit 16848da
Show file tree
Hide file tree
Showing 1,540 changed files with 841,037 additions and 67,965 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ root = true
indent_style = space

# Code files
[*.cs]
[*.{cs,sql}]
indent_size = 4
insert_final_newline = true
charset = utf-8
charset = utf-8
12 changes: 7 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.200
- name: Build Project
run: dotnet build --configuration Release
dotnet-version: 6.x
- name: Build
run: dotnet build --configuration Release
- name: Test
run: dotnet test --configuration Release --no-restore --no-build
8 changes: 4 additions & 4 deletions .vscode/ddon.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@
"",
"namespace Arrowgene.Ddon.GameServer.Handler",
"{",
"\tpublic class $1 : GameStructurePacketHandler<C2S$2>",
"\tpublic class $1Handler : GameRequestPacketHandler<C2S$1Req, S2C$1Res>",
"\t{",
"\t\tprivate static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof($1));",
"\t\tprivate static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof($1Handler));",
"\t\t",
"\t\tpublic $1(DdonGameServer server) : base(server)",
"\t\tpublic $1Handler(DdonGameServer server) : base(server)",
"\t\t{",
"\t\t}",
"",
"\t\tpublic override void Handle(GameClient client, StructurePacket<C2S$2> packet)",
"\t\tpublic override S2C$1Res Handle(GameClient client, C2S$1Req request)",
"\t\t{",
"\t\t\t$0",
"\t\t}",
Expand Down
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"recommendations": [
"fudge.auto-using",
"jeff-hykin.better-cpp-syntax",
"ms-dotnettools.csharp",
"notblank00.hexeditor",
Expand Down
40 changes: 39 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@
"moduleLoad": false
}
},
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": "DDOn Migrate Database",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/Arrowgene.Ddon.Cli/bin/Debug/net6.0/Arrowgene.Ddon.Cli.dll",
"args": ["dbmigration"],
"cwd": "${workspaceFolder}/Arrowgene.Ddon.Cli",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "integratedTerminal",
"stopAtEntry": false,
"logging": {
"moduleLoad": false
}
},
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
Expand All @@ -52,7 +71,26 @@
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/Arrowgene.Ddon.Cli/bin/Debug/net6.0/Arrowgene.Ddon.Cli.dll",
"args": ["client", "J:\\Juegos\\Dragon's Dogma Online\\nativePC\\rom"],
"args": ["client", "D:\\Juegos\\DDOn\\Dragon's Dogma Online\\nativePC\\rom"],
"cwd": "${workspaceFolder}/Arrowgene.Ddon.Cli",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "integratedTerminal",
"stopAtEntry": false,
"logging": {
"moduleLoad": false
}
},
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": "DDOn Client Translation Patch",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/Arrowgene.Ddon.Cli/bin/Debug/net6.0/Arrowgene.Ddon.Cli.dll",
"args": ["client", "packGmd", "gmdCsv=C:\\Users\\GAMER\\Downloads\\gmd.csv", "romDir=D:\\Juegos\\DDOn\\Dragon's Dogma Online\\nativePC\\rom", "romLang=English"],
"cwd": "${workspaceFolder}/Arrowgene.Ddon.Cli",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "integratedTerminal",
Expand Down
6 changes: 6 additions & 0 deletions Arrowgene.Ddon.Cli/Arrowgene.Ddon.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
<Version>$(Version)</Version>
<Copyright>Copyright © 2019-2022 DDON Team</Copyright>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<Import Project="./../SetSourceRevision.targets" />
<ItemGroup>
<ProjectReference Include="..\Arrowgene.Ddon.Client\Arrowgene.Ddon.Client.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion Arrowgene.Ddon.Cli/Command/ClientCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public CommandResultType Run(CommandParameter parameter)

if (string.IsNullOrEmpty(newMsg))
{
Logger.Error(
Logger.Info(
$"csv message is empty, skipping (ArcPath:{arcPath}, GmdPath:{gmdPath}, Key:{entry.Key}. Msg:{entry.Msg})");
continue;
}
Expand Down
98 changes: 98 additions & 0 deletions Arrowgene.Ddon.Cli/Command/DbMigrationCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using Arrowgene.Ddon.Database;
using Arrowgene.Ddon.Database.Sql.Core.Migration;
using Arrowgene.Ddon.Shared;
using Arrowgene.Logging;
using System.Linq;
using System.IO;
using System.Reflection;
using System;
using System.Collections.Generic;

namespace Arrowgene.Ddon.Cli.Command
{
public class DbMigrationCommand : ICommand
{
private static readonly ILogger Logger = LogProvider.Logger<Logger>(typeof(ServerCommand));

public string Key => "dbmigration";

public string Description => $"Commandline tool to update the database\n\n" +
$"usage:\n" +
$"{Key}\n";

public CommandResultType Run(CommandParameter parameter)
{

string settingPath = Path.Combine(Util.ExecutingDirectory(), "Files/Arrowgene.Ddon.config.json");
Setting settings = Setting.LoadFromFile(settingPath);
if (settings == null)
{
return CommandResultType.Exit;
}

DatabaseSetting dbSettings = settings.DatabaseSetting;
if (dbSettings == null)
{
return CommandResultType.Exit;
}

IDatabase database = DdonDatabaseBuilder.Build(dbSettings);
if (database == null)
{
return CommandResultType.Exit;
}

// Instance all implementations of IMigrationStrategy located in the Migration namespace
// supplying the adequate arguments to the constructor
DatabaseMigrator migrator = new DatabaseMigrator(typeof(IMigrationStrategy).Assembly.GetTypes()
.Where(type => type != typeof(IMigrationStrategy) && typeof(IMigrationStrategy).IsAssignableFrom(type) && type.Namespace == typeof(IMigrationStrategy).Namespace)
.Select(type => InstanceMigrationStrategy(type, dbSettings))
.ToList());

// TODO: Warn that migration is destructive
bool result = database.MigrateDatabase(migrator, DdonDatabaseBuilder.Version);

// TODO: Better logging
if(result)
{
Logger.Info($"Successfully migrated the database to version '{DdonDatabaseBuilder.Version}'.");
}
else
{
Logger.Error("Failed to migrate the database.");
}

return CommandResultType.Exit;
}

public void Shutdown()
{
}

private IMigrationStrategy InstanceMigrationStrategy(Type type, DatabaseSetting databaseSetting)
{
foreach(ConstructorInfo constructorInfo in type.GetConstructors())
{
List<object> parameters = new List<object>();
foreach (var constructorParam in constructorInfo.GetParameters())
{
if(constructorParam.ParameterType == typeof(DatabaseSetting))
{
parameters.Add(databaseSetting);
}
else
{
break;
}
}

if(parameters.Count == constructorInfo.GetParameters().Length)
{
return (IMigrationStrategy) constructorInfo.Invoke(parameters.ToArray());
}
}

throw new MissingMethodException("No suitable constructor found in "+type.Name);
}
}
}
14 changes: 14 additions & 0 deletions Arrowgene.Ddon.Cli/Command/Packet/PacketCommandException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace Arrowgene.Ddon.Cli.Command.Packet;

public class PacketCommandException : Exception
{
public PacketCommandException(string message) : base(message)
{
}

public PacketCommandException(string message, Exception innerException) : base(message, innerException)
{
}
}
61 changes: 61 additions & 0 deletions Arrowgene.Ddon.Cli/Command/Packet/PacketCommandOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System.Collections.Generic;

namespace Arrowgene.Ddon.Cli.Command.Packet;

public class PacketCommandOptions
{
private static string ByteDumpSwitch => "--byte-dump";
private static string ByteDumpHeaderSwitch => "--byte-dump-header";
private static string ByteDumpPrefixSwitch => "--byte-dump-prefix";
private static string Utf8StringDumpSwitch => "--utf8-dump";
private static string StructureDumpSwitch => "--structure-dump";
private static string PacketIncludeFilterSwitch => "--packet-include-filter";
private static string ExportDecryptedPacketsSwitch => "--export-decrypted-packets";

public bool AddByteDump { get; }
public bool AddByteDumpHeader { get; }
public string ByteDumpSeparator { get; }
public string ByteDumpPrefix { get; }
public bool AddUtf8StringDump { get; }
public bool AddStructureDump { get; }
public string StructureDumpFormat { get; }
public string PacketIncludeFilter { get; }
public bool ExportDecryptedPackets { get; }

public PacketCommandOptions(bool addByteDump = false, bool addByteDumpHeader = false, string byteDumpSeparator = "", string byteDumpPrefix = "", bool addUtf8StringDump = false,
bool addStructureDump = false, string structureDumpFormat = "", string packetIncludeFilter = "", bool exportDecryptedPackets = false)
{
AddByteDump = addByteDump;
AddByteDumpHeader = addByteDumpHeader;
ByteDumpSeparator = byteDumpSeparator;
ByteDumpPrefix = byteDumpPrefix;
AddUtf8StringDump = addUtf8StringDump;
AddStructureDump = addStructureDump;
StructureDumpFormat = structureDumpFormat;
PacketIncludeFilter = packetIncludeFilter;
ExportDecryptedPackets = exportDecryptedPackets;
}

public PacketCommandOptions(CommandParameter parameters) : this(parameters.Switches, parameters.SwitchMap)
{
}

private PacketCommandOptions(List<string> parameterSwitches, Dictionary<string, string> parameterSwitchMap)
{
AddByteDump = parameterSwitches.Contains(ByteDumpSwitch) || parameterSwitchMap.ContainsKey(ByteDumpSwitch);
AddByteDumpHeader = parameterSwitches.Contains(ByteDumpHeaderSwitch) || parameterSwitchMap.ContainsKey(ByteDumpHeaderSwitch);
ByteDumpSeparator = parameterSwitchMap.GetValueOrDefault(ByteDumpSwitch, "");
ByteDumpPrefix = parameterSwitchMap.GetValueOrDefault(ByteDumpPrefixSwitch, "");
AddUtf8StringDump = parameterSwitches.Contains(Utf8StringDumpSwitch) || parameterSwitchMap.ContainsKey(Utf8StringDumpSwitch);
AddStructureDump = parameterSwitches.Contains(StructureDumpSwitch) || parameterSwitchMap.ContainsKey(StructureDumpSwitch);
StructureDumpFormat = parameterSwitchMap.GetValueOrDefault(StructureDumpSwitch, "JSON").ToLowerInvariant();
PacketIncludeFilter = parameterSwitchMap.GetValueOrDefault(PacketIncludeFilterSwitch, "");
ExportDecryptedPackets = parameterSwitches.Contains(ExportDecryptedPacketsSwitch) || parameterSwitchMap.ContainsKey(ExportDecryptedPacketsSwitch);
}

public static string GetUsage()
{
return
$"[{ByteDumpSwitch}[=,]] [{ByteDumpHeaderSwitch}] [{ByteDumpPrefixSwitch}=0x] [{Utf8StringDumpSwitch}] [{StructureDumpSwitch}[=JSON|YAML]] [{PacketIncludeFilterSwitch}=11.21.2,S2C_QUEST_QUEST_PROGRESS_RES,...]";
}
}
8 changes: 8 additions & 0 deletions Arrowgene.Ddon.Cli/Command/Packet/PacketServerType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Arrowgene.Ddon.Cli.Command.Packet
{
public enum PacketServerType : ushort
{
Login = 52100,
Game = 52000
}
}
15 changes: 15 additions & 0 deletions Arrowgene.Ddon.Cli/Command/Packet/PcapPacket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using Arrowgene.Ddon.Shared.Network;

namespace Arrowgene.Ddon.Cli.Command.Packet;

public class PcapPacket
{
public PacketServerType PacketServerType { get; set; }
public PacketSource Source { get; set; }
public string TimeStamp { get; set; }
public uint Index { get; set; }
public uint Packet { get; set; }
public byte[] Data { get; set; }
public List<IPacket> ResolvedPackets { get; set; }
}
9 changes: 9 additions & 0 deletions Arrowgene.Ddon.Cli/Command/Packet/YamlFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace Arrowgene.Ddon.Cli.Command.Packet;

public class YamlFile
{
public List<YamlPeer> peers;
public List<YamlPacket> packets;
}
10 changes: 10 additions & 0 deletions Arrowgene.Ddon.Cli/Command/Packet/YamlPacket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Arrowgene.Ddon.Cli.Command.Packet;

public class YamlPacket
{
public uint packet;
public uint peer;
public uint index;
public string timestamp;
public string data;
}
8 changes: 8 additions & 0 deletions Arrowgene.Ddon.Cli/Command/Packet/YamlPeer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Arrowgene.Ddon.Cli.Command.Packet;

public class YamlPeer
{
public uint peer;
public string host;
public ushort port;
}
Loading

0 comments on commit 16848da

Please sign in to comment.