From bc0868e80ecc543029921049a14e2b16c1e01fda Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 10 Mar 2022 19:23:38 -0800 Subject: [PATCH] Implemented dynos model packs into configfile --- data/dynos_gfx_init.cpp | 4 ++++ data/dynos_gfx_update.cpp | 3 --- include/stb/stb_image.h | 10 ++++++++-- src/pc/configfile.c | 29 +++++++++++++++++++++++++++++ src/pc/crash_handler.c | 5 +++-- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/data/dynos_gfx_init.cpp b/data/dynos_gfx_init.cpp index 0bf93ebc..4f758cc2 100644 --- a/data/dynos_gfx_init.cpp +++ b/data/dynos_gfx_init.cpp @@ -51,6 +51,10 @@ Array DynOS_Gfx_Init() { // Add pack to pack list pDynosPacks.Add(_Pack); +#ifdef COOP + // Add enabled flag + DynOS_Gfx_GetPacksEnabled().Add(true); +#endif } } closedir(_DynosPacksDir); diff --git a/data/dynos_gfx_update.cpp b/data/dynos_gfx_update.cpp index 9116ebe9..7c89cd64 100644 --- a/data/dynos_gfx_update.cpp +++ b/data/dynos_gfx_update.cpp @@ -106,9 +106,6 @@ void DynOS_Gfx_Update() { #ifdef COOP Array &_Enabled = DynOS_Gfx_GetPacksEnabled(); const Array &pDynosPacks = DynOS_Gfx_GetPacks(); - while (_Enabled.Count() < pDynosPacks.Count()) { - _Enabled.Add(true); - } #else Array _Enabled; const Array &pDynosPacks = DynOS_Gfx_GetPacks(); diff --git a/include/stb/stb_image.h b/include/stb/stb_image.h index d9c21bc8..a2ef9dbc 100644 --- a/include/stb/stb_image.h +++ b/include/stb/stb_image.h @@ -332,6 +332,12 @@ extern "C" { #define STBIDEF extern #endif +#ifdef __GNUC__ +#define UNUSED __attribute__((unused)) +#else +#define UNUSED +#endif + ////////////////////////////////////////////////////////////////////////////// // // PRIMARY API - works on images of any type @@ -6336,7 +6342,7 @@ static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) // this function is designed to support animated gifs, although stb_image doesn't support it // two back is the image from two frames ago, used for a very specific disposal format -static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back) +static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, UNUSED int req_comp, UNUSED stbi_uc *two_back) { int dispose; int first_frame; @@ -6560,7 +6566,7 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, } } -static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, UNUSED stbi__result_info *ri) { stbi_uc *u = 0; stbi__gif g; diff --git a/src/pc/configfile.c b/src/pc/configfile.c index bf29f3cc..21eab362 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -246,9 +246,38 @@ static void ban_write(FILE* file) { } } +static void dynos_pack_read(char** tokens, UNUSED int numTokens) { + if (numTokens < 3) { return; } + char fullPackName[256] = { 0 }; + for (int i = 1; i < numTokens - 1; i++) { + strncat(fullPackName, tokens[i], 255); + } + + bool enabled = !(strcmp(tokens[numTokens-1], "true")); + int packCount = dynos_packs_get_count(); + + for (int i = 0; i < packCount; i++) { + const char* pack = dynos_packs_get(i); + if (!strcmp(fullPackName, pack)) { + dynos_packs_set_enabled(i, enabled); + break; + } + } +} + +static void dynos_pack_write(FILE* file) { + int packCount = dynos_packs_get_count(); + for (int i = 0; i < packCount; i++) { + bool enabled = dynos_packs_get_enabled(i); + const char* pack = dynos_packs_get(i); + fprintf(file, "%s %s %s\n", "dynos-pack:", pack, enabled ? "true" : "false"); + } +} + static const struct FunctionConfigOption functionOptions[] = { { .name = "enable-mod:", .read = enable_mod_read, .write = enable_mod_write }, { .name = "ban:", .read = ban_read, .write = ban_write }, + { .name = "dynos-pack:", .read = dynos_pack_read, .write = dynos_pack_write }, }; // Reads an entire line from a file (excluding the newline character) and returns an allocated string diff --git a/src/pc/crash_handler.c b/src/pc/crash_handler.c index c0a377a6..f7022b29 100644 --- a/src/pc/crash_handler.c +++ b/src/pc/crash_handler.c @@ -447,6 +447,7 @@ static CRASH_HANDLER_TYPE crash_handler(EXCEPTION_POINTERS *ExceptionInfo) { crash_handler_add_info_int(&pText, 380, -4 + (8 * 0), "Id", (int)gPcDebug.id & 0xFF); crash_handler_add_info_int(&pText, 380, -4 + (8 * 1), "Ofs", (int)gPcDebug.bhvOffset & 0xFF); + extern s16 gPrevFrameObjectCount; crash_handler_add_info_int(&pText, 315, -4 + (8 * 4), "Objs", gPrevFrameObjectCount); int modCount = 0; @@ -463,8 +464,8 @@ static CRASH_HANDLER_TYPE crash_handler(EXCEPTION_POINTERS *ExceptionInfo) { for (int i = 0; i < gModTableCurrent->entryCount; i++) { struct ModListEntry* entry = &gModTableCurrent->entries[i]; if (entry == NULL || !entry->enabled) { continue; } - u8 b = (gPcDebug.lastModRun == entry) ? 0 : 0xFF; - crash_handler_set_text(x, y, 0xFF, 0xFF, 200, "%.21s", entry->name); + u8 g = (gPcDebug.lastModRun == entry) ? 0 : 0xFF; + crash_handler_set_text(x, y, 0xFF, g, 200, "%.21s", entry->name); y += 8; } }