From 64327fafb1a71c897006f4980d5231178641432a Mon Sep 17 00:00:00 2001 From: Sirius902 <10891979+Sirius902@users.noreply.github.com> Date: Wed, 6 Apr 2022 17:42:23 -0700 Subject: [PATCH] Make ResourceMgr and CVar more const correct, remove unnecessary const_cast (#118) --- libultraship/libultraship/Cvar.cpp | 24 ++++++------ libultraship/libultraship/Cvar.h | 24 ++++++------ libultraship/libultraship/GameSettings.cpp | 44 +++++++++++----------- libultraship/libultraship/SohConsole.cpp | 2 +- libultraship/libultraship/SohImGuiImpl.cpp | 30 +++++++-------- soh/soh/OTRGlobals.cpp | 36 +++++++++--------- soh/soh/OTRGlobals.h | 14 +++---- 7 files changed, 87 insertions(+), 87 deletions(-) diff --git a/libultraship/libultraship/Cvar.cpp b/libultraship/libultraship/Cvar.cpp index 306a18e83..91788fd48 100644 --- a/libultraship/libultraship/Cvar.cpp +++ b/libultraship/libultraship/Cvar.cpp @@ -5,16 +5,16 @@ std::map cvars; -CVar* CVar_GetVar(char* name) { +CVar* CVar_GetVar(const char* name) { std::string key(name); return cvars.contains(key) ? cvars[key] : nullptr; } -extern "C" CVar* CVar_Get(char* name) { +extern "C" CVar* CVar_Get(const char* name) { return CVar_GetVar(name); } -extern "C" s32 CVar_GetS32(char* name, s32 defaultValue) { +extern "C" s32 CVar_GetS32(const char* name, s32 defaultValue) { CVar* cvar = CVar_Get(name); if (cvar != nullptr) { @@ -25,7 +25,7 @@ extern "C" s32 CVar_GetS32(char* name, s32 defaultValue) { return defaultValue; } -extern "C" float CVar_GetFloat(char* name, float defaultValue) { +extern "C" float CVar_GetFloat(const char* name, float defaultValue) { CVar* cvar = CVar_Get(name); if (cvar != nullptr) { @@ -36,7 +36,7 @@ extern "C" float CVar_GetFloat(char* name, float defaultValue) { return defaultValue; } -extern "C" char* CVar_GetString(char* name, char* defaultValue) { +extern "C" char* CVar_GetString(const char* name, char* defaultValue) { CVar* cvar = CVar_Get(name); if (cvar != nullptr) { @@ -47,7 +47,7 @@ extern "C" char* CVar_GetString(char* name, char* defaultValue) { return defaultValue; } -extern "C" void CVar_SetS32(char* name, s32 value) { +extern "C" void CVar_SetS32(const char* name, s32 value) { CVar* cvar = CVar_Get(name); if (!cvar) { cvar = new CVar; @@ -57,7 +57,7 @@ extern "C" void CVar_SetS32(char* name, s32 value) { cvar->value.valueS32 = value; } -void CVar_SetFloat(char* name, float value) { +void CVar_SetFloat(const char* name, float value) { CVar* cvar = CVar_Get(name); if (!cvar) { cvar = new CVar; @@ -67,7 +67,7 @@ void CVar_SetFloat(char* name, float value) { cvar->value.valueFloat = value; } -void CVar_SetString(char* name, char* value) { +void CVar_SetString(const char* name, char* value) { CVar* cvar = CVar_Get(name); if (!cvar) { cvar = new CVar; @@ -78,23 +78,23 @@ void CVar_SetString(char* name, char* value) { } -extern "C" void CVar_RegisterS32(char* name, s32 defaultValue) { +extern "C" void CVar_RegisterS32(const char* name, s32 defaultValue) { CVar* cvar = CVar_Get(name); if (cvar == nullptr) CVar_SetS32(name, defaultValue); } -extern "C" void CVar_RegisterFloat(char* name, float defaultValue) { +extern "C" void CVar_RegisterFloat(const char* name, float defaultValue) { CVar* cvar = CVar_Get(name); if (cvar == nullptr) CVar_SetFloat(name, defaultValue); } -extern "C" void CVar_RegisterString(char* name, char* defaultValue) { +extern "C" void CVar_RegisterString(const char* name, char* defaultValue) { CVar* cvar = CVar_Get(name); if (cvar == nullptr) CVar_SetString(name, defaultValue); -} \ No newline at end of file +} diff --git a/libultraship/libultraship/Cvar.h b/libultraship/libultraship/Cvar.h index 7bac8f20b..a85bb8fd3 100644 --- a/libultraship/libultraship/Cvar.h +++ b/libultraship/libultraship/Cvar.h @@ -23,15 +23,15 @@ extern "C" //#include -CVar* CVar_Get(char* name); -s32 CVar_GetS32(char* name, s32 defaultValue); -float CVar_GetFloat(char* name, float defaultValue); -char* CVar_GetString(char* name, char* defaultValue); -void CVar_SetS32(char* name, s32 value); +CVar* CVar_Get(const char* name); +s32 CVar_GetS32(const char* name, s32 defaultValue); +float CVar_GetFloat(const char* name, float defaultValue); +char* CVar_GetString(const char* name, char* defaultValue); +void CVar_SetS32(const char* name, s32 value); -void CVar_RegisterS32(char* name, s32 defaultValue); -void CVar_RegisterFloat(char* name, float defaultValue); -void CVar_RegisterString(char* name, char* defaultValue); +void CVar_RegisterS32(const char* name, s32 defaultValue); +void CVar_RegisterFloat(const char* name, float defaultValue); +void CVar_RegisterString(const char* name, char* defaultValue); #ifdef __cplusplus }; @@ -42,8 +42,8 @@ void CVar_RegisterString(char* name, char* defaultValue); #include extern std::map cvars; -CVar* CVar_GetVar(char* name); -void CVar_SetFloat(char* name, float value); -void CVar_SetString(char* name, char* value); +CVar* CVar_GetVar(const char* name); +void CVar_SetFloat(const char* name, float value); +void CVar_SetString(const char* name, char* value); +#endif #endif -#endif \ No newline at end of file diff --git a/libultraship/libultraship/GameSettings.cpp b/libultraship/libultraship/GameSettings.cpp index 1186fa27c..f12042bc0 100644 --- a/libultraship/libultraship/GameSettings.cpp +++ b/libultraship/libultraship/GameSettings.cpp @@ -50,73 +50,73 @@ namespace Game { // Enhancements Settings.enhancements.fast_text = stob(Conf[EnhancementSection]["fast_text"]); - CVar_SetS32(const_cast("gFastText"), Settings.enhancements.fast_text); + CVar_SetS32("gFastText", Settings.enhancements.fast_text); Settings.enhancements.disable_lod = stob(Conf[EnhancementSection]["disable_lod"]); - CVar_SetS32(const_cast("gDisableLOD"), Settings.enhancements.disable_lod); + CVar_SetS32("gDisableLOD", Settings.enhancements.disable_lod); Settings.enhancements.animated_pause_menu = stob(Conf[EnhancementSection]["animated_pause_menu"]); - CVar_SetS32(const_cast("gPauseLiveLink"), Settings.enhancements.animated_pause_menu); + CVar_SetS32("gPauseLiveLink", Settings.enhancements.animated_pause_menu); Settings.enhancements.minimal_ui = stob(Conf[EnhancementSection]["minimal_ui"]); CVar_SetS32(const_cast("gMinimalUI"), Settings.enhancements.minimal_ui); // Audio Settings.audio.master = Ship::stof(Conf[AudioSection]["master"]); - CVar_SetFloat(const_cast("gGameMasterVolume"), Settings.audio.master); + CVar_SetFloat("gGameMasterVolume", Settings.audio.master); Settings.audio.music_main = Ship::stof(Conf[AudioSection]["music_main"]); - CVar_SetFloat(const_cast("gMainMusicVolume"), Settings.audio.music_main); + CVar_SetFloat("gMainMusicVolume", Settings.audio.music_main); Settings.audio.music_sub = Ship::stof(Conf[AudioSection]["music_sub"]); - CVar_SetFloat(const_cast("gSubMusicVolume"), Settings.audio.music_sub); + CVar_SetFloat("gSubMusicVolume", Settings.audio.music_sub); Settings.audio.sfx = Ship::stof(Conf[AudioSection]["sfx"]); - CVar_SetFloat(const_cast("gSFXMusicVolume"), Settings.audio.sfx); + CVar_SetFloat("gSFXMusicVolume", Settings.audio.sfx); Settings.audio.fanfare = Ship::stof(Conf[AudioSection]["fanfare"]); - CVar_SetFloat(const_cast("gFanfareVolume"), Settings.audio.fanfare); + CVar_SetFloat("gFanfareVolume", Settings.audio.fanfare); // Controllers Settings.controller.gyro_sensitivity = Ship::stof(Conf[ControllerSection]["gyro_sensitivity"]); - CVar_SetFloat(const_cast("gGyroSensitivity"), Settings.controller.gyro_sensitivity); + CVar_SetFloat("gGyroSensitivity", Settings.controller.gyro_sensitivity); Settings.controller.rumble_strength = Ship::stof(Conf[ControllerSection]["rumble_strength"]); - CVar_SetFloat(const_cast("gRumbleStrength"), Settings.controller.rumble_strength); + CVar_SetFloat("gRumbleStrength", Settings.controller.rumble_strength); Settings.controller.input_scale = Ship::stof(Conf[ControllerSection]["input_scale"]); - CVar_SetFloat(const_cast("gInputScale"), Settings.controller.input_scale); + CVar_SetFloat("gInputScale", Settings.controller.input_scale); Settings.controller.input_enabled = stob(Conf[ControllerSection]["input_enabled"]); - CVar_SetS32(const_cast("gInputEnabled"), Settings.controller.input_enabled); + CVar_SetS32("gInputEnabled", Settings.controller.input_enabled); // Cheats Settings.cheats.debug_mode = stob(Conf[CheatSection]["debug_mode"]); - CVar_SetS32(const_cast("gDebugEnabled"), Settings.cheats.debug_mode); + CVar_SetS32("gDebugEnabled", Settings.cheats.debug_mode); Settings.cheats.infinite_money = stob(Conf[CheatSection]["infinite_money"]); - CVar_SetS32(const_cast("gInfiniteMoney"), Settings.cheats.infinite_money); + CVar_SetS32("gInfiniteMoney", Settings.cheats.infinite_money); Settings.cheats.infinite_health = stob(Conf[CheatSection]["infinite_health"]); - CVar_SetS32(const_cast("gInfiniteHealth"), Settings.cheats.infinite_health); + CVar_SetS32("gInfiniteHealth", Settings.cheats.infinite_health); Settings.cheats.infinite_ammo = stob(Conf[CheatSection]["infinite_ammo"]); - CVar_SetS32(const_cast("gInfiniteAmmo"), Settings.cheats.infinite_ammo); + CVar_SetS32("gInfiniteAmmo", Settings.cheats.infinite_ammo); Settings.cheats.infinite_magic = stob(Conf[CheatSection]["infinite_magic"]); - CVar_SetS32(const_cast("gInfiniteMagic"), Settings.cheats.infinite_magic); + CVar_SetS32("gInfiniteMagic", Settings.cheats.infinite_magic); Settings.cheats.no_clip = stob(Conf[CheatSection]["no_clip"]); - CVar_SetS32(const_cast("gNoClip"), Settings.cheats.no_clip); + CVar_SetS32("gNoClip", Settings.cheats.no_clip); Settings.cheats.climb_everything = stob(Conf[CheatSection]["climb_everything"]); - CVar_SetS32(const_cast("gClimbEverything"), Settings.cheats.climb_everything); + CVar_SetS32("gClimbEverything", Settings.cheats.climb_everything); Settings.cheats.moon_jump_on_l = stob(Conf[CheatSection]["moon_jump_on_l"]); - CVar_SetS32(const_cast("gMoonJumpOnL"), Settings.cheats.moon_jump_on_l); + CVar_SetS32("gMoonJumpOnL", Settings.cheats.moon_jump_on_l); Settings.cheats.super_tunic = stob(Conf[CheatSection]["super_tunic"]); - CVar_SetS32(const_cast("gSuperTunic"), Settings.cheats.super_tunic); + CVar_SetS32("gSuperTunic", Settings.cheats.super_tunic); UpdateAudio(); } @@ -173,4 +173,4 @@ namespace Game { void SetSeqPlayerVolume(SeqPlayers playerId, float volume) { Audio_SetGameVolume(playerId, volume); } -} \ No newline at end of file +} diff --git a/libultraship/libultraship/SohConsole.cpp b/libultraship/libultraship/SohConsole.cpp index 71a067196..618cd1e1d 100644 --- a/libultraship/libultraship/SohConsole.cpp +++ b/libultraship/libultraship/SohConsole.cpp @@ -92,7 +92,7 @@ void Console::Update() { } for (auto [key, var] : BindingToggle) { if (ImGui::IsKeyPressed(key)) { - CVar* cvar = CVar_GetVar(const_cast(var.c_str())); + CVar* cvar = CVar_GetVar(var.c_str()); Dispatch("set " + var + " " + std::to_string(cvar == nullptr ? 0 : !static_cast(cvar->value.valueS32))); } } diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index d95a27d08..bdf9c267b 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -225,7 +225,7 @@ namespace SohImGui { ImGui::Text(name, static_cast(100 * *(value))); if (ImGui::SliderFloat((std::string("##") + key).c_str(), value, 0.0f, 1.0f, "")) { const float volume = floorf(*(value) * 100) / 100; - CVar_SetFloat(const_cast(key), volume); + CVar_SetFloat(key, volume); needs_save = true; Game::SetSeqPlayerVolume(playerId, volume); } @@ -289,7 +289,7 @@ namespace SohImGui { const float volume = Game::Settings.audio.master; ImGui::Text("Master Volume: %d %%", static_cast(100 * volume)); if (ImGui::SliderFloat("##Master_Vol", &Game::Settings.audio.master, 0.0f, 1.0f, "")) { - CVar_SetFloat(const_cast("gGameMasterVolume"), volume); + CVar_SetFloat("gGameMasterVolume", volume); needs_save = true; } @@ -337,7 +337,7 @@ namespace SohImGui { ImGui::Separator(); if (ImGui::Checkbox("Fast Text", &Game::Settings.enhancements.fast_text)) { - CVar_SetS32(const_cast("gFastText"), Game::Settings.enhancements.fast_text); + CVar_SetS32("gFastText", Game::Settings.enhancements.fast_text); needs_save = true; } @@ -354,12 +354,12 @@ namespace SohImGui { } if (ImGui::Checkbox("Animated Link in Pause Menu", &Game::Settings.enhancements.animated_pause_menu)) { - CVar_SetS32(const_cast("gPauseLiveLink"), Game::Settings.enhancements.animated_pause_menu); + CVar_SetS32("gPauseLiveLink", Game::Settings.enhancements.animated_pause_menu); needs_save = true; } if (ImGui::Checkbox("Disable LOD", &Game::Settings.enhancements.disable_lod)) { - CVar_SetS32(const_cast("gDisableLOD"), Game::Settings.enhancements.disable_lod); + CVar_SetS32("gDisableLOD", Game::Settings.enhancements.disable_lod); needs_save = true; } @@ -374,7 +374,7 @@ namespace SohImGui { ImGui::Separator(); if (ImGui::Checkbox("Debug Mode", &Game::Settings.cheats.debug_mode)) { - CVar_SetS32(const_cast("gDebugEnabled"), Game::Settings.cheats.debug_mode); + CVar_SetS32("gDebugEnabled", Game::Settings.cheats.debug_mode); needs_save = true; } @@ -383,42 +383,42 @@ namespace SohImGui { if (ImGui::BeginMenu("Cheats")) { if (ImGui::Checkbox("Infinite Money", &Game::Settings.cheats.infinite_money)) { - CVar_SetS32(const_cast("gInfiniteMoney"), Game::Settings.cheats.infinite_money); + CVar_SetS32("gInfiniteMoney", Game::Settings.cheats.infinite_money); needs_save = true; } if (ImGui::Checkbox("Infinite Health", &Game::Settings.cheats.infinite_health)) { - CVar_SetS32(const_cast("gInfiniteHealth"), Game::Settings.cheats.infinite_health); + CVar_SetS32("gInfiniteHealth", Game::Settings.cheats.infinite_health); needs_save = true; } if (ImGui::Checkbox("Infinite Ammo", &Game::Settings.cheats.infinite_ammo)) { - CVar_SetS32(const_cast("gInfiniteAmmo"), Game::Settings.cheats.infinite_ammo); + CVar_SetS32("gInfiniteAmmo", Game::Settings.cheats.infinite_ammo); needs_save = true; } if (ImGui::Checkbox("Infinite Magic", &Game::Settings.cheats.infinite_magic)) { - CVar_SetS32(const_cast("gInfiniteMagic"), Game::Settings.cheats.infinite_magic); + CVar_SetS32("gInfiniteMagic", Game::Settings.cheats.infinite_magic); needs_save = true; } if (ImGui::Checkbox("No Clip", &Game::Settings.cheats.no_clip)) { - CVar_SetS32(const_cast("gNoClip"), Game::Settings.cheats.no_clip); + CVar_SetS32("gNoClip", Game::Settings.cheats.no_clip); needs_save = true; } if (ImGui::Checkbox("Climb Everything", &Game::Settings.cheats.climb_everything)) { - CVar_SetS32(const_cast("gClimbEverything"), Game::Settings.cheats.climb_everything); + CVar_SetS32("gClimbEverything", Game::Settings.cheats.climb_everything); needs_save = true; } if (ImGui::Checkbox("Moon Jump on L", &Game::Settings.cheats.moon_jump_on_l)) { - CVar_SetS32(const_cast("gMoonJumpOnL"), Game::Settings.cheats.moon_jump_on_l); + CVar_SetS32("gMoonJumpOnL", Game::Settings.cheats.moon_jump_on_l); needs_save = true; } if (ImGui::Checkbox("Super Tunic", &Game::Settings.cheats.super_tunic)) { - CVar_SetS32(const_cast("gSuperTunic"), Game::Settings.cheats.super_tunic); + CVar_SetS32("gSuperTunic", Game::Settings.cheats.super_tunic); needs_save = true; } @@ -538,4 +538,4 @@ namespace SohImGui { void BindCmd(const std::string& cmd, CommandEntry entry) { console->Commands[cmd] = std::move(entry); } -} \ No newline at end of file +} diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index c000ce8e1..d10600bce 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -183,9 +183,9 @@ extern "C" char* ResourceMgr_LoadJPEG(char* data, int dataSize) return (char*)finalBuffer; } -extern "C" char* ResourceMgr_LoadTexByName(char* texPath); +extern "C" char* ResourceMgr_LoadTexByName(const char* texPath); -extern "C" char* ResourceMgr_LoadTexOrDListByName(char* filePath) { +extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) { auto res = OTRGlobals::Instance->context->GetResourceManager()->LoadResource(filePath); if (res->resType == Ship::ResourceType::DisplayList) @@ -196,28 +196,28 @@ extern "C" char* ResourceMgr_LoadTexOrDListByName(char* filePath) { return ResourceMgr_LoadTexByName(filePath); } -extern "C" char* ResourceMgr_LoadPlayerAnimByName(char* animPath) { +extern "C" char* ResourceMgr_LoadPlayerAnimByName(const char* animPath) { auto anim = std::static_pointer_cast( OTRGlobals::Instance->context->GetResourceManager()->LoadResource(animPath)); return (char*)&anim->limbRotData[0]; } -extern "C" Gfx* ResourceMgr_LoadGfxByName(char* path) +extern "C" Gfx* ResourceMgr_LoadGfxByName(const char* path) { auto res = std::static_pointer_cast( OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); return (Gfx*)&res->instructions[0]; } -extern "C" char* ResourceMgr_LoadArrayByName(char* path) +extern "C" char* ResourceMgr_LoadArrayByName(const char* path) { auto res = std::static_pointer_cast(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); return (char*)res->scalars.data(); } -extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(char* path) { +extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(const char* path) { auto res = std::static_pointer_cast(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); @@ -239,7 +239,7 @@ extern "C" char* ResourceMgr_LoadArrayByNameAsVec3s(char* path) { } } -extern "C" CollisionHeader* ResourceMgr_LoadColByName(char* path) +extern "C" CollisionHeader* ResourceMgr_LoadColByName(const char* path) { auto colRes = std::static_pointer_cast(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); @@ -333,7 +333,7 @@ extern "C" CollisionHeader* ResourceMgr_LoadColByName(char* path) return (CollisionHeader*)colHeader; } -extern "C" Vtx * ResourceMgr_LoadVtxByName(char* path) +extern "C" Vtx * ResourceMgr_LoadVtxByName(const char* path) { auto res = std::static_pointer_cast(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); return (Vtx*)res->vertices.data(); @@ -355,7 +355,7 @@ extern "C" int ResourceMgr_OTRSigCheck(char* imgData) return 0; } -extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(char* path) { +extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(const char* path) { auto res = std::static_pointer_cast( OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); @@ -424,7 +424,7 @@ extern "C" AnimationHeaderCommon* ResourceMgr_LoadAnimByName(char* path) { return anim; } -extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) { +extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path) { auto res = std::static_pointer_cast(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); if (res->cachedGameAsset != nullptr) @@ -470,14 +470,14 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) { limbC->sibling = limb->siblingIndex; if (limb->dListPtr != "") { - auto dList = ResourceMgr_LoadGfxByName((char*)limb->dListPtr.c_str()); + auto dList = ResourceMgr_LoadGfxByName(limb->dListPtr.c_str()); limbC->dLists[0] = dList; } else { limbC->dLists[0] = nullptr; } if (limb->dList2Ptr != "") { - auto dList = ResourceMgr_LoadGfxByName((char*)limb->dList2Ptr.c_str()); + auto dList = ResourceMgr_LoadGfxByName(limb->dList2Ptr.c_str()); limbC->dLists[1] = dList; } else { limbC->dLists[1] = nullptr; @@ -496,7 +496,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) { limbC->dList = nullptr; if (!limb->dListPtr.empty()) { - const auto dList = ResourceMgr_LoadGfxByName(const_cast(limb->dListPtr.c_str())); + const auto dList = ResourceMgr_LoadGfxByName(limb->dListPtr.c_str()); limbC->dList = dList; } @@ -512,12 +512,12 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) { limbC->dList[1] = nullptr; if (!limb->dListPtr.empty()) { - const auto dList = ResourceMgr_LoadGfxByName(const_cast(limb->dListPtr.c_str())); + const auto dList = ResourceMgr_LoadGfxByName(limb->dListPtr.c_str()); limbC->dList[0] = dList; } if (!limb->dList2Ptr.empty()) { - const auto dList = ResourceMgr_LoadGfxByName(const_cast(limb->dList2Ptr.c_str())); + const auto dList = ResourceMgr_LoadGfxByName(limb->dList2Ptr.c_str()); limbC->dList[1] = dList; } @@ -543,7 +543,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) { limbC->segmentType = 0; if (limb->skinSegmentType == Ship::ZLimbSkinType::SkinType_DList) - limbC->segment = ResourceMgr_LoadGfxByName(const_cast(limb->skinDList.c_str())); + limbC->segment = ResourceMgr_LoadGfxByName(limb->skinDList.c_str()); else if (limb->skinSegmentType == Ship::ZLimbSkinType::SkinType_4) { const auto animData = new SkinAnimatedLimbData; const int skinDataSize = limb->skinData.size(); @@ -551,7 +551,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) { animData->totalVtxCount = limb->skinVtxCnt; animData->limbModifCount = skinDataSize; animData->limbModifications = new SkinLimbModif[animData->limbModifCount]; - animData->dlist = ResourceMgr_LoadGfxByName(const_cast(limb->skinDList2.c_str())); + animData->dlist = ResourceMgr_LoadGfxByName(limb->skinDList2.c_str()); for (int i = 0; i < skinDataSize; i++) { @@ -611,7 +611,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path) { return baseHeader; } -extern "C" s32* ResourceMgr_LoadCSByName(char* path) +extern "C" s32* ResourceMgr_LoadCSByName(const char* path) { auto res = std::static_pointer_cast(OTRGlobals::Instance->context->GetResourceManager()->LoadResource(path)); return (s32*)res->commands.data(); diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 4a439fc6d..4f62f0694 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -31,17 +31,17 @@ uint32_t ResourceMgr_GetGameVersion(); void ResourceMgr_CacheDirectory(const char* resName); void ResourceMgr_LoadFile(const char* resName); char* ResourceMgr_LoadFileFromDisk(const char* filePath); -char* ResourceMgr_LoadTexByName(char* texPath); -char* ResourceMgr_LoadTexOrDListByName(char* filePath); -char* ResourceMgr_LoadPlayerAnimByName(char* animPath); +char* ResourceMgr_LoadTexByName(const char* texPath); +char* ResourceMgr_LoadTexOrDListByName(const char* filePath); +char* ResourceMgr_LoadPlayerAnimByName(const char* animPath); char* ResourceMgr_GetNameByCRC(uint64_t crc, char* alloc); Gfx* ResourceMgr_LoadGfxByCRC(uint64_t crc); -Gfx* ResourceMgr_LoadGfxByName(char* path); +Gfx* ResourceMgr_LoadGfxByName(const char* path); Vtx* ResourceMgr_LoadVtxByCRC(uint64_t crc); -Vtx* ResourceMgr_LoadVtxByName(char* path); -CollisionHeader* ResourceMgr_LoadColByName(char* path); +Vtx* ResourceMgr_LoadVtxByName(const char* path); +CollisionHeader* ResourceMgr_LoadColByName(const char* path); uint64_t GetPerfCounter(); -struct SkeletonHeader* ResourceMgr_LoadSkeletonByName(char* path); +struct SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path); int ResourceMgr_OTRSigCheck(char* imgData); uint64_t osGetTime(void); uint32_t osGetCount(void);