Skip to content

Commit 1004a81

Browse files
2.7.1
fixed large (256+ states) FSMs
1 parent 68e06f0 commit 1004a81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1553
-197
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ cmake-*
1212
/build*
1313
/hfsm_test.dir
1414
/projects/code-lite/build-*
15+
/projects/code-lite/compile_commands.json
1516
/projects/code-lite/tags
1617
/projects/code-lite/Makefile
1718
/projects/code-lite/test/compile_flags.txt

development/hfsm2/detail/root/registry.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ struct RegistryT<
107107
using OrthoParents = StaticArrayT<Parent, ORTHO_COUNT>;
108108
using OrthoUnits = StaticArrayT<Units, ORTHO_UNITS>;
109109
using RegionHeads = StaticArrayT<StateID, REGION_COUNT>;
110-
using RegionSizes = StaticArrayT<Short, REGION_COUNT>;
110+
using RegionSizes = StaticArrayT<Long, REGION_COUNT>;
111111

112112
using CompoForks = StaticArrayT<Prong, COMPO_COUNT>;
113113
using OrthoForks = BitArrayT <ORTHO_UNITS * 8>;
@@ -202,7 +202,7 @@ struct RegistryT<
202202
using StateParents = StaticArrayT<Parent, STATE_COUNT>;
203203
using CompoParents = StaticArrayT<Parent, COMPO_COUNT>;
204204
using RegionHeads = StaticArrayT<StateID, REGION_COUNT>;
205-
using RegionSizes = StaticArrayT<Short, REGION_COUNT>;
205+
using RegionSizes = StaticArrayT<Long, REGION_COUNT>;
206206

207207
using CompoForks = StaticArrayT<Prong, COMPO_COUNT>;
208208
using OrthoForks = BitArrayT <0>;

development/hfsm2/detail/shared/utility.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ struct BottomUp;
1515
using Short = uint8_t;
1616
static constexpr Short INVALID_SHORT = UINT8_MAX;
1717

18+
using Long = uint16_t;
19+
static constexpr Long INVALID_LONG = UINT16_MAX;
20+
21+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22+
1823
using Prong = Short;
1924
static constexpr Prong INVALID_PRONG = INVALID_SHORT;
2025

@@ -26,9 +31,6 @@ static constexpr ForkID INVALID_FORK_ID = INT8_MIN;
2631

2732
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2833

29-
using Long = uint16_t;
30-
static constexpr Long INVALID_LONG = UINT16_MAX;
31-
3234
using StateID = Long;
3335
static constexpr StateID INVALID_STATE_ID = INVALID_LONG;
3436

development/hfsm2/detail/structure/composite.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct HFSM2_EMPTY_BASES C_
103103
static constexpr Short WIDTH_BITS = Info::WIDTH_BITS;
104104
#endif
105105

106-
static constexpr Short REGION_SIZE = Info::STATE_COUNT;
106+
static constexpr Long REGION_SIZE = Info::STATE_COUNT;
107107

108108
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
109109

development/hfsm2/detail/structure/orthogonal.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct HFSM2_EMPTY_BASES O_
7171

7272
using Info = OI_<Head, TSubStates...>;
7373
static constexpr Short WIDTH = Info::WIDTH;
74-
static constexpr Short REGION_SIZE = Info::STATE_COUNT;
74+
static constexpr Long REGION_SIZE = Info::STATE_COUNT;
7575
static constexpr Short ORTHO_UNITS = Info::ORTHO_UNITS;
7676

7777
using SubStates = OS_<

development/hfsm2/machine_dev.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// HFSM2 (hierarchical state machine for games and interactive applications)
2-
// 2.7.0 (2025-04-17)
2+
// 2.7.1 (2025-05-27)
33
//
44
// Created by Andrew Gresyk
55
//
@@ -33,7 +33,7 @@
3333

3434
#define HFSM2_VERSION_MAJOR 2
3535
#define HFSM2_VERSION_MINOR 7
36-
#define HFSM2_VERSION_PATCH 0
36+
#define HFSM2_VERSION_PATCH 1
3737

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

include/hfsm2/machine.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// HFSM2 (hierarchical state machine for games and interactive applications)
2-
// 2.7.0 (2025-04-17)
2+
// 2.7.1 (2025-05-27)
33
//
44
// Created by Andrew Gresyk
55
//
@@ -33,7 +33,7 @@
3333

3434
#define HFSM2_VERSION_MAJOR 2
3535
#define HFSM2_VERSION_MINOR 7
36-
#define HFSM2_VERSION_PATCH 0
36+
#define HFSM2_VERSION_PATCH 1
3737

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

@@ -391,6 +391,9 @@ struct BottomUp;
391391
using Short = uint8_t;
392392
static constexpr Short INVALID_SHORT = UINT8_MAX;
393393

394+
using Long = uint16_t;
395+
static constexpr Long INVALID_LONG = UINT16_MAX;
396+
394397
using Prong = Short;
395398
static constexpr Prong INVALID_PRONG = INVALID_SHORT;
396399

@@ -400,9 +403,6 @@ static constexpr RegionID INVALID_REGION_ID = INVALID_SHORT;
400403
using ForkID = int8_t;
401404
static constexpr ForkID INVALID_FORK_ID = INT8_MIN;
402405

403-
using Long = uint16_t;
404-
static constexpr Long INVALID_LONG = UINT16_MAX;
405-
406406
using StateID = Long;
407407
static constexpr StateID INVALID_STATE_ID = INVALID_LONG;
408408

@@ -3201,7 +3201,7 @@ struct RegistryT<
32013201
using OrthoParents = StaticArrayT<Parent, ORTHO_COUNT>;
32023202
using OrthoUnits = StaticArrayT<Units, ORTHO_UNITS>;
32033203
using RegionHeads = StaticArrayT<StateID, REGION_COUNT>;
3204-
using RegionSizes = StaticArrayT<Short, REGION_COUNT>;
3204+
using RegionSizes = StaticArrayT<Long, REGION_COUNT>;
32053205

32063206
using CompoForks = StaticArrayT<Prong, COMPO_COUNT>;
32073207
using OrthoForks = BitArrayT <ORTHO_UNITS * 8>;
@@ -3294,7 +3294,7 @@ struct RegistryT<
32943294
using StateParents = StaticArrayT<Parent, STATE_COUNT>;
32953295
using CompoParents = StaticArrayT<Parent, COMPO_COUNT>;
32963296
using RegionHeads = StaticArrayT<StateID, REGION_COUNT>;
3297-
using RegionSizes = StaticArrayT<Short, REGION_COUNT>;
3297+
using RegionSizes = StaticArrayT<Long, REGION_COUNT>;
32983298

32993299
using CompoForks = StaticArrayT<Prong, COMPO_COUNT>;
33003300
using OrthoForks = BitArrayT <0>;
@@ -11492,7 +11492,7 @@ struct HFSM2_EMPTY_BASES C_
1149211492
static constexpr Short WIDTH_BITS = Info::WIDTH_BITS;
1149311493
#endif
1149411494

11495-
static constexpr Short REGION_SIZE = Info::STATE_COUNT;
11495+
static constexpr Long REGION_SIZE = Info::STATE_COUNT;
1149611496

1149711497
#if HFSM2_SERIALIZATION_AVAILABLE()
1149811498
HFSM2_CONSTEXPR(11) static Prong compoRequested (const Registry& registry) noexcept { return registry.compoRequested[COMPO_INDEX]; }
@@ -13700,7 +13700,7 @@ struct HFSM2_EMPTY_BASES O_
1370013700

1370113701
using Info = OI_<Head, TSubStates...>;
1370213702
static constexpr Short WIDTH = Info::WIDTH;
13703-
static constexpr Short REGION_SIZE = Info::STATE_COUNT;
13703+
static constexpr Long REGION_SIZE = Info::STATE_COUNT;
1370413704
static constexpr Short ORTHO_UNITS = Info::ORTHO_UNITS;
1370513705

1370613706
using SubStates = OS_<

premake.lua

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ workspace "hfsm2"
99
"UNICODE",
1010
"_UNICODE",
1111
}
12+
fatalwarnings "All"
1213
filename "hfsm2-all"
13-
flags {
14-
"FatalCompileWarnings",
15-
"NoPCH",
16-
}
14+
flags "NoPCH"
1715
includedirs {
1816
"development",
1917
"include",
@@ -29,17 +27,18 @@ workspace "hfsm2"
2927

3028
system "windows"
3129
systemversion "latest"
32-
--systemversion "$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))"
33-
34-
targetdir "binaries/"
35-
targetname "$(ProjectName)-$(Configuration)-$(Platform)"
36-
warnings "High"
3730

3831
filter "toolset:msc-v140 or msc-v141"
3932
if os.getversion().majorversion == 10 then
4033
local sWin10SDK = os.getWindowsRegistry( "HKLM:SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0\\ProductVersion" )
4134
if sWin10SDK ~= nil then systemversion( sWin10SDK .. ".0" ) end
4235
end
36+
--systemversion "$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))"
37+
filter {}
38+
39+
targetdir "binaries/"
40+
targetname "$(ProjectName)-$(Configuration)-$(Platform)"
41+
warnings "High"
4342

4443
filter "configurations:debug"
4544
defines "_DEBUG"
@@ -48,30 +47,25 @@ workspace "hfsm2"
4847
filter "configurations:release"
4948
defines "NDEBUG"
5049
intrinsics "On"
50+
linktimeoptimization "On"
5151
optimize "Speed"
52-
flags {
53-
"LinkTimeOptimization",
54-
}
5552

56-
filter { "platforms:32" }
53+
filter "platforms:32"
5754
architecture "x86"
5855

59-
filter { "platforms:64" }
56+
filter "platforms:64"
6057
architecture "x86_64"
6158

62-
filter "toolset:msc-ClangCL"
63-
buildoptions {
64-
"-Wpedantic",
65-
}
66-
linkoptions {
67-
"/INCREMENTAL:NO"
68-
}
69-
70-
filter "toolset:msc-v143"
59+
filter "toolset:msc-v141 or msc-v142 or msc-v143"
7160
buildoptions {
61+
"/bigobj",
7262
"/permissive-",
7363
}
7464

65+
filter "toolset:msc-ClangCL"
66+
buildoptions "-Wpedantic"
67+
linkoptions "/INCREMENTAL:NO"
68+
7569
-- advanced_event_handling
7670

7771
project "advanced_event_handling-14"

projects/code-lite/hfsm2.workspace

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<CodeLite_Workspace Name="hfsm2" Database="" Version="10000">
33
<Project Name="test" Path="test/test.project" Active="Yes"/>
44
<BuildMatrix>
5-
<WorkspaceConfiguration Name="Debug" Selected="yes">
5+
<WorkspaceConfiguration Name="Debug">
66
<Environment/>
77
<Project Name="test" ConfigName="Debug_Windows"/>
88
</WorkspaceConfiguration>
9-
<WorkspaceConfiguration Name="Release" Selected="no">
9+
<WorkspaceConfiguration Name="Release">
1010
<Environment/>
1111
<Project Name="test" ConfigName="Release_Windows"/>
1212
</WorkspaceConfiguration>

projects/code-lite/test/test.project

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,38 @@
44
<VirtualDirectory Name="hfsm2">
55
<File Name="../../../development/hfsm2/machine_dev.hpp"/>
66
<VirtualDirectory Name="detail">
7-
<File Name="../../../development/hfsm2/detail/root.inl"/>
8-
<File Name="../../../development/hfsm2/detail/root.hpp"/>
7+
<File Name="../../../development/hfsm2/detail/root_4.hpp"/>
8+
<File Name="../../../development/hfsm2/detail/root_3.inl"/>
9+
<File Name="../../../development/hfsm2/detail/root_3.hpp"/>
10+
<File Name="../../../development/hfsm2/detail/root_2.inl"/>
11+
<File Name="../../../development/hfsm2/detail/root_2.hpp"/>
12+
<File Name="../../../development/hfsm2/detail/root_1.inl"/>
13+
<File Name="../../../development/hfsm2/detail/root_1.hpp"/>
14+
<File Name="../../../development/hfsm2/detail/root_0.inl"/>
15+
<File Name="../../../development/hfsm2/detail/root_0.hpp"/>
16+
<File Name="../../../development/hfsm2/detail/config.hpp"/>
917
<VirtualDirectory Name="structure">
18+
<File Name="../../../development/hfsm2/detail/structure/state_2.inl"/>
19+
<File Name="../../../development/hfsm2/detail/structure/state_2.hpp"/>
20+
<File Name="../../../development/hfsm2/detail/structure/state_1.inl"/>
21+
<File Name="../../../development/hfsm2/detail/structure/state_1.hpp"/>
22+
<File Name="../../../development/hfsm2/detail/structure/reactions.inl"/>
23+
<File Name="../../../development/hfsm2/detail/structure/orthogonal_sub_2.hpp"/>
24+
<File Name="../../../development/hfsm2/detail/structure/orthogonal_sub_1.hpp"/>
25+
<File Name="../../../development/hfsm2/detail/structure/composite_sub_2.hpp"/>
26+
<File Name="../../../development/hfsm2/detail/structure/composite_sub_1.hpp"/>
27+
<File Name="../../../development/hfsm2/detail/structure/base.hpp"/>
28+
<File Name="../../../development/hfsm2/detail/structure/ancestors_2.hpp"/>
29+
<File Name="../../../development/hfsm2/detail/structure/ancestors_1.hpp"/>
1030
<File Name="../../../development/hfsm2/detail/structure/ancestors_2.inl"/>
1131
<File Name="../../../development/hfsm2/detail/structure/ancestors_1.inl"/>
12-
<File Name="../../../development/hfsm2/detail/structure/ancestors.hpp"/>
13-
<File Name="../../../development/hfsm2/detail/structure/state.inl"/>
14-
<File Name="../../../development/hfsm2/detail/structure/state.hpp"/>
1532
<File Name="../../../development/hfsm2/detail/structure/orthogonal_sub_2.inl"/>
1633
<File Name="../../../development/hfsm2/detail/structure/orthogonal_sub_1.inl"/>
17-
<File Name="../../../development/hfsm2/detail/structure/orthogonal_sub.hpp"/>
1834
<File Name="../../../development/hfsm2/detail/structure/orthogonal.inl"/>
1935
<File Name="../../../development/hfsm2/detail/structure/orthogonal.hpp"/>
2036
<File Name="../../../development/hfsm2/detail/structure/forward.hpp"/>
2137
<File Name="../../../development/hfsm2/detail/structure/composite_sub_2.inl"/>
2238
<File Name="../../../development/hfsm2/detail/structure/composite_sub_1.inl"/>
23-
<File Name="../../../development/hfsm2/detail/structure/composite_sub.hpp"/>
2439
<File Name="../../../development/hfsm2/detail/structure/composite.inl"/>
2540
<File Name="../../../development/hfsm2/detail/structure/composite.hpp"/>
2641
</VirtualDirectory>
@@ -36,26 +51,40 @@
3651
<File Name="../../../development/hfsm2/detail/shared/bit_stream.hpp"/>
3752
</VirtualDirectory>
3853
<VirtualDirectory Name="root">
54+
<File Name="../../../development/hfsm2/detail/root/plan_2.inl"/>
55+
<File Name="../../../development/hfsm2/detail/root/plan_2.hpp"/>
56+
<File Name="../../../development/hfsm2/detail/root/plan_1.inl"/>
57+
<File Name="../../../development/hfsm2/detail/root/plan_1.hpp"/>
58+
<File Name="../../../development/hfsm2/detail/root/plan_0.inl"/>
59+
<File Name="../../../development/hfsm2/detail/root/plan_0.hpp"/>
60+
<File Name="../../../development/hfsm2/detail/root/control_5.hpp"/>
61+
<File Name="../../../development/hfsm2/detail/root/control_4.inl"/>
62+
<File Name="../../../development/hfsm2/detail/root/control_4.hpp"/>
63+
<File Name="../../../development/hfsm2/detail/root/control_3.inl"/>
64+
<File Name="../../../development/hfsm2/detail/root/control_3.hpp"/>
65+
<File Name="../../../development/hfsm2/detail/root/control_2.inl"/>
66+
<File Name="../../../development/hfsm2/detail/root/control_2.hpp"/>
67+
<File Name="../../../development/hfsm2/detail/root/control_1.inl"/>
68+
<File Name="../../../development/hfsm2/detail/root/control_1.hpp"/>
69+
<File Name="../../../development/hfsm2/detail/root/control_0.inl"/>
70+
<File Name="../../../development/hfsm2/detail/root/control_0.hpp"/>
3971
<File Name="../../../development/hfsm2/detail/root/core.inl"/>
4072
<File Name="../../../development/hfsm2/detail/root/core.hpp"/>
4173
<File Name="../../../development/hfsm2/detail/root/registry_2.inl"/>
4274
<File Name="../../../development/hfsm2/detail/root/registry_1.inl"/>
4375
<File Name="../../../development/hfsm2/detail/root/registry.hpp"/>
4476
<File Name="../../../development/hfsm2/detail/root/plan_data.inl"/>
4577
<File Name="../../../development/hfsm2/detail/root/plan_data.hpp"/>
46-
<File Name="../../../development/hfsm2/detail/root/plan.inl"/>
47-
<File Name="../../../development/hfsm2/detail/root/plan.hpp"/>
48-
<File Name="../../../development/hfsm2/detail/root/control.inl"/>
49-
<File Name="../../../development/hfsm2/detail/root/control.hpp"/>
5078
</VirtualDirectory>
5179
<VirtualDirectory Name="features">
80+
<File Name="../../../development/hfsm2/detail/features/transition.hpp"/>
81+
<File Name="../../../development/hfsm2/detail/features/task_list.inl"/>
82+
<File Name="../../../development/hfsm2/detail/features/task_list.hpp"/>
83+
<File Name="../../../development/hfsm2/detail/features/task.hpp"/>
5284
<File Name="../../../development/hfsm2/detail/features/structure_report.hpp"/>
5385
<File Name="../../../development/hfsm2/detail/features/logger_interface.hpp"/>
54-
<File Name="../../../development/hfsm2/detail/features/common.hpp"/>
5586
</VirtualDirectory>
5687
<VirtualDirectory Name="containers">
57-
<File Name="../../../development/hfsm2/detail/containers/task_list.inl"/>
58-
<File Name="../../../development/hfsm2/detail/containers/task_list.hpp"/>
5988
<File Name="../../../development/hfsm2/detail/containers/bit_array.inl"/>
6089
<File Name="../../../development/hfsm2/detail/containers/bit_array.hpp"/>
6190
<File Name="../../../development/hfsm2/detail/containers/array.inl"/>
@@ -71,20 +100,26 @@
71100
<Extensions>
72101
<![CDATA[*.cpp;*.hpp;*.inl]]>
73102
</Extensions>
74-
<Topleveldir>/Work/HFSM2-experimental</Topleveldir>
103+
<Topleveldir>/Work/HFSM2</Topleveldir>
75104
</Reconciliation>
76105
<VirtualDirectory Name="test">
106+
<File Name="../../../test/wiki_transitions_within_hierarchy.cpp"/>
107+
<File Name="../../../test/wiki_class_member.hpp"/>
108+
<File Name="../../../test/wiki_class_member.cpp"/>
109+
<File Name="../../../test/test_types.cpp"/>
110+
<File Name="../../../test/test_react_order.cpp"/>
111+
<File Name="../../../test/test_plan_hierarchy.cpp"/>
77112
<File Name="../../../test/test_query.cpp"/>
78113
<File Name="../../../test/test_plan_external_payloads.cpp"/>
79114
<File Name="../../../test/test_plan_external.cpp"/>
80115
<File Name="../../../test/wiki_tutorial.cpp"/>
81-
<File Name="../../../test/wiki_transitions-within-hierarchy.cpp"/>
82116
<File Name="../../../test/wiki_serialization.cpp"/>
83117
<File Name="../../../test/wiki_plans.cpp"/>
84118
<File Name="../../../test/test_select.cpp"/>
85119
<File Name="../../../test/test_ancestors.cpp"/>
86120
<File Name="../../../test/tools.inl"/>
87121
<VirtualDirectory Name="reported">
122+
<File Name="../../../test/reported/resuming_plan.cpp"/>
88123
<File Name="../../../test/reported/issue_49.cpp"/>
89124
</VirtualDirectory>
90125
<File Name="../../../test/tools.hpp"/>
@@ -180,7 +215,7 @@
180215
<SearchPaths/>
181216
</Completion>
182217
</Configuration>
183-
<Configuration Name="Debug_Windows" CompilerType="MinGW ( C:\GCC\TDM-GCC-64\bin\ )" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
218+
<Configuration Name="Debug_Windows" CompilerType="mingw64" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
184219
<Compiler Options="-g;-O0" C_Options="-g;-O0" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" PCHFlags="" PCHFlagsPolicy="1"/>
185220
<Linker Options="" Required="yes"/>
186221
<ResourceCompiler Options="" Required="no"/>

projects/premake/advanced_event_handling-14.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
<SubSystem>Console</SubSystem>
162162
<EnableCOMDATFolding>true</EnableCOMDATFolding>
163163
<OptimizeReferences>true</OptimizeReferences>
164+
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
164165
</Link>
165166
</ItemDefinitionGroup>
166167
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -182,6 +183,7 @@
182183
<SubSystem>Console</SubSystem>
183184
<EnableCOMDATFolding>true</EnableCOMDATFolding>
184185
<OptimizeReferences>true</OptimizeReferences>
186+
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
185187
</Link>
186188
</ItemDefinitionGroup>
187189
<ItemGroup>

0 commit comments

Comments
 (0)