Skip to content
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

Easy way to fix LocalData related file loading error #402

Closed
pine-apple-pie opened this issue Jun 3, 2024 · 1 comment
Closed

Easy way to fix LocalData related file loading error #402

pine-apple-pie opened this issue Jun 3, 2024 · 1 comment

Comments

@pine-apple-pie
Copy link

I discovered a much easier way of resolving this issue than the one posted in readme which I could not fully understand.
https://github.com/pixeltris/YgoMaster/blob/master/Docs/FileLoadError.md

Start up a command prompt in admin mode and type:
mklink /d "Path to MD folder\LocalData\0000000" "Path to MD folder\LocalData\random letters"
This sets up a symbolic link between your actual MD cache folder and the folder \00000000\ (which YgoMaster uses).

#401

@pixeltris
Copy link
Owner

There is code which handles the folder lookup:

static void SetupStorageDirectory(IntPtr thisPtr, IntPtr storage, IntPtr mountPath)
{
string path = new IL2String(mountPath).ToString();
//Console.WriteLine("Mount: " + path);
if (!string.IsNullOrEmpty(path))
{
// NOTE: Allowing "/../LocalSave/" to point to "00000000"
string localDataPath = "/../LocalData/";
int localDataPathIndex = path.IndexOf(localDataPath);
if (localDataPathIndex >= 0)
{
string folderName = path.Substring(localDataPathIndex + localDataPath.Length);
path = path.Substring(0, localDataPathIndex + localDataPath.Length);
if (folderName == "00000000")
{
Dictionary<string, DateTime> possibleFolders = new Dictionary<string, DateTime>();
Dictionary<string, DateTime> possibleFoldersExactMatch = new Dictionary<string, DateTime>();
foreach (string dir in Directory.GetDirectories(path))
{
DirectoryInfo dirInfo = new DirectoryInfo(dir);
if (dirInfo.Name != folderName)
{
// Exodia the Forbidden One (card image) - "Card/Images/Illust/tcg/4027"
string findFile = Path.Combine(dirInfo.FullName, "0000", "f5", "f5e2cfa8");
if (File.Exists(findFile))
{
possibleFoldersExactMatch[dirInfo.Name] = dirInfo.LastWriteTime;
}
else
{
possibleFolders[dirInfo.Name] = dirInfo.LastWriteTime;
}
}
}
if (possibleFoldersExactMatch.Count > 0)
{
folderName = possibleFoldersExactMatch.OrderByDescending(x => x.Value).First().Key;
}
else if (possibleFolders.Count > 0)
{
folderName = possibleFolders.OrderByDescending(x => x.Value).First().Key;
}
}
path += folderName;
LocalDataDir = path;
}
hookSetupStorageDirectory.Original(thisPtr, storage, new IL2String(path).ptr);
}
else
{
hookSetupStorageDirectory.Original(thisPtr, storage, mountPath);
}
}
}

People usually either have outdated folders or multiple folders inside of LocalData which is where problems arise from.

There is also an issue with LocalSave where by the client seemingly expects some data which results in the error if not correct. That's the reason for the LocalSave copying instructions. I haven't looked deeply into the exact causes of this one and it could be the symlink fixes those but this should be something that should be fixed where the issue occurs in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants