mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
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:
@@ -79,6 +79,7 @@ void ItemManager::add(const std::filesystem::path& path) {
|
||||
if (a->second.kind == ItemKind::BLOCK) {
|
||||
BlockType b = BlockManager::id_from_name(a->second.name);
|
||||
m_block_to_id_map.emplace(b, a->first);
|
||||
a->second.property = b;
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -91,7 +92,7 @@ const ItemData& ItemManager::get_item_data(std::string_view key) const {
|
||||
{
|
||||
IDMap::const_accessor cacc;
|
||||
|
||||
if (m_id_map.find(cacc, key)) {
|
||||
if (m_id_map.find(cacc, std::string(key))) {
|
||||
id = cacc->second;
|
||||
} else {
|
||||
Logger::error("Can't Find key {} in id map", key);
|
||||
|
||||
Reference in New Issue
Block a user