Skip to content

Commit a953f5b

Browse files
committed
fix inconsistency with field get using typed vs void
1 parent 9816376 commit a953f5b

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

WORKSPACE.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ http_archive(
1818

1919
http_archive(
2020
name = "ecsact_lang_cpp",
21-
sha256 = "f66c5d31cc303022c313a424f4c432c41ff517b73143915436c6c6f06a969a47",
22-
strip_prefix = "ecsact_lang_cpp-34d73ebce5e99ae9711efa79a30ca7acda8599f0",
23-
url = "https://github.com/ecsact-dev/ecsact_lang_cpp/archive/34d73ebce5e99ae9711efa79a30ca7acda8599f0.zip",
21+
sha256 = "2866569ed8d58f3e42b705bf38f77455fe9acf8ab2d1b05f611b847d4c291a67",
22+
strip_prefix = "ecsact_lang_cpp-b1fa28b445b98d5ba62ede19cd6a5bdfa51141be",
23+
url = "https://github.com/ecsact-dev/ecsact_lang_cpp/archive/b1fa28b445b98d5ba62ede19cd6a5bdfa51141be.zip",
2424
)
2525

2626
load("@rules_ecsact//ecsact:repositories.bzl", "ecsact_register_toolchains", "rules_ecsact_dependencies")

ecsact/entt/detail/registry_info.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct registry_info {
6060
using boost::mp11::mp_with_index;
6161
using ecsact::entt::detail::association;
6262

63-
auto entity_field = field.template get<ecsact_entity_id>(component);
63+
auto entity_field = field.template get<ecsact_entity_id>(&component);
6464
auto entity_field_entt = entities_map.at(entity_field);
6565
mp_with_index<64>(field.offset, [&](auto I) {
6666
registry.emplace<association<C, I>>(entity_field_entt);
@@ -75,7 +75,7 @@ struct registry_info {
7575
using boost::mp11::mp_with_index;
7676
using ecsact::entt::detail::association;
7777

78-
auto entity_field = field.template get<ecsact_entity_id>(component);
78+
auto entity_field = field.template get<ecsact_entity_id>(&component);
7979
auto entity_field_entt = entities_map.at(entity_field);
8080
mp_with_index<64>(field.offset, [&](auto I) {
8181
registry.erase<association<C, I>>(entity_field_entt);

ecsact/entt/runtime.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public:
199199
for(auto& field : fields_info) {
200200
if(field.storage_type == ECSACT_ENTITY_TYPE) {
201201
auto entity_field =
202-
field.template get<ecsact_entity_id>(component_data);
202+
field.template get<ecsact_entity_id>(&component_data);
203203
if(!info.entities_map.contains(entity_field)) {
204204
return ECSACT_ADD_ERR_ENTITY_INVALID;
205205
}
@@ -397,7 +397,7 @@ public:
397397
for(auto& field : fields_info) {
398398
if(field.storage_type == ECSACT_ENTITY_TYPE) {
399399
auto entity_field =
400-
field.template get<ecsact_entity_id>(component_data);
400+
field.template get<ecsact_entity_id>(&component_data);
401401
if(!info.entities_map.contains(entity_field)) {
402402
return ECSACT_UPDATE_ERR_ENTITY_INVALID;
403403
}

runtime/test/runtime_test.cc

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ TEST(Core, DynamicSystemImpl) {
423423
&runtime_test__OtherEntitySystem
424424
);
425425

426-
ecsact_execute_systems(reg.id(), 1, nullptr, nullptr);
426+
auto exec_err = ecsact_execute_systems(reg.id(), 1, nullptr, nullptr);
427+
ASSERT_EQ(exec_err, ECSACT_EXEC_SYS_OK);
427428

428429
// Sanity check
429430
ASSERT_TRUE(reg.has_component<ComponentA>(entity));
@@ -439,12 +440,10 @@ TEST(Core, DynamicSystemImpl) {
439440

440441
TEST(Core, ExecuteSystemsErrors) {
441442
auto reg = ecsact::core::registry("ExecuteSystemsErrors");
442-
auto comp = OtherEntityComponent{
443-
.num = 42,
444-
.target = static_cast<ecsact_entity_id>(4000),
445-
};
446443
auto options = ecsact_execution_options{};
447-
auto test_action = runtime_test::AssocTestAction{};
444+
auto test_action = runtime_test::AssocTestAction{
445+
.assoc_entity = static_cast<ecsact_entity_id>(4000),
446+
};
448447
auto test_action_c = ecsact_action{
449448
.action_id = runtime_test::AssocTestAction::id,
450449
.action_data = &test_action,
@@ -457,6 +456,26 @@ TEST(Core, ExecuteSystemsErrors) {
457456
EXPECT_EQ(exec_err, ECSACT_EXEC_SYS_ERR_ACTION_ENTITY_INVALID);
458457
}
459458

459+
TEST(Core, ExecuteSystemsAssocActionOk) {
460+
auto reg = ecsact::core::registry("ExecuteSystemsErrors");
461+
auto test_entity = reg.create_entity();
462+
463+
auto options = ecsact_execution_options{};
464+
auto test_action = runtime_test::AssocTestAction{
465+
.assoc_entity = test_entity,
466+
};
467+
auto test_action_c = ecsact_action{
468+
.action_id = runtime_test::AssocTestAction::id,
469+
.action_data = &test_action,
470+
};
471+
472+
options.actions_length = 1;
473+
options.actions = &test_action_c;
474+
auto exec_err = ecsact_execute_systems(reg.id(), 1, &options, nullptr);
475+
476+
EXPECT_EQ(exec_err, ECSACT_EXEC_SYS_OK);
477+
}
478+
460479
TEST(Core, AssociationEntityCorrectness) {
461480
using runtime_test::AttackDamage;
462481
using runtime_test::AttackDamageWeakened;

0 commit comments

Comments
 (0)