fix(gameplay): use inline const for static EMPTY members

Use inline const for static EMPTY members to avoid ODR and linker issues.
Add missing block_manager.hpp includes in gameplay sources.
This commit is contained in:
2026-08-04 16:20:16 +08:00
parent 0259ca71ce
commit 8af30e159d
8 changed files with 8 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ private:
using IDMap = tbb::concurrent_hash_map<std::string, BlockType>; using IDMap = tbb::concurrent_hash_map<std::string, BlockType>;
using CrossPlaneMap = tbb::concurrent_hash_map<BlockType, BlockType>; using CrossPlaneMap = tbb::concurrent_hash_map<BlockType, BlockType>;
static const BlockData EMPTY; static inline const BlockData EMPTY;
static inline BlockMap m_datas; static inline BlockMap m_datas;
static inline IDMap m_id_map; static inline IDMap m_id_map;

View File

@@ -34,6 +34,6 @@ private:
IDMap m_id_map; IDMap m_id_map;
BlockToIDMap m_block_to_id_map; BlockToIDMap m_block_to_id_map;
static constexpr ItemData EMPTY; static inline const ItemData EMPTY;
}; };
} // namespace Cubed } // namespace Cubed

View File

@@ -1,5 +1,6 @@
#include "Cubed/gameplay/chunk_generator.hpp" #include "Cubed/gameplay/chunk_generator.hpp"
#include "Cubed/gameplay/block_manager.hpp"
#include "Cubed/gameplay/builders/desert_builder.hpp" #include "Cubed/gameplay/builders/desert_builder.hpp"
#include "Cubed/gameplay/builders/forest_builder.hpp" #include "Cubed/gameplay/builders/forest_builder.hpp"
#include "Cubed/gameplay/builders/mountain_builder.hpp" #include "Cubed/gameplay/builders/mountain_builder.hpp"

View File

@@ -1,5 +1,6 @@
#include "Cubed/gameplay/client_chunk.hpp" #include "Cubed/gameplay/client_chunk.hpp"
#include "Cubed/gameplay/block_manager.hpp"
namespace Cubed { namespace Cubed {
using OptionalBlockVectorArray = using OptionalBlockVectorArray =
std::array<std::optional<std::vector<BlockType>>, 4>; std::array<std::optional<std::vector<BlockType>>, 4>;

View File

@@ -1,9 +1,9 @@
#include "Cubed/gameplay/client_player_manager.hpp" #include "Cubed/gameplay/client_player_manager.hpp"
#include "Cubed/gameplay/block_manager.hpp"
#include "Cubed/gameplay/client_world.hpp" #include "Cubed/gameplay/client_world.hpp"
#include "Cubed/gameplay/hitbox_manager.hpp" #include "Cubed/gameplay/hitbox_manager.hpp"
#include "Cubed/tools/math_tools.hpp" #include "Cubed/tools/math_tools.hpp"
using namespace google::protobuf; using namespace google::protobuf;
namespace Cubed { namespace Cubed {

View File

@@ -1,6 +1,7 @@
#include "Cubed/gameplay/client_world.hpp" #include "Cubed/gameplay/client_world.hpp"
#include "Cubed/config.hpp" #include "Cubed/config.hpp"
#include "Cubed/gameplay/block_manager.hpp"
#include "Cubed/gameplay/chunk_generator.hpp" #include "Cubed/gameplay/chunk_generator.hpp"
#include "Cubed/gameplay/game_time.hpp" #include "Cubed/gameplay/game_time.hpp"
#include "Cubed/gameplay/packet.hpp" #include "Cubed/gameplay/packet.hpp"

View File

@@ -15,6 +15,7 @@ ItemManager::ItemManager() {}
ItemManager& ItemManager::instance() { ItemManager& ItemManager::instance() {
static ItemManager inst; static ItemManager inst;
return inst; return inst;
} }

View File

@@ -1,5 +1,6 @@
#include "Cubed/gameplay/server_world.hpp" #include "Cubed/gameplay/server_world.hpp"
#include "Cubed/gameplay/block_manager.hpp"
#include "Cubed/gameplay/packet.hpp" #include "Cubed/gameplay/packet.hpp"
#include "Cubed/gameplay/session.hpp" #include "Cubed/gameplay/session.hpp"
#include "Cubed/tools/cubed_assert.hpp" #include "Cubed/tools/cubed_assert.hpp"