-
Notifications
You must be signed in to change notification settings - Fork 28
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
IO.MPQ MapHash.cs GetHashedFileName #59
Comments
I didn't write the implementation for the hashing algorithm myself and I'm not sure if it's a bug or if the algorithm simply does not support chinese characters. Have you tried different tools to see if they have the same problem? Or if it works in different tools, can you give an example chinese file name and its hashed value? I could probably fix this by UTF8 encoding the string to a byte array, but I'm not sure if that would give the correct result, so if you can please provide an example so I can test if the solution is correct. |
var map = Map.Open("input.w3x", MapFiles.All
& ~MapFiles.Script
& ~MapFiles.Triggers
);
MapBuilder mapBuilder = new(map);
mapBuilder.Build("out.w3x"); If "test.w3x" file contains any Chinese file name, this code will report an error, for example, if there is a '攻击之爪.blp' file in this' "test. w3x" file [DllImport("Stormlib.dll")]
public static extern int SFileAddFileEx(
uint hMpq,
[MarshalAs(UnmanagedType.LPWStr)] string szFileName,
[MarshalAs(UnmanagedType.LPArray)] byte[] szArchivedName,
uint dwFlags,
uint dwCompression,
uint dwCompressionNext
);
public static byte[] GetArchivedNameBytes(string fileName)
{
var bytes = Encoding.UTF8.GetBytes(fileName);
var result = new byte[bytes.Length + 1];
Array.Copy(bytes, result, bytes.Length);
result[bytes.Length] = 0;
return result;
}
public bool AddFile(string archivedName, string path)
{
if (Handle == 0)
return false;
if (ReadOnly)
throw new ArgumentException("ReadOnly Modeing Not AddFile!!!");
if (!File.Exists(path))
throw new FileNotFoundException("File not found.", path);
lock (_lock)
{
return 1 == StormLib.SFileAddFileEx(
Handle,
path,
StormLib.GetArchivedNameBytes(archivedName),
StormLib.MPQ_FILE_COMPRESS | StormLib.MPQ_FILE_REPLACEEXISTING,
StormLib.MPQ_COMPRESSION_ZLIB,
StormLib.MPQ_COMPRESSION_ZLIB
);
}
} I used 'Stormlib. dll' to solve this problem |
I think you can support UTF8 so that Chinese can be used. Also, external JASS functions are not supported in Triggers. Can we make some changes |
This function reports an error when packaging in MapBuilder. I think it's a problem with the Chinese file name? How to repair it? Please help me.
The text was updated successfully, but these errors were encountered: