Skip to content

Commit

Permalink
[skip CI] CI/CD: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 13, 2024
1 parent 6619084 commit 11e7334
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 70 deletions.
14 changes: 7 additions & 7 deletions Fuyu.Backend/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ static async Task Main()
ItemFactoryService.Load();

var coreServer = new CoreServer();
container.RegisterSingleton<HttpServer, CoreServer>(coreServer);
container.RegisterSingleton<HttpServer, CoreServer>(coreServer);

coreServer.RegisterServices();
coreServer.RegisterServices();
coreServer.Start();

var eftMainServer = new EftMainServer();
container.RegisterSingleton<HttpServer, EftMainServer>(eftMainServer);
container.RegisterSingleton<HttpServer, EftMainServer>(eftMainServer);

eftMainServer.RegisterServices();
eftMainServer.RegisterServices();
eftMainServer.Start();

Terminal.WriteLine("Loading mods...");
ModManager.Instance.AddMods("./Fuyu/Mods");
await ModManager.Instance.Load(container);
ModManager.Instance.AddMods("./Fuyu/Mods");
await ModManager.Instance.Load(container);
Terminal.WriteLine("Finished loading mods");

Terminal.WaitForInput();
Terminal.WaitForInput();
await ModManager.Instance.UnloadAll();
}
}
Expand Down
66 changes: 33 additions & 33 deletions Fuyu.Common/IO/Resx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,46 +41,46 @@ public static void SetSource(string id, Assembly assembly)
_assemblies.Add(id, assembly);
_fullpaths.Add(id, paths);
}
}
}

public static Stream GetStream(string id, string path)
{
// validate assembly
var hasAssembly = _assemblies.TryGetValue(id, out var assembly);

public static Stream GetStream(string id, string path)
{
// validate assembly
var hasAssembly = _assemblies.TryGetValue(id, out var assembly);
if (!hasAssembly)
{
throw new ArgumentException($"Source {id} is not registered for assemblies");
}

if (!hasAssembly)
{
throw new ArgumentException($"Source {id} is not registered for assemblies");
}
// validate fullpaths
var hasFullpath = _fullpaths.TryGetValue(id, out var fullpaths);

// validate fullpaths
var hasFullpath = _fullpaths.TryGetValue(id, out var fullpaths);
if (!hasFullpath)
{
throw new ArgumentException($"Source {id} is not registered for paths");
}

if (!hasFullpath)
{
throw new ArgumentException($"Source {id} is not registered for paths");
}
// find target

// find target

// NOTE: replacing ".Resources" is, ideally, a temporary solution
// -- nexus4880, 2024-12-11
var target = $"{assembly.GetName().Name.Replace(".Resources", string.Empty)}.embedded.{path}";

foreach (var fullpath in fullpaths)
{
if (fullpath == target)
{
// target found
return assembly.GetManifestResourceStream(target);
}
}

// target not found
throw new FileNotFoundException($"Cannot find resource {path}");
}

public static string GetText(string id, string path)
var target = $"{assembly.GetName().Name.Replace(".Resources", string.Empty)}.embedded.{path}";

foreach (var fullpath in fullpaths)
{
if (fullpath == target)
{
// target found
return assembly.GetManifestResourceStream(target);
}
}

// target not found
throw new FileNotFoundException($"Cannot find resource {path}");
}

public static string GetText(string id, string path)
{
using (var rs = GetStream(id, path))
{
Expand Down
44 changes: 22 additions & 22 deletions Fuyu.Common/IO/VFS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ public static void CreateDirectory(string path)
public static string ReadTextFile(string filepath)
{
using (var fs = OpenRead(filepath))
{
using (var sr = new StreamReader(fs))
{
var text = sr.ReadToEnd();
return text;
}
}
}
{
using (var sr = new StreamReader(fs))
{
var text = sr.ReadToEnd();
return text;
}
}
}

// NOTE: we must prevent threads from accessing the same file at the
// same time. This way we can prevent data corruption when
Expand Down Expand Up @@ -124,21 +124,21 @@ public static void WriteTextFile(string filepath, string text, bool append = fal
_writeLock.TryRemove(filepath, out _);
}

public static Stream OpenRead(string filepath)
{
var path = Path.GetDirectoryName(filepath);
public static Stream OpenRead(string filepath)
{
var path = Path.GetDirectoryName(filepath);

if (!DirectoryExists(path))
{
throw new DirectoryNotFoundException($"Directory {path} doesn't exist.");
}
if (!DirectoryExists(path))
{
throw new DirectoryNotFoundException($"Directory {path} doesn't exist.");
}

if (!File.Exists(filepath))
{
throw new FileNotFoundException($"File {filepath} doesn't exist.");
}
if (!File.Exists(filepath))
{
throw new FileNotFoundException($"File {filepath} doesn't exist.");
}

return new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.None);
}
}
return new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.None);
}
}
}
12 changes: 6 additions & 6 deletions Fuyu.Modding/EModType.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace Fuyu.Modding
{
public enum EModType
{
Invalid,
DLL,
Source
}
public enum EModType
{
Invalid,
DLL,
Source
}
}
4 changes: 2 additions & 2 deletions Fuyu.Modding/ModManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ private void ProcessAssembly(Assembly assembly, EModType assemblyModType)
var resourceAssembly = GenerateResourceAssembly(assembly);
if (resourceAssembly != null)
{
Resx.SetSource(assembly.GetName().Name, resourceAssembly);
Resx.SetSource(assembly.GetName().Name, resourceAssembly);
}
}
}

// Get types where T inherits from Mod
var modTypes = assembly.GetExportedTypes()
Expand Down

0 comments on commit 11e7334

Please sign in to comment.