ApplicationLibrary.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. using JsonPrettyPrinterPlus;
  2. using LibHac;
  3. using LibHac.Common;
  4. using LibHac.Fs;
  5. using LibHac.Fs.Shim;
  6. using LibHac.FsSystem;
  7. using LibHac.FsSystem.NcaUtils;
  8. using LibHac.Ncm;
  9. using LibHac.Ns;
  10. using LibHac.Spl;
  11. using Ryujinx.Common.Logging;
  12. using Ryujinx.Configuration.System;
  13. using Ryujinx.HLE.FileSystem;
  14. using Ryujinx.HLE.Loaders.Npdm;
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Globalization;
  18. using System.IO;
  19. using System.Linq;
  20. using System.Reflection;
  21. using System.Text;
  22. using Utf8Json;
  23. using Utf8Json.Resolvers;
  24. using RightsId = LibHac.Fs.RightsId;
  25. namespace Ryujinx.Ui
  26. {
  27. public class ApplicationLibrary
  28. {
  29. public static event EventHandler<ApplicationAddedEventArgs> ApplicationAdded;
  30. public static event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated;
  31. private static readonly byte[] _nspIcon = GetResourceBytes("Ryujinx.Ui.assets.NSPIcon.png");
  32. private static readonly byte[] _xciIcon = GetResourceBytes("Ryujinx.Ui.assets.XCIIcon.png");
  33. private static readonly byte[] _ncaIcon = GetResourceBytes("Ryujinx.Ui.assets.NCAIcon.png");
  34. private static readonly byte[] _nroIcon = GetResourceBytes("Ryujinx.Ui.assets.NROIcon.png");
  35. private static readonly byte[] _nsoIcon = GetResourceBytes("Ryujinx.Ui.assets.NSOIcon.png");
  36. private static VirtualFileSystem _virtualFileSystem;
  37. private static Language _desiredTitleLanguage;
  38. private static bool _loadingError;
  39. public static IEnumerable<string> GetFilesInDirectory(string directory)
  40. {
  41. Stack<string> stack = new Stack<string>();
  42. stack.Push(directory);
  43. while (stack.Count > 0)
  44. {
  45. string dir = stack.Pop();
  46. string[] content = { };
  47. try
  48. {
  49. content = Directory.GetFiles(dir, "*");
  50. }
  51. catch (UnauthorizedAccessException)
  52. {
  53. Logger.PrintWarning(LogClass.Application, $"Failed to get access to directory: \"{dir}\"");
  54. }
  55. if (content.Length > 0)
  56. {
  57. foreach (string file in content)
  58. yield return file;
  59. }
  60. try
  61. {
  62. content = Directory.GetDirectories(dir);
  63. }
  64. catch (UnauthorizedAccessException)
  65. {
  66. Logger.PrintWarning(LogClass.Application, $"Failed to get access to directory: \"{dir}\"");
  67. }
  68. if (content.Length > 0)
  69. {
  70. foreach (string subdir in content)
  71. stack.Push(subdir);
  72. }
  73. }
  74. }
  75. public static void ReadControlData(IFileSystem controlFs, Span<byte> outProperty)
  76. {
  77. controlFs.OpenFile(out IFile controlFile, "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure();
  78. controlFile.Read(out long _, 0, outProperty, ReadOption.None).ThrowIfFailure();
  79. }
  80. public static void LoadApplications(List<string> appDirs, VirtualFileSystem virtualFileSystem, Language desiredTitleLanguage)
  81. {
  82. int numApplicationsFound = 0;
  83. int numApplicationsLoaded = 0;
  84. _loadingError = false;
  85. _virtualFileSystem = virtualFileSystem;
  86. _desiredTitleLanguage = desiredTitleLanguage;
  87. // Builds the applications list with paths to found applications
  88. List<string> applications = new List<string>();
  89. foreach (string appDir in appDirs)
  90. {
  91. if (!Directory.Exists(appDir))
  92. {
  93. Logger.PrintWarning(LogClass.Application, $"The \"game_dirs\" section in \"Config.json\" contains an invalid directory: \"{appDir}\"");
  94. continue;
  95. }
  96. foreach (string app in GetFilesInDirectory(appDir))
  97. {
  98. if ((Path.GetExtension(app).ToLower() == ".nsp") ||
  99. (Path.GetExtension(app).ToLower() == ".pfs0") ||
  100. (Path.GetExtension(app).ToLower() == ".xci") ||
  101. (Path.GetExtension(app).ToLower() == ".nca") ||
  102. (Path.GetExtension(app).ToLower() == ".nro") ||
  103. (Path.GetExtension(app).ToLower() == ".nso"))
  104. {
  105. applications.Add(app);
  106. numApplicationsFound++;
  107. }
  108. }
  109. }
  110. // Loops through applications list, creating a struct and then firing an event containing the struct for each application
  111. foreach (string applicationPath in applications)
  112. {
  113. double fileSize = new FileInfo(applicationPath).Length * 0.000000000931;
  114. string titleName = "Unknown";
  115. string titleId = "0000000000000000";
  116. string developer = "Unknown";
  117. string version = "0";
  118. string saveDataPath = null;
  119. byte[] applicationIcon = null;
  120. BlitStruct<ApplicationControlProperty> controlHolder = new BlitStruct<ApplicationControlProperty>(1);
  121. try
  122. {
  123. using (FileStream file = new FileStream(applicationPath, FileMode.Open, FileAccess.Read))
  124. {
  125. if ((Path.GetExtension(applicationPath).ToLower() == ".nsp") ||
  126. (Path.GetExtension(applicationPath).ToLower() == ".pfs0") ||
  127. (Path.GetExtension(applicationPath).ToLower() == ".xci"))
  128. {
  129. try
  130. {
  131. PartitionFileSystem pfs;
  132. bool isExeFs = false;
  133. if (Path.GetExtension(applicationPath).ToLower() == ".xci")
  134. {
  135. Xci xci = new Xci(_virtualFileSystem.KeySet, file.AsStorage());
  136. pfs = xci.OpenPartition(XciPartitionType.Secure);
  137. }
  138. else
  139. {
  140. pfs = new PartitionFileSystem(file.AsStorage());
  141. // If the NSP doesn't have a main NCA, decrement the number of applications found and then continue to the next application.
  142. bool hasMainNca = false;
  143. foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*"))
  144. {
  145. if (Path.GetExtension(fileEntry.FullPath).ToLower() == ".nca")
  146. {
  147. pfs.OpenFile(out IFile ncaFile, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
  148. Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFile.AsStorage());
  149. int dataIndex = Nca.GetSectionIndexFromType(NcaSectionType.Data, NcaContentType.Program);
  150. if (nca.Header.ContentType == NcaContentType.Program && !nca.Header.GetFsHeader(dataIndex).IsPatchSection())
  151. {
  152. hasMainNca = true;
  153. break;
  154. }
  155. }
  156. else if (Path.GetFileNameWithoutExtension(fileEntry.FullPath) == "main")
  157. {
  158. isExeFs = true;
  159. }
  160. }
  161. if (!hasMainNca && !isExeFs)
  162. {
  163. numApplicationsFound--;
  164. continue;
  165. }
  166. }
  167. if (isExeFs)
  168. {
  169. applicationIcon = _nspIcon;
  170. Result result = pfs.OpenFile(out IFile npdmFile, "/main.npdm".ToU8Span(), OpenMode.Read);
  171. if (ResultFs.PathNotFound.Includes(result))
  172. {
  173. Npdm npdm = new Npdm(npdmFile.AsStream());
  174. titleName = npdm.TitleName;
  175. titleId = npdm.Aci0.TitleId.ToString("x16");
  176. }
  177. }
  178. else
  179. {
  180. // Store the ControlFS in variable called controlFs
  181. GetControlFsAndTitleId(pfs, out IFileSystem controlFs, out titleId);
  182. ReadControlData(controlFs, controlHolder.ByteSpan);
  183. // Creates NACP class from the NACP file
  184. controlFs.OpenFile(out IFile controlNacpFile, "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure();
  185. Nacp controlData = new Nacp(controlNacpFile.AsStream());
  186. // Get the title name, title ID, developer name and version number from the NACP
  187. version = controlData.DisplayVersion;
  188. GetNameIdDeveloper(controlData, out titleName, out _, out developer);
  189. // Read the icon from the ControlFS and store it as a byte array
  190. try
  191. {
  192. controlFs.OpenFile(out IFile icon, $"/icon_{_desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure();
  193. using (MemoryStream stream = new MemoryStream())
  194. {
  195. icon.AsStream().CopyTo(stream);
  196. applicationIcon = stream.ToArray();
  197. }
  198. }
  199. catch (HorizonResultException)
  200. {
  201. foreach (DirectoryEntryEx entry in controlFs.EnumerateEntries("/", "*"))
  202. {
  203. if (entry.Name == "control.nacp")
  204. {
  205. continue;
  206. }
  207. controlFs.OpenFile(out IFile icon, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
  208. using (MemoryStream stream = new MemoryStream())
  209. {
  210. icon.AsStream().CopyTo(stream);
  211. applicationIcon = stream.ToArray();
  212. }
  213. if (applicationIcon != null)
  214. {
  215. break;
  216. }
  217. }
  218. if (applicationIcon == null)
  219. {
  220. applicationIcon = Path.GetExtension(applicationPath).ToLower() == ".xci" ? _xciIcon : _nspIcon;
  221. }
  222. }
  223. }
  224. }
  225. catch (MissingKeyException exception)
  226. {
  227. applicationIcon = Path.GetExtension(applicationPath).ToLower() == ".xci" ? _xciIcon : _nspIcon;
  228. Logger.PrintWarning(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}");
  229. }
  230. catch (InvalidDataException)
  231. {
  232. applicationIcon = Path.GetExtension(applicationPath).ToLower() == ".xci" ? _xciIcon : _nspIcon;
  233. Logger.PrintWarning(LogClass.Application, $"The header key is incorrect or missing and therefore the NCA header content type check has failed. Errored File: {applicationPath}");
  234. }
  235. catch (Exception exception)
  236. {
  237. Logger.PrintWarning(LogClass.Application, $"The file encountered was not of a valid type. Errored File: {applicationPath}");
  238. Logger.PrintDebug(LogClass.Application, exception.ToString());
  239. numApplicationsFound--;
  240. _loadingError = true;
  241. continue;
  242. }
  243. }
  244. else if (Path.GetExtension(applicationPath).ToLower() == ".nro")
  245. {
  246. BinaryReader reader = new BinaryReader(file);
  247. byte[] Read(long position, int size)
  248. {
  249. file.Seek(position, SeekOrigin.Begin);
  250. return reader.ReadBytes(size);
  251. }
  252. try
  253. {
  254. file.Seek(24, SeekOrigin.Begin);
  255. int assetOffset = reader.ReadInt32();
  256. if (Encoding.ASCII.GetString(Read(assetOffset, 4)) == "ASET")
  257. {
  258. byte[] iconSectionInfo = Read(assetOffset + 8, 0x10);
  259. long iconOffset = BitConverter.ToInt64(iconSectionInfo, 0);
  260. long iconSize = BitConverter.ToInt64(iconSectionInfo, 8);
  261. ulong nacpOffset = reader.ReadUInt64();
  262. ulong nacpSize = reader.ReadUInt64();
  263. // Reads and stores game icon as byte array
  264. applicationIcon = Read(assetOffset + iconOffset, (int) iconSize);
  265. // Creates memory stream out of byte array which is the NACP
  266. using (MemoryStream stream = new MemoryStream(Read(assetOffset + (int) nacpOffset, (int) nacpSize)))
  267. {
  268. // Creates NACP class from the memory stream
  269. Nacp controlData = new Nacp(stream);
  270. // Get the title name, title ID, developer name and version number from the NACP
  271. version = controlData.DisplayVersion;
  272. GetNameIdDeveloper(controlData, out titleName, out titleId, out developer);
  273. }
  274. }
  275. else
  276. {
  277. applicationIcon = _nroIcon;
  278. titleName = Path.GetFileNameWithoutExtension(applicationPath);
  279. }
  280. }
  281. catch
  282. {
  283. Logger.PrintWarning(LogClass.Application, $"The file encountered was not of a valid type. Errored File: {applicationPath}");
  284. numApplicationsFound--;
  285. continue;
  286. }
  287. }
  288. else if (Path.GetExtension(applicationPath).ToLower() == ".nca")
  289. {
  290. try
  291. {
  292. Nca nca = new Nca(_virtualFileSystem.KeySet, new FileStream(applicationPath, FileMode.Open, FileAccess.Read).AsStorage());
  293. int dataIndex = Nca.GetSectionIndexFromType(NcaSectionType.Data, NcaContentType.Program);
  294. if (nca.Header.ContentType != NcaContentType.Program || nca.Header.GetFsHeader(dataIndex).IsPatchSection())
  295. {
  296. numApplicationsFound--;
  297. continue;
  298. }
  299. }
  300. catch (InvalidDataException)
  301. {
  302. Logger.PrintWarning(LogClass.Application, $"The NCA header content type check has failed. This is usually because the header key is incorrect or missing. Errored File: {applicationPath}");
  303. }
  304. catch
  305. {
  306. Logger.PrintWarning(LogClass.Application, $"The file encountered was not of a valid type. Errored File: {applicationPath}");
  307. numApplicationsFound--;
  308. _loadingError = true;
  309. continue;
  310. }
  311. applicationIcon = _ncaIcon;
  312. titleName = Path.GetFileNameWithoutExtension(applicationPath);
  313. }
  314. // If its an NSO we just set defaults
  315. else if (Path.GetExtension(applicationPath).ToLower() == ".nso")
  316. {
  317. applicationIcon = _nsoIcon;
  318. titleName = Path.GetFileNameWithoutExtension(applicationPath);
  319. }
  320. }
  321. }
  322. catch (IOException exception)
  323. {
  324. Logger.PrintWarning(LogClass.Application, exception.Message);
  325. numApplicationsFound--;
  326. _loadingError = true;
  327. continue;
  328. }
  329. ApplicationMetadata appMetadata = LoadAndSaveMetaData(titleId);
  330. if (ulong.TryParse(titleId, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong titleIdNum))
  331. {
  332. SaveDataFilter filter = new SaveDataFilter();
  333. filter.SetUserId(new UserId(1, 0));
  334. filter.SetProgramId(new TitleId(titleIdNum));
  335. Result result = virtualFileSystem.FsClient.FindSaveDataWithFilter(out SaveDataInfo saveDataInfo, SaveDataSpaceId.User, ref filter);
  336. if (result.IsSuccess())
  337. {
  338. saveDataPath = Path.Combine(virtualFileSystem.GetNandPath(), $"user/save/{saveDataInfo.SaveDataId:x16}");
  339. }
  340. }
  341. ApplicationData data = new ApplicationData()
  342. {
  343. Favorite = appMetadata.Favorite,
  344. Icon = applicationIcon,
  345. TitleName = titleName,
  346. TitleId = titleId,
  347. Developer = developer,
  348. Version = version,
  349. TimePlayed = ConvertSecondsToReadableString(appMetadata.TimePlayed),
  350. LastPlayed = appMetadata.LastPlayed,
  351. FileExtension = Path.GetExtension(applicationPath).ToUpper().Remove(0 ,1),
  352. FileSize = (fileSize < 1) ? (fileSize * 1024).ToString("0.##") + "MB" : fileSize.ToString("0.##") + "GB",
  353. Path = applicationPath,
  354. SaveDataPath = saveDataPath,
  355. ControlHolder = controlHolder
  356. };
  357. numApplicationsLoaded++;
  358. OnApplicationAdded(new ApplicationAddedEventArgs()
  359. {
  360. AppData = data
  361. });
  362. OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs()
  363. {
  364. NumAppsFound = numApplicationsFound,
  365. NumAppsLoaded = numApplicationsLoaded
  366. });
  367. }
  368. OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs()
  369. {
  370. NumAppsFound = numApplicationsFound,
  371. NumAppsLoaded = numApplicationsLoaded
  372. });
  373. if (_loadingError)
  374. {
  375. Gtk.Application.Invoke(delegate
  376. {
  377. GtkDialog.CreateErrorDialog("One or more files encountered could not be loaded, check logs for more info.");
  378. });
  379. }
  380. }
  381. protected static void OnApplicationAdded(ApplicationAddedEventArgs e)
  382. {
  383. ApplicationAdded?.Invoke(null, e);
  384. }
  385. protected static void OnApplicationCountUpdated(ApplicationCountUpdatedEventArgs e)
  386. {
  387. ApplicationCountUpdated?.Invoke(null, e);
  388. }
  389. private static byte[] GetResourceBytes(string resourceName)
  390. {
  391. Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName);
  392. byte[] resourceByteArray = new byte[resourceStream.Length];
  393. resourceStream.Read(resourceByteArray);
  394. return resourceByteArray;
  395. }
  396. private static void GetControlFsAndTitleId(PartitionFileSystem pfs, out IFileSystem controlFs, out string titleId)
  397. {
  398. Nca controlNca = null;
  399. // Add keys to key set if needed
  400. foreach (DirectoryEntryEx ticketEntry in pfs.EnumerateEntries("/", "*.tik"))
  401. {
  402. Result result = pfs.OpenFile(out IFile ticketFile, ticketEntry.FullPath.ToU8Span(), OpenMode.Read);
  403. if (result.IsSuccess())
  404. {
  405. Ticket ticket = new Ticket(ticketFile.AsStream());
  406. _virtualFileSystem.KeySet.ExternalKeySet.Add(new RightsId(ticket.RightsId), new AccessKey(ticket.GetTitleKey(_virtualFileSystem.KeySet)));
  407. }
  408. }
  409. // Find the Control NCA and store it in variable called controlNca
  410. foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
  411. {
  412. pfs.OpenFile(out IFile ncaFile, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
  413. Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFile.AsStorage());
  414. if (nca.Header.ContentType == NcaContentType.Control)
  415. {
  416. controlNca = nca;
  417. }
  418. }
  419. // Return the ControlFS
  420. controlFs = controlNca?.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None);
  421. titleId = controlNca?.Header.TitleId.ToString("x16");
  422. }
  423. internal static ApplicationMetadata LoadAndSaveMetaData(string titleId, Action<ApplicationMetadata> modifyFunction = null)
  424. {
  425. string metadataFolder = Path.Combine(_virtualFileSystem.GetBasePath(), "games", titleId, "gui");
  426. string metadataFile = Path.Combine(metadataFolder, "metadata.json");
  427. IJsonFormatterResolver resolver = CompositeResolver.Create(new[] { StandardResolver.AllowPrivateSnakeCase });
  428. ApplicationMetadata appMetadata;
  429. if (!File.Exists(metadataFile))
  430. {
  431. Directory.CreateDirectory(metadataFolder);
  432. appMetadata = new ApplicationMetadata
  433. {
  434. Favorite = false,
  435. TimePlayed = 0,
  436. LastPlayed = "Never"
  437. };
  438. byte[] data = JsonSerializer.Serialize(appMetadata, resolver);
  439. File.WriteAllText(metadataFile, Encoding.UTF8.GetString(data, 0, data.Length).PrettyPrintJson());
  440. }
  441. using (Stream stream = File.OpenRead(metadataFile))
  442. {
  443. appMetadata = JsonSerializer.Deserialize<ApplicationMetadata>(stream, resolver);
  444. }
  445. if (modifyFunction != null)
  446. {
  447. modifyFunction(appMetadata);
  448. byte[] saveData = JsonSerializer.Serialize(appMetadata, resolver);
  449. File.WriteAllText(metadataFile, Encoding.UTF8.GetString(saveData, 0, saveData.Length).PrettyPrintJson());
  450. }
  451. return appMetadata;
  452. }
  453. private static string ConvertSecondsToReadableString(double seconds)
  454. {
  455. const int secondsPerMinute = 60;
  456. const int secondsPerHour = secondsPerMinute * 60;
  457. const int secondsPerDay = secondsPerHour * 24;
  458. string readableString;
  459. if (seconds < secondsPerMinute)
  460. {
  461. readableString = $"{seconds}s";
  462. }
  463. else if (seconds < secondsPerHour)
  464. {
  465. readableString = $"{Math.Round(seconds / secondsPerMinute, 2, MidpointRounding.AwayFromZero)} mins";
  466. }
  467. else if (seconds < secondsPerDay)
  468. {
  469. readableString = $"{Math.Round(seconds / secondsPerHour, 2, MidpointRounding.AwayFromZero)} hrs";
  470. }
  471. else
  472. {
  473. readableString = $"{Math.Round(seconds / secondsPerDay, 2, MidpointRounding.AwayFromZero)} days";
  474. }
  475. return readableString;
  476. }
  477. private static void GetNameIdDeveloper(Nacp controlData, out string titleName, out string titleId, out string developer)
  478. {
  479. Enum.TryParse(_desiredTitleLanguage.ToString(), out TitleLanguage desiredTitleLanguage);
  480. NacpDescription nacpDescription = controlData.Descriptions.ToList().Find(x => x.Language == desiredTitleLanguage);
  481. if (nacpDescription != null)
  482. {
  483. titleName = nacpDescription.Title;
  484. developer = nacpDescription.Developer;
  485. }
  486. else
  487. {
  488. titleName = null;
  489. developer = null;
  490. }
  491. if (string.IsNullOrWhiteSpace(titleName))
  492. {
  493. titleName = controlData.Descriptions.ToList().Find(x => !string.IsNullOrWhiteSpace(x.Title)).Title;
  494. }
  495. if (string.IsNullOrWhiteSpace(developer))
  496. {
  497. developer = controlData.Descriptions.ToList().Find(x => !string.IsNullOrWhiteSpace(x.Developer)).Developer;
  498. }
  499. if (controlData.PresenceGroupId != 0)
  500. {
  501. titleId = controlData.PresenceGroupId.ToString("x16");
  502. }
  503. else if (controlData.SaveDataOwnerId != 0)
  504. {
  505. titleId = controlData.SaveDataOwnerId.ToString("x16");
  506. }
  507. else if (controlData.AddOnContentBaseId != 0)
  508. {
  509. titleId = (controlData.AddOnContentBaseId - 0x1000).ToString("x16");
  510. }
  511. else
  512. {
  513. titleId = "0000000000000000";
  514. }
  515. }
  516. }
  517. }