diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f7865218..9995ca40 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,7 @@ jobs: submodules: true # Download inklecate - - uses: suisei-cn/actions-download-file@v1 + - uses: suisei-cn/actions-download-file@v1.4.0 name: Download Inklecate id: download_inklecate with: @@ -62,7 +62,7 @@ jobs: # Setup CMake - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v1.9 + uses: jwlawson/actions-setup-cmake@v1.14.2 with: cmake-version: '3.21.x' @@ -144,7 +144,7 @@ jobs: shell: bash working-directory: proofing/ink-proof run: | - python3 proof.py --examples 'I...' inkcpp inklecate_v0.9.0 > run.out + python3 proof.py --examples 'I...' inklecate_v1.1.1 inkcpp_runtime > run.out echo -e "| ${{ matrix.name }} | $(cat run.out) |" > ${{ matrix.artifact }}.txt # Creates a "disabled" artifact if ink proofing is disabled @@ -172,11 +172,17 @@ jobs: reporting: name: "Pull Request Report" - if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }} + # if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'brwarner/inkcpp' }} + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'master' }} runs-on: ubuntu-latest needs: compilation + permissions: + pull-requests: write steps: # Download Ink Proof Results + - name: Debug + run: | + echo ${{github.event_name}} ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.ref}} ${{github.event.pull_request.base.full_name}} ${{github.event.pull_request.base.ref}} - uses: actions/download-artifact@v2 with: name: results @@ -200,7 +206,7 @@ jobs: done # Post Comment - - uses: marocchino/sticky-pull-request-comment@v2 + - uses: marocchino/sticky-pull-request-comment@v2.8.0 with: recreate: true path: comment.txt diff --git a/inkcpp/array.h b/inkcpp/array.h index 5c3ac652..42a6a40f 100644 --- a/inkcpp/array.h +++ b/inkcpp/array.h @@ -20,6 +20,12 @@ namespace ink::runtime::internal { } } + ~managed_array() { + if constexpr (dynamic) { + delete[] _dynamic_data; + } + } + const T& operator[]( size_t i ) const { return data()[i]; } T& operator[]( size_t i ) { return data()[i]; } const T* data() const diff --git a/inkcpp/output.cpp b/inkcpp/output.cpp index 0c13452e..392ec3d3 100644 --- a/inkcpp/output.cpp +++ b/inkcpp/output.cpp @@ -140,8 +140,12 @@ namespace ink::runtime::internal std::string result = str.str(); if ( !result.empty() ) { auto end = clean_string( result.begin(), result.end() ); - _last_char = *( end - 1 ); - result.resize( end - result.begin() - ( _last_char == ' ' ? 1 : 0 ) ); + if (result.begin() == end) { + result.resize(0); + } else { + _last_char = *( end - 1 ); + result.resize( end - result.begin() - ( _last_char == ' ' ? 1 : 0 ) ); + } } return result; } diff --git a/inkcpp/runner_impl.cpp b/inkcpp/runner_impl.cpp index 7ae1a136..5f4d829c 100644 --- a/inkcpp/runner_impl.cpp +++ b/inkcpp/runner_impl.cpp @@ -185,7 +185,7 @@ namespace ink::runtime::internal const uint32_t* iter = nullptr; container_t id; - ip_t offset; + ip_t offset = nullptr; size_t comm_end; bool reversed = _ptr > dest; diff --git a/inkcpp/story_ptr.cpp b/inkcpp/story_ptr.cpp index 99f9b6dd..d425bacc 100644 --- a/inkcpp/story_ptr.cpp +++ b/inkcpp/story_ptr.cpp @@ -66,4 +66,4 @@ namespace ink::runtime::internal _instance_block = _story_block = nullptr; return is_destroyed; } -} \ No newline at end of file +} diff --git a/inkcpp_cl/inkcpp_cl.cpp b/inkcpp_cl/inkcpp_cl.cpp index f5d55f4b..1e800450 100644 --- a/inkcpp_cl/inkcpp_cl.cpp +++ b/inkcpp_cl/inkcpp_cl.cpp @@ -155,7 +155,7 @@ int main(int argc, const char** argv) using namespace ink::runtime; // Load story - story* myInk = story::from_file(outputFilename.c_str()); + std::unique_ptr myInk{story::from_file(outputFilename.c_str())}; // Start runner runner thread; @@ -213,12 +213,11 @@ int main(int argc, const char** argv) // out of content break; } - - return 0; } catch (const std::exception& e) { std::cerr << "Unhandled ink runtime exception: " << e.what() << std::endl; return 1; } + return 0; } diff --git a/inkcpp_test/CMakeLists.txt b/inkcpp_test/CMakeLists.txt index 7ffc8aff..4f5166d5 100644 --- a/inkcpp_test/CMakeLists.txt +++ b/inkcpp_test/CMakeLists.txt @@ -13,6 +13,7 @@ add_executable(inkcpp_test catch.hpp Main.cpp LabelCondition.cpp Observer.cpp InkyJson.cpp + SpaceAfterBracketChoice.cpp ) target_link_libraries(inkcpp_test PUBLIC inkcpp inkcpp_compiler inkcpp_shared) diff --git a/inkcpp_test/SpaceAfterBracketChoice.cpp b/inkcpp_test/SpaceAfterBracketChoice.cpp new file mode 100644 index 00000000..9ee8715e --- /dev/null +++ b/inkcpp_test/SpaceAfterBracketChoice.cpp @@ -0,0 +1,48 @@ +#include "catch.hpp" +#include "../inkcpp_cl/test.h" + +#include +#include +#include +#include + +using namespace ink::runtime; + +SCENARIO("a story with bracketed choices and spaces can choose correctly", "[choices]") +{ + GIVEN("a story with line breaks") + { + inklecate("ink/ChoiceBracketStory.ink", "ChoiceBracketStory.tmp"); + ink::compiler::run("ChoiceBracketStory.tmp", "ChoiceBracketStory.bin"); + auto ink = story::from_file("ChoiceBracketStory.bin"); + runner thread = ink->new_runner(); + thread->getall(); + WHEN("start thread") + { + THEN("thread has choices") + { + thread->getall(); + REQUIRE(thread->has_choices()); + } + WHEN("choose choice 1") + { + thread->choose(0); + thread->getall(); + THEN("still has choices") + { + thread->getall(); + REQUIRE(thread->has_choices()); + } + } + WHEN("choose choice 2") + { + thread->choose(1); + thread->getall(); + THEN("still has choices") + { + REQUIRE(thread->has_choices()); + } + } + } + } +} diff --git a/inkcpp_test/ink/ChoiceBracketStory.ink b/inkcpp_test/ink/ChoiceBracketStory.ink new file mode 100644 index 00000000..6658b24c --- /dev/null +++ b/inkcpp_test/ink/ChoiceBracketStory.ink @@ -0,0 +1,7 @@ +-> choices += choices + ++ [Choice 1] ++ [Choice 2] + +- -> choices \ No newline at end of file diff --git a/proofing/ink-proof b/proofing/ink-proof index efdfb70e..6f22c543 160000 --- a/proofing/ink-proof +++ b/proofing/ink-proof @@ -1 +1 @@ -Subproject commit efdfb70e81350d94375e221b457197be140dc968 +Subproject commit 6f22c5430f98e76cf29f1d92d8e8b718207e407e diff --git a/proofing/inkcpp_runtime_driver b/proofing/inkcpp_runtime_driver index 5db41602..25022f95 100644 --- a/proofing/inkcpp_runtime_driver +++ b/proofing/inkcpp_runtime_driver @@ -6,7 +6,7 @@ import shutil ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) PATH = os.path.join(ROOT, 'deps', 'inkcpp', 'inkcpp_cl') -ARGS = ["inkcpp_cl", "-p"] + sys.argv[1:] +ARGS = ["inkcpp_cl", "--ommit-choice-tags", "-p"] + sys.argv[1:] os.execv(PATH, ARGS) sleep(2)