Skip to content

Commit

Permalink
Fixes more strdup problems and finalized removal of GameSetting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenix3 committed Aug 4, 2022
1 parent 2f5bd9a commit d370acb
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 26 deletions.
7 changes: 6 additions & 1 deletion libultraship/libultraship/Cvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <memory>
#include <utility>
#include <Utils/File.h>
#include "GlobalCtx2.h"

std::map<std::string, std::unique_ptr<CVar>, std::less<>> cvars;

Expand Down Expand Up @@ -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<float>(cfg[1])) {
CVar_SetFloat(cfg[0].c_str(), std::stof(cfg[1]));
Expand Down
30 changes: 15 additions & 15 deletions libultraship/libultraship/Cvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
1 change: 0 additions & 1 deletion libultraship/libultraship/Lib/Fast3D/gfx_dxgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions libultraship/libultraship/Lib/Fast3D/gfx_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#ifdef _WIN32
#include <WTypesbase.h>
#endif
#include <time.h>
#include "../../GameSettings.h"

#define GFX_API_NAME "SDL2 - OpenGL"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <spdlog/sinks/base_sink.h>
#include <spdlog/details/synchronous_factory.h>
#include "ImGuiImpl.h"
#include "GameSettings.h"
#include "Cvar.h"
#include <chrono>
#include <mutex>
Expand Down
5 changes: 0 additions & 5 deletions soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#include "CosmeticsEditor.h"
#include "../../util.h"
#include "../libultraship/ImGuiImpl.h"
#include "GameSettings.h"

#include <array>
#include <bit>
#include <map>
#include <string>
#include <Cvar.h>
#include <PR/ultra64/types.h>
Expand Down
1 change: 0 additions & 1 deletion soh/soh/Enhancements/randomizer/randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <Cvar.h>
#include <textures/icon_item_static/icon_item_static.h>
#include <textures/icon_item_24_static/icon_item_24_static.h>
#include <GameSettings.h>
#include "../libultraship/ImGuiImpl.h"
#include <thread>
#include "3drando/rando_main.hpp"
Expand Down

0 comments on commit d370acb

Please sign in to comment.