Skip to content

Commit

Permalink
fix(fs_read): check for instance (#178)
Browse files Browse the repository at this point in the history
Co-authored-by: xensik <[email protected]>
  • Loading branch information
ineedbots and xensik authored Jan 12, 2024
1 parent ecffa88 commit 638ff54
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/tool/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,35 +439,35 @@ auto fs_read(context const* ctx, std::string const& name) -> std::pair<buffer, s
{
auto path = fs::path{ name };

auto bin_ext = ".gscbin";
auto gsc_ext = ".gsc";
auto gsh_ext = ".gsh";

if (ctx->instance() == 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" };
}

if (!utils::file::exists(path))
{
path = fs::path{ path.string() + ".gscbin" };
}

if (!utils::file::exists(path))
{
path = fs::path{ path.string() + ".gsh" };
path = fs::path{ std::to_string(id) + bin_ext };
}

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);
Expand Down

0 comments on commit 638ff54

Please sign in to comment.