Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consume tool charges incrementally during crafting #31844

Merged
merged 3 commits into from
Jun 30, 2019

Conversation

ifreund
Copy link
Contributor

@ifreund ifreund commented Jun 25, 2019

Summary

SUMMARY: Bugfixes "Consume tool charges incrementally during crafting."

Purpose of change

Fixes #7126
Fixes #24230
Progress towards #29210 (getting very close to drastic craft time extension being feasible)

Describe the solution

Tool charges are now consumed before every 5% crafting progress,
with the remainder consumed at the start of the craft.

Describe alternatives you've considered

Rewriting a large portion of this code to make things cleaner. The way this is currently implemented feels more than a little hacky, but should work without issues.

Additional context

This may fix other old issues that I'm not aware of. If you know of any please add a comment so we can close them with this PR as well.

@ifreund ifreund added <Enhancement / Feature> New features, or enhancements on existing Crafting / Construction / Recipes Includes: Uncrafting / Disassembling [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) labels Jun 25, 2019
@ifreund ifreund added this to the 0.E milestone Jun 25, 2019
@ifreund ifreund force-pushed the craft-incremental-tools branch 2 times, most recently from 14cd4a5 to 7c141d7 Compare June 26, 2019 07:26
@ifreund
Copy link
Contributor Author

ifreund commented Jun 26, 2019

Conflicts resolved

ifreund added 3 commits June 27, 2019 00:50
Tool charges are now consumed before every 5% crafting progress,
with the remainder consumed at the start of the craft.
Tool charges are now consumed incrementally and the relevant crafting
tests need to be updated to reflect that.

In particular, it is no longer sufficient to check tool charges after
merely starting the craft; the activity must be completed.
I forgot to add serialization for `tools_to_continue` and
`cached_tool_selections` which were added to `item` in a previous
commit.

This commit adds io support for `comp_selection` and properly
serializes the new item members.
@ifreund ifreund force-pushed the craft-incremental-tools branch from 7c141d7 to d70e1dd Compare June 26, 2019 22:50
@ZhilkinSerg ZhilkinSerg self-assigned this Jun 27, 2019
@kevingranade kevingranade merged commit b537172 into CleverRaven:master Jun 30, 2019
@ZhilkinSerg ZhilkinSerg removed their assignment Jun 30, 2019
@jbytheway
Copy link
Contributor

jbytheway commented Jun 30, 2019

I've seen a test failure that looks plausibly related to this


cata_test: src/ui.cpp:112: void uilist::init(): Assertion `!test_mode' failed.
Stack trace at fatal error:

        /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/libasan.so.4(+0x55630) [0x7f7cdf359630]
        tests/cata_test(_Z21debug_write_backtraceRSo+0x34b) [0x560f3866f496]
        tests/cata_test(_ZN12CataListener14assertionEndedERKN5Catch14AssertionStatsE+0x74) [0x560f37f49572]
        tests/cata_test(_ZN5Catch17ListeningReporter14assertionEndedERKNS_14AssertionStatsE+0x2c7) [0x560f37e94adf]
        tests/cata_test(_ZN5Catch10RunContext14assertionEndedERKNS_15AssertionResultE+0x179) [0x560f37f07e23]
        tests/cata_test(_ZN5Catch10RunContext25handleFatalErrorConditionENS_9StringRefE+0x4b7) [0x560f37f08957]
        tests/cata_test(+0x101b8a4) [0x560f37ea18a4]
        tests/cata_test(_ZN5Catch21FatalConditionHandler12handleSignalEi+0x77) [0x560f37ea1a09]
        /lib64/libc.so.6(+0x35fc0) [0x7f7cde219fc0]
        /lib64/libc.so.6(gsignal+0x110) [0x7f7cde219f00]
        /lib64/libc.so.6(abort+0x1c7) [0x7f7cde21ba57]
        /lib64/libc.so.6(+0x2d85a) [0x7f7cde21185a]
        /lib64/libc.so.6(+0x2d8e2) [0x7f7cde2118e2]
        tests/cata_test(_ZN6uilist4initEv+0x28b) [0x560f3b1a70f5]
        tests/cata_test(_ZN6uilistC1Ev+0x99e) [0x560f3b1a8ece]
        tests/cata_test(_ZN6player21select_item_componentERKSt6vectorI9item_compSaIS1_EEiR9inventorybRKSt8functionIFbRK4itemEEb+0x1c09) [0x560f38558309]
        tests/cata_test(_ZN13craft_command7executeERK8tripoint+0x1e10) [0x560f3ba7d696]
        tests/cata_test(_ZN6player23make_craft_with_commandERK9string_idI6recipeEibRK8tripoint+0xd68) [0x560f38516f58]
        tests/cata_test(_ZN6player10make_craftERK9string_idI6recipeEiRK8tripoint+0x11) [0x560f38516fd9]
        tests/cata_test(+0x8f9f5a) [0x560f3777ff5a]

        Attempting to repeat stack trace using debug symbols...
        ??
        ??:0
        debug_write_backtrace(std::ostream&)
        .../src/debug.cpp:620
        CataListener::assertionEnded(Catch::AssertionStats const&)
        .../tests/test_main.cpp:244
        __gnu_cxx::__normal_iterator<std::unique_ptr<Catch::IStreamingReporter, std::default_delete<Catch::IStreamingReporter> >*, std::vector<std::unique_ptr<Catch::IStreamingReporter, std::default_delete<Catch::IStreamingReporter> >, std::allocator<std::unique_ptr<Catch::IStreamingReporter, std::default_delete<Catch::IStreamingReporter> > > > >::operator++()
        /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/include/g++-v7.3.1/bits/stl_iterator.h:805
        Catch::ListeningReporter::assertionEnded(Catch::AssertionStats const&)
        .../tests/catch/catch.hpp:16101
        Catch::RunContext::assertionEnded(Catch::AssertionResult const&)
        .../tests/catch/catch.hpp:12099
        Catch::RunContext::handleFatalErrorCondition(Catch::StringRef)
        .../tests/catch/catch.hpp:12224
        (anonymous namespace)::reportFatal(char const*)
        .../tests/catch/catch.hpp:10302
        Catch::FatalConditionHandler::handleSignal(int)
        .../tests/catch/catch.hpp:10397
        killpg
        ??:?
        gsignal
        ??:?
        abort
        ??:?
        uselocale
        ??:?
        __assert_fail
        ??:?
        uilist::init()
        .../src/ui.cpp:113
        uilist::uilist()
        .../src/ui.cpp:33
        player::select_item_component(std::vector<item_comp, std::allocator<item_comp> > const&, int, inventory&, bool, std::function<bool (item const&)> const&, bool)
        .../src/crafting.cpp:1373
        craft_command::execute(tripoint const&)
        .../src/craft_command.cpp:149
        player::make_craft_with_command(string_id<recipe> const&, int, bool, tripoint const&)
        .../src/crafting.cpp:564
        player::make_craft(string_id<recipe> const&, int, tripoint const&)
        .../src/crafting.cpp:547
        actually_test_craft(string_id<recipe> const&, std::vector<item, std::allocator<item> > const&, int)
        .../tests/crafting_test.cpp:314

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cata_test is a Catch v2.9.1 host application.
Run with -? for options

Randomness seeded to: 1561885818

-------------------------------------------------------------------------------
charge_handling
  carver
-------------------------------------------------------------------------------
crafting_test.cpp:330
...............................................................................

crafting_test.cpp:311: FAILED:
  {Unknown expression after the reported line}
due to a fatal error condition:
  SIGABRT - Abort (abnormal termination) signal

0.000 s: charge_handling

Something is causing a UI popup which isn't permitted in the tests because there's no one to respond to it.

@ifreund ifreund deleted the craft-incremental-tools branch June 30, 2019 09:58
@ifreund
Copy link
Contributor Author

ifreund commented Jun 30, 2019

Certainly seems like it must be related, but I haven't been able to reproduce the failure locally. Does it happen every time for you or is it intermittent?

@jbytheway
Copy link
Contributor

Only seen it once so far (out of maybe three test runs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Crafting / Construction / Recipes Includes: Uncrafting / Disassembling <Enhancement / Feature> New features, or enhancements on existing
Projects
None yet
4 participants