From bc6340588edbba07253fd3f3c60463194b866eeb Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sat, 10 Jan 2026 01:59:34 +0900 Subject: [PATCH] register paks --- engine/src/core.c | 13 +++++++++++-- engine/tools/gb_makepak/main.c | 10 +++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/engine/src/core.c b/engine/src/core.c index 06dea59..47cc616 100644 --- a/engine/src/core.c +++ b/engine/src/core.c @@ -34,8 +34,13 @@ GBEngine GBEngineCreate(GBEngineParam* param) { sh_new_strdup(engine->resource); - resource = GBResourceOpen(engine, "base.pak"); - shput(engine->resource, "base", resource); + if((resource = GBResourceOpen(engine, "base.pak")) != NULL) { + shput(engine->resource, "base", resource); + } + + if((resource = GBResourceOpen(engine, "game.pak")) != NULL) { + shput(engine->resource, "game", resource); + } if(engine != NULL && param->client && (engine->client = GBClientCreate(engine)) == NULL) { GBLog(GBLogError, "Failed to create client"); @@ -61,6 +66,10 @@ GBEngine GBEngineCreate(GBEngineParam* param) { } void GBEngineDestroy(GBEngine engine) { + int i; + for(i = 0; i < shlen(engine->resource); i++) { + GBResourceClose(engine->resource[i].value); + } shfree(engine->resource); if(engine->server != NULL) GBServerDestroy(engine->server); diff --git a/engine/tools/gb_makepak/main.c b/engine/tools/gb_makepak/main.c index dde97c0..0da820a 100644 --- a/engine/tools/gb_makepak/main.c +++ b/engine/tools/gb_makepak/main.c @@ -13,7 +13,9 @@ typedef struct kv { } kv_t; -static FILE* out; +static FILE* out; +static unsigned int total = 0; +static unsigned int totalact = 0, totalcmp = 0; static void scan(const char* path, const char* pre); @@ -72,6 +74,10 @@ static void pack(const char* fullpath, const char* path) { fwrite(output, 1, outsz, out); printf("done (%6d -> %6d)\n", insz, outsz); + + total++; + totalact += insz; + totalcmp += outsz; } else { printf("failed\n"); } @@ -188,5 +194,7 @@ int main(int argc, char** argv) { memset(dat, 0, 128); fwrite(dat, 1, 128, out); + printf("total %u files added, compressed %u -> %u bytes\n", total, totalact, totalcmp); + fclose(out); }