Skip to content

Prepare For Releases #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Sep 16, 2021
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Uchu.Char/Packets/Client/CharacterListRequest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using RakDotNet.IO;
using Uchu.Core;

namespace Uchu.Char
Expand All @@ -7,5 +8,10 @@ public class CharacterListRequest : Packet
public override RemoteConnectionType RemoteConnectionType => RemoteConnectionType.Client;

public override uint PacketId => 0x2;

public override void Deserialize(BitReader reader)
{

}
}
}
}
4 changes: 2 additions & 2 deletions Uchu.Core/Cache/DatabaseCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public async Task<Session> GetSessionAsync(IPEndPoint endpoint)
await using var ctx = new UchuContext();

string key;
var timeout = 1000;
var timeout = 5000;

while (!_keys.TryGetValue(endpoint.ToString(), out key))
{
Expand Down Expand Up @@ -160,4 +160,4 @@ public void Dispose()
_rng.Dispose();
}
}
}
}
4 changes: 2 additions & 2 deletions Uchu.Core/Config/UchuConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class UchuConfiguration
[XmlElement]
public LoggingConfiguration ConsoleLogging { get; set; } = new LoggingConfiguration
{
Level = LogLevel.Debug.ToString()
Level = LogLevel.Information.ToString()
};

/// <summary>
Expand Down Expand Up @@ -142,7 +142,7 @@ public class CacheConfig
/// if no service is installed and the connection will
/// always timeout.
/// </summary>
[XmlElement] public bool UseService { get; set; } = true;
[XmlElement] public bool UseService { get; set; } = false;

/// <summary>
/// Hostname to use when connecting to the cache service
Expand Down
2 changes: 1 addition & 1 deletion Uchu.Core/UchuServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ private static async Task InvokeHandlerAsync(Handler handler, object packet, IRa
if (task && res != null)
await ((Task) res).ConfigureAwait(false);
if (res == null)
Logger.Warning($"Handler {handler.GetType().FullName} returned null for {endPoint}.");
Logger.Debug($"Handler {handler.GetType().FullName} returned null for {endPoint}.");
}
}
}
11 changes: 9 additions & 2 deletions Uchu.Master/MasterServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,14 @@ private static async Task ConfigureAsync()
Logger.SetConfiguration(Config);
Logger.SetServerTypeInformation("Master");

// Add default value for script DLL source
Config.DllSource.ScriptDllSource.Add("../../../../Uchu.StandardScripts/bin/Debug/net5.0/Uchu.StandardScripts.dll");
// Add default value for instance DLL source and script DLL source.
if (File.Exists("lib/Uchu.Instance.dll"))
{
Config.DllSource.Instance = "lib/Uchu.Instance.dll";
}
Config.DllSource.ScriptDllSource.Add(File.Exists("lib/Uchu.StandardScripts.dll")
? "lib/Uchu.StandardScripts.dll"
: "../../../../Uchu.StandardScripts/bin/Debug/net5.0/Uchu.StandardScripts.dll");

// Write config file
Config.Save(configFilename);
Expand All @@ -365,6 +371,7 @@ private static async Task ConfigureAsync()
try
{
Config.ResourcesConfiguration.GameResourceFolder = FindNlulClientResources();
Config.Save(configFilename);
Logger.Information($"Using automatically detected client resource folder: {Config.ResourcesConfiguration.GameResourceFolder}");
}
catch
Expand Down
44 changes: 37 additions & 7 deletions Uchu.Master/ServerInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Uchu.Core;

namespace Uchu.Master
Expand All @@ -18,24 +19,54 @@ public class ServerInstance

public int ApiPort { get; set; }

public List<ZoneId> Zones { get; set; }
public List<ZoneId> Zones { get; set; } = new List<ZoneId>();

public bool Ready { get; set; }

public ServerInstance(Guid id)
{
Id = id;

Zones = new List<ZoneId>();
}

/// <summary>
/// Starts the server instance.
/// </summary>
/// <param name="location">Executable location to use.</param>
/// <param name="dotnet">Location of the dotnet command.</param>
public void Start(string location, string dotnet)
{
// Determine if the dotnet command should be used.
// If the default (dotnet) is used, the system PATH is checked.
var useDotNet = !string.IsNullOrWhiteSpace(dotnet);
if (useDotNet && dotnet?.ToLower() == "dotnet" && !File.Exists(dotnet))
{
var pathDirectories = (Environment.GetEnvironmentVariable("PATH") ?? "").Split(";");
var dotNetInPath = pathDirectories.Any(pathDirectory => File.Exists(Path.Combine(pathDirectory, dotnet)));
if (!dotNetInPath)
{
useDotNet = false;
}
}

// Adjust the file name.
// If dotnet isn't used, the file name may need to be corrected to have .exe or no extension.
var file = useDotNet ? dotnet : location;
if (!useDotNet && file.ToLower().EndsWith(".dll"))
{
var parentDirectory = Path.GetDirectoryName(file) ?? "";
var baseFileName = Path.GetFileNameWithoutExtension(file);
var baseFileLocation = Path.Combine(parentDirectory, baseFileName);
if (File.Exists(baseFileLocation + ".exe"))
{
file = baseFileLocation + ".exe";
} else if (File.Exists(baseFileLocation))
{
file = baseFileLocation;
}
}

Process = new Process
// Create and start the process.
this.Process = new Process
{
StartInfo =
{
Expand All @@ -45,11 +76,10 @@ public void Start(string location, string dotnet)
RedirectStandardOutput = false,
UseShellExecute = true,
CreateNoWindow = false,
WindowStyle = ProcessWindowStyle.Normal
WindowStyle = ProcessWindowStyle.Normal,
}
};

Process.Start();
this.Process.Start();
}
}
}
7 changes: 7 additions & 0 deletions Uchu.Master/Uchu.Master.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>8</LangVersion>
<BeautyLibsDir>lib</BeautyLibsDir>
<NoBeautyFlag>True</NoBeautyFlag>
<ForceBeauty>True</ForceBeauty>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Uchu.Api\Uchu.Api.csproj" />
<ProjectReference Include="..\Uchu.Core\Uchu.Core.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetCoreBeauty" Version="1.2.9.2" />
</ItemGroup>

</Project>
72 changes: 72 additions & 0 deletions publish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""
TheNexusAvenger, enteryournamehere

Creates the binaries for distribution.
"""

PROJECTS = [
"Uchu.Master",
"Uchu.Instance",
"Uchu.StandardScripts",
]
DIRECTORY_ADDITIONS = {
"Uchu.Instance": "/lib",
"Uchu.StandardScripts": "/lib",
}
PLATFORMS = [
["Windows-x64", "win-x64"],
["macOS-x64", "osx-x64"],
["Linux-x64", "linux-x64"],
]

import os
import shutil
import subprocess
import sys



# Display a warning for Windows runs.
if os.name == "nt":
sys.stderr.write("Windows was detected. Linux and macOS binaries will be missing the permissions to run.\n")

# Create the directory.
if os.path.exists("bin"):
shutil.rmtree("bin")
os.mkdir("bin")

# Compile the releases.
for platform in PLATFORMS:
# Create the base directory.
print("Building Uchu for " + platform[0])
platformDirectory = "bin/Uchu-" + platform[0]
if os.path.exists(platformDirectory):
shutil.rmtree(platformDirectory)
os.mkdir(platformDirectory)

for project in PROJECTS:
# Compile the project for the platform.
print("\tExporting " + project + " for " + platform[0])

outputDirectory = platformDirectory + DIRECTORY_ADDITIONS.get(project, "")
buildParameters = ["dotnet", "publish",
"--runtime", platform[1],
"--configuration", "Release",
"--output", outputDirectory,
project + "/" + project + ".csproj"
]
subprocess.call(buildParameters, stdout=open(os.devnull, "w"))

# Clear the unwanted files of the compile.
for file in os.listdir(outputDirectory):
if file.endswith(".pdb") or file.endswith(".bak"):
os.remove(outputDirectory + "/" + file)

# Add documentation & license to the output directory.
for file in ["README.md", "Configuration.md", "LICENSE"]:
shutil.copy(file, platformDirectory)

# Create the archive.
print("\tCreating archive for " + platform[0])
shutil.make_archive("bin/Uchu-" + platform[0], "zip", platformDirectory)
shutil.rmtree(platformDirectory, True)