Skip to content

Commit

Permalink
Fix CLEO not loading with UAL (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC authored Sep 23, 2024
1 parent 4f49346 commit b91818c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
13 changes: 13 additions & 0 deletions cleo_sdk/CLEO_Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,19 @@ namespace CLEO
path.replace(0, base.length() + 1, ""); // remove path separator too if present
}

// get path without last file/directory element
static const std::string_view FilepathGetParent(const std::string_view str)
{
auto separatorPos = str.find_last_of('\\');

if (separatorPos == std::string::npos)
{
return {};
}

return std::string_view(str.data(), separatorPos);
}

// this plugin's config file
static std::string GetConfigFilename()
{
Expand Down
9 changes: 2 additions & 7 deletions source/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,11 @@ namespace FS = std::filesystem;

static std::string GetGameDirectory() // already stored in Filepath_Game
{
static const auto GTA_GetCWD = (char* (__cdecl*)(char*, int))0x00836E91; // SA 1.0 US ingame function

std::string path;

path.resize(MAX_PATH);
GTA_GetCWD(path.data(), path.size()); // assume work dir is game location when initialized
path.resize(strlen(path.data()));

GetModuleFileNameA(NULL, path.data(), path.size()); // game exe absolute path
path.resize(CLEO::FilepathGetParent(path).length());
CLEO::FilepathNormalize(path);

return std::move(path);
}

Expand Down

0 comments on commit b91818c

Please sign in to comment.