Skip to content

Commit

Permalink
fix: compilation errors on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Sep 30, 2024
1 parent f8d5707 commit 7855335
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
11 changes: 7 additions & 4 deletions src/endstone_core/block/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ bool EndstoneBlock::isValid() const

Result<std::string> EndstoneBlock::getType() const
{
return checkState().and_then([](const auto *self) -> Result<std::string> {
return self->block_source_.getBlock(self->block_pos_).getLegacyBlock().getFullNameId();
return checkState().and_then([&](const auto * /*self*/) -> Result<std::string> {
return block_source_.getBlock(block_pos_).getLegacyBlock().getFullNameId();
});
}

Expand All @@ -51,8 +51,11 @@ Result<void> EndstoneBlock::setType(std::string type, bool apply_physics)
{
return checkState().and_then([&](const auto * /*self*/) -> Result<void> {
const auto &server = entt::locator<EndstoneServer>::value();
return server.createBlockData(type).and_then(
[&](auto &block_data) -> Result<void> { return setData(block_data, apply_physics); });
auto result = server.createBlockData(type);
if (!result) {
return nonstd::make_unexpected(result.error());
}
return setData(result.value(), apply_physics);
});
}

Expand Down
18 changes: 11 additions & 7 deletions src/endstone_core/block/block_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,17 @@ Result<bool> EndstoneBlockState::update(bool force)

Result<bool> EndstoneBlockState::update(bool force, bool apply_physics)
{
return getBlock().and_then([&](const auto &block) -> Result<bool> {
if (block->getType() != getType() && !force) {
return false;
}
block->setData(getData(), apply_physics);
return true;
});
auto result = getBlock();
if (!result) {
return nonstd::make_unexpected(result.error());
}

auto &block = result.value();
if (block->getType() != getType() && !force) {
return false;
}
block->setData(getData(), apply_physics);
return true;
}

} // namespace endstone::detail

0 comments on commit 7855335

Please sign in to comment.