From e2a2d2c46468075e967edd00a414f658ec0e83b7 Mon Sep 17 00:00:00 2001 From: shweet Date: Sat, 28 Feb 2026 22:14:32 -0500 Subject: [PATCH] moar fixes --- src/resource/audio.cpp | 11 ++++++----- src/resource/font.cpp | 8 +++++--- src/resource/shader.cpp | 2 +- src/resource/texture.cpp | 11 ++++++----- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/resource/audio.cpp b/src/resource/audio.cpp index 1c608d2..992bb3b 100644 --- a/src/resource/audio.cpp +++ b/src/resource/audio.cpp @@ -51,19 +51,20 @@ namespace game::resource Audio::Audio(const std::filesystem::path& path) { - auto key = std::string("fs:") + path.string(); + auto pathString = path.string(); + auto key = std::string("fs:") + pathString; internal = cache_get(key); if (internal) { - logger.info(std::format("Using cached audio: {}", path.string())); + logger.info(std::format("Using cached audio: {}", pathString)); return; } - internal = audio_make(MIX_LoadAudio(mixer_get(), path.c_str(), true)); + internal = audio_make(MIX_LoadAudio(mixer_get(), pathString.c_str(), true)); cache_set(key, internal); - if (internal) logger.info(std::format("Initialized audio: {}", path.string())); + if (internal) logger.info(std::format("Initialized audio: {}", pathString)); - if (!internal) logger.info(std::format("Failed to intialize audio: {} ({})", path.string(), SDL_GetError())); + if (!internal) logger.info(std::format("Failed to intialize audio: {} ({})", pathString, SDL_GetError())); } Audio::Audio(const physfs::Path& path) diff --git a/src/resource/font.cpp b/src/resource/font.cpp index a10a817..0938c19 100644 --- a/src/resource/font.cpp +++ b/src/resource/font.cpp @@ -8,15 +8,17 @@ namespace game::resource { Font::Font(const std::filesystem::path& path, float size) { + auto pathString = path.string(); + ImFontConfig config; config.FontDataOwnedByAtlas = false; - internal = ImGui::GetIO().Fonts->AddFontFromFileTTF(path.c_str(), size, &config); + internal = ImGui::GetIO().Fonts->AddFontFromFileTTF(pathString.c_str(), size, &config); if (internal) - logger.info(std::format("Initialized font: {}", path.c_str())); + logger.info(std::format("Initialized font: {}", pathString)); else - logger.error(std::format("Failed to initialize font: {}", path.c_str())); + logger.error(std::format("Failed to initialize font: {}", pathString)); } Font::Font(const physfs::Path& path, float size) diff --git a/src/resource/shader.cpp b/src/resource/shader.cpp index af5d695..c17ad38 100644 --- a/src/resource/shader.cpp +++ b/src/resource/shader.cpp @@ -20,7 +20,7 @@ namespace game::resource glGetShaderiv(shaderHandle, GL_INFO_LOG_LENGTH, &logLength); std::string log(logLength, '\0'); if (logLength > 0) glGetShaderInfoLog(shaderHandle, logLength, nullptr, log.data()); - logger.error(std::format("Failed to compile shader: {}", log)); + logger.error(std::format("Failed to compile {} shader: {}", stage, log)); return false; } return true; diff --git a/src/resource/texture.cpp b/src/resource/texture.cpp index 02c72db..d3a37aa 100644 --- a/src/resource/texture.cpp +++ b/src/resource/texture.cpp @@ -136,14 +136,15 @@ namespace game::resource Texture::Texture(const std::filesystem::path& path) { - auto key = std::string("fs:") + path.string(); + auto pathString = path.string(); + auto key = std::string("fs:") + pathString; if (cache_get(key, idShared, id, size, channels)) { - logger.info(std::format("Using cached texture: {}", path.string())); + logger.info(std::format("Using cached texture: {}", pathString)); return; } - if (auto surface = SDL_LoadPNG(path.c_str())) + if (auto surface = SDL_LoadPNG(pathString.c_str())) { auto rgbaSurface = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_RGBA32); SDL_DestroySurface(surface); @@ -152,10 +153,10 @@ namespace game::resource init((const uint8_t*)surface->pixels); SDL_DestroySurface(surface); cache_set(key, idShared, this->size, channels); - logger.info(std::format("Initialized texture: {}", path.string())); + logger.info(std::format("Initialized texture: {}", pathString)); } else - logger.error(std::format("Failed to initialize texture: {} ({})", path.string(), SDL_GetError())); + logger.error(std::format("Failed to initialize texture: {} ({})", pathString, SDL_GetError())); } Texture::Texture(const physfs::Path& path)