fix: correct argument typo and path/error handling

Fix --enable-consolelog flag, screenshot filter bug, paths to C APIs, add includes and gitignore entries, and improve ShellExecuteW failure detection.
This commit is contained in:
2026-08-07 21:33:46 +08:00
parent d9b4b42f74
commit 0919faa3e4
9 changed files with 26 additions and 12 deletions

1
.gitignore vendored
View File

@@ -14,6 +14,7 @@
*.pch *.pch
*.sbr *.sbr
build/ build/
build_debug/
Build/ Build/
bin/ bin/
Debug/ Debug/

View File

@@ -7,6 +7,7 @@
#include <tbb/concurrent_hash_map.h> #include <tbb/concurrent_hash_map.h>
#include <tbb/concurrent_queue.h> #include <tbb/concurrent_queue.h>
#include <tbb/concurrent_vector.h> #include <tbb/concurrent_vector.h>
#include <variant>
namespace Cubed { namespace Cubed {
class ServerWorld; class ServerWorld;
class Session; class Session;

View File

@@ -17,9 +17,18 @@ namespace Cubed::Tools {
inline void open_file_manager(const std::filesystem::path& path) { inline void open_file_manager(const std::filesystem::path& path) {
#ifdef _WIN32 #ifdef _WIN32
auto abs_path = std::filesystem::absolute(path);
ShellExecuteW(nullptr, L"open", path.wstring().c_str(), nullptr, nullptr, if (!std::filesystem::exists(abs_path)) {
SW_SHOWNORMAL); Logger::warn("Path does not exist: {}", abs_path.string());
return;
}
HINSTANCE result =
ShellExecuteW(nullptr, L"open", abs_path.wstring().c_str(), nullptr,
nullptr, SW_SHOWNORMAL);
if ((INT_PTR)result <= 32) {
Logger::warn("ShellExecuteW failed for path: {}, error code: {}",
path.string(), (int)(INT_PTR)result);
}
#elif __linux__ #elif __linux__

View File

@@ -1,8 +1,10 @@
#pragma once #pragma once
#include <rapidjson/document.h> #include <rapidjson/document.h>
#include <string>
#include <string_view>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
namespace Cubed { namespace Cubed {
class SensitiveFilter { class SensitiveFilter {
public: public:

View File

@@ -187,7 +187,7 @@ void App::handle_argument(int argc, char** argv) {
}}, }},
{"--enable-filelog", {"--enable-filelog",
[&](ArgParser&) { m_argument.enable_filelog = true; }}, [&](ArgParser&) { m_argument.enable_filelog = true; }},
{"--enale-consolelog", {"--enable-consolelog",
[&](ArgParser&) { m_argument.enable_consolelog = true; }}, [&](ArgParser&) { m_argument.enable_consolelog = true; }},
{"--direct-enter", {"--direct-enter",
[&](ArgParser&) { m_argument.direct_enter = true; }} [&](ArgParser&) { m_argument.direct_enter = true; }}

View File

@@ -88,7 +88,7 @@ ModelManager::Handle ModelManager::load_model(std::string_view model_name) {
auto model = m_loader.load(path); auto model = m_loader.load(path);
fs::path anim_path = path; fs::path anim_path = path;
anim_path = anim_path.parent_path() / "animation.json"; anim_path = anim_path.parent_path() / "animation.json";
load_anim_config(model, anim_path); load_anim_config(model, anim_path.string());
ModelMap::accessor acc; ModelMap::accessor acc;
if (m_models.insert(acc, m_next++)) { if (m_models.insert(acc, m_next++)) {
acc->second = std::move(model); acc->second = std::move(model);

View File

@@ -311,11 +311,11 @@ void Renderer::handle_screenshot() {
fs::create_directories(path); fs::create_directories(path);
fs::path image = fs::path image =
path / std::format("screenshot {}.png", Tools::get_time_date_str()); path / std::format("screenshot {}.png", Tools::get_time_date_str());
if (!stbi_write_png(image.c_str(), width, height, 4, flipped_pixels.data(), if (!stbi_write_png(image.string().c_str(), width, height, 4,
width * 4)) { flipped_pixels.data(), width * 4)) {
Logger::error("Failed to write {} image", image.c_str()); Logger::error("Failed to write {} image", image.string());
} else { } else {
Logger::info("save {} success!", image.c_str()); Logger::info("save {} success!", image.string());
} }
} }

View File

@@ -184,7 +184,7 @@ ImageData load_image_data(const std::string& tex_image_path, bool check_exist,
path = ASSETS_PATH + tex_image_path; path = ASSETS_PATH + tex_image_path;
} }
if (check_exist) { if (check_exist) {
ASSERT_MSG(fs::is_regular_file(path), path.c_str()); ASSERT_MSG(fs::is_regular_file(path), path.string().c_str());
} }
unsigned char* data = nullptr; unsigned char* data = nullptr;
int width, height, channels; int width, height, channels;

View File

@@ -54,7 +54,8 @@ void ScreenshotUI::update_layout(int width, int height) {
if (!fs::is_regular_file(entry)) { if (!fs::is_regular_file(entry)) {
continue; continue;
} }
if (!std::ranges::find(IMAGE_EXT, entry.path().extension())) { if (std::ranges::find(IMAGE_EXT, entry.path().extension()) ==
IMAGE_EXT.end()) {
continue; continue;
} }
ImageInfo info; ImageInfo info;