From 29d9b9306d3b5de597572dba8aa765fe76ddbe70 Mon Sep 17 00:00:00 2001 From: Dominik Madarasz Date: Wed, 29 May 2024 11:10:44 +0200 Subject: [PATCH] drop lists dir --- code/foundation/src/{lists => }/assets_ids.h | 5 +++-- code/foundation/src/lists/entity_spawnlist.c | 18 ------------------ code/foundation/src/models/assets.c | 15 ++++++++++++--- code/foundation/src/models/assets.h | 3 ++- 4 files changed, 17 insertions(+), 24 deletions(-) rename code/foundation/src/{lists => }/assets_ids.h (91%) delete mode 100644 code/foundation/src/lists/entity_spawnlist.c diff --git a/code/foundation/src/lists/assets_ids.h b/code/foundation/src/assets_ids.h similarity index 91% rename from code/foundation/src/lists/assets_ids.h rename to code/foundation/src/assets_ids.h index 81b6cbb..994d4b7 100644 --- a/code/foundation/src/lists/assets_ids.h +++ b/code/foundation/src/assets_ids.h @@ -51,8 +51,9 @@ typedef enum { #define X(idx) idx, _ASSETS #undef X - - MAX_ASSETS + MAX_INTERNAL_ASSETS, + NEXT_FREE_ASSET = MAX_INTERNAL_ASSETS, + MAX_ASSETS = 255 } asset_id; extern const char *asset_names[]; diff --git a/code/foundation/src/lists/entity_spawnlist.c b/code/foundation/src/lists/entity_spawnlist.c deleted file mode 100644 index 03adc14..0000000 --- a/code/foundation/src/lists/entity_spawnlist.c +++ /dev/null @@ -1,18 +0,0 @@ -// NOTE(zaklaus): access to spawners -#include "models/prefabs/prefabs_list.c" -static struct { - asset_id id; - uint64_t (*proc)(); - uint64_t (*proc_udata)(void*); -} entity_spawnlist[] = { - { .id = ASSET_CHEST, .proc = storage_spawn }, - { .id = ASSET_FURNACE, .proc = furnace_spawn }, - { .id = ASSET_CRAFTBENCH, .proc = craftbench_spawn }, - { .id = ASSET_SPLITTER, .proc = splitter_spawn }, - { .id = ASSET_ASSEMBLER, .proc = assembler_spawn }, - { .id = ASSET_BLUEPRINT, .proc_udata = blueprint_spawn_udata }, - { .id = ASSET_CREATURE, .proc = creature_spawn }, - { .id = ASSET_MOB, .proc = mob_spawn }, -}; - -#define MAX_ENTITY_SPAWNDEFS ((sizeof(entity_spawnlist))/(sizeof(entity_spawnlist[0]))) diff --git a/code/foundation/src/models/assets.c b/code/foundation/src/models/assets.c index d3cdf86..7339bd3 100644 --- a/code/foundation/src/models/assets.c +++ b/code/foundation/src/models/assets.c @@ -1,8 +1,8 @@ #include "models/assets.h" -#include "lists/assets_ids.h" #include "raylib.h" #include "gen/texgen.h" #include "models/database.h" +#include //#define ASSETS_COUNT (sizeof(assets)/sizeof(asset)) @@ -30,10 +30,19 @@ static double assets_frame_next_draw = 0.0; #include +static uint16_t asset_counter; + +void assets_new(const char *name) { + assert(asset_counter < MAX_ASSETS); + db_exec(zpl_bprintf("INSERT INTO assets (id, name) VALUES (%d, '%s');", asset_counter++, name)); +} + void assets_db_init(void) { - for (uint16_t i=0; i