Jump to content


Photo

cah_file - Battle for Middle-Earth II - Rise of the Witch-king: .cah (CreateAHero) parser/writer (ALAESTR2)

createahero cah alae2str eala rts2

  • Please log in to reply
1 reply to this topic

#1 withmorten

withmorten
  • Members
  • 21 posts
  • Location:Berlin

Posted 11 February 2022 - 11:39 PM

Hi there, first productive thread here in a long time, or rather, ever :)

 

Last week I had a look at the CreateAHero file format, and since I couldn't find anything that parses/documents it, I wrote a quick parser in c-style .cpp that parses, and can edit it.

 

You can find the source code here: https://github.com/withmorten/cah_file

 

src/cah_file.h and cah_file::read should explain the format easily just by reading the code, for anybody even slightly acquainted with programming languages.

 

Every string that is read has a byte detailing the string length before it.

 

The file ends with a standard CRC32 checksum, implementation probably "inspired" from this famous example: https://web.mit.edu/...libkern/crc32.c

 

This tool can i.e. update the GUID of a CreateAHero (not on by default, you have to compile it yourself), and update the checksum so the game accepts it as valid.

 

I added some helper functions that require more logic than just simply setting a field, for the rest, go wild. Specifically is_system_hero at the bottom might be interesting.

 

The original rotwk exe nicely includes some strings that detail the names of the entries in the file, i.e. IsSystemHero and all the other comments written in PascalCase.

 

Feel free to use the info contained in that repository for your projects, with credit or without!

 

(I added the ALAE2STR to the title since that's the one thing you can see when you open the file in a Hex Editor)


Edited by withmorten, 11 February 2022 - 11:42 PM.


#2 OfficialNecro

OfficialNecro
  • Members
  • 12 posts
  • Location:Wales

Posted 28 December 2022 - 09:15 PM

I'm glad you added ALAESTR2 to the title, it's what lead me here. Really cool job, you just saved me a bunch of time :thumbsuphappy:


Posted Image





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users