Warspear-Online-Extractor/Program.cs

46 lines
1.5 KiB
C#
Raw Normal View History

2024-05-10 17:30:50 +02:00
//Written for Warspear Online. https://store.steampowered.com/app/326360
using System.IO;
namespace Warspear_Online_Extractor
{
class Program
{
public static BinaryReader br;
static void Main(string[] args)
{
br = new(File.OpenRead(args[0]));
if (new string(br.ReadChars(4)) != "MDPK")
throw new System.Exception("This is not Warspear Online's pak file.");
br.ReadInt16();//Version?
int count = br.ReadInt32();
string date = new string(br.ReadChars(10));
br.BaseStream.Position += 6;
System.Collections.Generic.List<Subfile> subfiles = new();
for (int i = 0; i < count; i++)
{
subfiles.Add(new());
}
string path = Path.GetDirectoryName(args[0]) + "//" + Path.GetFileNameWithoutExtension(args[0]) + "//";
foreach (Subfile file in subfiles)
{
Directory.CreateDirectory(path + Path.GetDirectoryName(file.name));
br.BaseStream.Position = file.start;
BinaryWriter bw = new(File.Create(path + file.name));
bw.Write(br.ReadBytes(file.size));
bw.Close();
}
}
class Subfile
{
2024-08-12 00:00:04 +02:00
public int start = br.ReadInt32(), size = br.ReadInt32(), unknown = br.ReadInt32();
2024-05-10 17:30:50 +02:00
byte unknown2 = br.ReadByte();
public string name = new string(br.ReadChars(55)).TrimEnd('\0');
}
}
}