Iterate all buildings in Daggerfall

Discuss coding questions, pull requests, and implementation details.
Post Reply
electrorobobody
Posts: 4
Joined: Wed Dec 21, 2016 6:18 am

Iterate all buildings in Daggerfall

Post by electrorobobody »

Using Daggerfall Unity I've tried to iterate through all buildings to gather some stats about the game world. And I found that Building Count for location (DFLocation) is different to number of buildings on all blocks (DFBlock) of this location. For example, location "Daggerfall/Stokhead" has 20 buildings. It is built with 2 blocks, one block has 12 buildings, the other block has 9 buildings, giving 21 in total.

Is there a known approach to match those numbers? I cannot figure out which building should be excluded?

DFU allows entering all 21, but this is not ideal. One building cannot be entered in the original game on that location.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Iterate all buildings in Daggerfall

Post by Interkarma »

This one has vexed me for a while. It's also frustrating that important building data is contained at map level and needs to be merged with block level data - and there's no obvious method to link them together as yet.

I've sunk a fair amount of time to resolve that linkage without 100% success. But I have made some reasonable progress. The best I can tell you right now could be summed up with the following points:
  1. BuildingData in MAPS.BSA appears to be authoritative. As blocks are re-used across many locations and regions, the map building data is like a (slightly ill-fitting) skin to ensure the same building names don't appear everywhere that same block is used. I hypothesise that map BuildingData should be merged with block BuildingData during scene construction to create a kind of resultant set of building data attached to building geometry inside scene.
  2. Key buildings (shops, temples, guilds, etc.) always seem to appear in the same order and quantity in both block and map BuildingData across the location as a whole. These buildings appear to be fixed.
  3. Residences appear to be fluid however. When there's a mismatch between map and block building counts, it seems to always be residences that should be excluded, not key buildings. This may account for the "this house has nothing of value" (i.e. when linking is not possible).
So the approach that I've used in my tests is to link key buildings in order and use first-come-first-serve on residences between key buildings. This does seem to meet with success around 99.9% of the time. In fact, I have reason to think the failures might be due to a bug in how some block names are resolved. This is a separate issue I need to chase down.

Anyway, I'm not convinced the approach is fully correct. It's just the best I have so far. :) I'm totally open to new ideas and methods to ensure a strong link between the two sets of data. I do seem to be on the right track however.

electrorobobody
Posts: 4
Joined: Wed Dec 21, 2016 6:18 am

Re: Iterate all buildings in Daggerfall

Post by electrorobobody »

Thank you. This is very detailed response. I'm going to investigate if there are other possible solutions. It is good to know that this is not something wellknown, and extra discoveries are potentially useful.

Post Reply