Skip to content

Commit

Permalink
HACK: NitroxServer-Subnautica: Fix Resources/ capitalization
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Mar 24, 2020
1 parent dbd8775 commit d3e4f4a
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace NitroxServer_Subnautica.Serialization.Resources
public static class ResourceAssetsParser
{
private static Dictionary<AssetIdentifier, uint> assetIdentifierToClassId = new Dictionary<AssetIdentifier, uint>();

private static Dictionary<string, int> fileIdByResourcePath = new Dictionary<string, int>();
private static HashSet<string> parsedManifests = new HashSet<string>();

private static PrefabPlaceholderExtractor prefabPlaceholderExtractor = new PrefabPlaceholderExtractor();

// https://docs.huihoo.com/unity/4.3/Documentation/Manual/ClassIDReference.html
private static Dictionary<uint, AssetParser> assetParsersByClassId = new Dictionary<uint, AssetParser>()
{
Expand Down Expand Up @@ -50,7 +50,9 @@ public static ResourceAssets Parse()

private static void ParseAssetManifest(string basePath, string fileName, int fileId, ResourceAssets resourceAssets)
{
if(parsedManifests.Contains(fileName))
fileName = fileName.Replace("resources/", "Resources/");

if (parsedManifests.Contains(fileName))
{
return;
}
Expand All @@ -64,13 +66,13 @@ private static void ParseAssetManifest(string basePath, string fileName, int fil
{
AssetsFile file = new AssetsFile(reader);
AssetsFileTable resourcesFileTable = new AssetsFileTable(file);
foreach (AssetsFileDependency dependency in file.dependencies.dependencies)

foreach (AssetsFileDependency dependency in file.dependencies.dependencies)
{
int dependencyFileId = fileIdByResourcePath[dependency.assetPath];
ParseAssetManifest(basePath, dependency.assetPath, dependencyFileId, resourceAssets);
}

foreach (AssetFileInfoEx assetFileInfo in resourcesFileTable.assetFileInfo)
{
reader.Position = assetFileInfo.absoluteFilePos;
Expand Down Expand Up @@ -101,14 +103,14 @@ private static void CalculateDependencyFileIds(string basePath, string fileName)
{
AssetsFile file = new AssetsFile(reader);
AssetsFileTable resourcesFileTable = new AssetsFileTable(file);

int fileId = 1;

foreach (AssetsFileDependency dependency in file.dependencies.dependencies)
{
fileIdByResourcePath.Add(dependency.assetPath, fileId);
fileId++;
}
}
}
}

Expand All @@ -121,7 +123,7 @@ private static string FindDirectoryContainingResourceAssets()
{
Log.Info($"Could not locate Subnautica installation directory: {Environment.NewLine}{string.Join(Environment.NewLine, errors)}");
}

if (File.Exists(Path.Combine(subnauticaPath.Get(), "Subnautica_Data", "resources.assets")))
{
return Path.Combine(subnauticaPath.Get(), "Subnautica_Data");
Expand Down

0 comments on commit d3e4f4a

Please sign in to comment.