Skip to content

Commit

Permalink
Merge branch 'develop' into adv_cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 authored Feb 10, 2025
2 parents 19b613f + 82c6551 commit 5f3874b
Show file tree
Hide file tree
Showing 68 changed files with 763 additions and 401 deletions.
2 changes: 1 addition & 1 deletion depends/dfhooks
3 changes: 3 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,17 @@ Template for new versions:

## Misc Improvements
- `spectate`: player-set configuration is now stored globally instead of per-fort
- `autobutcher`: treat animals on restraints as unavailable for slaughter

## Documentation
- `stonesense-art-guide`: new guide for making sprite art for Stonesense

## API
- ``Military::removeFromSquad``: removes unit from any squad assignments

## Lua
- ``dfhack.units.setAutomaticProfessions``: sets unit labors according to current work detail settings
- ``dfhack.military.removeFromSquad``: Lua API for ``Military::removeFromSquad``

## Removed

Expand Down
8 changes: 8 additions & 0 deletions docs/dev/Lua API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,14 @@ Military module

Returns the name of a squad as a string.

* ``dfhack.military.removeFromSquad(unit_id)``

Removes a unit from its squad. Unsets the unit's
military information (i.e., ``unit.military.squad_id`` and
``unit.military.squad_pos``), the squad's position information (i.e.,
``squad.positions[squad_pos].occupant``), and modifies the unit's entity links
to indicate former squad membership or command.

Items module
------------

Expand Down
1 change: 1 addition & 0 deletions docs/plugins/autobutcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Units are protected from being automatically butchered if they are:
* Untamed
* Named or nicknamed
* Caged, if and only if the cage is in a zone (to protect zoos)
* On a restraint
* Trained for war or hunting
* Females who are pregnant or brooding a clutch of fertile eggs

Expand Down
51 changes: 21 additions & 30 deletions docs/plugins/spectate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ to following a different dwarf. It can also switch to following animals,
hostiles, or visiting units. You can switch to the next target (or a previous
target) immediately with the left/right arrow keys.

`spectate` will disengage and turn itself off when you move the map, just like
the vanilla follow mechanic. It will also disengage immediately if you open the
squads menu for military action.
By default, `spectate` will disengage and turn itself off when you move the
map, just like the vanilla follow mechanic. It will also disengage immediately
if you open the squads menu for military action.

It can also annotate your dwarves on the map with their name, job, and other
information, either as floating tooltips or in a panel that comes up when you
Expand All @@ -37,7 +37,7 @@ Usage
spectate [status]
spectate toggle
spectate set <setting> <value>
spectate overlay <name> enable|disable
spectate overlay enable|disable

Examples
--------
Expand All @@ -59,16 +59,18 @@ Examples
``spectate set follow-seconds 30``
Configure `spectate` to switch targets every 30 seconds when in follow mode.

``spectate overlay follow enable``
Show informative tooltips that follow each unit on the map.
``spectate overlay enable``
Show informative tooltips that follow each unit on the map. Note that this
can be enabled independently of `spectate` itself.

Settings
--------

``auto-disengage`` (default: enabled)
Toggle automatically disabling the plugin when the player moves the map or
opens the squad panel. If this is disabled, you will need to manually
disable the plugin to turn off follow mode.
disable the plugin to turn off follow mode. You can still interact normally
with the DF UI.

``auto-unpause`` (default: disabled)
Toggle auto-dismissal of announcements that pause the game, like sieges,
Expand All @@ -82,7 +84,7 @@ Settings
include time that the game is paused.

``include-animals`` (default: disabled)
Toggle whether to sometimes follow fort animals.
Toggle whether to sometimes follow fort animals and wildlife.

``include-hostiles`` (default: disabled)
Toggle whether to sometimes follow hostiles (eg. undead, titans, invaders,
Expand All @@ -102,47 +104,36 @@ Settings
arrived on the map.

``tooltip-follow-job`` (default: enabled)
If the ``spectate.follow`` overlay is enabled, toggle whether to show the
If the ``spectate.tooltip`` overlay is enabled, toggle whether to show the
job of the dwarf in the tooltip.

``tooltip-follow-name`` (default: enabled)
If the ``spectate.follow`` overlay is enabled, toggle whether to show the
If the ``spectate.tooltip`` overlay is enabled, toggle whether to show the
name of the dwarf in the tooltip.

``tooltip-follow-stress`` (default: enabled)
If the ``spectate.follow`` overlay is enabled, toggle whether to show the
If the ``spectate.tooltip`` overlay is enabled, toggle whether to show the
happiness level (stress) of the dwarf in the tooltip.

``tooltip-hover-job`` (default: enabled)
If the ``spectate.follow`` overlay is enabled, toggle whether to show the
If the ``spectate.tooltip`` overlay is enabled, toggle whether to show the
job of the dwarf in the hover panel.

``tooltip-hover-name`` (default: enabled)
If the ``spectate.follow`` overlay is enabled, toggle whether to show the
If the ``spectate.tooltip`` overlay is enabled, toggle whether to show the
name of the dwarf in the hover panel.

``tooltip-hover-stress`` (default: enabled)
If the ``spectate.follow`` overlay is enabled, toggle whether to show the
If the ``spectate.tooltip`` overlay is enabled, toggle whether to show the
happiness level (stress) of the dwarf in the hover panel.

Overlays
--------

``spectate`` provides two overlays via the `overlay` framework to add
information and functionality to the main map. These overlays can be controlled
via the ``spectate overlay`` command or the ``Overlays`` tab in
`gui/control-panel`.
``spectate.tooltip``

The information displayed by these overlays can be configured via the
``spectate set`` command or the `gui/spectate` interface.
``spectate`` can show informative tooltips that follow each unit on the map
and/or a popup panel with information when your mouse cursor hovers over a unit.

``spectate.follow``
Show informative tooltips that follow each unit on the map. You can enable
this overlay by running ``spectate overlay follow enable`` or,
equivalently, ``overlay enable spectate.follow``.

``spectate.hover``
Show a popup panel with selected information when your mouse cursor hovers
over a unit. You can enable this overlay by running
``spectate overlay hover enable`` or, equivalently,
``overlay enable spectate.hover``.
This overlay is managed via the `overlay` framework. It can be controlled via
the ``spectate overlay`` command or the ``Overlays`` tab in `gui/control-panel`.
6 changes: 4 additions & 2 deletions library/LuaApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ distribution.
#include "df/report_zoom_type.h"
#include "df/specific_ref.h"
#include "df/specific_ref_type.h"
#include "df/squad_use_flags.h"
#include "df/squad.h"
#include "df/unit.h"
#include "df/unit_misc_trait.h"
Expand Down Expand Up @@ -2341,6 +2342,7 @@ static const LuaWrapper::FunctionReg dfhack_military_module[] = {
WRAPM(Military, makeSquad),
WRAPM(Military, updateRoomAssignments),
WRAPM(Military, getSquadName),
WRAPM(Military, removeFromSquad),
{ NULL, NULL }
};

Expand Down Expand Up @@ -2442,7 +2444,7 @@ static int items_moveToBuilding(lua_State *state)
static int items_moveToInventory(lua_State *state) {
auto item = Lua::CheckDFObject<df::item>(state, 1);
auto unit = Lua::CheckDFObject<df::unit>(state, 2);
auto use_mode = (df::unit_inventory_item::T_mode)luaL_optint(state, 3, 0);
auto use_mode = (df::inv_item_role_type)luaL_optint(state, 3, 0);
int body_part = luaL_optint(state, 4, -1);
lua_pushboolean(state, Items::moveToInventory(item, unit, use_mode, body_part));
return 1;
Expand Down Expand Up @@ -2815,7 +2817,7 @@ int buildings_setSize(lua_State *state)
lua_pushinteger(state, size.x);
lua_pushinteger(state, size.y);
lua_pushinteger(state, area);
lua_pushinteger(state, Buildings::countExtentTiles(&bld->room, area));
lua_pushinteger(state, Buildings::countExtentTiles(bld, area));
return 5;
}
else
Expand Down
2 changes: 1 addition & 1 deletion library/RemoteTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ static command_result ListEnums(color_ostream &stream,
BITFIELD(cie_add_tag_mask1);
BITFIELD(cie_add_tag_mask2);

describe_bitfield<df::incident::T_flags>(out->mutable_death_info_flags());
describe_bitfield<df::incident_flag>(out->mutable_death_info_flags());

ENUM(profession);

Expand Down
2 changes: 1 addition & 1 deletion library/include/df/custom/creature_handler.methods.inc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
friend struct world_raws;
friend struct world;
5 changes: 2 additions & 3 deletions library/include/modules/Buildings.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ namespace df {
struct building;
struct building_cagest;
struct building_civzonest;
struct building_extents;
struct building_stockpilest;
struct item;
struct job_item;
Expand Down Expand Up @@ -112,7 +111,7 @@ DFHACK_EXPORT bool getCorrectSize(df::coord2d &size, df::coord2d &center,
* Checks if the tiles are free to be built upon.
*/
DFHACK_EXPORT bool checkFreeTiles(df::coord pos, df::coord2d size,
df::building_extents *ext = NULL,
df::building *bld,
bool create_ext = false,
bool allow_occupied = false,
bool allow_wall = false,
Expand All @@ -121,7 +120,7 @@ DFHACK_EXPORT bool checkFreeTiles(df::coord pos, df::coord2d size,
/**
* Returns the number of tiles included by the extent, or defval.
*/
DFHACK_EXPORT int countExtentTiles(df::building_extents *ext, int defval = -1);
DFHACK_EXPORT int countExtentTiles(df::building *bld, int defval = -1);

/**
* Checks if the building contains the specified tile. If the building has
Expand Down
2 changes: 1 addition & 1 deletion library/include/modules/Items.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ DFHACK_EXPORT bool moveToContainer(df::item *item, df::item *container);
DFHACK_EXPORT bool moveToBuilding(df::item *item, df::building_actual *building,
df::building_item_role_type use_mode = df::building_item_role_type::TEMP, bool force_in_building = false);
DFHACK_EXPORT bool moveToInventory(df::item *item, df::unit *unit,
df::unit_inventory_item::T_mode mode = df::unit_inventory_item::Hauled, int body_part = -1);
df::inv_item_role_type mode = df::inv_item_role_type::Hauled, int body_part = -1);

/// Remove item from jobs and inventories, hide and forbid.
/// Unless no_uncat, item is marked for garbage collection.
Expand Down
2 changes: 1 addition & 1 deletion library/include/modules/Job.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace DFHack
DFHACK_EXPORT bool listNewlyCreated(std::vector<df::job*> *pvec, int *id_var);

DFHACK_EXPORT bool attachJobItem(df::job *job, df::item *item,
df::job_item_ref::T_role role,
df::job_role_type role,
int filter_idx = -1, int insert_idx = -1);

DFHACK_EXPORT bool isSuitableItem(const df::job_item *item, df::item_type itype, int isubtype);
Expand Down
2 changes: 1 addition & 1 deletion library/include/modules/MapCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class BlockInfo
};
static GroundType getGroundType(int material);

typedef df::block_square_event_mineralst::T_flags DFVeinFlags;
typedef df::mineral_event_flag DFVeinFlags;

t_veintype veintype;
t_blockmaterials veinmats;
Expand Down
1 change: 1 addition & 0 deletions library/include/modules/Military.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Military
DFHACK_EXPORT std::string getSquadName(int32_t squad_id);
DFHACK_EXPORT df::squad* makeSquad(int32_t assignment_id);
DFHACK_EXPORT void updateRoomAssignments(int32_t squad_id, int32_t civzone_id, df::squad_use_flags flags);
DFHACK_EXPORT bool removeFromSquad(int32_t unit_id);

}
}
2 changes: 1 addition & 1 deletion library/lua/custom-raw-tokens.lua
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ local function getTokenArg1Else(userdata, token)
elseif df.is_instance(df.building_workshopst, userdata) or df.is_instance(df.building_furnacest, userdata) then
rawStruct = df.building_def.find(userdata.custom_type)
elseif df.is_instance(df.interaction_instance, userdata) then
rawStruct = df.global.world.raws.interactions[userdata.interaction_id]
rawStruct = df.global.world.raws.interactions.all[userdata.interaction_id]
else
-- Assume raw struct *is* argument 1
rawStruct = userdata
Expand Down
2 changes: 1 addition & 1 deletion library/lua/dfhack/workshops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ local function addReactionJobs(ret,bid,wid,cid)
end
local function scanRawsOres()
local ret={}
for idx,ore in ipairs(df.global.world.raws.inorganics) do
for idx,ore in ipairs(df.global.world.raws.inorganics.all) do
if #ore.metal_ore.mat_index~=0 then
ret[idx]=ore
end
Expand Down
2 changes: 1 addition & 1 deletion library/lua/gui/dwarfmode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ end

function get_hotkey_target(key)
local hk = HOTKEY_KEYS[key]
if hk and hk.cmd == df.ui_hotkey.T_cmd.Zoom then
if hk and hk.cmd == df.hotkey_type.Zoom then
return xyz2pos(hk.x, hk.y, hk.z)
end
end
Expand Down
6 changes: 3 additions & 3 deletions library/lua/gui/materials.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ end
function MaterialDialog:initInorganicMode()
local choices = {}

for i,mat in ipairs(df.global.world.raws.inorganics) do
for i,mat in ipairs(df.global.world.raws.inorganics.all) do
self:addMaterial(choices, mat.material, 0, i, false, mat)
end

Expand Down Expand Up @@ -378,14 +378,14 @@ function ItemTraitsDialog(args)
end
--------------------------------------
local set_ore_ix = {}
for i, raw in ipairs(df.global.world.raws.inorganics) do
for i, raw in ipairs(df.global.world.raws.inorganics.all) do
for _, ix in ipairs(raw.metal_ore.mat_index) do
set_ore_ix[ix] = true
end
end
local ores = {}
for ix in pairs(set_ore_ix) do
local raw = df.global.world.raws.inorganics[ix]
local raw = df.global.world.raws.inorganics.all[ix]
ores[#ores+1] = {mat_index = ix, name = raw.material.state_name.Solid}
end
table.sort(ores, function(a,b) return a.name < b.name end)
Expand Down
2 changes: 1 addition & 1 deletion library/lua/syndrome-util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function infectWithSyndrome(target,syndrome,resetPolicy)
unitSyndrome.ticks = 0
unitSyndrome.wound_id = -1
for k,v in ipairs(syndrome.ce) do
local symptom = df.unit_syndrome.T_symptoms:new()
local symptom = df.active_creature_interaction_effectst:new()
symptom.quantity = 0
symptom.delay = 0
symptom.ticks = 0
Expand Down
Loading

0 comments on commit 5f3874b

Please sign in to comment.