Skip to content

Commit

Permalink
fix fs_read to check for instance
Browse files Browse the repository at this point in the history
  • Loading branch information
ineed bots committed Jan 8, 2024
1 parent ecffa88 commit a867532
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/tool/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,35 +439,36 @@ 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";
gsh_ext = ".csh";
}

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 a867532

Please sign in to comment.