Skip to content

Commit

Permalink
2.6.0
Browse files Browse the repository at this point in the history
No longer clear composite region's plan on exiting it to allow continuation of plan execution on resuming the region
  • Loading branch information
andrew-gresyk authored Feb 1, 2025
1 parent 22e3d1f commit 156af7c
Show file tree
Hide file tree
Showing 19 changed files with 219 additions and 36 deletions.
8 changes: 0 additions & 8 deletions development/hfsm2/detail/root/control_3.inl
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ FullControlT<ArgsT<TG_, TSL_, TRL_, NCC_, NOC_, NOU_, TRO_ HFSM2_IF_SERIALIZATIO
_taskStatus.result = TaskStatus::FAILURE;
headState.wrapPlanFailed(*this);

plan().clear();

return FullControlBase::template buildPlanStatus<TState>();
} else if (subStatus.result == TaskStatus::SUCCESS) {
if (Plan p = plan(_regionId)) {
Expand Down Expand Up @@ -268,8 +266,6 @@ FullControlT<ArgsT<TG_, TSL_, TRL_, NCC_, NOC_, NOU_, TRO_ HFSM2_IF_SERIALIZATIO
_taskStatus.result = TaskStatus::SUCCESS;
headState.wrapPlanSucceeded(*this);

plan().clear();

return FullControlBase::template buildPlanStatus<TState>();
}
} else
Expand Down Expand Up @@ -422,8 +418,6 @@ FullControlT<ArgsT<TG_, TSL_, TRL_, NCC_, NOC_, NOU_, TRO_ HFSM2_IF_SERIALIZATIO
_taskStatus.result = TaskStatus::FAILURE;
headState.wrapPlanFailed(*this);

plan().clear();

return FullControlBase::template buildPlanStatus<TState>();
} else if (subStatus.result == TaskStatus::SUCCESS) {
if (Plan p = plan(_regionId)) {
Expand Down Expand Up @@ -455,8 +449,6 @@ FullControlT<ArgsT<TG_, TSL_, TRL_, NCC_, NOC_, NOU_, TRO_ HFSM2_IF_SERIALIZATIO
_taskStatus.result = TaskStatus::SUCCESS;
headState.wrapPlanSucceeded(*this);

plan().clear();

return FullControlBase::template buildPlanStatus<TState>();
}
} else
Expand Down
4 changes: 2 additions & 2 deletions development/hfsm2/detail/structure/ancestors_2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ struct HFSM2_EMPTY_BASES A_<TFirst>
HFSM2_CONSTEXPR(14) void exit ( PlanControl& ) noexcept {}

#if HFSM2_PLANS_AVAILABLE()
HFSM2_CONSTEXPR(14) void planSucceeded ( FullControl& control) noexcept { control.succeed(); }
HFSM2_CONSTEXPR(14) void planFailed ( FullControl& control) noexcept { control.fail(); }
HFSM2_CONSTEXPR(14) void planSucceeded ( FullControl& control) noexcept;
HFSM2_CONSTEXPR(14) void planFailed ( FullControl& control) noexcept;
#endif

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down
23 changes: 23 additions & 0 deletions development/hfsm2/detail/structure/ancestors_2.inl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ namespace detail {

////////////////////////////////////////////////////////////////////////////////

#if HFSM2_PLANS_AVAILABLE()

template <typename TF_>
HFSM2_CONSTEXPR(14)
void
A_<TF_>::planSucceeded(FullControl& control) noexcept {
control.succeed();
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

template <typename TF_>
HFSM2_CONSTEXPR(14)
void
A_<TF_>::planFailed(FullControl& control) noexcept {
control.plan().clear();
control.fail();
}

#endif

//------------------------------------------------------------------------------

template <typename TF_>
HFSM2_CONSTEXPR(14)
void
Expand Down
5 changes: 0 additions & 5 deletions development/hfsm2/detail/structure/composite.inl
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,6 @@ C_<TN_, TA_, SG_, TH_, TS_...>::deepExit(PlanControl& control) noexcept {

resumable = active;
active = INVALID_PRONG;

#if HFSM2_PLANS_AVAILABLE()
Plan plan = control.plan(REGION_ID);
plan.clear();
#endif
}

// COMMON
Expand Down
6 changes: 3 additions & 3 deletions development/hfsm2/machine_dev.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// HFSM2 (hierarchical state machine for games and interactive applications)
// 2.5.2 (2025-01-10)
// 2.6.0 (2025-02-01)
//
// Created by Andrew Gresyk
//
Expand Down Expand Up @@ -32,8 +32,8 @@
#pragma once

#define HFSM2_VERSION_MAJOR 2
#define HFSM2_VERSION_MINOR 5
#define HFSM2_VERSION_PATCH 2
#define HFSM2_VERSION_MINOR 6
#define HFSM2_VERSION_PATCH 0

#define HFSM2_VERSION (10000 * HFSM2_VERSION_MAJOR + 100 * HFSM2_VERSION_MINOR + HFSM2_VERSION_PATCH)

Expand Down
42 changes: 24 additions & 18 deletions include/hfsm2/machine.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// HFSM2 (hierarchical state machine for games and interactive applications)
// 2.5.2 (2025-01-10)
// 2.6.0 (2025-02-01)
//
// Created by Andrew Gresyk
//
Expand Down Expand Up @@ -32,8 +32,8 @@
#pragma once

#define HFSM2_VERSION_MAJOR 2
#define HFSM2_VERSION_MINOR 5
#define HFSM2_VERSION_PATCH 2
#define HFSM2_VERSION_MINOR 6
#define HFSM2_VERSION_PATCH 0

#define HFSM2_VERSION (10000 * HFSM2_VERSION_MAJOR + 100 * HFSM2_VERSION_MINOR + HFSM2_VERSION_PATCH)

Expand Down Expand Up @@ -7142,8 +7142,6 @@ FullControlT<ArgsT<TG_, TSL_, TRL_, NCC_, NOC_, NOU_, TRO_ HFSM2_IF_SERIALIZATIO
_taskStatus.result = TaskStatus::FAILURE;
headState.wrapPlanFailed(*this);

plan().clear();

return FullControlBase::template buildPlanStatus<TState>();
} else if (subStatus.result == TaskStatus::SUCCESS) {
if (Plan p = plan(_regionId)) {
Expand Down Expand Up @@ -7178,8 +7176,6 @@ FullControlT<ArgsT<TG_, TSL_, TRL_, NCC_, NOC_, NOU_, TRO_ HFSM2_IF_SERIALIZATIO
_taskStatus.result = TaskStatus::SUCCESS;
headState.wrapPlanSucceeded(*this);

plan().clear();

return FullControlBase::template buildPlanStatus<TState>();
}
} else
Expand Down Expand Up @@ -7316,8 +7312,6 @@ FullControlT<ArgsT<TG_, TSL_, TRL_, NCC_, NOC_, NOU_, TRO_ HFSM2_IF_SERIALIZATIO
_taskStatus.result = TaskStatus::FAILURE;
headState.wrapPlanFailed(*this);

plan().clear();

return FullControlBase::template buildPlanStatus<TState>();
} else if (subStatus.result == TaskStatus::SUCCESS) {
if (Plan p = plan(_regionId)) {
Expand Down Expand Up @@ -7349,8 +7343,6 @@ FullControlT<ArgsT<TG_, TSL_, TRL_, NCC_, NOC_, NOU_, TRO_ HFSM2_IF_SERIALIZATIO
_taskStatus.result = TaskStatus::SUCCESS;
headState.wrapPlanSucceeded(*this);

plan().clear();

return FullControlBase::template buildPlanStatus<TState>();
}
} else
Expand Down Expand Up @@ -7857,8 +7849,8 @@ struct HFSM2_EMPTY_BASES A_<TFirst>
HFSM2_CONSTEXPR(14) void exit ( PlanControl& ) noexcept {}

#if HFSM2_PLANS_AVAILABLE()
HFSM2_CONSTEXPR(14) void planSucceeded ( FullControl& control) noexcept { control.succeed(); }
HFSM2_CONSTEXPR(14) void planFailed ( FullControl& control) noexcept { control.fail(); }
HFSM2_CONSTEXPR(14) void planSucceeded ( FullControl& control) noexcept;
HFSM2_CONSTEXPR(14) void planFailed ( FullControl& control) noexcept;
#endif

HFSM2_CONSTEXPR(14) void wideEntryGuard(GuardControl& control) noexcept;
Expand Down Expand Up @@ -7898,6 +7890,25 @@ struct HFSM2_EMPTY_BASES A_<TFirst>
namespace hfsm2 {
namespace detail {

#if HFSM2_PLANS_AVAILABLE()

template <typename TF_>
HFSM2_CONSTEXPR(14)
void
A_<TF_>::planSucceeded(FullControl& control) noexcept {
control.succeed();
}

template <typename TF_>
HFSM2_CONSTEXPR(14)
void
A_<TF_>::planFailed(FullControl& control) noexcept {
control.plan().clear();
control.fail();
}

#endif

template <typename TF_>
HFSM2_CONSTEXPR(14)
void
Expand Down Expand Up @@ -11998,11 +12009,6 @@ C_<TN_, TA_, SG_, TH_, TS_...>::deepExit(PlanControl& control) noexcept {

resumable = active;
active = INVALID_PRONG;

#if HFSM2_PLANS_AVAILABLE()
Plan plan = control.plan(REGION_ID);
plan.clear();
#endif
}

template <typename TN_, typename TA_, Strategy SG_, typename TH_, typename... TS_>
Expand Down
5 changes: 5 additions & 0 deletions projects/premake/hfsm2-lite.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-clang", "test-clang.vc
EndProject
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "tools", "tools.pyproj", "{2347027E-E5DE-43C4-8EF9-5F1411ADE33B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_", "_", "{CAF6FD08-F000-458A-9DC3-74685C05D7F2}"
ProjectSection(SolutionItems) = preProject
..\..\hfsm2.natvis = ..\..\hfsm2.natvis
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
1 change: 1 addition & 0 deletions projects/premake/test-14.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@
<ItemGroup>
<ClCompile Include="..\..\test\main.cpp" />
<ClCompile Include="..\..\test\reported\issue_49.cpp" />
<ClCompile Include="..\..\test\reported\resuming_plan.cpp" />
<ClCompile Include="..\..\test\shared\test_bit_array.cpp" />
<ClCompile Include="..\..\test\shared\test_bit_stream.cpp" />
<ClCompile Include="..\..\test\shared\test_random.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions projects/premake/test-14.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@
<ClCompile Include="..\..\test\reported\issue_49.cpp">
<Filter>test\reported</Filter>
</ClCompile>
<ClCompile Include="..\..\test\reported\resuming_plan.cpp">
<Filter>test\reported</Filter>
</ClCompile>
<ClCompile Include="..\..\test\shared\test_bit_array.cpp">
<Filter>test\shared</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions projects/premake/test-15.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
<ItemGroup>
<ClCompile Include="..\..\test\main.cpp" />
<ClCompile Include="..\..\test\reported\issue_49.cpp" />
<ClCompile Include="..\..\test\reported\resuming_plan.cpp" />
<ClCompile Include="..\..\test\shared\test_bit_array.cpp" />
<ClCompile Include="..\..\test\shared\test_bit_stream.cpp" />
<ClCompile Include="..\..\test\shared\test_random.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions projects/premake/test-15.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@
<ClCompile Include="..\..\test\reported\issue_49.cpp">
<Filter>test\reported</Filter>
</ClCompile>
<ClCompile Include="..\..\test\reported\resuming_plan.cpp">
<Filter>test\reported</Filter>
</ClCompile>
<ClCompile Include="..\..\test\shared\test_bit_array.cpp">
<Filter>test\shared</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions projects/premake/test-16.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@
<ItemGroup>
<ClCompile Include="..\..\test\main.cpp" />
<ClCompile Include="..\..\test\reported\issue_49.cpp" />
<ClCompile Include="..\..\test\reported\resuming_plan.cpp" />
<ClCompile Include="..\..\test\shared\test_bit_array.cpp" />
<ClCompile Include="..\..\test\shared\test_bit_stream.cpp" />
<ClCompile Include="..\..\test\shared\test_random.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions projects/premake/test-16.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@
<ClCompile Include="..\..\test\reported\issue_49.cpp">
<Filter>test\reported</Filter>
</ClCompile>
<ClCompile Include="..\..\test\reported\resuming_plan.cpp">
<Filter>test\reported</Filter>
</ClCompile>
<ClCompile Include="..\..\test\shared\test_bit_array.cpp">
<Filter>test\shared</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions projects/premake/test-17.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
<ItemGroup>
<ClCompile Include="..\..\test\main.cpp" />
<ClCompile Include="..\..\test\reported\issue_49.cpp" />
<ClCompile Include="..\..\test\reported\resuming_plan.cpp" />
<ClCompile Include="..\..\test\shared\test_bit_array.cpp" />
<ClCompile Include="..\..\test\shared\test_bit_stream.cpp" />
<ClCompile Include="..\..\test\shared\test_random.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions projects/premake/test-17.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@
<ClCompile Include="..\..\test\reported\issue_49.cpp">
<Filter>test\reported</Filter>
</ClCompile>
<ClCompile Include="..\..\test\reported\resuming_plan.cpp">
<Filter>test\reported</Filter>
</ClCompile>
<ClCompile Include="..\..\test\shared\test_bit_array.cpp">
<Filter>test\shared</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions projects/premake/test-clang.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@
<ItemGroup>
<ClCompile Include="..\..\test\main.cpp" />
<ClCompile Include="..\..\test\reported\issue_49.cpp" />
<ClCompile Include="..\..\test\reported\resuming_plan.cpp" />
<ClCompile Include="..\..\test\shared\test_bit_array.cpp" />
<ClCompile Include="..\..\test\shared\test_bit_stream.cpp" />
<ClCompile Include="..\..\test\shared\test_random.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions projects/premake/test-clang.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@
<ClCompile Include="..\..\test\reported\issue_49.cpp">
<Filter>test\reported</Filter>
</ClCompile>
<ClCompile Include="..\..\test\reported\resuming_plan.cpp">
<Filter>test\reported</Filter>
</ClCompile>
<ClCompile Include="..\..\test\shared\test_bit_array.cpp">
<Filter>test\shared</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions test/reported/issue_49.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ struct A : FSM::State
void enter(PlanControl& control)
{
auto plan = control.plan();
plan.clear();

plan.change<A, B>();
plan.change<B, C>();
Expand Down
Loading

0 comments on commit 156af7c

Please sign in to comment.