Jump to content

NI diff


Recommended Posts

I'm not sure I can get it working. I downloaded the archive from the location the bigg linked me to and extracted the files to NI directory. Was I supposed to apply the diff at that point or is it just there for reference purposes? Either way, I re-archived the jar and ran it but there seems to be no change. NI still reports that it cannot locate the biffs.


Would it be easier to write a script which lowercased all the names in the chitin.key?

Link to comment

Hmm, I installed the JDK RPM and messed around with $PATH for a bit to get it to use the right binaries (there was some stupid GNU Java stuff in the way).


When I ran the make command however I got a few warnings and then the following error:

java.lang.ClassCastException: java.io.File cannot be cast to sun.misc.JarIndex
	at sun.tools.jar.Main.update(Main.java:459)
	at sun.tools.jar.Main.run(Main.java:184)
	at sun.tools.jar.Main.main(Main.java:1022)
make: *** [jar] Error 123

Is there anything I can do?



It's ok, turned out it was just easier to go through chitin.key and make everything lowercase.

Link to comment

khexedit chitin.key &


It's binary so a normal text editor will give you jargon. KHexEdit gives you the binary and the ASCII together.


That's if you have KDE. I'm not sure what the GNOME/XFCE equivalent is, I'm sure there's some standalone linux hexeditors out there.


Basically you need to get to the part of the file where you see a lot of DATA/FOO. The rest of the file lists all the files inside the biffs so you can ignore that. You can then go through and make all those filepaths lowercase. It takes a while... I find it's quicker if you skip all the areas because I never use NI for area editing.


If I was really motivated I would write a script to do it automatically (it's only a case of finding the offsets for that DATA/FOO chunk and then shifting the byte values up by a fixed amount (can't remember what it is between upper and lowercase)) but that would require some research as I have very little experience with working with binary.

Link to comment

thanks. I think I will wait for a script, because I don't want to edit so many entries; I've installed many (so many) mods, which means a huge multiplication of the entries to edit, but also I'm fed up with Baldur's modification ;)


Actually, I've been able to run Shadowkeeper (only by renaming CHITIN.KEY to chitin.key), which is not exactly the same program, but it could help also.

Link to comment

Yeah Shadowkeeper and DLTCEP will work because they're being run through Wine which will ignore case for you but NI is run natively via Java and so doesn't. The patch was supposed to fix that but I've been unable to get it to compile properly.


Actually, unless you've biffed your override folder your chitin.key will stay exactly the same because the mods just stick stuff in the override and the vanilla biffs don't get touched (except for some mega-mods which automatically biff their files - although that's done via batch script which won't run on Linux). Once you ignore all the area biffs there really aren't that many things to make lowercase (the biff locations are a very tiny part of the chitin.key, the rest is biff contents which you don't need to worry about). If you really need to work with areas then it will take ages but otherwise it'll be a max of 10 mins I'd say.

Link to comment

OK, I wrote a PHP script for it:


function read_long($h, $offset) {
	fseek($h, $offset);
	$ar = unpack('L', fread($h, 4));
	return (int) $ar[1];

function read_short($h, $offset) {
	fseek($h, $offset);
	$ar = unpack('S', fread($h, 2));
	return (int) $ar[1];

$h = fopen('chitin.key', 'r+b');
$num_entries = read_long($h, 0x0008);
$entries_offset = read_long($h, 0x0010);
$start = ($num_entries * 12) + $entries_offset;
$coff = $entries_offset;
$total_len = 0;
for($i = 0; $i < $num_entries; $i++) {
	$readfrom = $coff + 8;
	$total_len += read_short($h, $readfrom);
	$coff += 12;
fseek($h, $start);
$data = strtolower(fread($h, $total_len));
fseek($h, $start);
fwrite($h, $data);

Copy and paste that into a file called 'chitin-lower' and save it in your BG2 directory. Right-click the file, go to the Permissions tab and check the 'executable' box. Or open up a terminal and do:

$ chmod +x chitin-lower


Then you should just be able to do:

$ ./chitin-lower



Oh yeah, you'll need the CLI version of PHP installed but I think it's standard on most distros and if not there'll be a DEB/RPM out there for it.


Oh and make a backup of your chitin.key file first >_<. I've tested it myself and it worked but I will not accept any responsibility for it running rampant and deleting all your system files.

Link to comment


This topic is now archived and is closed to further replies.

  • Create New...