From a95606d21b52665bbdc834a2b86cd6acd3413d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Mon, 12 Sep 2022 07:08:22 +0000 Subject: [PATCH] fix enum warn --- code/game/src/items.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/code/game/src/items.c b/code/game/src/items.c index 92526e6..361d611 100644 --- a/code/game/src/items.c +++ b/code/game/src/items.c @@ -26,14 +26,14 @@ static inline asset_id item_fix_kind(asset_id id) { uint64_t item_spawn(asset_id kind, uint32_t qty) { ecs_entity_t e = entity_spawn(EKIND_ITEM); - + ItemDrop *d = ecs_get_mut(world_ecs(), e, ItemDrop); *d = (ItemDrop){ .kind = item_fix_kind(kind), .quantity = qty, .merger_time = 0, }; - + return (uint64_t)e; } @@ -58,7 +58,7 @@ void item_use(ecs_world_t *ecs, ItemDrop *it, Position p, uint64_t udata) { asset_id item_asset = blocks_get_asset(l.bid); item_id item_asset_id = item_find(item_asset); if (item_asset_id == ASSET_INVALID) return; - + // NOTE(zaklaus): If we replace the same item, refund 1 qty and let it replace it if (item_asset_id == it_id) { it->quantity++; @@ -73,7 +73,7 @@ void item_use(ecs_world_t *ecs, ItemDrop *it, Position p, uint64_t udata) { world_chunk_replace_block(l.chunk_id, l.id, blocks_find(desc->place.kind + (asset_id)udata)); it->quantity--; }break; - + case UKIND_PLACE_ITEM:{ world_block_lookup l = world_block_from_realpos(p.x, p.y); if (l.is_outer && l.bid > 0) { @@ -83,15 +83,21 @@ void item_use(ecs_world_t *ecs, ItemDrop *it, Position p, uint64_t udata) { else if (l.bid > 0 && blocks_get_flags(l.bid) & (BLOCK_FLAG_COLLISION|BLOCK_FLAG_ESSENTIAL)) { return; } - + ecs_entity_t e = entity_spawn_id(desc->place_item.id); ZPL_ASSERT(world_entity_valid(e)); Position *pos = ecs_get_mut(ecs, e, Position); pos->x = p.x; pos->y = p.y; - + it->quantity--; }break; + + + case UKIND_DELETE: + case UKIND_END_PLACE: + case UKIND_PROXY: + break; } }