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 .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BraceWrapping:
AfterStruct: false
BeforeElse: false
IndentBraces: false
NamespaceIndentation: None
NamespaceIndentation: All
PointerAlignment: Left
SortIncludes: false
SpaceAfterCStyleCast: false
Expand Down
26 changes: 8 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,19 @@ jobs:
version: "0.0.0-ci"
run_tests: "true"

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

# Pinned so the gate cannot drift with whatever LLVM the runner image ships.
- name: clang-format check
shell: pwsh
run: |
$clangFormat = Get-Command clang-format -ErrorAction SilentlyContinue
if (-not $clangFormat) {
Write-Host "clang-format not on PATH; trying LLVM install locations"
$candidates = @(
"C:\Program Files\LLVM\bin\clang-format.exe",
"C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\bin\clang-format.exe"
)
foreach ($c in $candidates) {
if (Test-Path $c) { $clangFormat = $c; break }
}
} else {
$clangFormat = $clangFormat.Source
}
if (-not $clangFormat) {
Write-Host "clang-format unavailable on runner - skipping style check"
exit 0
}
python -m pip install --quiet clang-format==22.1.8
$files = Get-ChildItem -Recurse src,loader,compat,tests -Include *.cpp,*.h,*.c |
Where-Object { $_.FullName -notmatch '\\vendor\\' }
& $clangFormat --dry-run --Werror @($files.FullName)
clang-format --dry-run --Werror @($files.FullName)
if ($LASTEXITCODE -ne 0) { throw "clang-format check failed" }

- name: Upload artifacts
Expand Down
10 changes: 6 additions & 4 deletions compat/logger_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ namespace {
vsnprintf(message, _countof(message), format, args);

wchar_t wide[MAX_MESSAGE];
if (MultiByteToWideChar(CP_UTF8, 0, message, -1, wide, static_cast<int>(_countof(wide))) > 0) {
if (MultiByteToWideChar(CP_UTF8, 0, message, -1, wide, static_cast<int>(_countof(wide))) >
0) {
GW::Chat::WriteChat(GWTOOLBOX_CHAN, wide, L"GWDash", transient);
}
}
Expand All @@ -55,7 +56,7 @@ namespace {
_vsnwprintf_s(message, _countof(message), _TRUNCATE, format, args);
GW::Chat::WriteChat(GWTOOLBOX_CHAN, message, L"GWDash", transient);
}
}
} // namespace

namespace Log {
void Log(const char* msg, ...)
Expand Down Expand Up @@ -145,7 +146,8 @@ namespace Log {
void FatalAssert(const char* expr, const char* file, const unsigned line)
{
char line_buffer[MAX_MESSAGE];
snprintf(line_buffer, _countof(line_buffer), "[GWDash] assertion failed: %s (%s:%u)\n", expr, file, line);
snprintf(line_buffer, _countof(line_buffer), "[GWDash] assertion failed: %s (%s:%u)\n",
expr, file, line);
OutputDebugStringA(line_buffer);
}
}
} // namespace Log
25 changes: 14 additions & 11 deletions loader/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ namespace {
{
std::vector<wchar_t> buffer(MAX_PATH);
for (;;) {
const DWORD length = GetModuleFileNameW(plugin_handle, buffer.data(),
static_cast<DWORD>(buffer.size()));
const DWORD length =
GetModuleFileNameW(plugin_handle, buffer.data(), static_cast<DWORD>(buffer.size()));
if (length == 0) {
return {};
}
Expand Down Expand Up @@ -152,19 +152,21 @@ namespace {
* returning nullptr from ToolboxPluginInstance is not an option.
*/
class FallbackPlugin final : public ToolboxPlugin {
public:
public:
[[nodiscard]] const char* Name() const override { return "GWDash"; }
[[nodiscard]] bool HasSettings() const override { return true; }

void Initialize(ImGuiContext* ctx, const ImGuiAllocFns allocator_fns, const HMODULE toolbox_dll) override
void Initialize(ImGuiContext* ctx, const ImGuiAllocFns allocator_fns,
const HMODULE toolbox_dll) override
{
ToolboxPlugin::Initialize(ctx, allocator_fns, toolbox_dll);
if (!reported) {
reported = true;
Debug(load_error.empty() ? "payload failed to load" : load_error);
// Visible once without needing GWCA WriteChat in the loader.
MessageBoxA(nullptr,
load_error.empty() ? "GWDash.core.dll failed to load." : load_error.c_str(),
load_error.empty() ? "GWDash.core.dll failed to load."
: load_error.c_str(),
"GWDash", MB_OK | MB_ICONWARNING);
}
}
Expand All @@ -177,10 +179,10 @@ namespace {
ImGui::TextWrapped("Loader version %s", GWDASH_VERSION);
}

private:
private:
bool reported = false;
};
}
} // namespace

DLLAPI ToolboxPlugin* ToolboxPluginInstance()
{
Expand All @@ -207,9 +209,11 @@ DLLAPI ToolboxPlugin* ToolboxPluginInstance()
}

using InstanceFn = ToolboxPlugin* (*)();
const auto entry = reinterpret_cast<InstanceFn>(GetProcAddress(payload, "ToolboxPluginInstance"));
const auto entry =
reinterpret_cast<InstanceFn>(GetProcAddress(payload, "ToolboxPluginInstance"));
if (!entry) {
load_error = "GWDash.core.dll has no ToolboxPluginInstance export - the install looks corrupt.";
load_error =
"GWDash.core.dll has no ToolboxPluginInstance export - the install looks corrupt.";
FreeLibrary(payload);
return instance;
}
Expand All @@ -220,8 +224,7 @@ DLLAPI ToolboxPlugin* ToolboxPluginInstance()
// The payload therefore has to tolerate repeated Initialize/Terminate
// cycles if the user unloads and reloads us from the Plugins panel.
instance = forwarded;
}
else {
} else {
load_error = "GWDash.core.dll returned no plugin instance.";
FreeLibrary(payload);
}
Expand Down
Loading
Loading