/sorcery-xtractobb

Tool to extract Inkle's Sorcery! OBB files

Primary LanguageC++OtherNOASSERTION

Badges

JSONT License: MIT Other License: GPL v3

CodeFactor Grade LGTM Alerts LGTM Grade

CI Mac OS Catalina 10.15 CI Ubuntu 20.04 CI Windows Server 2019

Coverity Scan Analysis Coverity Scan

Windows snapshot build Latest Windows snapshot

Inkle Sorcery! Extractor

This software is capable of extracting the Android OBB files used in the Inkle Sorcery! series. It is possible that other Inkle games can also be extracted with this tool, but I did not test it.

To compile this tool you need a C++17-compatible compiler (GCC 7 is enough), as well as Boost. When you meet the requirements, run "make" and the "xtractobb" executable will be created. Its usage is:

xtractobb <obbfile> <outputdir>

The tool will scan all files packed into the OBB and extract them into the output directory. It will also create a "SorceryN-Reference.json" file that stitches together "SorceryN.json" with the contents of "SorceryN.inkcontent".

Also provided is a "xtract_all_obbs.sh" which will extract all Sorcery! OBBs and link all JSON files for easier browsing.

TODO

  • Create a OBB directory abstraction layer;
  • Determine main story filename using "StoryFilename" and "[StoryFilename]PartNumber" properties from "Info.plist" file instead of hard-coding;
  • Use "indexed-content/filename" attribute in story file to determine inkcontent file instead of hard-coding;
  • Support for other Inkle games;
  • Support for generating new OBB files;
  • Decompile the reference file into Ink script;
  • Use a different JSON tokenizer.
  • Get Coverity working again once it supports GCC8/c++17
  • Figure out what the ktx files are on the Steam version

Notes on file types

Most of the extracted files should be easily readable. There are two file types that need some additional care: the img and ktx files. These files are always paired up as such:

  • either a <filename>.img + <filename>.ktx pair;
  • or a <filename>.img + <filename>.ktx + <filename>.alpha.ktx triple.

The img files are metadata for the corresponding ktx file(s); they are always 20 bytes long, being composed of 5 little endian 4-byte integers:

  • Always a 3 or 4; I believe this is the number of channels in the composed texture
  • Width of texture
  • Height of texture
  • Width of alpha texture
  • Height of alpha texture

The ktx files are trickier: in the Android version (and, presumably, the iOS version), they are Khronos Textures, and typically comes in pairs: one <filename>.ktx and one <filename>.alpha.ktx. The alpha file, when present, must be merged in as an alpha channel in the "main" ktx file, and they must both be resized according to the metadata in the corresponding img file. You can obtain software for reading ktx files here.

In the Steam version, the ktx files are in a different format, and the separate alpha files do not exist; what format these are in is unknown at this time.