Coding the BAR archiver

Hi folks,

As I’ve mentioned in my previous post, I have been working on archiving code for Dračí Historie during the last week. The coding process went smoothly enough thanks to Robert’s helpful comments about the archive format; I have been able to do it almost without looking at the original code.

Before I implemented the archiver in C++, I coded a quick and dirty Python prototype to ease development and analysis of the game’s data files. Since I only need to implement those parts of the engine that are required to make the game playable, I wanted to check which features of the original archiver were used in creating the final data files. To my surprise, none of the files appeared to use compression even though the original archiver was capable of handling multiple types (including LZW and Huffman coding). After a bit of digging around, Robert confirmed that this was indeed the case. Too bad; I was looking forward to implementing a Huffman tree for something other than university assignments. ?

I also did a tremendously stupid thing which I would like to share since it almost cost me my entire code. During development, I kept the code in a working copy of ScummVM’s Subversion repository. When I needed to make a diff of the work, I noticed that I haven’t yet made svn keep track of the new files. I did a ‘svn add’ on the whole directory, but then I realised that it added a bunch of temporary files my editor had left there. Not really thinking it through, I did a ”svn delete’ on the whole directory, planning to readd it once I’ve deleted the superfluous files. Of course, the files had never been committed before and I forgot to use the ‘–keep-local’ option. The moment I realised what I had done, my mind painfully replayed all those stories about how ext3 files cannot be easily undeleted. Fortunately for me, a bit of googling turned up this (a very good read). Naturally, the entire incident happened moments before I wanted to send the code to the patch tracker. I have to learn to backup more often.

I was away during the last three days so I haven’t done much work during that time. The next thing on my list is to implement a basic parser/decompiler of the game’s scripting language bytecode. The original parser is written in x86 assembly so I’m expecting loads of fun with it. I’ll also have to investigate which streams in the archives contain the bytecode.

I’ll keep you posted on that.