DaggerXL is a Modern Daggerfall Engine Recreation for current Operating Systems and hardware – essentially it is a remake in the spirit of a port. It will ultimately fully emulate the game of Daggerfall and then optionally enhance it by refining existing features and adding new gameplay elements that were originally intended. The game will make use of hardware acceleration providing higher resolutions, color depth, greatly improved visibility, better texture filtering, enhanced performance and more. In addition DaggerXL will support full modability, similar to more modern Elder Scrolls games, using custom tools.

The last couple of days have been slow due to work, Halloween and such, so I’m still working on loading save games. However, to keep the news flowing, I’ll talk about a specific element - factions.

When loading a save game or starting a new game the first thing that needs to happen is to load the base faction data from FACTION.TXT. The parser first frees all the previous faction data and then counts the number of factions – by counting the number of times ’#' shows up in the text file. At this point, the parser looks for certain symbols: ’#’ for faction ID and ’:' for tags. Tags themselves are hashed, with a callback function being called for any matching table entry using the following table:

A few of the entries are ignored – the callback functions actually just skip past the data without recording it, but most fill out the Faction structure. The following tags are ignored: Summon (the game determines this using other methods), MinF, MaxF and Rank. Some tags can occur more then once – up to 2 flats, 3 allies and 3 enemies for example.

Then once all the factions are processed, enemy and ally IDs are converted to faction pointers. Once all this is complete, faction data is read from the save games and overwrites the data (but leaves the pointers as-is). These then have their pointers fixed up again.

So the factions in the text file determine the default faction data, including reputation (which doesn’t always start at 0). Only those factions that have been modified or that the player are directly a part of are actually tracked in the save game files. The rest stay at their default values – except for one thing. Each time the faction data is loaded, two random numbers are generated which are used to help determine certain behaviors (more on this later).

Anyway, here is the final Faction structure – I keep track of the actual hex offsets for each variable to make it easier for me to convert from offsets in the assembly code to the variable in the structure.

Obviously I already know how Bethesda hashed the tag names, since I reverse engineered the code that does it, but as a fun puzzle let’s see if any of you guys can figure it out – given the data below. This is one kind of puzzle that is often involved with this work since I oftentimes get data that is referenced but understanding the code requires understanding what the data actually means – which is very often not explicit in the code (though it was this time). Unfortunately they are not always as simple as this one.