Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/unrealsdk/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace impl {
#ifndef UNREALSDK_IMPORTING

bool is_command_valid(std::wstring_view line, bool direct_user_input) {
if (direct_user_input && commands.find(NEXT_LINE) != commands.end()) {
if (direct_user_input && commands.contains(NEXT_LINE)) {
return true;
}
auto non_space = std::ranges::find_if_not(line, &std::iswspace);
Expand Down
8 changes: 4 additions & 4 deletions src/unrealsdk/game/bl1/bl1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void BL1Hook::post_init(void) {

namespace {

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes" // thiscall on non-class
#endif
Expand All @@ -59,7 +59,7 @@ const constinit Pattern<11> GNATIVES_SIG{
typedef void(__thiscall* fframe_step_func)(UObject*, FFrame*, void*);
fframe_step_func** fframe_step_gnatives;

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif

Expand All @@ -78,7 +78,7 @@ void BL1Hook::fframe_step(FFrame* frame, UObject* obj, void* param) const {

namespace {

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes" // thiscall on non-class
#endif
Expand Down Expand Up @@ -115,7 +115,7 @@ typedef void(__thiscall* fname_init_func)(FName* name,

fname_init_func fname_init_ptr = nullptr;

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/unrealsdk/game/bl1/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace unrealsdk::game {

namespace {

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes" // thiscall on non-class
#endif
Expand All @@ -29,7 +29,7 @@ struct FMalloc {
FMallocVFtable* vftable;
};

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/unrealsdk/game/bl1/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ UObject* BL1Hook::construct_object(UClass* cls,

namespace {

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes" // thiscall on non-class
#endif
Expand All @@ -78,7 +78,7 @@ typedef void(__thiscall* get_path_name_func)(const UObject* self,
const UObject* stop_outer,
ManagedFString* str);

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/unrealsdk/game/bl1/steamdrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void GetStartupInfoA_hook(LPSTARTUPINFOA lpStartupInfo) {
return;
}

const std::lock_guard<std::mutex> lock{ready_mutex};
const std::scoped_lock lock{ready_mutex};
ready.store(true);
ready_cv.notify_all();
}
Expand Down
4 changes: 2 additions & 2 deletions src/unrealsdk/game/bl2/bl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void BL2Hook::post_init(void) {
inject_console();
}

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes" // thiscall on non-class
#endif
Expand Down Expand Up @@ -114,7 +114,7 @@ void BL2Hook::ftext_as_culture_invariant(unreal::FText* /*text*/,

#pragma endregion

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/unrealsdk/game/bl2/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace unrealsdk::game {

namespace {

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes" // thiscall on non-class
#endif
Expand All @@ -29,7 +29,7 @@ struct FMalloc {
FMallocVFtable* vftable;
};

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/unrealsdk/game/bl2/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ UObject* BL2Hook::construct_object(UClass* cls,

namespace {

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes" // thiscall on non-class
#endif
Expand All @@ -90,7 +90,7 @@ typedef void(__thiscall* get_path_name_func)(const UObject* self,
const UObject* stop_outer,
ManagedFString* str);

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/unrealsdk/game/tps/tps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace unrealsdk::unreal;

namespace unrealsdk::game {

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes" // thiscall on non-class
#endif
Expand All @@ -23,7 +23,7 @@ void TPSHook::fname_init(FName* name, const wchar_t* str, int32_t number) const
reinterpret_cast<fname_init_func>(this->fname_init_ptr)(name, str, number, 1, 1, 0);
}

#if defined(__MINGW32__)
#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/unrealsdk/hook_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ std::mutex log_all_calls_stream_mutex{};
void log_all_calls(bool should_log) {
// Only keep this file stream open while we need it
if (should_log) {
const std::lock_guard<std::mutex> lock(log_all_calls_stream_mutex);
const std::scoped_lock lock(log_all_calls_stream_mutex);
log_all_calls_stream.open(
utils::get_this_dll().parent_path()
/ config::get_str("unrealsdk.log_all_calls_file").value_or("unrealsdk.calls.tsv"),
Expand All @@ -147,7 +147,7 @@ void log_all_calls(bool should_log) {
should_log_all_calls = should_log;

if (!should_log) {
const std::lock_guard<std::mutex> lock(log_all_calls_stream_mutex);
const std::scoped_lock lock(log_all_calls_stream_mutex);
log_all_calls_stream.close();
}
}
Expand Down Expand Up @@ -432,7 +432,7 @@ std::shared_ptr<Node> preprocess_hook(std::wstring_view source,
func_name = func->get_path_name();
auto obj_name = obj->get_path_name();

const std::lock_guard<std::mutex> lock(log_all_calls_stream_mutex);
const std::scoped_lock lock(log_all_calls_stream_mutex);
log_all_calls_stream << source << L'\t' << func_name << L'\t' << obj_name << L'\n';
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/unrealsdk/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ std::vector<log_callback> all_log_callbacks{};
}

{
const std::lock_guard<std::mutex> callback_lock(callback_mutex);
const std::scoped_lock callback_lock(callback_mutex);
while (!pending_messages.empty()) {
auto msg = std::move(pending_messages.front());
pending_messages.pop();
Expand Down Expand Up @@ -289,7 +289,7 @@ void enqueue_log_msg(uint64_t unix_time_ms,
size_t location_size,
int line) {
{
const std::lock_guard<std::mutex> lock(pending_messages_mutex);
const std::scoped_lock lock(pending_messages_mutex);
pending_messages.emplace(unix_time_ms, level, msg, msg_size, location, location_size, line);
}
pending_messages_available.notify_all();
Expand All @@ -305,13 +305,13 @@ bool set_console_level(Level level) {
}

void add_callback(log_callback callback) {
const std::lock_guard<std::mutex> lock(callback_mutex);
const std::scoped_lock lock(callback_mutex);

all_log_callbacks.push_back(callback);
}

void remove_callback(log_callback callback) {
const std::lock_guard<std::mutex> lock(callback_mutex);
const std::scoped_lock lock(callback_mutex);

auto [begin, end] = std::ranges::remove(all_log_callbacks, callback);
all_log_callbacks.erase(begin, end);
Expand Down
1 change: 1 addition & 0 deletions src/unrealsdk/unreal/structs/fframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace unrealsdk::unreal {

uint8_t* FFrame::extract_current_args(WrappedStruct& args) {
auto args_addr = reinterpret_cast<uintptr_t>(args.base.get());
// NOLINTNEXTLINE(misc-const-correctness) - see llvm/llvm-project#157320
uint8_t* original_code = this->Code;

for (auto prop = reinterpret_cast<UProperty*>(args.type->Children());
Expand Down
2 changes: 1 addition & 1 deletion src/unrealsdk/unreal/structs/fscriptdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void FScriptDelegate::validate_signature(const std::optional<BoundFunction>& fun
// Since delegates store the function name, make sure we can find this function again from just
// it's name
{
UFunction* func_from_find = nullptr;
const UFunction* func_from_find = nullptr;
try {
func_from_find = func->object->Class()->find_func_and_validate(func->func->Name());
} catch (const std::invalid_argument&) {
Expand Down
4 changes: 3 additions & 1 deletion src/unrealsdk/unreal/structs/fstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ UnmanagedFString::operator std::wstring() const {
return std::wstring{this->operator std::wstring_view()};
}
UnmanagedFString::operator std::wstring_view() const {
// You'd think data == nullptr implies size == 0, but occasionally during game shutdown I've
// seen otherwise.
auto size = this->size();
if (size == 0) {
if (size == 0 || this->data == nullptr) {
return L"";
}

Expand Down
6 changes: 3 additions & 3 deletions src/unrealsdk/unrealsdk_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ std::unordered_set<void*> unreal_allocations{};
#endif

bool init(const std::function<std::unique_ptr<game::AbstractHook>(void)>& game_getter) {
const std::lock_guard<std::mutex> lock(init_mutex);
const std::scoped_lock lock(init_mutex);

if (hook_instance != nullptr) {
return false;
Expand Down Expand Up @@ -75,12 +75,12 @@ bool init(const std::function<std::unique_ptr<game::AbstractHook>(void)>& game_g
}

UNREALSDK_CAPI([[nodiscard]] bool, is_initialized) {
const std::lock_guard<std::mutex> lock(init_mutex);
const std::scoped_lock lock(init_mutex);
return hook_instance != nullptr;
}

UNREALSDK_CAPI([[nodiscard]] bool, is_console_ready) {
return hook_instance && hook_instance->is_console_ready();
return is_initialized() && hook_instance->is_console_ready();
}

UNREALSDK_CAPI([[nodiscard]] const GObjects*, gobjects) {
Expand Down
Loading