# Bugfixing Scripts

`fix/*` scripts fix various bugs and issues, some of them obscure.

Contents

- Bugfixing Scripts
  - fix/blood-del
  - fix/build-location
  - fix/dead-units
  - fix/diplomats
  - fix/dry-buckets
  - fix/fat-dwarves
  - fix/feeding-timers
  - fix/item-occupancy
  - fix/loyaltycascade
  - fix/merchants
  - fix/population-cap
  - fix/retrieve-units
  - fix/stable-temp
  - fix/stuck-merchants
  - fix/stuckdoors
  - fix/tile-occupancy

## fix/blood-del

Makes it so that future caravans won’t bring barrels full of blood, ichor, or goo.

## fix/build-location

Fixes construction jobs that are stuck trying to build a wall while standing on the same exact tile (Bug 5991), designates the tile restricted traffic to hopefully avoid jamming it again, and unsuspends them.

## fix/dead-units

Removes uninteresting dead units from the unit list. Doesn’t seem to give any noticeable performance gain, but migrants normally stop if the unit list grows to around 3000 units, and this script reduces it back.

## fix/diplomats

Adds a Diplomat position to all Elven civilizations, allowing them to negotiate tree cutting quotas - and you to violate them and start wars. This was vanilla behaviour until version 0.31.12, in which the “bug” was “fixed”.

## fix/dry-buckets

Removes water from all buckets in your fortress, allowing them to be used for making lye. Skips buckets in buildings (eg a well), being carried, or currently used by a job.

## fix/fat-dwarves

Avoids 5-10% FPS loss due to constant recalculation of insulation for dwarves at maximum fatness, by reducing the cap from 1,000,000 to 999,999. Recalculation is triggered in steps of 250 units, and very fat dwarves constantly bounce off the maximum value while eating.

## fix/feeding-timers

Reset the GiveWater and GiveFood timers of all living citizens.

## fix/item-occupancy

Diagnoses and fixes issues with nonexistant ‘items occupying site’, usually caused by autodump bugs or other hacking mishaps. Checks that:

1. Item has `flags.on_ground` <=> it is in the correct block item list
2. A tile has items in block item list <=> it has `occupancy.item`
3. The block item lists are sorted

## fix/loyaltycascade

Aborts loyalty cascades by fixing units whose own civ is the enemy.

## fix/merchants

Adds the Guild Representative position to all Human civilizations, allowing them to make trade agreements. This was the default behaviour in version 0.28.181.40d and earlier.

## fix/population-cap

Run this after every migrant wave to ensure your population cap is not exceeded.

The reason for population cap problems is that the population value it is compared against comes from the last dwarven caravan that successfully left for mountainhomes. This script instantly updates it. Note that a migration wave can still overshoot the limit by 1-2 dwarves because of the last migrant bringing his family. Likewise, king arrival ignores cap.

## fix/retrieve-units

This script forces some units off the map to enter the map, which can fix issues such as the following:

- Stuck [SIEGE] tags due to invisible armies (or parts of armies)
- Forgotten beasts that never appear
- Packs of wildlife that are missing from the surface or caverns
- Caravans that are partially or completely missing.

Note

For caravans that are missing entirely, this script may retrieve the merchants but not the items. Using fix/stuck-merchants followed by force to create a new caravan may work better.

## fix/stable-temp

Instantly sets the temperature of all free-lying items to be in equilibrium with the environment, which stops temperature updates until something changes. To maintain this efficient state, use tweak fast-heat.

## fix/stuck-merchants

Dismisses merchants that haven’t entered the map yet. This can fix Bug 9593. This script should probably not be run if any merchants are on the map, so using it with repeat is not recommended.

Run `fix/stuck-merchants -n` or `fix/stuck-merchants --dry-run` to list all merchants that would be dismissed but make no changes.

## fix/stuckdoors

Fix doors that are stuck open due to incorrect map occupancy flags, eg due to incorrect use of teleport.

## fix/tile-occupancy

Clears bad occupancy flags at the selected tile. Useful for getting rid of phantom “building present” messages. Currently only supports issues with building and unit occupancy. Requires that a tile is selected with the in-game cursor (`k`).

Can be used to fix problematic tiles caused by Issue 1047.