Skip to content

Commit

Permalink
swap_lib: changed return type from const char* to std::string
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileyAG committed Mar 13, 2024
1 parent 63654a1 commit 4c8a6d8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions BunnymodXT/helper_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace helper_functions
#endif
}

const char *swap_lib(const char* current_lib_path, std::string new_lib_path, const char *start)
std::string swap_lib(const char* current_lib_path, std::string new_lib_path, const char *start)
{
const std::string filename = current_lib_path;
const auto index = filename.find(start);
Expand All @@ -25,10 +25,9 @@ namespace helper_functions

com_fixslashes(new_lib_path);

static std::string new_path;
new_path = filename.substr(0, index) + new_lib_path + DLL_EXTENSION;
std::string new_path = filename.substr(0, index) + new_lib_path + DLL_EXTENSION;

return new_path.c_str();
return new_path;
}

void crash_if_failed(std::string str)
Expand Down
2 changes: 1 addition & 1 deletion BunnymodXT/helper_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
namespace helper_functions
{
void com_fixslashes(std::string &str);
const char *swap_lib(const char* current_lib_path, std::string new_lib_path, const char *start);
std::string swap_lib(const char* current_lib_path, std::string new_lib_path, const char *start);
void crash_if_failed(std::string str);
}
2 changes: 1 addition & 1 deletion BunnymodXT/modules/HwDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8092,7 +8092,7 @@ HOOK_DEF_1(HwDLL, void, __cdecl, LoadThisDll, const char*, szDllFilename)
#endif

EngineDevMsg("[hw dll] Old path to game library: %s\n", szDllFilename);
szDllFilename = helper_functions::swap_lib(szDllFilename, cs_lib, "addons");
szDllFilename = helper_functions::swap_lib(szDllFilename, cs_lib, "addons").c_str();
EngineDevMsg("[hw dll] New path to game library: %s\n", szDllFilename);

if (!strcmp(szDllFilename, oldszDllFilename))
Expand Down

0 comments on commit 4c8a6d8

Please sign in to comment.