From 776af1904537afc48aee36b02dda0557d9a18881 Mon Sep 17 00:00:00 2001 From: Zac-HD Date: Fri, 14 Aug 2015 11:54:38 +1000 Subject: [PATCH 01/11] Add and document points.lua A trivial script to choose the number of points available at embark. --- NEWS | 3 ++- Readme.rst | 6 ++++++ scripts/points.lua | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 scripts/points.lua diff --git a/NEWS b/NEWS index a47a18934..f364bdb3e 100644 --- a/NEWS +++ b/NEWS @@ -22,8 +22,9 @@ DFHack Future New scripts burial: sets all unowned coffins to allow burial ("-pets" to allow pets too) fix-ster: changes fertility/sterility of animals or dwarves - view-item-info: adds information and customisable descriptions to item viewscreens + view-item-info: adds information and customisable descriptions to item viewscreens warn-starving: check for starving, thirsty, or very drowsy units and pause with warning if any are found + points: set number of points available at embark screen New tweaks kitchen-keys: Fixes DF kitchen meal keybindings kitchen-prefs-color: Changes color of enabled items to green in kitchen preferences diff --git a/Readme.rst b/Readme.rst index 2c4d5d203..6843fb71e 100644 --- a/Readme.rst +++ b/Readme.rst @@ -2589,6 +2589,12 @@ Example:: multicmd locate-ore iron ; digv +points +====== +Sets available points at the embark screen to the specified number. Eg. +``points 1000000`` would allow you to buy everything, or ``points 0`` would +make life quite difficult. + position ======== Reports the current time: date, clock time, month, and season. Also reports diff --git a/scripts/points.lua b/scripts/points.lua new file mode 100644 index 000000000..f39009c8a --- /dev/null +++ b/scripts/points.lua @@ -0,0 +1,3 @@ +-- by Meph +-- http://www.bay12forums.com/smf/index.php?topic=135506.msg4925005#msg4925005 +df.global.world.worldgen.worldgen_parms.embark_points=tonumber(...) \ No newline at end of file From 55b703a5aae2f56af895f19b69e621aad786635b Mon Sep 17 00:00:00 2001 From: Zac-HD Date: Fri, 14 Aug 2015 12:30:45 +1000 Subject: [PATCH 02/11] Document hide, show, startdwarf --- NEWS | 1 + Readme.rst | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/NEWS b/NEWS index f364bdb3e..11935062d 100644 --- a/NEWS +++ b/NEWS @@ -75,6 +75,7 @@ DFHack Future memview: Fixed display issue nyan: Can now be stopped with dfhack-run quicksave: Restricted to fortress mode + README: documented show/hide command, startdwarf.rb remotefortressreader: Exposes more information search: - Supports noble suggestion screen (e.g. suggesting a baron) diff --git a/Readme.rst b/Readme.rst index 6843fb71e..41fb0d935 100644 --- a/Readme.rst +++ b/Readme.rst @@ -291,6 +291,11 @@ control of the game. * Activate with 'forcepause 1' * Deactivate with 'forcepause 0' +hide / show +----------- +Hides or shows the DFHack terminal window, respectively. To use ``show``, use +the in-game console (default keybinding Ctrl-Shift-P). Only available on Windows. + nopause ------- Disables pausing (both manual and automatic) with the exception of pause forced @@ -2676,6 +2681,13 @@ Other options available: ``del``, ``clear``, ``list``. This plugin also shortens the 'sleeping' and 'on break' periods of targets. +startdwarf +========== +Use at the embark screen to embark with the specified number of dwarves. Eg. +``startdwarf 500`` would lead to a severe food shortage and FPS issues, while +``startdwarf 10`` would just allow a few more warm bodies to dig in. +Trying a number less than 7 may have strange effects. + stripcaged ========== For dumping items inside cages. Will mark selected items for dumping, then From 15c8ae187b9245e5f463a81415e1b49731554c29 Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Fri, 14 Aug 2015 13:20:22 +1000 Subject: [PATCH 03/11] Clarify startdwarf documentation --- Readme.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.rst b/Readme.rst index 41fb0d935..e50fea72e 100644 --- a/Readme.rst +++ b/Readme.rst @@ -2686,7 +2686,7 @@ startdwarf Use at the embark screen to embark with the specified number of dwarves. Eg. ``startdwarf 500`` would lead to a severe food shortage and FPS issues, while ``startdwarf 10`` would just allow a few more warm bodies to dig in. -Trying a number less than 7 may have strange effects. +The number must be 7 or greater. stripcaged ========== From 8c93177f1d07a51ebeefbe19b3d657f245d4fa6c Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 14 Aug 2015 16:33:34 -0400 Subject: [PATCH 04/11] No need to document documentation updates --- NEWS | 1 - scripts/points.lua | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 11935062d..f364bdb3e 100644 --- a/NEWS +++ b/NEWS @@ -75,7 +75,6 @@ DFHack Future memview: Fixed display issue nyan: Can now be stopped with dfhack-run quicksave: Restricted to fortress mode - README: documented show/hide command, startdwarf.rb remotefortressreader: Exposes more information search: - Supports noble suggestion screen (e.g. suggesting a baron) diff --git a/scripts/points.lua b/scripts/points.lua index f39009c8a..0bedd2074 100644 --- a/scripts/points.lua +++ b/scripts/points.lua @@ -1,3 +1,3 @@ -- by Meph -- http://www.bay12forums.com/smf/index.php?topic=135506.msg4925005#msg4925005 -df.global.world.worldgen.worldgen_parms.embark_points=tonumber(...) \ No newline at end of file +df.global.world.worldgen.worldgen_parms.embark_points=tonumber(...) From 0b4d32d0e6c81fa6bc8382531f233286b30733db Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 14 Aug 2015 16:40:38 -0400 Subject: [PATCH 05/11] Add @sethwoodworth to Contributors.rst see #669 --- Contributors.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Contributors.rst b/Contributors.rst index a3225fe5c..7fb774085 100644 --- a/Contributors.rst +++ b/Contributors.rst @@ -80,6 +80,7 @@ melkor217 melkor217 acwatkins acwatkins Wes Malone wesQ3 Michon van Dooren MaienM +Seth Woodworth sethwoodworth ======================= ==================== =========================== And these are the cool people who made **Stonesense**. From 9b1f394032961b5aed0961516e45ea0aa8484789 Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Sat, 15 Aug 2015 16:43:33 +1000 Subject: [PATCH 06/11] Add remaining basic and fix/* scripts to readme --- Readme.rst | 237 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 176 insertions(+), 61 deletions(-) diff --git a/Readme.rst b/Readme.rst index e50fea72e..2f28dfd06 100644 --- a/Readme.rst +++ b/Readme.rst @@ -645,6 +645,39 @@ Options: :show X: Marks the selected map feature as discovered. :hide X: Marks the selected map feature as undiscovered. +fortplan +-------- +Usage: fortplan [filename] + +Designates furniture for building according to a .csv file with +quickfort-style syntax. Companion to digfort. + +The first line of the file must contain the following:: + + #build start(X; Y; ) + +...where X and Y are the offset from the top-left corner of the file's area +where the in-game cursor should be located, and +is an optional description of where that is. You may also leave a description +of the contents of the file itself following the closing parenthesis on the +same line. + +The syntax of the file itself is similar to digfort or quickfort. At present, +only buildings constructed of an item with the same name as the building +are supported. All other characters are ignored. For example:: + + `,`,d,`,` + `,f,`,t,` + `,s,b,c,` + +This section of a file would designate for construction a door and some +furniture inside a bedroom: specifically, clockwise from top left, a cabinet, +a table, a chair, a bed, and a statue. + +All of the building designation uses Planning Mode, so you do not need to +have the items available to construct all the buildings when you run +fortplan with the .csv file. + infiniteSky ----------- Automatically allocates new z-levels of sky at the top of the map as you build up, or on request allocates many levels all at once. @@ -2120,6 +2153,7 @@ Advanced usage: :`autolabor reset-all`: Return all labors to the default handling. :`autolabor list`: List current status of all labors. :`autolabor status`: Show basic status information. +:`autolabor-artisans `: Run a command for labors where skill affects output quality *Examples:* @@ -2251,6 +2285,11 @@ scripts that are obscure, developer-oriented, or should be used as keybindings. The following scripts are distibuted with DFHack: +devel/* +======= +Scripts in this subdirectory are intended for developers, or still substantially +under development. If you don't already know what they do, best to leave them alone. + fix/* ===== Scripts in this subdirectory fix various bugs and issues, some of them obscure. @@ -2265,19 +2304,17 @@ Scripts in this subdirectory fix various bugs and issues, some of them obscure. on the same exact tile (bug 5991), designates the tile restricted traffic to hopefully avoid jamming it again, and unsuspends them. -* fix/cloth-stockpile - - Fixes erratic behavior of cloth stockpiles by scanning material objects - in memory and patching up some invalid reference fields. Needs to be run - every time a save game is loaded; putting ``fix/cloth-stockpile enable`` - in ``dfhack.init`` makes it run automatically. - * 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/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. + * fix/feeding-timers Reset the GiveWater and GiveFood timers of all units as appropriate. @@ -2292,6 +2329,10 @@ Scripts in this subdirectory fix various bugs and issues, some of them obscure. Diagnoses and fixes issues with nonexistant 'items occupying site', usually caused by autodump bugs or other hacking mishaps. +* fix/loyaltycascade + + Aborts loyalty cascades by fixing units whose own civ is the enemy. + * fix/population-cap Run this after every migrant wave to ensure your population cap is not exceeded. @@ -2305,6 +2346,11 @@ Scripts in this subdirectory fix various bugs and issues, some of them obscure. the environment and stops temperature updates. In order to maintain this efficient state however, use ``tweak stable-temp`` and ``tweak fast-heat``. +* fix/stuckdoors + + Fix doors that are stuck open due to incorrect map occupancy flags, eg due to + incorrect use of teleport. + gui/* ===== @@ -2328,6 +2374,39 @@ directory. Don't forget to `enable stockpiles` and create the `stocksettings` directory in the DF folder before trying to use this plugin. +adaptation +========== +View or set level of cavern adaptation for the selected unit or the whole fort. +Usage: ``adaptation [value]``. The ``value`` must be +between 0 and 800,000 inclusive. + +add-thought +=========== +Adds a thought or emotion to the selected unit. Can be used by other scripts, +or the gui invoked by running ``add-thought gui`` with a unit selected. + +autofarm +======== +Automatically handle crop selection in farm plots based on current plant stocks. +Selects a crop for planting if current stock is below a threshold. +Selected crops are dispatched on all farmplots. + +Usage:: + + autofarm start + autofarm default 30 + autofarm threshold 150 helmet_plump tail_pig + +autounsuspend +============= +Automatically unsuspend all jobs, on a recurring basis. See ``unsuspend`` for one-off use. + +ban-cooking +=========== +A more convenient way to ban cooking various categories of foods than the +kitchen interface. Usage: ``ban-cooking ``. Valid types are ``booze``, +``honey``, ``tallow``, ``oil``, and ``seeds`` (non-tree plants with seeds). + binpatch ======== Checks, applies or removes binary patches directly in memory at runtime:: @@ -2370,6 +2449,16 @@ Examples:: create-items bar CREATURE:CAT:SOAP create-items bar adamantine +deathcause +========== +Focus a body part ingame, and this script will display the cause of death of +the creature. +Also works when selecting units from the (``u``) unitlist viewscreen. + +dfstatus +======== +Show a quick overview of critical stock quantities, including food, drinks, wood, and various bars. + digfort ======= A script to designate an area for digging according to a plan in csv format. @@ -2400,16 +2489,6 @@ drain-aquifer ============= Remove all 'aquifer' tag from the map blocks. Irreversible. -deathcause -========== -Focus a body part ingame, and this script will display the cause of death of -the creature. -Also works when selecting units from the (``u``) unitlist viewscreen. - -dfstatus -======== -Show a quick overview of critical stock quantities, including food, drinks, wood, and various bars. - exterminate =========== Kills any unit of a given race. @@ -2449,6 +2528,10 @@ To purify all elves on the map with fire (may have side-effects):: exterminate elve magma +fixnaked +======== +Removes all unhappy thoughts due to lack of clothing. + fix-ster ======== Utilizes the orientation tag to either fix infertile creatures or inflict @@ -2461,38 +2544,20 @@ or sterile. Optional arguments specify the target: no argument for the selected unit, ``all`` for all units on the map, ``animals`` for all non-dwarf creatures, or ``only:`` to only process matching creatures. -fortplan -======== -Usage: fortplan [filename] - -Designates furniture for building according to a .csv file with -quickfort-style syntax. Companion to digfort. - -The first line of the file must contain the following:: - - #build start(X; Y; ) - -...where X and Y are the offset from the top-left corner of the file's area -where the in-game cursor should be located, and -is an optional description of where that is. You may also leave a description -of the contents of the file itself following the closing parenthesis on the -same line. - -The syntax of the file itself is similar to digfort or quickfort. At present, -only buildings constructed of an item with the same name as the building -are supported. All other characters are ignored. For example:: - - `,`,d,`,` - `,f,`,t,` - `,s,b,c,` +forum-dwarves +============= +Saves a copy of a text screen, formatted in bbcode for posting to the Bay12 Forums. +Use ``forum-dwarves help`` for more information. -This section of a file would designate for construction a door and some -furniture inside a bedroom: specifically, clockwise from top left, a cabinet, -a table, a chair, a bed, and a statue. +full-heal +========= +Attempts to fully heal the selected unit. ``full-heal -r`` attempts to resurrect the unit. -All of the building designation uses Planning Mode, so you do not need to -have the items available to construct all the buildings when you run -fortplan with the .csv file. +gaydar +====== +Shows the sexual orientation of units, useful for social engineering or checking +the viability of livestock breeding programs. Use ``gaydar -help`` for information +on available filters for orientation, citizenship, species, etc. growcrops ========= @@ -2576,6 +2641,15 @@ There are the following ways to invoke this command: Parses and executes the lua statement like the interactive interpreter would. +make-monarch +============ +Make the selected unit King or Queen or your civilisation. + +markdown +======== +Save a copy of a text screen in markdown (for reddit among others). +Use 'markdown help' for more details. + masspit ======= Designate all creatures in cages on top of a pit/pond activity zone for pitting. @@ -2587,7 +2661,7 @@ or with the game cursor on top of the area. multicmd ======== Run multiple dfhack commands. The argument is split around the -character ; and all parts are run sequencially as independent +character ; and all parts are run sequentially as independent dfhack commands. Useful for hotkeys. Example:: @@ -2615,15 +2689,52 @@ quicksave If called in dwarf mode, makes DF immediately auto-save the game by setting a flag normally used in seasonal auto-save. +region-pops +=========== +Show or modify the populations of animals in the region. Use ``region-pops`` for details. + remove-stress ============= -Sets stress to -1,000,000; the normal range is 0 to 500,000 with very stable or very stressed dwarves taking on negative or greater values respectively. Applies to the selected unit, or use "remove-stress -all" to apply to all units. +Sets stress to -1,000,000; the normal range is 0 to 500,000 with very stable or +very stressed dwarves taking on negative or greater values respectively. +Applies to the selected unit, or use "remove-stress -all" to apply to all units. + +remove-wear +=========== +Sets the wear on all items in your fort to zero. + +repeat +====== +Repeatedly calls a lua script at the specified interval. + +This allows neat background changes to the function of the game, especially when +invoked from an init file. For detailed usage instructions, use ``repeat -help``. + +Usage examples:: + + repeat -name jim -time delay -timeUnits units -printResult true -command [ printArgs 3 1 2 ] + repeat -time 1 -timeUnits months -command [ multicmd cleanowned scattered x; clean all ] -name clean + +The first example is abstract; the second will regularly remove all contaminants +and worn items from the game. + +``-name`` sets the name for the purposes of cancelling and making sure you don't schedule the +same repeating event twice. If not specified, it's set to the first argument after ``-command``. +``-time delay -timeUnits units``; delay is some positive integer, and units is some valid time +unit for ``dfhack.timeout(delay,timeUnits,function)``. ``-command [ ... ]`` specifies the +command to be run. setfps ====== Run ``setfps `` to set the FPS cap at runtime, in case you want to watch combat in slow motion or something :) +show-unit-syndromes +=================== +Show syndromes affecting units and the remaining and maximum duration, along +with (optionally) substantial detail on the effects. Call +``show-unit-syndromes help`` for further options. + siren ===== Wakes up sleeping units, cancels breaks and stops parties either everywhere, @@ -2669,18 +2780,6 @@ Ex:: source add magma 7 - magma source source add water 0 - water drain -superdwarf -========== -Similar to fastdwarf, per-creature. - -To make any creature superfast, target it ingame using 'v' and:: - - superdwarf add - -Other options available: ``del``, ``clear``, ``list``. - -This plugin also shortens the 'sleeping' and 'on break' periods of targets. - startdwarf ========== Use at the embark screen to embark with the specified number of dwarves. Eg. @@ -2708,6 +2807,18 @@ alternatively pass cage IDs as arguments:: stripcaged weapons 25321 34228 +superdwarf +========== +Similar to fastdwarf, per-creature. + +To make any creature superfast, target it ingame using 'v' and:: + + superdwarf add + +Other options available: ``del``, ``clear``, ``list``. + +This plugin also shortens the 'sleeping' and 'on break' periods of targets. + teleport ======== Teleports a unit to given coordinates. @@ -2722,6 +2833,10 @@ undump-buildings ================ Undesignates building base materials for dumping. +unsuspend +========= +Unsuspend all jobs, on a one-off basis. See ``autounsuspend`` for regular use. + view-item-info ============== A script to extend the item or unit viewscreen with additional information From 84a1edc3b8d7b9e1d0994c3b7eb623dc17d3129b Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Sat, 15 Aug 2015 16:43:50 +1000 Subject: [PATCH 07/11] Add initial comments to some scripts --- scripts/autounsuspend.rb | 2 ++ scripts/ban-cooking.rb | 4 ++-- scripts/fixnaked.lua | 2 ++ scripts/unsuspend.rb | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/autounsuspend.rb b/scripts/autounsuspend.rb index 2c474e993..94c6b1f26 100644 --- a/scripts/autounsuspend.rb +++ b/scripts/autounsuspend.rb @@ -1,3 +1,5 @@ +# un-suspend all jobs, on a recurring basis + class AutoUnsuspend attr_accessor :running diff --git a/scripts/ban-cooking.rb b/scripts/ban-cooking.rb index 9f21bb01a..544447277 100644 --- a/scripts/ban-cooking.rb +++ b/scripts/ban-cooking.rb @@ -1,3 +1,5 @@ +# convenient way to ban cooking categories of food + already_banned = {} kitchen = df.ui.kitchen kitchen.item_types.length.times { |i| @@ -84,5 +86,3 @@ $script_args.each do |arg| puts "ban-cooking seeds - bans cooking of plants that have seeds (tree seeds don't count)" end end - -# vim: et:sw=4:ts=4 diff --git a/scripts/fixnaked.lua b/scripts/fixnaked.lua index 3f1ee6fdd..6e154440f 100644 --- a/scripts/fixnaked.lua +++ b/scripts/fixnaked.lua @@ -1,3 +1,5 @@ +--removes unhappy thoughts due to lack of clothing + function fixnaked() local total_fixed = 0 local total_removed = 0 diff --git a/scripts/unsuspend.rb b/scripts/unsuspend.rb index 690ce6f03..0e1f52f35 100644 --- a/scripts/unsuspend.rb +++ b/scripts/unsuspend.rb @@ -1,3 +1,5 @@ +# un-suspend all jobs, one time only + joblist = df.world.job_list.next count = 0 From f8f7194f822ca51bf15e617e80cfd4bf2160e905 Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Sat, 15 Aug 2015 16:44:12 +1000 Subject: [PATCH 08/11] Make exportlegends compatible with open-legends --- scripts/exportlegends.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/exportlegends.lua b/scripts/exportlegends.lua index 7c8c539fb..a7178361f 100644 --- a/scripts/exportlegends.lua +++ b/scripts/exportlegends.lua @@ -564,7 +564,8 @@ function export_site_maps() end -- main() -if dfhack.gui.getCurFocus() == "legends" then +if dfhack.gui.getCurFocus() == "legends" or dfhack.gui.getCurFocus() == "dfhack/lua/legends" then + -- either native legends mode, or using the open-legends.lua script if args[1] == "all" then export_legends_info() export_site_maps() From d5513eac1bae3989192827e2768d0cbc04041a33 Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Sun, 16 Aug 2015 13:15:11 +1000 Subject: [PATCH 09/11] Tweak readme based on feedback --- Readme.rst | 16 +++++++++------- scripts/autounsuspend.rb | 2 +- scripts/unsuspend.rb | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Readme.rst b/Readme.rst index 2f28dfd06..66ec5106c 100644 --- a/Readme.rst +++ b/Readme.rst @@ -2361,6 +2361,10 @@ directory. A graphical interface for creating items. +* gui/dfstatus + + Show a quick overview of critical stock quantities, including food, drinks, wood, and various bars. + * gui/stockpiles Load and save stockpile settings from the 'q' menu. @@ -2399,7 +2403,8 @@ Usage:: autounsuspend ============= -Automatically unsuspend all jobs, on a recurring basis. See ``unsuspend`` for one-off use. +Automatically unsuspend construction jobs, on a recurring basis. +See ``unsuspend`` for one-off use, or ``resume all``. ban-cooking =========== @@ -2455,10 +2460,6 @@ Focus a body part ingame, and this script will display the cause of death of the creature. Also works when selecting units from the (``u``) unitlist viewscreen. -dfstatus -======== -Show a quick overview of critical stock quantities, including food, drinks, wood, and various bars. - digfort ======= A script to designate an area for digging according to a plan in csv format. @@ -2643,7 +2644,7 @@ There are the following ways to invoke this command: make-monarch ============ -Make the selected unit King or Queen or your civilisation. +Make the selected unit King or Queen of your civilisation. markdown ======== @@ -2835,7 +2836,8 @@ Undesignates building base materials for dumping. unsuspend ========= -Unsuspend all jobs, on a one-off basis. See ``autounsuspend`` for regular use. +Unsuspend construction jobs, on a one-off basis. See ``autounsuspend`` for regular use. +Equivalent to ``resume all``. view-item-info ============== diff --git a/scripts/autounsuspend.rb b/scripts/autounsuspend.rb index 94c6b1f26..9613288ba 100644 --- a/scripts/autounsuspend.rb +++ b/scripts/autounsuspend.rb @@ -1,4 +1,4 @@ -# un-suspend all jobs, on a recurring basis +# un-suspend construction jobs, on a recurring basis class AutoUnsuspend attr_accessor :running diff --git a/scripts/unsuspend.rb b/scripts/unsuspend.rb index 0e1f52f35..bd0c3ad78 100644 --- a/scripts/unsuspend.rb +++ b/scripts/unsuspend.rb @@ -1,4 +1,5 @@ -# un-suspend all jobs, one time only +# un-suspend construction jobs, one time only +# same as "resume all" joblist = df.world.job_list.next count = 0 From f60b3e81173b66931a37b45d5f665993faf4ded1 Mon Sep 17 00:00:00 2001 From: Japa Date: Sun, 16 Aug 2015 20:28:52 +0530 Subject: [PATCH 10/11] Added a function to get region tiles from remotefortressreader.cpp --- plugins/proto/RemoteFortressReader.proto | 7 ++ plugins/remotefortressreader.cpp | 102 +++++++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/plugins/proto/RemoteFortressReader.proto b/plugins/proto/RemoteFortressReader.proto index b8056cb7d..8b5fd5863 100644 --- a/plugins/proto/RemoteFortressReader.proto +++ b/plugins/proto/RemoteFortressReader.proto @@ -294,4 +294,11 @@ message WorldMap repeated int32 savagery = 12; repeated Cloud clouds = 13; repeated int32 salinity = 14; + optional int32 map_x = 15; + optional int32 map_y = 16; +} + +message RegionMaps +{ + repeated WorldMap world_maps = 1; } diff --git a/plugins/remotefortressreader.cpp b/plugins/remotefortressreader.cpp index 47ad5e251..3a1d6ca87 100644 --- a/plugins/remotefortressreader.cpp +++ b/plugins/remotefortressreader.cpp @@ -41,6 +41,7 @@ #include "df/color_modifier_raw.h" #include "df/region_map_entry.h" +#include "df/world_region_details.h" #include "df/unit.h" @@ -90,6 +91,7 @@ static command_result ResetMapHashes(color_ostream &stream, const EmptyMessage * static command_result GetItemList(color_ostream &stream, const EmptyMessage *in, MaterialList *out); static command_result GetBuildingDefList(color_ostream &stream, const EmptyMessage *in, BuildingList *out); static command_result GetWorldMap(color_ostream &stream, const EmptyMessage *in, WorldMap *out); +static command_result GetRegionMaps(color_ostream &stream, const EmptyMessage *in, RegionMaps *out); void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC, DFCoord pos); @@ -139,6 +141,7 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &) svc->addFunction("GetItemList", GetItemList); svc->addFunction("GetBuildingDefList", GetBuildingDefList); svc->addFunction("GetWorldMap", GetWorldMap); + svc->addFunction("GetRegionMaps", GetRegionMaps); return svc; } @@ -1221,4 +1224,103 @@ static command_result GetWorldMap(color_ostream &stream, const EmptyMessage *in, clouds->set_stratus((RemoteFortressReader::StratusType)map_entry->clouds.bits.stratus); } return CR_OK; +} + +static void AddAveragedRegionTiles(WorldMap * out, df::region_map_entry * e1, df::region_map_entry * e2, df::region_map_entry * e3, df::region_map_entry * e4) +{ + out->add_rainfall((e1->rainfall + e2->rainfall + e3->rainfall + e4->rainfall) / 4); + out->add_vegetation((e1->vegetation + e2->vegetation + e3->vegetation + e4->vegetation) / 4); + out->add_temperature((e1->temperature + e2->temperature + e3->temperature + e4->temperature) / 4); + out->add_evilness((e1->evilness + e2->evilness + e3->evilness + e4->evilness) / 4); + out->add_drainage((e1->drainage + e2->drainage + e3->drainage + e4->drainage) / 4); + out->add_volcanism((e1->volcanism + e2->volcanism + e3->volcanism + e4->volcanism) / 4); + out->add_savagery((e1->savagery + e2->savagery + e3->savagery + e4->savagery) / 4); + out->add_salinity((e1->salinity + e2->salinity + e3->salinity + e4->salinity) / 4); +} + +static void AddAveragedRegionTiles(WorldMap * out, df::region_map_entry * e1, df::region_map_entry * e2) +{ + AddAveragedRegionTiles(out, e1, e1, e2, e2); +} + +static void AddAveragedRegionTiles(WorldMap * out, df::region_map_entry * e1) +{ + AddAveragedRegionTiles(out, e1, e1, e1, e1); +} + +static void CopyLocalMap(df::world_data * worldData, df::world_region_details* worldRegionDetails, WorldMap * out) +{ + int pos_x = worldRegionDetails->pos.x; + int pos_y = worldRegionDetails->pos.y; + out->set_map_x(pos_x); + out->set_map_y(pos_y); + out->set_world_width(17); + out->set_world_height(17); + char name[256]; + sprintf(name, "Region %d, %d", pos_x, pos_y); + out->set_name_english(name); + out->set_name(name); + + df::region_map_entry * maps[] = + { + &worldData->region_map[pos_x][pos_y], &worldData->region_map[pos_x + 1][pos_y], + &worldData->region_map[pos_x][pos_y + 1], &worldData->region_map[pos_x + 1][pos_y + 1] + }; + + for (int yy = 0; yy < 17; yy++) + for (int xx = 0; xx < 17; xx++) + { + out->add_elevation(worldRegionDetails->elevation[xx][yy]); + switch (worldRegionDetails->biome[xx][yy]) + { + case 1: + AddAveragedRegionTiles(out, maps[1]); + break; + case 2: + AddAveragedRegionTiles(out, maps[2], maps[3]); + break; + case 3: + AddAveragedRegionTiles(out, maps[3]); + break; + case 4: + AddAveragedRegionTiles(out, maps[0], maps[2]); + break; + case 5: + AddAveragedRegionTiles(out, maps[0], maps[1], maps[2], maps[3]); + break; + case 6: + AddAveragedRegionTiles(out, maps[1], maps[3]); + break; + case 7: + AddAveragedRegionTiles(out, maps[0]); + break; + case 8: + AddAveragedRegionTiles(out, maps[0], maps[1]); + break; + case 9: + AddAveragedRegionTiles(out, maps[2]); + break; + default: + AddAveragedRegionTiles(out, maps[0], maps[1], maps[2], maps[3]); + break; + } + } +} + +static command_result GetRegionMaps(color_ostream &stream, const EmptyMessage *in, RegionMaps *out) +{ + if (!df::global::world->world_data) + { + return CR_FAILURE; + } + df::world_data * data = df::global::world->world_data; + for (int i = 0; i < data->region_details.size(); i++) + { + df::world_region_details * region = data->region_details[i]; + if (!region) + continue; + WorldMap * regionMap = out->add_world_maps(); + CopyLocalMap(data, region, regionMap); + } + return CR_OK; } \ No newline at end of file From bf7fc42710c5d777eae79a2ad55a785159a02202 Mon Sep 17 00:00:00 2001 From: Japa Date: Mon, 17 Aug 2015 00:11:52 +0530 Subject: [PATCH 11/11] Made remotefortressreader.cpp get the elevations from the next region over for the last line. --- plugins/remotefortressreader.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/plugins/remotefortressreader.cpp b/plugins/remotefortressreader.cpp index 3a1d6ca87..e2a7911ce 100644 --- a/plugins/remotefortressreader.cpp +++ b/plugins/remotefortressreader.cpp @@ -1261,6 +1261,22 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w out->set_name_english(name); out->set_name(name); + df::world_region_details * south = NULL; + df::world_region_details * east = NULL; + df::world_region_details * southEast = NULL; + + for (int i = 0; i < worldData->region_details.size(); i++) + { + auto region = worldData->region_details[i]; + if (region->pos.x == pos_x + 1 && region->pos.y == pos_y + 1) + southEast = region; + else if (region->pos.x == pos_x + 1 && region->pos.y == pos_y) + east = region; + else if (region->pos.x == pos_x && region->pos.y == pos_y + 1) + south = region; + } + + df::region_map_entry * maps[] = { &worldData->region_map[pos_x][pos_y], &worldData->region_map[pos_x + 1][pos_y], @@ -1270,7 +1286,16 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w for (int yy = 0; yy < 17; yy++) for (int xx = 0; xx < 17; xx++) { - out->add_elevation(worldRegionDetails->elevation[xx][yy]); + //This is because the bottom row doesn't line up. + if (xx == 16 && yy == 16 && southEast != NULL) + out->add_elevation(southEast->elevation[0][0]); + else if (xx == 16 && east != NULL) + out->add_elevation(east->elevation[0][yy]); + else if (yy == 16 && south != NULL) + out->add_elevation(south->elevation[xx][0]); + else + out->add_elevation(worldRegionDetails->elevation[xx][yy]); + switch (worldRegionDetails->biome[xx][yy]) { case 1: