Skip to content

Instantly share code, notes, and snippets.

@DCxDemo
Created February 23, 2025 15:21
Show Gist options
  • Select an option

  • Save DCxDemo/bd3c2c31951dbd5c62c5695cae65ca9c to your computer and use it in GitHub Desktop.

Select an option

Save DCxDemo/bd3c2c31951dbd5c62c5695cae65ca9c to your computer and use it in GitHub Desktop.
Fight'n Rage asset extractor
using System;
using System.IO;
using System.IO.Compression;
using System.Threading;
internal class Program
{
static void Main(string[] args)
{
try
{
FightnExtractApp();
}
catch (Exception ex)
{
// check is game exe is even there
if (!File.Exists("FIGHT_N_RAGE.exe"))
{
Console.WriteLine("There is no FIGHT_N_RAGE.exe in this folder.");
Console.WriteLine("Please copy this tool to your Fight'n Rage game folder.\r\n");
}
Console.WriteLine(ex.Message);
Console.WriteLine(ex.ToString() + "\r\n");
Console.WriteLine("Press any key to exit...");
// wait for user input
Console.ReadKey();
}
}
// extraction tool entry point
public static void FightnExtractApp()
{
Console.WriteLine("Fight'n Rage asset extractor - dcxdemo, 2025\r\n");
// we will use this file name for temp data
var tempFile = "fightnrage_temp_can_delete";
// extract file list
// first file contains a list of filenames in assets folder
// every even line is filename, every odd line is filename
FightnExtractAsset("data/0.dat", tempFile);
// extract files, using the decompressed list
FightnExtractAll(tempFile);
// cleanup
if (File.Exists(tempFile))
File.Delete(tempFile);
// we're done
Console.WriteLine("\r\nDone!");
// wait a second
Thread.Sleep(1000);
}
// extract single asset
public static void FightnExtractAsset(string assetname, string targetname = "test.txt")
{
using (var file = File.Open(assetname, FileMode.Open))
{
// read header int
var br = new BinaryReader(file);
uint header = br.ReadUInt32();
file.Position = 0;
// this is GZIP specific header
// if header is present, decompress, otherwise simply copy
// not all game data is gzip compressed, notably music is not compressed.
if (header == 0x00088b1f)
{
// compressed
var packed = new GZipStream(file, CompressionMode.Decompress);
var unpacked = File.Create(targetname);
packed.CopyTo(unpacked);
packed.Close();
unpacked.Flush();
unpacked.Close();
file.Close();
}
else
{
// not compressed
file.Close();
if (File.Exists(targetname))
File.Delete(targetname);
File.Copy(assetname, targetname);
}
// print a dot, just to give some progress
Console.Write(".");
}
}
// extract all assets
public static void FightnExtractAll(string rootlistfile)
{
// read lines from the list
var lines = File.ReadAllLines(rootlistfile);
for (int i = 0; i < lines.Length / 2; i++)
{
// every even line is name
var name = lines[i * 2];
// every odd line is size
int size = 0;
Int32.TryParse(lines[i * 2 + 1], out size);
// validate path and create if needed
var path = Path.GetDirectoryName(name);
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
// get indexed dat file path and decompress the asset
FightnExtractAsset($"data/{i + 1}.dat", name);
}
Console.WriteLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment