Skip to content

Commit

Permalink
Merge pull request #14 from RaidcoreGG/dev
Browse files Browse the repository at this point in the history
various fixes
  • Loading branch information
DeltaGW2 authored Nov 16, 2023
2 parents f61d04e + 9b013f8 commit 7080300
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
19 changes: 12 additions & 7 deletions src/GUI/Widgets/Addons/AddonItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ namespace GUI
void AddonItem(Addon* aAddon)
{
if (aAddon->State == EAddonState::NotLoadedDuplicate ||
aAddon->State == EAddonState::Incompatible)
aAddon->State == EAddonState::Incompatible ||
aAddon->Definitions == nullptr)
{
return;
}
Expand Down Expand Up @@ -34,7 +35,8 @@ namespace GUI
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetColumnWidth() - 120.0f);
{
ImGui::BeginGroup();
if (aAddon->State == EAddonState::Loaded)
if (aAddon->State == EAddonState::Loaded &&
!(aAddon->Definitions->Unload == nullptr || aAddon->Definitions->HasFlag(EAddonFlags::DisableHotloading)))
{
if (ImGui::Button(("Disable##" + sig).c_str(), ImVec2(120.0f, 24.0f)))
{
Expand Down Expand Up @@ -62,14 +64,17 @@ namespace GUI
}
}
}
if (ImGui::Button(("Uninstall##" + sig).c_str(), ImVec2(120.0f, 24.0f)))
if (!(aAddon->Definitions->Unload == nullptr || aAddon->Definitions->HasFlag(EAddonFlags::DisableHotloading)))
{
for (auto& it : Loader::Addons)
if (ImGui::Button(("Uninstall##" + sig).c_str(), ImVec2(120.0f, 24.0f)))
{
if (it.second->Definitions == aAddon->Definitions)
for (auto& it : Loader::Addons)
{
LogDebug(CH_GUI, "Uninstall called: %s", it.second->Definitions->Name);
Loader::QueueAddon(ELoaderAction::Uninstall, it.first);
if (it.second->Definitions == aAddon->Definitions)
{
LogDebug(CH_GUI, "Uninstall called: %s", it.second->Definitions->Name);
Loader::QueueAddon(ELoaderAction::Uninstall, it.first);
}
}
}
}
Expand Down
20 changes: 15 additions & 5 deletions src/GUI/Widgets/Debug/DebugWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,19 +249,29 @@ namespace GUI
std::string state = "State: ";
switch (addon->State)
{
case EAddonState::None: state.append("None"); break;
case EAddonState::Loaded: state.append("Loaded"); break;
case EAddonState::NotLoaded: state.append("NotLoaded"); break;
case EAddonState::None: state.append("None"); break;
case EAddonState::Loaded: state.append("Loaded"); break;
case EAddonState::NotLoaded: state.append("NotLoaded"); break;
case EAddonState::NotLoadedDuplicate: state.append("NotLoadedDuplicate"); break;
case EAddonState::Incompatible: state.append("Incompatible"); break;
case EAddonState::IncompatibleAPI: state.append("IncompatibleAPI"); break;
case EAddonState::Incompatible: state.append("Incompatible"); break;
case EAddonState::IncompatibleAPI: state.append("IncompatibleAPI"); break;
}

ImGui::TextDisabled(state.c_str());
ImGui::TextDisabled("Module: %p", addon->Module);
ImGui::TextDisabled("Module Size: %u", addon->ModuleSize);
ImGui::TextDisabled("AddonDefs: %p", addon->Definitions);

if (addon->Definitions != nullptr)
{
if (ImGui::SmallButton("Memory Editor"))
{
memEditor.Open = true;
memPtr = addon->Definitions;
memSz = sizeof(AddonDefinition);
}
}

ImGui::TreePop();
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Loader/AddonDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ bool AddonDefinition::HasMinimumRequirements()
Name &&
Author &&
Description &&
Load &&
(HasFlag(EAddonFlags::DisableHotloading) || Unload))
Load)
{
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Loader/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace Loader
/* doesn't full fill min reqs */
if (hMod && !defs->HasMinimumRequirements())
{
LogWarning(CH_LOADER, "\"%s\" does not fulfill minimum requirements. At least define Name, Version, Author, Description as well as Load and Unload functions. Incompatible.", path);
LogWarning(CH_LOADER, "\"%s\" does not fulfill minimum requirements. At least define Name, Version, Author, Description as well as the Load function. Incompatible.", path);
addon->State = EAddonState::Incompatible;
FreeLibrary(hMod);
return;
Expand All @@ -162,7 +162,7 @@ namespace Loader
// if defs defined && not the same path && signature the same though
if (it.second->Definitions != nullptr && it.first != aPath && it.second->Definitions->Signature == defs->Signature)
{
LogWarning(CH_LOADER, "\"%s\" or another addon with sig%d is already loaded. Added to blacklist.", path, defs->Signature);
LogWarning(CH_LOADER, "\"%s\" or another addon with this signature (%d) is already loaded. Added to blacklist.", path, defs->Signature);
addon->State = EAddonState::NotLoadedDuplicate;
FreeLibrary(hMod);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool FindFunction(HMODULE aModule, LPVOID aFunction, LPCSTR aName)
{
FARPROC* fp = (FARPROC*)aFunction;
*fp = aModule ? GetProcAddress(aModule, aName) : 0;
return (fp != 0);
return (*fp != 0);
}

std::string WStrToStr(std::wstring& aWstring)
Expand Down

0 comments on commit 7080300

Please sign in to comment.