From 638ff54d931810466d1ac9043a2d641fc2b81422 Mon Sep 17 00:00:00 2001 From: INeedGames Date: Fri, 12 Jan 2024 13:37:49 -0600 Subject: [PATCH] fix(fs_read): check for instance (#178) Co-authored-by: xensik --- src/tool/main.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/tool/main.cpp b/src/tool/main.cpp index c48ee48a..ff56d050 100644 --- a/src/tool/main.cpp +++ b/src/tool/main.cpp @@ -439,35 +439,35 @@ auto fs_read(context const* ctx, std::string const& name) -> std::pairinstance() == gsc::instance::client) + { + bin_ext = ".cscbin"; + gsc_ext = ".csc"; + } + if (!utils::file::exists(path)) { - path.replace_extension(""); + auto const name_noext = path.replace_extension("").string(); - auto id = ctx->token_id(path.string()); + auto id = ctx->token_id(name_noext); if (id > 0) { - path = fs::path{ std::to_string(id) + ".gscbin" }; + path = fs::path{ std::to_string(id) + bin_ext }; } if (!utils::file::exists(path)) { - path = fs::path{ path.string() + ".gscbin" }; - } - - if (!utils::file::exists(path)) - { - path = fs::path{ path.string() + ".gsh" }; - } - - if (!utils::file::exists(path)) - { - path = fs::path{ path.string() + ".gsc" }; + path = fs::path{ name_noext + bin_ext }; } } auto data = utils::file::read(path); - if (path.extension().string() == ".gscbin" || (path.extension().string() != ".gsh" && path.extension().string() != ".gsc")) + if (path.extension().string() == bin_ext || (path.extension().string() != gsh_ext && path.extension().string() != gsc_ext)) { asset s; s.deserialize(data);