/// <summary> /// This function will parse and check the virtual file system for the game files /// </summary> public override void DiscoverLayout() { // Clear possibly old data. Packages.Clear(); Superbundles.Clear(); FileSystems.Clear(); AuthoritativePackage = null; Layout = null; // Try to find a Data directory if (!FileSystem.DirectoryExists("/game/Data")) #if DEBUG { throw new Exception("Failed to find the Data directory. Content mounting failed."); } #else { return; } #endif // Discover any packages that might exist. if (FileSystem.DirectoryExists("/game/Update")) { DiscoverPackages(); } // Parse the base Layout file. ParseLayout(); // Discover available superbundles. DiscoverSuperbundles(); // Discover filesystems. DiscoverFileSystems(); }
/// <summary> /// This function should discover all superbundles that are paired with the current game /// </summary> protected override void DiscoverSuperbundles() { var s_BaseLayout = Layout[0].Value as DbObject; // Check to ensure that we actually have a base layout if (s_BaseLayout == null) #if DEBUG { throw new Exception("No Superbundles found in Layout. This probably means data is corrupted or the engine you're trying to load is unsupported."); } #else { return; } #endif // Get the superbundle list var s_Superbundles = s_BaseLayout["superBundles"].Value as DbObject; // Ensure that we actually have the superbundles object before iterating if (s_Superbundles == null) #if DEBUG { throw new Exception("No Superbundles found in Layout. This probably means data is corrupted or the engine you're trying to load is unsupported."); } #else { return; } #endif // Iterate through each of the superbundles in the list for (var i = 0; i < s_Superbundles.Count; ++i) { var s_SuperBundleEntry = s_Superbundles[i].Value as DbObject; var s_Name = s_SuperBundleEntry?["name"]; if (s_Name == null) { continue; } // Get the path of the superbundle var s_SbPath = (string)s_Name.Value; // Create a new superbundle entry to keep track of the superbundle var s_Entry = new SuperbundleEntry(s_SbPath); // Figure out in which package this entry is in (if any). if (!FileSystem.FileExists("/game/Data/" + s_Entry.Name + ".sb") || !FileSystem.FileExists("/game/Data/" + s_Entry.Name + ".toc")) { foreach (var s_Package in Packages) { if (!FileSystem.FileExists("/game" + s_Package.Path + "/Data/" + s_Entry.Name + ".sb") || !FileSystem.FileExists("/game" + s_Package.Path + "/Data/" + s_Entry.Name + ".toc")) { continue; } s_Entry.ContainedPackage = s_Package; break; } // Base superbundle doesn't exist at all. if (s_Entry.ContainedPackage == null) { continue; } } // Check whether this entry also exists in the authoritative package. if (AuthoritativePackage != null && FileSystem.FileExists("/game" + AuthoritativePackage.Path + "/Data/" + s_Entry.Name + ".sb") && FileSystem.FileExists("/game" + AuthoritativePackage.Path + "/Data/" + s_Entry.Name + ".toc")) { s_Entry.AuthoritativePackage = AuthoritativePackage; } Superbundles.Add(s_Entry); } }