Commit Graph

2691 Commits (dec61b89bee78c7f7fe06a4c5df0d4eb6f66671e)

Author SHA1 Message Date
Pauli dec61b89be Fix windows ReadConsoleInput return value check
I messed up the check. I forgot that windows commonly has opposite
return values to posix and failed to check it from documentation.

Fixes 1345
2018-07-08 00:50:43 +03:00
lethosor aa76b92662 Merge remote-tracking branch 'suokko/main_thread_ownership_for_df_ai' into develop 2018-07-06 16:37:06 -04:00
lethosor c006df561e Merge remote-tracking branch 'suokko/lua_printall_recurse' into develop 2018-07-06 14:25:35 -04:00
lethosor be9affc8fb Update xml, changelog 2018-07-06 14:22:46 -04:00
lethosor dc6fd8d35c Merge remote-tracking branch 'suokko/stl_printf_remove_extra_null' into develop 2018-07-06 11:09:39 -04:00
lethosor 54cf8b7dc3 Fix getVisibleName for units with identities
As of 0.44.11 (possibly 0.44.01), identity names take precedence over the
associated histfig names. Tested with:

https://drive.google.com/file/d/1bX5CQMqNsb_mjJOEOS4wBm4mGDLLs_cZ/view (#1279)
http://dffd.bay12games.com/file.php?id=13428 (from http://www.bay12games.com/dwarves/mantisbt/view.php?id=10530)

Fixes #1279
2018-07-06 11:06:04 -04:00
Pauli d1a3f1a738 Allow canceling lineedit with ctrl+c 2018-07-04 15:21:25 +03:00
Pauli a550e112c3 Allow temporary transfer of main logic thread ownership
Dependency to fix df-ai to work with the new CoreSuspender
2018-07-04 00:02:03 +03:00
Pauli 320e94a1eb Avoid locking CoreSuspender second time in main thread 2018-07-04 00:00:06 +03:00
lethosor 616675f0ce Merge remote-tracking branch 'suokko/kittens_data_race_fix' into develop 2018-07-03 00:30:36 -04:00
lethosor c449041c11 Merge remote-tracking branch 'suokko/lua_List_setChoices_internal_table_1171' into develop 2018-07-03 00:27:22 -04:00
lethosor c543a17250 Improve RPC port handling
- Use port from remote-server.json in dfhack-run
- Make DFHACK_RUN environment variable take priority over remote-server.json
- Log current port to stderr
2018-07-02 23:53:56 -04:00
lethosor 81a7ddcf92 Merge remote-tracking branch 'suokko/screen_show_memory_leak' into develop 2018-07-02 22:58:11 -04:00
lethosor f0ff96f614 Merge remote-tracking branch 'suokko/multibyte_console' into develop 2018-07-02 10:55:03 -04:00
Pauli ba1d3fcb6a Add dfhack.printall_recurse to quickly print df containers
I often want to see multiple items quickly when trying to figure out
what states actually matter to an issue that I debug. I decided to make
it easier to quickly dump df structures with substructures and
containers. It will generate large amount of data which can be sometimes
slow to process manually. But processing can be automated using
dfhack-run lua ^<df data to inspect> and pipe to other tools (eg grep,
sed, perl, sort, uniq etc)
2018-06-30 22:31:49 +03:00
Pauli 645ec0d591 Improve kittens thread safety and shutdown with core
The bools could use acquire&release memory order or even relaxed but I
didn't think code was worth auditing for such low level optimizations.
Sequantial consistent is fast enough but much harder to use incorrectly.

The timeLast is protected by CoreSuspender lock. plugin_update is only
called when CoreSuspender lock is held.

The last_menu is protected by trackmenu_flg loads and stores.
2018-06-30 21:53:12 +03:00
Pauli 0727403ac1 Fix devel plugins linking in linux 2018-06-30 21:12:42 +03:00
Pauli 7a2245c2fa Remove null byte from string length
I noticed an extra null when trying to grep dfhack.run ls output.

std::string manages null byte at end(). Pre C++11 didn't require null
termination for std::string but C++11 add the null termination to make
c_str() and data() truely const. It is undefined behavior to modify the
internal null termination but this modification sets the null to null.
2018-06-30 12:51:38 +03:00
lethosor 1a4440859c Update xml (viewscreen_civlistst) 2018-06-29 22:33:15 -04:00
lethosor 105ddd86d8 Merge remote-tracking branch 'suokko/jsoncpp_upgrade_to_submodule' into develop 2018-06-29 22:33:00 -04:00
Pauli c39a882b57 Add missing Unit::isDiplomat
Fixes #1324
2018-06-29 16:19:18 +03:00
lethosor 3c2bfb6f47 Bump to 0.44.11-alpha1, update changelog, xml 2018-06-28 13:31:56 -04:00
lethosor f9dfb5907b Update submodules, authors 2018-06-27 13:57:34 -04:00
lethosor 19627b9221 Bump to 0.44.11 2018-06-24 17:42:31 -04:00
Pauli f6b0ac7819 Refactor CoreSuspender to fix Console::lineedit exit hangs
The old CoreSuspender requires processing from Core::Update to allow
commands execute. But that causes issues if Core::Shutdown wants
quarentee cleanup order with std:🧵:join. Fixing shutdown ordering
adds too many branches to already fairly complex code.

I decided to try to refactor CoreSuspender to use simpler locking
locking using a std::recusive_muted as primary synchronization
primitive.
To help control when Core::Update unlocks the primary mutex there is
std::contition_variable_any and std::atomic<size_t> queue lenght
counter.
The last state variable is std::atomic<std:🧵:id> that is used to
keep track of owner thread for Core::IsSuspended query.

This should be merged only just after a release to make sure that it
gets maximum testing in develop branch before next release.

Fixes #1066
2018-06-22 17:57:37 +03:00
Pauli 0bc1db4f07 Make sure hotkeythread exits before cleanup 2018-06-22 17:57:37 +03:00
Pauli 1fc37f8ddc Checke Console::lineedit error return values
Console::lineedit can return -1 to indicate input error and -2 to
indicate the program is closing. But most users don't check possible
unusual return values which can lead to exit hang.
2018-06-22 17:57:37 +03:00
Pauli 84f8a75a2e Add cuchar fallback implementation for gcc 4 and 5 2018-06-22 17:57:37 +03:00
Pauli 820b787cd0 Add multibyte character handling to posix console
I noticed that multibyte characters can mess up the console state
variables. I decided to add a minimal multibyte support to make sure the
input only collects complete valid multibyte characters in case user
enters them to console.

This change assumes that UTF-32 has one to one mapping between printed
characters and char32 indexes. But I remember reading there is a few
rare corner cases with accents where character might require multiple
4byte characters too. But this patch at least changes correct handling
from about 100 characters to 99% of unicode characters.
2018-06-22 17:57:37 +03:00
Pauli 1acb60daa2 Prevent data races during console/init thread shutdown
There is a minor chance that console or init thread would access already
freed memory when core is shutting down and cleaning up state. To avoid
any danger of having random bugs caused by the potential data race I
decided to make sure the shutdown code waits for the thread to exit
first.

Windows change is completely untested. It is purely based on msdn
documentation.
2018-06-22 17:57:37 +03:00
Pauli 19a169ba65 Convert Core.cpp to use c++11 thread
I noticed that tthread is missing some c++11 features that make thread
handling code a bit easier. To be able to use those features I decided
to convert Core.cpp to use equivalent standard classes.

This patch has no functional changes.
2018-06-22 17:57:37 +03:00
Pauli b7871c7368 Console-posix: Use lowest possible nfds parameter to the select call 2018-06-22 17:57:37 +03:00
lethosor 854f467f56 Merge remote-tracking branch 'suokko/check_jobs_on_mapcache_commit_1229' into develop 2018-06-21 15:03:51 -04:00
lethosor 7a5e7c7c86 Rename unit_flags1.dead to killed, update submodules/changelog
Follow-up for dfhack/df-structures#247
2018-06-21 11:17:09 -04:00
lethosor 1deb6ab024 Update xml 2018-06-20 16:19:00 -04:00
lethosor 7fda8506f0 Merge remote-tracking branch 'suokko/cmake_option_to_enable_all_symbols' into develop 2018-06-20 16:16:03 -04:00
lethosor 6077a8ce4c Merge remote-tracking branch 'suokko/printf_warnings' into develop 2018-06-20 11:25:14 -04:00
lethosor 2f1d3c68c6 Merge remote-tracking branch 'suokko/stl_vsnprintf' into develop 2018-06-20 11:23:57 -04:00
lethosor b9df6fae85 Update xml, authors 2018-06-20 10:51:24 -04:00
Pauli 98b25e3462 Allow calling List:setChoices() to clear choices 2018-06-20 17:46:24 +03:00
Pauli ed23d2c4e2 Change gui.widgets.List:setChoices to keep state in internal table
Fixes #1171
2018-06-20 17:23:57 +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 87e7c0f7aa Add cmake configuration to select if stubs include symbols
G++ generates structure debug symbols for a few df namespace classes to
generated stub source files. I decided to test how much symbols from
those files would increase binary size. When the result was about double
size I decided to add cmake configuration option to let user easily
select if they prefer complete symbols or reduced size.
2018-06-19 16:16:38 +03:00
Pauli bcf9387ce9 Only remove jobs that were created from a designation 2018-06-18 19:57:00 +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
Pauli 0bc2b3ab1b Update toSimpleString to use a the new builder API 2018-06-14 21:20:54 +03:00
Pauli 2b79b4cce7 Use jsoncpp 1.8.4 as a submodule
This makes jsoncpp a submodule that can be build directly from git
sources. This changes depends/jsoncpp to depends/jsoncpp-sub to avoid
filename conflict if someone tries to use git bisect.

jsoncpp library name changes to jsoncpp_lib_static.

jsoncpp version is the latest tagged release.
2018-06-14 21:20:46 +03:00
lethosor aac892c560 Adapted to changed Units functions
Squashed version of #1307

Closes #1307
2018-06-14 10:30:35 -04:00
Pauli 4cfdd7d92e Check if second vsnprintf does something unexpected 2018-06-13 23:33:13 +03:00