Use debugfilter; remove redundant changelog entries

develop
Ryan Williams 2022-05-16 18:41:47 -07:00 committed by GitHub
parent 14afcc2b0a
commit ce34ac8f33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 295 additions and 233 deletions

@ -69,7 +69,7 @@ jobs:
- name: Download DF
run: |
sh ci/download-df.sh
- name: Build DFHack
- name: Configure DFHack
env:
CC: gcc-${{ matrix.gcc }}
CXX: g++-${{ matrix.gcc }}
@ -85,6 +85,8 @@ jobs:
-DBUILD_STONESENSE:BOOL=${{ matrix.plugins == 'all' }} \
-DBUILD_SUPPORTED:BOOL=1 \
-DCMAKE_INSTALL_PREFIX="$DF_FOLDER"
- name: Build DFHack
run: |
ninja -C build-ci install
- name: Run tests
id: run_tests

@ -1,5 +1,6 @@
ci:
autofix_prs: false
autoupdate_schedule: monthly
repos:
# shared across repos:
- repo: https://github.com/pre-commit/pre-commit-hooks

@ -81,11 +81,11 @@ def check_file(fname):
def main():
"""Check that all DFHack scripts include documentation"""
err = 0
exclude = set(['internal', 'test'])
exclude = {'.git', 'internal', 'test'}
for root, dirs, files in os.walk(SCRIPT_PATH, topdown=True):
dirs[:] = [d for d in dirs if d not in exclude]
for f in files:
if f[-3:] in {'.rb', 'lua'}:
if f.split('.')[-1] in {'rb', 'lua'}:
err += check_file(join(root, f))
return err

@ -1,7 +1,9 @@
library/xml master
scripts master
plugins/stonesense master
plugins/isoworld dfhack
depends/libzip dfhack
depends/libexpat dfhack
depends/xlsxio dfhack
depends/luacov dfhack
depends/jsoncpp-sub dfhack

@ -1,12 +1,34 @@
[
{
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"amount_left" : 150,
"amount_total" : 150,
"frequency" : "Monthly",
"id" : 0,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
[
{
"condition" : "LessThan",
"flags" :
[
"unrotten"
],
"item_type" : "FOOD",
"value" : 400
}
],
"job" : "PrepareMeal",
"meal_ingredients" : 2
},
{
"amount_left" : 10,
"amount_total" : 10,
"frequency" : "Daily",
"id" : 1,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
[
{
"condition" : "AtLeast",
@ -25,7 +47,7 @@
"unrotten",
"cookable"
],
"value" : 15
"value" : 500
},
{
"condition" : "AtMost",
@ -35,6 +57,15 @@
],
"item_type" : "FOOD",
"value" : 3500
},
{
"condition" : "AtLeast",
"flags" :
[
"unrotten"
],
"item_type" : "FOOD",
"value" : 400
}
],
"job" : "PrepareMeal",
@ -44,7 +75,7 @@
"amount_left" : 2,
"amount_total" : 2,
"frequency" : "Daily",
"id" : 1,
"id" : 2,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -81,7 +112,7 @@
"amount_left" : 2,
"amount_total" : 2,
"frequency" : "Daily",
"id" : 2,
"id" : 3,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -118,7 +149,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 3,
"id" : 4,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -139,7 +170,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 4,
"id" : 5,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -174,7 +205,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 5,
"id" : 6,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -206,7 +237,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 6,
"id" : 7,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -238,7 +269,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 7,
"id" : 8,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -260,7 +291,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 8,
"id" : 9,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -293,7 +324,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 9,
"id" : 10,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -324,7 +355,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 10,
"id" : 11,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -357,7 +388,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 11,
"id" : 12,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -397,7 +428,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 12,
"id" : 13,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -423,7 +454,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 13,
"id" : 14,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -458,7 +489,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 14,
"id" : 15,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -493,7 +524,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 15,
"id" : 16,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -528,7 +559,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 16,
"id" : 17,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -559,7 +590,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 17,
"id" : 18,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -589,7 +620,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 18,
"id" : 19,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -613,7 +644,6 @@
],
"item_subtype" : "ITEM_TOOL_LARGE_POT",
"item_type" : "TOOL",
"material" : "INORGANIC",
"value" : 25
}
],
@ -625,7 +655,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 19,
"id" : 20,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -649,7 +679,6 @@
],
"item_subtype" : "ITEM_TOOL_JUG",
"item_type" : "TOOL",
"material" : "INORGANIC",
"value" : 10
}
],
@ -661,7 +690,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 20,
"id" : 21,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -690,7 +719,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 21,
"id" : 22,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -718,7 +747,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 22,
"id" : 23,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -746,7 +775,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 23,
"id" : 24,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -776,7 +805,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 24,
"id" : 25,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -806,7 +835,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 25,
"id" : 26,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -835,7 +864,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 26,
"id" : 27,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -866,7 +895,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 27,
"id" : 28,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -902,7 +931,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 28,
"id" : 29,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -938,7 +967,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 29,
"id" : 30,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -974,7 +1003,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 30,
"id" : 31,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -993,7 +1022,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 31,
"id" : 32,
"is_active" : false,
"is_validated" : true,
"item_conditions" :
@ -1019,7 +1048,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 32,
"id" : 33,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -1041,7 +1070,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 33,
"id" : 34,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -1067,7 +1096,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 34,
"id" : 35,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -1093,7 +1122,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 35,
"id" : 36,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -1119,7 +1148,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 36,
"id" : 37,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -1152,7 +1181,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 37,
"id" : 38,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -1191,7 +1220,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 38,
"id" : 39,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -1225,7 +1254,7 @@
"amount_left" : 4,
"amount_total" : 4,
"frequency" : "Daily",
"id" : 39,
"id" : 40,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -1248,7 +1277,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 40,
"id" : 41,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -1272,7 +1301,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 41,
"id" : 42,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -1306,7 +1335,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 42,
"id" : 43,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -1335,7 +1364,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 43,
"id" : 44,
"is_active" : false,
"is_validated" : false,
"item_conditions" :
@ -1364,7 +1393,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 44,
"id" : 45,
"is_active" : false,
"is_validated" : true,
"item_conditions" :
@ -1395,7 +1424,7 @@
"amount_left" : 1,
"amount_total" : 1,
"frequency" : "Daily",
"id" : 45,
"id" : 46,
"is_active" : false,
"is_validated" : false,
"item_conditions" :

@ -12,10 +12,11 @@ endif()
add_subdirectory(tthread)
option(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" OFF)
option(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" OFF)
option(JSONCPP_BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF)
option(JSONCPP_BUILD_OBJECT_LIBS "Build jsoncpp_lib as a object library." OFF)
option(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" OFF)
add_subdirectory(jsoncpp-sub EXCLUDE_FROM_ALL)
if(UNIX)
set_target_properties(jsoncpp_lib_static PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations")
endif()
# build clsocket static and only as a dependency. Setting those options here overrides its own default settings.
option(CLSOCKET_SHARED "Build clsocket lib as shared." OFF)
option(CLSOCKET_DEP_ONLY "Build for use inside other CMake projects as dependency." ON)
@ -37,6 +38,7 @@ if(UNIX)
set_target_properties(expat PROPERTIES COMPILE_FLAGS "-Wno-maybe-uninitialized")
endif()
set(CMAKE_REQUIRED_QUIET ON)
set(LIBZIP_BUILD_DOC OFF CACHE BOOL "")
set(LIBZIP_BUILD_EXAMPLES OFF CACHE BOOL "")
set(LIBZIP_BUILD_REGRESS OFF CACHE BOOL "")

@ -1 +1 @@
Subproject commit ddabf50f72cf369bf652a95c4d9fe31a1865a781
Subproject commit ba5eac54136064af94ab4a923ac110d7534d4f83

@ -1 +1 @@
Subproject commit 3c0f2e86ce4e7a3a3b30e765087d02a68bba7e6f
Subproject commit 3e877cbb3c9bc8f22946053e70490d2e5431f4d5

@ -1 +1 @@
Subproject commit da0d18ae59ef2699013316b703cdc93809414c93
Subproject commit 081249cceb59adc857a72d67e60c32047680f787

@ -395,7 +395,7 @@ LUA_API size_t lua_rawlen (lua_State *L, int idx) {
case LUA_TSHRSTR: return tsvalue(o)->shrlen;
case LUA_TLNGSTR: return tsvalue(o)->u.lnglen;
case LUA_TUSERDATA: return uvalue(o)->len;
case LUA_TTABLE: return luaH_getn(hvalue(o));
case LUA_TTABLE: return size_t(luaH_getn(hvalue(o)));
default: return 0;
}
}

@ -1 +1 @@
Subproject commit 87d6ae018cb8d288d854f632e9d8d959d75d7db4
Subproject commit 99d06827848583232dd77afb34cd7ab589567086

@ -1 +1 @@
Subproject commit 4056226fe0df6bff4593ee2353cca07c2b7f327e
Subproject commit ab8fd7f3e9df457e8bc1b5cb31b78d57df0ac5a4

@ -32,6 +32,7 @@ billw2012 billw2012
BrickViking brickviking
brndd brndd burneddi
Caldfir caldfir
Cameron Ewell Ozzatron
Carter Bray Qartar
Chris Dombroski cdombroski
Chris Parsons chrismdp

@ -1015,7 +1015,7 @@ Fortress mode
``dfhack.gui.recenterViewscreen([zoom])``
Recenter the view on a position using a specific zoom type. If no position is given,
recenter on ``df.global.cursor``. Zoom types are ``df.report_zoom_type`` (0 = Generic, 1 = Item, 2 = Unit),
recenter on ``df.global.cursor``. Zoom types are ``df.report_zoom_type`` (see: `enum definition <https://github.com/DFHack/df-structures/blob/master/df.announcements.xml#L438>`_),
where ``Generic`` skips recentering and enforces valid view bounds (the same as x = -30000,) ``Item`` brings
the position onscreen without centering, and ``Unit`` centers the screen on the position. Default zoom type is Item.
@ -1088,15 +1088,14 @@ Announcements
Uses the type to look up options from announcements.txt, and calls the above
operations accordingly. The units are used to call ``addCombatReportAuto``.
* ``dfhack.gui.autoDFAnnouncement(report,text[,log_failures])``
``dfhack.gui.autoDFAnnouncement(type,pos,text,color[,is_bright,unit1,unit2,is_sparring,log_failures])``
* ``dfhack.gui.autoDFAnnouncement(report,text)``
``dfhack.gui.autoDFAnnouncement(type,pos,text,color[,is_bright,unit1,unit2,is_sparring])``
Takes a ``df.report_init`` (see: `structure definition <https://github.com/DFHack/df-structures/blob/master/df.announcements.xml#L451>`_)
and a string and processes them just like DF does. Sometimes this means the announcement won't occur.
Set ``log_failures`` to ``true`` to log the reason why to the dfhack console (e.g., unrevealed map or wrong gamemode.)
Can also be built from parameters instead of a ``report_init``. Setting ``is_sparring`` to ``true`` means the report
will be added to sparring logs (if applicable) rather than hunting or combat. Text uses ``&`` as an escape character, with ``&r`` being a newline,
``&&`` being just ``&``, and any other combination causing neither character to display.
will be added to sparring logs (if applicable) rather than hunting or combat. Text is parsed using ``&`` as an escape character, with ``&r``
being a newline, ``&&`` being just ``&``, and any other combination causing neither character to display.
Other
~~~~~

@ -10,6 +10,14 @@ work (e.g. links from the `changelog`).
:local:
:depth: 1
.. _devel/unforbidall:
devel/unforbidall
=================
Replaced by the `unforbid` script. Run ``unforbid all --quiet`` to match the
behavior of the original ``devel/unforbidall`` script.
.. _digfort:
digfort

@ -40,15 +40,14 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Fixes
## Misc Improvements
- `dfhack-examples-guide`: refine food preparation orders and fix conditions for making jugs and pots in the ``basic`` manager orders
## Documentation
- ``Lua API.rst``: added ``autoDFAnnouncement``, ``pauseRecenter``, ``recenterViewscreen``
## API
- add functions reverse-engineered from announcement code: ``Gui::parseReportString``, ``Gui::autoDFAnnouncement``, ``Gui::pauseRecenter``, ``Gui::recenterViewscreen``
## Lua
- ``dfhack.gui``: Lua wrappers for functions reverse-engineered from announcement code: ``autoDFAnnouncement``, ``pauseRecenter``, ``recenterViewscreen``
# 0.47.05-r5

@ -415,10 +415,10 @@ if(APPLE)
set_target_properties(dfhack PROPERTIES SOVERSION 1.0.0)
endif()
target_link_libraries(dfhack protobuf-lite clsocket lua jsoncpp_lib_static dfhack-version ${PROJECT_LIBS})
target_link_libraries(dfhack protobuf-lite clsocket lua jsoncpp_static dfhack-version ${PROJECT_LIBS})
set_target_properties(dfhack PROPERTIES INTERFACE_LINK_LIBRARIES "")
target_link_libraries(dfhack-client protobuf-lite clsocket jsoncpp_lib_static)
target_link_libraries(dfhack-client protobuf-lite clsocket jsoncpp_static)
target_link_libraries(dfhack-run dfhack-client)
if(APPLE)

@ -198,7 +198,7 @@ DebugCategory::cstring_ref DebugCategory::plugin() const noexcept
//! standards only provide runtime checks if an atomic type is lock free
struct failIfEnumAtomicIsNotLockFree {
failIfEnumAtomicIsNotLockFree() {
std::atomic<DebugCategory::level> test;
std::atomic<DebugCategory::level> test(DebugCategory::LINFO);
if (test.is_lock_free())
return;
std::cerr << __FILE__ << ':' << __LINE__

@ -1509,23 +1509,19 @@ static const LuaWrapper::FunctionReg dfhack_gui_module[] = {
static int gui_autoDFAnnouncement(lua_State *state)
{
int rv;
bool rv;
df::report_init *r = Lua::GetDFObject<df::report_init>(state, 1);
if (r)
{
std::string message = luaL_checkstring(state, 2);
if (lua_gettop(state) >= 3)
rv = Gui::autoDFAnnouncement(*r, message, lua_toboolean(state, 3));
else
rv = Gui::autoDFAnnouncement(*r, message);
}
else
{
df::coord pos;
int color = 0; //initialize these to prevent warning
bool bright = false, is_sparring = false, log_failures = false;
bool bright = false, is_sparring = false;
df::unit *unit1 = NULL, *unit2 = NULL;
auto type = (df::announcement_type)lua_tointeger(state, 1);
@ -1535,8 +1531,6 @@ static int gui_autoDFAnnouncement(lua_State *state)
switch (lua_gettop(state))
{
default:
case 9:
log_failures = lua_toboolean(state, 9);
case 8:
is_sparring = lua_toboolean(state, 8);
case 7:
@ -1554,9 +1548,6 @@ static int gui_autoDFAnnouncement(lua_State *state)
switch (lua_gettop(state))
{ // Use the defaults in Gui.h
default:
case 9:
rv = Gui::autoDFAnnouncement(type, pos, message, color, bright, unit1, unit2, is_sparring, log_failures);
break;
case 8:
rv = Gui::autoDFAnnouncement(type, pos, message, color, bright, unit1, unit2, is_sparring);
break;
@ -1577,7 +1568,7 @@ static int gui_autoDFAnnouncement(lua_State *state)
}
}
lua_pushinteger(state, rv);
lua_pushboolean(state, rv);
return 1;
}

@ -168,32 +168,58 @@ std::string to_search_normalized(const std::string &str)
return result;
}
bool word_wrap(std::vector<std::string> *out, const std::string &str, size_t line_length)
bool word_wrap(std::vector<std::string> *out, const std::string &str,
size_t line_length, bool collapse_whitespace)
{
out->clear();
std::istringstream input(str);
std::string out_line;
std::string word;
if (input >> word)
if (line_length == 0)
line_length = SIZE_MAX;
std::string line;
size_t break_pos = 0;
for (auto &c : str)
{
out_line += word;
// size_t remaining = line_length - std::min(line_length, word.length());
while (input >> word)
if (c == '\n')
{
if (out_line.length() + word.length() + 1 <= line_length)
out->push_back(line);
line.clear();
break_pos = 0;
continue;
}
if (isspace(c))
{
out_line += ' ';
out_line += word;
if (break_pos == line.length() && collapse_whitespace)
continue;
line.push_back(collapse_whitespace ? ' ' : c);
break_pos = line.length();
}
else {
line.push_back(c);
}
if (line.length() > line_length)
{
if (break_pos > 0)
{
// Break before last space, and skip that space
out->push_back(line.substr(0, break_pos - 1));
}
else
{
out->push_back(out_line);
out_line = word;
// Single word is too long, just break it
out->push_back(line.substr(0, line_length));
break_pos = line_length;
}
line = line.substr(break_pos);
break_pos = 0;
}
if (out_line.length())
out->push_back(out_line);
}
if (line.length())
out->push_back(line);
return true;
}

@ -326,7 +326,7 @@ public:
DFHack::DebugCategory::LDEBUG, ## __VA_ARGS__)
/*!
* Open a line for error level debug output if enabled
* Open a line for info level debug output if enabled
*
* Important debug messages when some rarely changed state changes. Example
* would be when a debug category filtering level changes.

@ -391,7 +391,8 @@ DFHACK_EXPORT std::string to_search_normalized(const std::string &str);
DFHACK_EXPORT bool word_wrap(std::vector<std::string> *out,
const std::string &str,
size_t line_length = 80);
size_t line_length = 80,
bool collapse_whitespace = false);
inline bool bits_match(unsigned required, unsigned ok, unsigned mask)
{

@ -129,9 +129,9 @@ namespace DFHack
DFHACK_EXPORT void showAutoAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color = 7, bool bright = true, df::unit *unit1 = NULL, df::unit *unit2 = NULL);
// Process an announcement exactly like DF would, which might result in no announcement
DFHACK_EXPORT int autoDFAnnouncement(df::report_init r, std::string message);
DFHACK_EXPORT int autoDFAnnouncement(df::report_init r, std::string message, bool log_failures);
DFHACK_EXPORT int autoDFAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color = 7, bool bright = true, df::unit *unit1 = NULL, df::unit *unit2 = NULL, bool is_sparring = false, bool log_failures = false);
DFHACK_EXPORT bool autoDFAnnouncement(df::report_init r, std::string message);
DFHACK_EXPORT bool autoDFAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color = 7, bool bright = true,
df::unit *unit1 = NULL, df::unit *unit2 = NULL, bool is_sparring = false);
/*
* Cursor and window coords

@ -37,6 +37,7 @@ using namespace std;
#include "Error.h"
#include "ModuleFactory.h"
#include "Core.h"
#include "Debug.h"
#include "PluginManager.h"
#include "MiscUtils.h"
using namespace DFHack;
@ -112,6 +113,11 @@ using namespace DFHack;
#include "df/viewscreen_workshop_profilest.h"
#include "df/world.h"
namespace DFHack
{
DBG_DECLARE(core, gui, DebugCategory::LINFO);
}
using namespace df::enums;
using df::global::gamemode;
@ -1707,22 +1713,28 @@ void Gui::showAutoAnnouncement(
addCombatReportAuto(unit2, flags, id);
}
int Gui::autoDFAnnouncement(df::report_init r, string message)
bool Gui::autoDFAnnouncement(df::report_init r, string message)
{ // Reverse-engineered from DF announcement code
if (!world->unk_26a9a8) // TODO: world->show_announcements
return 1;
if (!world->allow_announcements)
{
DEBUG(gui).print("Skipped announcement because world->allow_announcements is false:\n%s\n", message.c_str());
return false;
}
df::announcement_flags a_flags;
if (is_valid_enum_item(r.type))
a_flags = df::global::d_init->announcements.flags[r.type];
else
return 2;
{
WARN(gui).print("Invalid announcement type:\n%s\n", message.c_str());
return false;
}
if (message.empty())
{
Core::printerr("Empty announcement %u\n", r.type); // DF would print this to errorlog.txt
return 3;
return false;
}
// Check if the announcement will actually be announced
@ -1737,28 +1749,41 @@ int Gui::autoDFAnnouncement(df::report_init r, string message)
if ((world->units.active.empty() || (r.unit1 != world->units.active[0] && r.unit2 != world->units.active[0])) &&
((Maps::getTileDesignation(r.pos)->whole & 0x10) == 0x0)) // Adventure mode uses this bit to determine current visibility
{
return 4;
DEBUG(gui).print("Adventure mode announcement not heard:\n%s\n", message.c_str());
return false;
}
}
}
else
{ // Dwarf mode (or arena?)
if ((r.unit1 != NULL || r.unit2 != NULL) && (r.unit1 == NULL || Units::isHidden(r.unit1)) && (r.unit2 == NULL || Units::isHidden(r.unit2)))
return 5;
{
DEBUG(gui).print("Dwarf mode announcement not heard:\n%s\n", message.c_str());
return false;
}
if (!a_flags.bits.D_DISPLAY)
{
if (a_flags.bits.UNIT_COMBAT_REPORT)
{
if (r.unit1 == NULL && r.unit2 == NULL)
return 6;
{
DEBUG(gui).print("Skipped UNIT_COMBAT_REPORT because it has no units:\n%s\n", message.c_str());
return false;
}
}
else
{
if (!a_flags.bits.UNIT_COMBAT_REPORT_ALL_ACTIVE)
return 7;
if (!recent_report_any(r.unit1) && !recent_report_any(r.unit2))
return 8;
{
DEBUG(gui).print("Skipped announcement not enabled for this game mode:\n%s\n", message.c_str());
return false;
}
else if (!recent_report_any(r.unit1) && !recent_report_any(r.unit2))
{
DEBUG(gui).print("Skipped UNIT_COMBAT_REPORT_ALL_ACTIVE because there's no active report:\n%s\n", message.c_str());
return false;
}
}
}
}
@ -1774,7 +1799,10 @@ int Gui::autoDFAnnouncement(df::report_init r, string message)
parseReportString(results, message, line_length);
if (results.empty())
return 9;
{
DEBUG(gui).print("Skipped announcement because it was empty after parsing:\n%s\n", message.c_str());
return false;
}
// Check for repeat report
int32_t repeat_count = check_repeat_report(results);
@ -1785,7 +1813,8 @@ int Gui::autoDFAnnouncement(df::report_init r, string message)
world->status.display_timer = r.display_timer;
Gui::writeToGamelog("x" + to_string(repeat_count + 1));
}
return 0;
DEBUG(gui).print("Announcement succeeded as repeat:\n%s\n", message.c_str());
return true;
}
bool success = false; // only print to gamelog if report was used
@ -1864,66 +1893,25 @@ int Gui::autoDFAnnouncement(df::report_init r, string message)
delete_old_reports();
if (/*debug_gamelog &&*/ success)
if (/*debug_gamelog &&*/ success) // TODO: Add debug_gamelog to globals?
{
DEBUG(gui).print("Announcement succeeded and printed to gamelog.txt:\n%s\n", message.c_str());
Gui::writeToGamelog(message);
else if (success)
return 10;
else
return 11;
return 0;
}
int Gui::autoDFAnnouncement(df::report_init r, string message, bool log_failures)
{ // Prints info about failed announcements to DFHack console if log_failures is true
int rv = autoDFAnnouncement(r, message);
if (log_failures)
}
/*else if (success)
{
switch (rv)
DEBUG(gui).print("Announcement succeeded but skipped printing to gamelog.txt because debug_gamelog is false:\n%s\n", message.c_str());
}*/
else
{
case 0:
break; // success
case 1:
Core::print("Skipped an announcement because world->show_announcements is false:\n%s\n", message.c_str());
break;
case 2:
Core::printerr("Invalid announcement type!\n");
break;
case 3:
break; // empty announcement, already handled
case 4:
Core::print("An adventure announcement occured, but nobody heard:\n%s\n", message.c_str());
break;
case 5:
Core::print("An announcement occured, but nobody heard:\n%s\n", message.c_str());
break;
case 6:
Core::print("Skipped a UNIT_COMBAT_REPORT because it has no units:\n%s\n", message.c_str());
break;
case 7:
Core::print("Skipped an announcement not enabled for this game mode:\n%s\n", message.c_str());
break;
case 8:
Core::print("Skipped an announcement because there's no active report:\n%s\n", message.c_str());
break;
case 9:
Core::print("Skipped an announcement because it was empty after parsing:\n%s\n", message.c_str());
break;
case 10:
Core::print("Report added but skipped printing to gamelog.txt because debug_gamelog is false.\n");
break;
case 11:
Core::print("Report added but didn't qualify to be displayed anywhere:\n%s\n", message.c_str());
break;
default:
Core::printerr("autoDFAnnouncement: Unexpected return value!\n");
DEBUG(gui).print("Announcement succeeded internally but didn't qualify to be displayed anywhere:\n%s\n", message.c_str());
}
}
return rv;
return true;
}
int Gui::autoDFAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color, bool bright, df::unit *unit1, df::unit *unit2, bool is_sparring, bool log_failures)
bool Gui::autoDFAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color,
bool bright, df::unit *unit1, df::unit *unit2, bool is_sparring)
{
auto r = df::report_init();
r.type = type;
@ -1937,7 +1925,7 @@ int Gui::autoDFAnnouncement(df::announcement_type type, df::coord pos, std::stri
if (Maps::isValidTilePos(pos))
r.zoom_type = report_zoom_type::Unit;
return autoDFAnnouncement(r, message, log_failures);
return autoDFAnnouncement(r, message);
}
df::viewscreen *Gui::getCurViewscreen(bool skip_dismissed)

@ -1 +1 @@
Subproject commit 7ec5d86996269df5e01d64ea5bae67d0c29afd77
Subproject commit 59075f42bbc77c354b5f815c5c1cce5bf48e76a5

@ -87,7 +87,7 @@ if(BUILD_SUPPORTED)
dfhack_plugin(autoclothing autoclothing.cpp)
dfhack_plugin(autodump autodump.cpp)
dfhack_plugin(autofarm autofarm.cpp)
dfhack_plugin(autogems autogems.cpp LINK_LIBRARIES jsoncpp_lib_static)
dfhack_plugin(autogems autogems.cpp LINK_LIBRARIES jsoncpp_static)
dfhack_plugin(autohauler autohauler.cpp)
dfhack_plugin(autolabor autolabor.cpp)
dfhack_plugin(automaterial automaterial.cpp LINK_LIBRARIES lua)
@ -109,7 +109,7 @@ if(BUILD_SUPPORTED)
dfhack_plugin(cursecheck cursecheck.cpp)
dfhack_plugin(cxxrandom cxxrandom.cpp LINK_LIBRARIES lua)
dfhack_plugin(deramp deramp.cpp)
dfhack_plugin(debug debug.cpp LINK_LIBRARIES jsoncpp_lib_static)
dfhack_plugin(debug debug.cpp LINK_LIBRARIES jsoncpp_static)
dfhack_plugin(dig dig.cpp)
dfhack_plugin(dig-now dig-now.cpp LINK_LIBRARIES lua)
dfhack_plugin(digFlood digFlood.cpp)
@ -143,7 +143,7 @@ if(BUILD_SUPPORTED)
dfhack_plugin(mode mode.cpp)
dfhack_plugin(mousequery mousequery.cpp)
dfhack_plugin(nestboxes nestboxes.cpp)
dfhack_plugin(orders orders.cpp LINK_LIBRARIES jsoncpp_lib_static)
dfhack_plugin(orders orders.cpp LINK_LIBRARIES jsoncpp_static)
dfhack_plugin(pathable pathable.cpp LINK_LIBRARIES lua)
dfhack_plugin(petcapRemover petcapRemover.cpp)
dfhack_plugin(plants plants.cpp)

@ -873,7 +873,7 @@ static void assign_labor(unit_labor::unit_labor labor,
}
int pool = labor_infos[labor].talent_pool();
if (pool < 200 && candidates.size() > 1 && abs(pool) < candidates.size())
if (pool < 200 && candidates.size() > 1 && size_t(abs(pool)) < candidates.size())
{
// Sort in descending order
std::sort(candidates.begin(), candidates.end(), [&](const int lhs, const int rhs) -> bool {

@ -1,23 +1,25 @@
//command-prompt a one line command entry at the top of the screen for quick commands
// command-prompt: A one-line command entry at the top of the screen for quick commands
#include "Core.h"
#include <ColorText.h>
#include <Console.h>
#include <Export.h>
#include <MiscUtils.h>
#include <PluginManager.h>
#include <ColorText.h>
#include <modules/Screen.h>
#include <modules/Gui.h>
#include <modules/Screen.h>
#include <set>
#include <list>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "df/enabler.h"
#include "df/graphic.h"
#include "df/interface_key.h"
#include "df/ui.h"
#include "df/graphic.h"
#include "df/enabler.h"
using namespace DFHack;
using namespace df::enums;
@ -36,8 +38,10 @@ class prompt_ostream:public buffered_color_ostream
protected:
void flush_proxy();
public:
prompt_ostream(viewscreen_commandpromptst* parent):parent_(parent){}
bool empty(){return buffer.empty();}
prompt_ostream(viewscreen_commandpromptst* parent)
: parent_(parent)
{}
bool empty() { return buffer.empty(); }
};
class viewscreen_commandpromptst : public dfhack_viewscreen {
public:
@ -48,7 +52,7 @@ public:
}
void render();
void help() { }
void help() {}
int8_t movies_okay() { return 0; }
df::unit* getSelectedUnit() { return Gui::getAnyUnit(parent); }
@ -57,10 +61,11 @@ public:
df::plant* getSelectedPlant() { return Gui::getAnyPlant(parent); }
std::string getFocusString() { return "commandprompt"; }
viewscreen_commandpromptst(std::string entry):submitted(false), is_response(false)
viewscreen_commandpromptst(std::string entry)
: submitted(false), is_response(false)
{
show_fps=gps->display_frames;
gps->display_frames=0;
show_fps = gps->display_frames;
gps->display_frames = 0;
cursor_pos = entry.size();
frame = 0;
history_idx = command_history.size();
@ -76,7 +81,7 @@ public:
}
~viewscreen_commandpromptst()
{
gps->display_frames=show_fps;
gps->display_frames = show_fps;
}
void add_response(color_value v, std::string s)
@ -125,7 +130,7 @@ public:
}
protected:
std::list<std::pair<color_value,std::string> > responses;
std::list<std::pair<color_value, std::string> > responses;
int cursor_pos;
int history_idx;
bool submitted;
@ -138,8 +143,8 @@ void prompt_ostream::flush_proxy()
{
if (buffer.empty())
return;
for(auto it=buffer.begin();it!=buffer.end();it++)
parent_->add_response(it->first,it->second);
for(auto it = buffer.begin(); it != buffer.end(); it++)
parent_->add_response(it->first, it->second);
buffer.clear();
}
void viewscreen_commandpromptst::render()
@ -154,25 +159,31 @@ void viewscreen_commandpromptst::render()
auto dim = Screen::getWindowSize();
parent->render();
if(is_response)
if (is_response)
{
int y = 0;
for (auto &response : responses)
{
auto it=responses.begin();
for(int i=0;i<dim.y && it!=responses.end();i++,it++)
std::vector<std::string> lines;
word_wrap(&lines, response.second, dim.x);
for (auto &line : lines)
{
Screen::fillRect(Screen::Pen(' ', 7, 0),0,i,dim.x,i);
std::string cur_line=it->second;
Screen::paintString(Screen::Pen(' ',it->first,0),0,i,cur_line.substr(0,cur_line.size()-1));
Screen::fillRect(Screen::Pen(' ', 7, 0), 0, y, dim.x, y);
Screen::paintString(Screen::Pen(' ', response.first, 0), 0, y, line);
if (++y >= dim.y)
return;
}
}
}
else
{
std::string entry = get_entry();
Screen::fillRect(Screen::Pen(' ', 7, 0),0,0,dim.x,0);
Screen::paintString(Screen::Pen(' ', 7, 0), 0, 0,"[DFHack]#");
Screen::fillRect(Screen::Pen(' ', 7, 0), 0, 0, dim.x, 0);
Screen::paintString(Screen::Pen(' ', 7, 0), 0, 0, "[DFHack]#");
std::string cursor = (frame < enabler->gfps / 2) ? "_" : " ";
if(cursor_pos < (dim.x - 10))
if (cursor_pos < dim.x - 10)
{
Screen::paintString(Screen::Pen(' ', 7, 0), 10,0 , entry);
Screen::paintString(Screen::Pen(' ', 7, 0), 10, 0, entry);
if (int16_t(entry.size()) > dim.x - 10)
Screen::paintTile(Screen::Pen('\032', 7, 0), dim.x - 1, 0);
if (cursor != " ")
@ -191,12 +202,12 @@ void viewscreen_commandpromptst::render()
void viewscreen_commandpromptst::submit()
{
CoreSuspendClaimer suspend;
if(is_response)
if (is_response)
{
Screen::dismiss(this);
return;
}
if(submitted)
if (submitted)
return;
submitted = true;
prompt_ostream out(this);
@ -204,11 +215,11 @@ void viewscreen_commandpromptst::submit()
Screen::Hide hide_guard(this, Screen::Hide::RESTORE_AT_TOP);
Core::getInstance().runCommand(out, get_entry());
}
if(out.empty() && responses.empty())
if (out.empty() && responses.empty())
Screen::dismiss(this);
else
{
is_response=true;
is_response = true;
}
}
void viewscreen_commandpromptst::feed(std::set<df::interface_key> *events)
@ -240,14 +251,14 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *events)
for (auto it = events->begin(); it != events->end(); ++it)
{
auto key = *it;
if (key==interface_key::STRING_A000) //delete?
if (key == interface_key::STRING_A000) //delete?
{
if(entry.size() && cursor_pos > 0)
if (entry.size() && cursor_pos > 0)
{
entry.erase(cursor_pos - 1, 1);
cursor_pos--;
}
if(size_t(cursor_pos) > entry.size())
if (size_t(cursor_pos) > entry.size())
cursor_pos = entry.size();
continue;
}
@ -261,34 +272,34 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *events)
}
}
// Prevent number keys from moving cursor
if(events->count(interface_key::CURSOR_RIGHT))
if (events->count(interface_key::CURSOR_RIGHT))
{
cursor_pos++;
if (size_t(cursor_pos) > entry.size())
cursor_pos = entry.size();
}
else if(events->count(interface_key::CURSOR_LEFT))
else if (events->count(interface_key::CURSOR_LEFT))
{
cursor_pos--;
if (cursor_pos < 0) cursor_pos = 0;
}
else if(events->count(interface_key::CURSOR_RIGHT_FAST))
else if (events->count(interface_key::CURSOR_RIGHT_FAST))
{
forward_word();
}
else if(events->count(interface_key::CURSOR_LEFT_FAST))
else if (events->count(interface_key::CURSOR_LEFT_FAST))
{
back_word();
}
else if(events->count(interface_key::CUSTOM_CTRL_A))
else if (events->count(interface_key::CUSTOM_CTRL_A))
{
cursor_pos = 0;
}
else if(events->count(interface_key::CUSTOM_CTRL_E))
else if (events->count(interface_key::CUSTOM_CTRL_E))
{
cursor_pos = entry.size();
}
else if(events->count(interface_key::CURSOR_UP))
else if (events->count(interface_key::CURSOR_UP))
{
history_idx--;
if (history_idx < 0)
@ -296,7 +307,7 @@ void viewscreen_commandpromptst::feed(std::set<df::interface_key> *events)
entry = get_entry();
cursor_pos = entry.size();
}
else if(events->count(interface_key::CURSOR_DOWN))
else if (events->count(interface_key::CURSOR_DOWN))
{
if (size_t(history_idx) < command_history.size() - 1)
{
@ -321,8 +332,8 @@ command_result show_prompt(color_ostream &out, std::vector <std::string> & param
return CR_OK;
}
std::string params;
for(size_t i=0;i<parameters.size();i++)
params+=parameters[i]+" ";
for(size_t i = 0; i < parameters.size(); i++)
params += parameters[i] + " ";
Screen::show(dts::make_unique<viewscreen_commandpromptst>(params), plugin_self);
return CR_OK;
}
@ -330,21 +341,23 @@ bool hotkey_allow_all(df::viewscreen *top)
{
return true;
}
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
DFhackCExport command_result plugin_init(color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand(
"command-prompt","Shows a command prompt on window.",show_prompt,hotkey_allow_all,
"command-prompt [entry] - shows a cmd prompt in df window. Entry is used for default prefix (e.g. ':lua')"
"command-prompt", "Shows a command prompt on window.",
show_prompt, hotkey_allow_all,
"command-prompt [entry] - shows a cmd prompt in df window."
" Entry is used for default prefix (e.g. ':lua')"
));
return CR_OK;
}
DFhackCExport command_result plugin_onstatechange (color_ostream &out, state_change_event e)
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event e)
{
return CR_OK;
}
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
DFhackCExport command_result plugin_shutdown(color_ostream &out)
{
return CR_OK;
}

@ -1 +1 @@
Subproject commit e3c49ab017da2dcbeaadccd10e56d07d8f03b4ca
Subproject commit 3630c816df6962b4594d46d1ae75974c36c11629

@ -1 +1 @@
Subproject commit b808050d4a3885aa0e250e726708b2b28fe28260
Subproject commit e062237ee03a22d0d8b88b725ba3712e649f1bf6