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 Jan 24, 2025
1 parent 0f79aec commit c9a8d9b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/endstone/core/platform_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ std::string get_executable_pathname()
return module_info.pathname;
}

std::string_view get_name()
std::string_view get_platform()
{
return "Linux";
}
Expand Down
15 changes: 11 additions & 4 deletions src/endstone/core/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ EndstoneServer::~EndstoneServer()

void EndstoneServer::init(ServerInstance &server_instance)
{
if (server_instance_) {
throw std::runtime_error("Server instance already initialized.");
}
server_instance_ = &server_instance;
getLogger().info("{}This server is running {} version: {} (Minecraft: {})",
ColorFormat::DarkAqua + ColorFormat::Bold, getName(), getVersion(), getMinecraftVersion());
Expand All @@ -88,6 +91,9 @@ void EndstoneServer::init(ServerInstance &server_instance)

void EndstoneServer::setLevel(::Level &level)
{
if (level_) {
throw std::runtime_error("Level already initialized.");
}
level_ = std::make_unique<EndstoneLevel>(level);
scoreboard_ = std::make_unique<EndstoneScoreboard>(level.getScoreboard());
command_map_ = std::make_unique<EndstoneCommandMap>(*this);
Expand All @@ -100,11 +106,12 @@ void EndstoneServer::setLevel(::Level &level)

void EndstoneServer::setResourcePackRepository(Bedrock::NotNullNonOwnerPtr<IResourcePackRepository> repo)
{
resource_pack_repository_ = std::move(repo);
if (!resource_pack_source_) {
resource_pack_source_ = std::make_unique<EndstonePackSource>(
resource_pack_repository_->getResourcePacksPath().getContainer(), PackType::Resources);
if (resource_pack_repository_) {
throw std::runtime_error("Resource pack repository already set.");
}
resource_pack_repository_ = std::move(repo);
resource_pack_source_ = std::make_unique<EndstonePackSource>(
resource_pack_repository_->getResourcePacksPath().getContainer(), PackType::Resources);
}

PackSource &EndstoneServer::getPackSource() const
Expand Down
14 changes: 6 additions & 8 deletions src/endstone/core/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,24 @@ class EndstoneServer : public Server {
[[nodiscard]] EndstoneScoreboard &getPlayerBoard(const EndstonePlayer &player) const;
void setPlayerBoard(EndstonePlayer &player, Scoreboard &scoreboard);
void removePlayerBoard(EndstonePlayer &player);

void tick(std::uint64_t current_tick, const std::function<void()> &tick_function);
void init(ServerInstance &server_instance);
void setLevel(::Level &level);
void setResourcePackRepository(Bedrock::NotNullNonOwnerPtr<IResourcePackRepository> repo);
PackSource &getPackSource() const;

[[nodiscard]] ServerInstance &getServer() const;

static constexpr int MaxPlayers = 200;

private:
friend class EndstonePlayer;
friend class ResourcePackRepository;
friend class ServerInstanceEventCoordinator;

void init(ServerInstance &server_instance);
void setLevel(::Level &level);
void setResourcePackRepository(Bedrock::NotNullNonOwnerPtr<IResourcePackRepository> repo);
PackSource &getPackSource() const;
void enablePlugin(Plugin &plugin);
void loadResourcePacks();
void registerGameplayHandlers();

ServerInstance *server_instance_;
ServerInstance *server_instance_{nullptr};
Logger &logger_;
std::unique_ptr<CrashHandler> crash_handler_;
std::unique_ptr<SignalHandler> signal_handler_;
Expand Down
2 changes: 1 addition & 1 deletion src/endstone/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ endif ()
if (UNIX)
find_package(libelf REQUIRED)
target_link_libraries(endstone_runtime PRIVATE libelf::libelf)
target_link_options(endstone_runtime PRIVATE -g -Wl,--exclude-libs,ALL)
target_link_options(endstone_runtime PRIVATE -g -Wl,--no-undefined,--exclude-libs,ALL)
target_compile_options(endstone_runtime PRIVATE -O2 -DNDEBUG -g -fvisibility=hidden -fms-extensions)
if (ENDSTONE_SEPARATE_DEBUG_INFO)
add_custom_command(
Expand Down

0 comments on commit c9a8d9b

Please sign in to comment.