From d370acbd909939a5368bfff159cfada0ff303567 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 3 Aug 2022 22:42:07 -0400 Subject: [PATCH] Fixes more strdup problems and finalized removal of GameSetting. --- libultraship/libultraship/Cvar.cpp | 7 ++++- libultraship/libultraship/Cvar.h | 30 +++++++++---------- .../libultraship/Lib/Fast3D/gfx_dxgi.cpp | 1 - .../libultraship/Lib/Fast3D/gfx_sdl2.cpp | 2 -- .../include/spdlog/sinks/sohconsole_sink.h | 1 - .../cosmetics/CosmeticsEditor.cpp | 5 ---- .../Enhancements/randomizer/randomizer.cpp | 1 - 7 files changed, 21 insertions(+), 26 deletions(-) diff --git a/libultraship/libultraship/Cvar.cpp b/libultraship/libultraship/Cvar.cpp index def3f26d25a..d5171a87fa0 100644 --- a/libultraship/libultraship/Cvar.cpp +++ b/libultraship/libultraship/Cvar.cpp @@ -5,6 +5,7 @@ #include #include #include +#include "GlobalCtx2.h" std::map, std::less<>> cvars; @@ -170,7 +171,11 @@ void CVar_LoadLegacy() { if (cfg[1].find("\"") != std::string::npos) { std::string value(cfg[1]); value.erase(std::remove(value.begin(), value.end(), '\"'), value.end()); - CVar_SetString(cfg[0].c_str(), ImStrdup(value.c_str())); +#ifdef _MSC_VER + CVar_SetString(cfg[0].c_str(), _strdup(value.c_str())); +#else + CVar_SetString(cfg[0].c_str(), strdup(value.c_str())); +#endif } if (is_number(cfg[1])) { CVar_SetFloat(cfg[0].c_str(), std::stof(cfg[1])); diff --git a/libultraship/libultraship/Cvar.h b/libultraship/libultraship/Cvar.h index d3fd51484c5..b13e1ab32d4 100644 --- a/libultraship/libultraship/Cvar.h +++ b/libultraship/libultraship/Cvar.h @@ -33,23 +33,23 @@ extern "C" { #endif -int32_t CVar_GetS32(const char* name, int32_t defaultValue); -float CVar_GetFloat(const char* name, float defaultValue); -void CVar_SetFloat(const char* name, float value); -const char* CVar_GetString(const char* name, const char* defaultValue); -void CVar_SetS32(const char* name, int32_t value); -void CVar_SetString(const char* name, const char* value); -Color_RGB8 CVar_GetRGB(const char* name, Color_RGB8 defaultValue); -Color_RGBA8 CVar_GetRGBA(const char* name, Color_RGBA8 defaultValue); -void CVar_SetRGBA(const char* name, Color_RGBA8 value); + float CVar_GetFloat(const char* name, float defaultValue); + void CVar_SetFloat(const char* name, float value); + int32_t CVar_GetS32(const char* name, int32_t defaultValue); + void CVar_SetS32(const char* name, int32_t value); + const char* CVar_GetString(const char* name, const char* defaultValue); + void CVar_SetString(const char* name, const char* value); + Color_RGB8 CVar_GetRGB(const char* name, Color_RGB8 defaultValue); + Color_RGBA8 CVar_GetRGBA(const char* name, Color_RGBA8 defaultValue); + void CVar_SetRGBA(const char* name, Color_RGBA8 value); -void CVar_RegisterS32(const char* name, int32_t defaultValue); -void CVar_RegisterFloat(const char* name, float defaultValue); -void CVar_RegisterString(const char* name, const char* defaultValue); -void CVar_RegisterRGBA(const char* name, Color_RGBA8 defaultValue); + void CVar_RegisterS32(const char* name, int32_t defaultValue); + void CVar_RegisterFloat(const char* name, float defaultValue); + void CVar_RegisterString(const char* name, const char* defaultValue); + void CVar_RegisterRGBA(const char* name, Color_RGBA8 defaultValue); -void CVar_Load(); -void CVar_Save(); + void CVar_Load(); + void CVar_Save(); #ifdef __cplusplus }; diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp index fac462e27b1..c80dc4be528 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp @@ -32,7 +32,6 @@ #define DECLARE_GFX_DXGI_FUNCTIONS #include "gfx_dxgi.h" -#include "../../GameSettings.h" #define WINCLASS_NAME L"N64GAME" #define GFX_API_NAME "DirectX" diff --git a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp index 55074c888a4..8600aae1f94 100644 --- a/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp +++ b/libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp @@ -35,8 +35,6 @@ #ifdef _WIN32 #include #endif -#include -#include "../../GameSettings.h" #define GFX_API_NAME "SDL2 - OpenGL" diff --git a/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h b/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h index 9f71bdee42e..7b5da63fded 100644 --- a/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h +++ b/libultraship/libultraship/Lib/spdlog/include/spdlog/sinks/sohconsole_sink.h @@ -9,7 +9,6 @@ #include #include #include "ImGuiImpl.h" -#include "GameSettings.h" #include "Cvar.h" #include #include diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 3b1ccb4c0df..c565ce52b18 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -1,11 +1,6 @@ #include "CosmeticsEditor.h" -#include "../../util.h" #include "../libultraship/ImGuiImpl.h" -#include "GameSettings.h" -#include -#include -#include #include #include #include diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 98b31732d02..38eb0ea89b6 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include "../libultraship/ImGuiImpl.h" #include #include "3drando/rando_main.hpp"