Commit Graph

391 Commits (bf9db8e2230a4d28fd95abd34840587155a1e28d)

Author SHA1 Message Date
Ryan Williams c5fb28a13c
Rename getPlantAtCoords to getPlantAtTile 2021-06-23 23:00:30 -07:00
Ryan Williams d81de5e4c7
Add getPlantAtCoords function to Maps namespace
Derived from disassembly of DF code. Returns a pointer to plant struct that owns the tile at position. Useful for finding a tree from one of its branches. Lua API support.
2021-06-22 20:01:10 -07:00
myk002 fc860478e4
move fastdwarf's teleport code to Units module
and expose in Lua API
2021-06-06 08:48:32 -07:00
myk002 aff5c9bf35
add getCursorCoords overload for df::coord
and factor out active cursor detection
2021-05-15 12:05:00 -07:00
lethosor 59b023c71d
Ensure that command-prompt is dismissed after a command creates a new screen
Fixes #1803

Running a command that created a new screen would previously result in a screen
order that looked like this, due to how `Screen::Hide` works:

- DF screen
  - `command-prompt` screen (dismissed)
    - New screen

The `command-prompt` screen remained on the stack until the new screen was
dismissed, so it would intercept viewscreen vmethod calls intended for the
DF screen.

This change adds a new behavior to `Screen::Hide` that results in this screen
order after running a command:

- DF screen
  - New screen
    - `command-prompt` screen (dismissed) - DF removes this screen immediately
2021-03-21 20:42:50 -04:00
myk002 6819ee9928
make alchemist flag valid for controllable civs 2021-02-05 16:45:39 -08:00
myk002 3ba984c22c
only reset extents if they are unusable
this allows callers of Buildings::setSize() to "pre-initialize" the
extents to declare non-rectangular structures. this allows quickfort to
create non-rectangular stockpiles, farm plots, zones, etc. the extents
are still reset as before if the size of the building doesn't match the
caller's expectations.

this commit also fixes a memory leak when setSize() allocates memory for
extents, but the memory is not deallocated if the building is ultimately
invalid for some reason.
2020-12-16 11:10:47 -08:00
lethosor 8cb38ecf5b
Merge remote-tracking branch 'myk002/myk_metalhead_mario' into develop 2020-11-13 14:04:30 -05:00
myk002 10616a387f
cleaner mask-based implementation 2020-11-12 22:44:38 -08:00
myk002 02a86d761a
identify bars as non_economic items
allows Job::isSuitableMaterial() to match metal bars as a building
material
2020-11-12 19:10:06 -08:00
lethosor 913d860ae4
Use initial working directory as process path on Linux, and expose to Lua 2020-11-12 19:07:51 -05:00
lethosor 23b230495e
Merge branch 'develop' into cwd-handling 2020-11-12 18:44:05 -05:00
lethosor ce7772a1c2
Add Filesystem::restorecwd()
This allows restoring the working directory to its original value, which may not actually be the DF root. See #1671, dfhack/scripts#152
2020-10-14 21:22:53 -04:00
Myk Taylor 4d7f4d80ad prep buildingplan for core algorithm changes
player-visible changes
- removed text that showed up if you used the wrong hotkeys. no other
  dfhack screen does this, and it seems unneeded. can add back if others
  think otherwise, though

internal changes
- changed signature of lua-exported isPlannableBuilding to take subtype
  and custom type in addition to building type. this is only used by
  quickfort, and it already sends all three params in preparation for
  this change
- added lua-exported scheduleCycle(), which is like doCycle(), but only
  takes effect on the next non-paused frame. this lets quickfort
  run only one buildingplan cycle regardless of how many #build
  blueprints were run
- declared a few dfhack library methods and params const so buildingplan
  could call them from const methods
- converted buildingplan internal debug logging fn to have a printf api
- reshaped buildingplan-planner API and refactored implementation in
  preparation for upcoming core algorithm changes for supporing all
  building types (no externally-visible functionality changes)
  - changed df::building_type params to type, subtype, custom tuple keys
  - introduced capability to return multiple filters per building type
    (though the current buildings all only have one filter per)
- split monolith hook functions in buildingplan.cpp into one per scope.
  this significantly cleans up the code and preps the hooks to handle
  iterating through multiple item filters.
- got rid of send_key function and replaced with better reporting of
  whether keys have been handled
2020-10-04 20:05:08 -07:00
Myk Taylor e546d3eec3 rename is_civzone to the more general allow_wall 2020-08-15 20:13:48 -07:00
Myk Taylor ae872e812f properly detect valid tiles for civzones 2020-08-15 17:24:12 -07:00
lethosor 8c5b21b7ee
Fix a couple warnings in the Units module (#1615) 2020-08-08 14:35:12 -04:00
Ryan Bennitt 9510dd52e1 Add Goal to Manipulator Detail Modes 2020-08-04 23:01:28 +01:00
Myk Taylor e17d492203 address PR review comments on api docs 2020-07-23 21:55:05 -07:00
Myk Taylor 16cfd34678 recurs-ify default config copying logic
I refactored Filesystem::listdir_recursive to support removing the path
prefix from the returned files list. There are no current calls that
make use of the prefix parameter, so I converted it into a boolean.
Current usages will use the new default parameter and will not see any
changed behavior.
2020-07-18 22:22:37 -07:00
Myk Taylor c19fc1f349 gcc-4.8 compatibility 2020-07-15 21:35:21 -07:00
lethosor 7c1d1c43e5 Merge remote-tracking branch 'PatrikLundell/stocks' into develop
Conflicts:
	docs/changelog.txt
2020-04-25 21:12:27 -04:00
Ben Lubar ffb3c29cfc
simplify Graphic module. update structures.
it appears that all this added complexity including an extra pointer dereference was to avoid including the vector header.
2020-03-08 00:12:48 -06:00
PatrikLundell 121497a466 Propagated getBookTitle to Lua 2020-01-26 11:47:47 +01:00
PatrikLundell 876ac6c056 Renamed to getBookTitle, cut down on virtual_cast 2020-01-25 21:46:10 +01:00
PatrikLundell c6bbf39c6c Issue #1262. Added Items::getTitle and used in stocks 2020-01-25 12:43:02 +01:00
lethosor 5eca50476e Merge remote-tracking branch 'nornagon/unit-description' into develop 2020-01-13 23:31:23 -05:00
Jeremy Apthorp 50e696acf6 getDescription => getPhysicalDescription 2019-12-14 09:36:47 -08:00
Jeremy Apthorp 910f965838 wip 2019-12-07 22:17:59 -08:00
lethosor f3658db85f Merge branch 'develop' into avoid_rebuilding_df_statics_if_core_h_changes 2019-10-03 23:23:36 -04:00
lethosor 07575095fd Merge branch 'develop' into persist 2019-08-22 22:00:50 -04:00
Pauli f0632347d0 Remove Core.h include from DataDefs.h
Core.h isn't required for DataDefs.h which removes Core.h dependency
from DataStatics*.
2018-12-30 17:08:42 -05:00
Ben Lubar a672ffcb95
Use viewscreen_savegamest instead of viewscreen_optionst 2018-08-26 19:05:44 -05:00
Ben Lubar 4e690df96a
Add Persistence module.
Alter World to use Persistence instead of storing data in historical figures.

Fake historical figures will be converted to the new format when a world is loaded.

Added plugin_save and plugin_load functions to the plugin API.

Made the weird int7/int28 code that was in the old persistence API slightly safer.
2018-08-26 18:27:58 -05:00
Kelly Kinkade 59d70d6687 Add function to infer biome type to Maps module
This moves code intended to infer biome type currently living in a
couple of plugins into the Maps module, so that this code can be shared
more easily by multiple plugins, as discussed in #1392.
2018-08-15 20:28:18 -05:00
Ben Lubar 4837e65322
Add an identity to dfhack_viewscreen and dfhack_lua_viewscreen. 2018-07-22 17:31:39 -05:00
lethosor 9ee368d456 Merge remote-tracking branch 'suokko/MapCache_reduce_latency_from_designation_to_jobs' into develop 2018-07-11 11:51:24 -04:00
lethosor 2dac3c53c7 Add stress cutoffs to Units module, fix dwarfmonitor/manipulator
Fixes #1292
2018-07-09 15:59:12 -04:00
lethosor 037e7e4901 Merge remote-tracking branch 'suokko/spotclean_ui_state_fix_1194' into develop
Moved/adjusted changelog entry
2018-07-07 18:08:53 -04:00
lethosor 616675f0ce Merge remote-tracking branch 'suokko/kittens_data_race_fix' into develop 2018-07-03 00:30:36 -04:00
lethosor 81a7ddcf92 Merge remote-tracking branch 'suokko/screen_show_memory_leak' into develop 2018-07-02 22:58:11 -04:00
Pauli 0727403ac1 Fix devel plugins linking in linux 2018-06-30 21:12:42 +03:00
Pauli c39a882b57 Add missing Unit::isDiplomat
Fixes #1324
2018-06-29 16:19:18 +03:00
Pauli 123de7fdf7 Use constexpr to prevent attempts of linking static variable 2018-06-24 17:06:32 +03:00
Pauli 9b6781f0f2 Temporary lower command-prompt when executing the command
command-prompt viewscreen may affect command execution if they are
looking for UI state. To make commands execute simillary to hotkeys or
console commands the viewscreen needs to removed from the top position.

Fixes #1194
2018-06-20 21:51:45 +03:00
Pauli 9c59b7ff48 Fix unlikely memory leaks if Screen::show fails
The Screen::show takes ownership of the screen pointer. I decided to
switch the parameter to std::unique_ptr to make the pointer ownership
explicit. The unique_ptr then provides automatic screen destruction in
Screen::show unless pointer is inserted or is already in the linked list
that is managed by df.
2018-06-19 16:41:31 +03:00
Pauli 1b5ec7ce69 Update jobs when committing MapCache changes
The map_block->designation.{dig,smooth} are reset to zeros when a job
posting is created for the designation. The job is then used to override
the designation state in the map_block. To make the new designation set
propogate to jobs the job structure would require updating. The update
would be possible a complex operation. The simple alternative is to
remove the job and let df create a new job in the next tick.

Fixes #1229
2018-06-18 16:34:09 +03:00
Pauli 6a151353e3 Use automatic return type for index_tile 2018-06-18 16:23:57 +03:00
lethosor 10e6016989 Merge branch 'units_dead' into develop
Closes #1297
2018-06-13 15:38:35 -04:00
PatrikLundell f329774059 dead & killed flag separation
squashed 4 commits from #1297
2018-06-13 15:37:45 -04:00
lethosor 03968db344 Fix GCC warnings in 'tweak kitchen-prefs-all' and dev plugins 2018-06-01 10:02:38 -04:00
lethosor 7a04fefb0b Remove Vermin module (unused and obsolete) 2018-06-01 00:22:10 -04:00
lethosor 17ba492992 Add some exclusion functions to Kitchen module, expose to Lua, fix build 2018-05-17 19:34:03 -04:00
lethosor 97a79893e7 Change Kitchen.{h,cpp} to title case 2018-05-17 11:08:13 -04:00
lethosor e9ec08f419 Add Buildings::getRoomDescription(), moved from search plugin, +cleanup 2018-05-12 17:00:21 -04:00
lethosor c15571caa0 Move isRouteVehicle, isSquadEquipment from workflow to Items module 2018-05-12 14:49:30 -04:00
lethosor a34b34d3cb Move a few item functions from autotrade/stocks into DFHack::Items 2018-05-12 12:04:46 -04:00
lethosor 2a52582c1f Add Gui::inRenameBuilding 2018-05-09 10:23:05 -04:00
lethosor 1ba5477b63 Add designation priority support to MapCache and dig plugin
Fixes #481
2018-01-21 19:27:16 -05:00
lethosor 10e13c532a Add "tweak cage-butcher" and some extra Building module functions
* Buildings::markedForRemoval()
* Buildings::getCageOccupants()

Closes #906
2017-06-25 15:27:21 -04:00
lethosor ae809afde7 Add Gui::refreshSidebar()
This handles feeding CURSOR_DOWN_Z and CURSOR_UP_Z properly, avoiding issues
when on the lowest z-level.
2017-06-23 00:02:21 -04:00
lethosor 27343e3253 Add unit and tile visibility functions 2017-06-10 21:54:08 -04:00
lethosor 778ffb0971 More Units module cleanup, modernize getUnitsInBox 2017-06-10 21:02:30 -04:00
lethosor 1321a64613 Remove lots of old/unused functions from the Units module 2017-06-10 17:21:34 -04:00
lethosor 43c4a88068 Move some checks in paintTile/readTile after hooks are called 2017-06-02 00:40:14 -04:00
lethosor 05f322ca30 Merge remote-tracking branch 'lethosor/lua-dmdims' into develop 2017-06-01 23:34:35 -04:00
lethosor 939aff3231 readTile(): add hook support and map parameter 2017-05-31 12:12:15 -04:00
lethosor 55931703ac Designate the correct tile for trees with multi-tile trunks
DF always designates the southeast trunk tile, while plant.pos is the center,
which is sometimes inaccessible (see #1014)
2017-05-05 21:25:25 -04:00
lethosor d3c496cc2b Add getSelectedPlant() and related functions
Currently only works with the center tile of multi-tile trees
2017-05-05 14:45:46 -04:00
lethosor 1e469453fc Add Designations module, currently supporting plant/tree designations
This makes it easier for tools to properly handle designating and undesignating
trees for chopping and plants for gathering, which changed significantly in
0.40.20.

Ref #531 (?), #656, #1014, #1018, #1030, #1076
2017-05-04 21:47:12 -04:00
lethosor 71b553b305 Add a few functions to retrieve unit social activities 2017-04-28 17:25:58 -04:00
David Corbett acdb369aa8 Avoid non-trivial bitfield constructors 2016-12-09 13:41:14 -05:00
lethosor 8521b830b2 Merge remote-tracking branch 'CannibalVox/job_remove' into develop 2016-12-05 15:24:37 -05:00
Stephen Baynham 595f3857b6 Reverse the param order of these two methods
The current way doesn't match other Job module methods
2016-12-01 20:13:49 -08:00
Stephen Baynham 7920f71517 Bad formatting 2016-11-25 00:25:18 -08:00
Stephen Baynham e490afdf00 Rebuilt slightly to offer bool return val
We fail on unknown general ref types now, without modifying the job at
all yet
2016-11-24 22:36:11 -08:00
Stephen Baynham 74f5df99db Add job remove method
Job remove eliminates a job's worker & holder references, if any, puts
the worker on cd, if appropriate, removes the job's postings, eliminates
the job from the global linked list, and then finally deletes it.  This
code was tested by incorporating it into autochop and it does make the
plugin work.  However, chop jobs don't have holder building references,
and anyway, with DF being 90% edge case by volume, this could use a heck
of a lot more testing.

I saw elsewhere code that prevented worker removal if the job was a
special job, and that made me feel funny so I made the job remove method
not work if the job is a special job.
2016-11-17 19:54:41 -08:00
lethosor 8a138fcc4c Avoid polluting global namespace in MapCache.h 2016-10-15 14:53:10 -04:00
lethosor 70d3c07cdb Initial lua getDwarfmodeViewDims rewrite 2016-10-07 23:51:58 -04:00
lethosor e965f5318f Replace many includes with forward declarations in modules/Maps.h 2016-08-13 21:44:01 -04:00
lethosor 79377669a1 Merge remote-tracking branch 'NCommander/dwarfvet' into develop 2016-07-29 16:25:53 -04:00
lethosor 2455e36510 Initial 64-bit support 2016-07-03 23:32:43 -04:00
Michael Casadevall e45fbfc61d Modified dwaftvet plugin to work with latest DFHack
Initial commit of the dwarfvet plugin

Signed-off-by: Michael Casadevall <mcasadevall@ubuntu.com>
2016-06-08 04:14:59 -04:00
lethosor 52728babd4 Merge branch 'develop' into zone-unassign 2016-04-22 18:41:15 -04:00
lethosor b97d33ca28 moveToBuilding improvements
- Don't set in_building by default when use_mode is 0 (consistent with most vanilla DF items)
- make use_mode optional and default to 0 (including in Lua API)

Resolves #885
2016-04-05 11:43:02 -04:00
lethosor 25507a10f9 Add Units::getKillCount() and expose it to Lua 2016-02-25 15:21:14 -05:00
sv-esk 83c70ccb0f forbid manipulator editing non-citizens 2016-02-11 13:31:52 +02:00
James Gilles 0a670bb0db Implement #804, move some functions to Units, colorize zone output, a
little cleanup
2016-02-01 11:12:06 -05:00
lethosor d0c28d3f50 Prevent plugins with active viewscreens from being unloaded
This requires plugins to pass plugin_self to Screen::show(), but
avoids the need to implement special checks in plugin_onstatechange
for the SC_BEGIN_UNLOAD event.
2016-01-01 11:15:29 -05:00
lethosor 2a2ab00ca9 Add "map" parameter to a lot of drawing functions
Ref #746
2015-12-22 11:42:51 -05:00
lethosor 5a1e5e1464 Expose Units::casteFlagSet() 2015-12-19 11:07:35 -05:00
lethosor 2aeac718cc workflow: Account for job postings correctly and fix existing issues
Without removing postings correctly, it was possible to end up with
multiple workers assigned to a job that workflow had suspended
multiple times, which caused crashes if more than one worker was
assigned to the same job by DF.

This adds an additional command, fix-job-postings, that runs
automatically when loading a world and fixes:
- Multiple job postings that point to the same job
- Job postings that point to a job where posting_index == -1
  (i.e. jobs that should have no posting assigned)

Fixes #741
2015-11-25 20:33:13 -05:00
lethosor 610170b0b0 Add hooks for getDwarfmodeViewDims and getDepthAt (new) 2015-11-15 11:54:34 -05:00
lethosor fcfffd1cb6 Track state of gui hooks
Also fix a bug in drawborder() and expand color-dfhack-text to test
multiple hooks
2015-11-15 11:54:34 -05:00
lethosor fff9072b07 Add initial support for hooking into Gui-related functions 2015-11-15 11:54:34 -05:00
DoctorVanGogh e9be1aa657 Fix for construction over existing construction & on top of walls
Fix to allow constructions on top of (natural) down stairs
2015-11-06 19:00:43 +01:00
lethosor ac71fa8070 Add isValidLabor() to Units module
Closes #711 and could avoid potential issues when editing units from
other civs with manipulator.
2015-10-30 18:41:09 -04:00
lethosor 8de710f1c1 Add Renderer module - safer way to install custom renderers 2015-10-21 17:18:39 -04:00
lethosor 3f5c002634 Pass virtual_identity by reference 2015-10-03 09:27:24 -04:00
lethosor d343dfd8a0 Add a function to find viewscreens (or parents) of a given type
This makes it possible for some plugins to detect the game state more
reliably - for example, prospector would previously fail when
embarking if the viewscreen_choose_start_sitest instance had any
children.
2015-10-02 21:50:55 -04:00