fix: stabilize block item registration and display

Store item names as owned strings in ItemManager, set block type
property for block items, validate item kind before placement, and
handle items without textures gracefully in inventory UI.
This commit is contained in:
2026-08-04 16:58:57 +08:00
parent 8af30e159d
commit 1514338144
8 changed files with 46 additions and 30 deletions

View File

@@ -40,6 +40,7 @@ private:
static inline IDMap m_id_map;
static inline bool is_init = false;
static inline CrossPlaneMap m_cross_plane_map;
static void set_up_cross_plane_map();
static void set_up_cross_plane_map(
const std::vector<std::pair<bool, BlockType>>& types);
};
} // namespace Cubed

View File

@@ -25,7 +25,7 @@ private:
using acc = ItemMap::accessor;
using cacc = ItemMap::const_accessor;
using IDMap = tbb::concurrent_hash_map<std::string_view, ItemID>;
using IDMap = tbb::concurrent_hash_map<std::string, ItemID>;
using BlockToIDMap = tbb::concurrent_hash_map<BlockType, ItemID>;
void add(const std::filesystem::path& path);

View File

@@ -47,7 +47,7 @@ private:
void load_block_status(unsigned status_id);
void load_block_texture(unsigned block_id);
void load_item_texture();
void init_item_texture();
void load_cross_plane_texture(unsigned id);
const Texture* load_image_texture(const std::string& path);
void load_pbr_texture(unsigned id);