(XP3): implemented more CX encryption extensions.

This commit is contained in:
morkt
2018-04-07 03:09:04 +04:00
parent 8e7916556c
commit 9c3710d7f6
3 changed files with 110 additions and 74 deletions

View File

@@ -1034,68 +1034,6 @@ namespace GameRes.Formats.KiriKiri
}
}
[Serializable]
public class NanaCxCrypt : CxEncryption
{
uint m_random_seed;
public string FileMapName { get; set; }
public NanaCxCrypt (CxScheme scheme, uint seed) : base (scheme)
{
m_random_seed = seed;
}
internal override CxProgram NewProgram (uint seed)
{
return new CxProgramNana (seed, m_random_seed, ControlBlock);
}
public override string ReadName (BinaryReader header)
{
if (null == KnownNames)
ReadNames();
var hash = base.ReadName (header);
string name;
if (null == hash || !KnownNames.TryGetValue (hash, out name))
return hash;
if (string.IsNullOrEmpty (name))
return null;
return name;
}
void ReadNames ()
{
var dir = FormatCatalog.Instance.DataDirectory;
var names_file = Path.Combine (dir, FileMapName);
var names = new Dictionary<string, string> { { "$", "startup.tjs" } };
try
{
var hash_buf = new char[32];
using (var reader = new StreamReader (names_file))
{
while (32 == reader.Read (hash_buf, 0, 32))
{
if (',' != reader.Read())
break;
var name = reader.ReadLine();
if (null == name)
break;
names[new string (hash_buf)] = name;
}
}
}
catch (Exception X)
{
System.Diagnostics.Trace.WriteLine (X.Message, "[SenrenCxCrypt]");
}
KnownNames = names;
}
[NonSerialized]
Dictionary<string, string> KnownNames = null;
}
[Serializable]
public class KissCrypt : CzCrypt
{