Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .ini options to change logger level #12

Merged
merged 1 commit into from
Oct 12, 2024
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
11 changes: 11 additions & 0 deletions src/Gothic/Hooks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ namespace GOTHIC_NAMESPACE {
}
auto Partial_DefineExternals_Ulfi = Union::CreatePartialHook(oCGame_DefineExternals_Ulfi, &DefineExternals_Ulfi_PartialHook);

// G1: 0x00424AF0 public: void __thiscall CGameManager::Run(void)
// G1A: 0x004275D0 public: void __thiscall CGameManager::Run(void)
// G2: 0x004254F0 public: void __thiscall CGameManager::Run(void)
// G2A: 0x00425830 public: void __thiscall CGameManager::Run(void)
void* CGameManager_Run = reinterpret_cast<void*>(zSwitch(0x00424AF0, 0x004275D0, 0x004254F0, 0x00425830));
void __fastcall CGameManager_Run_PartialHook() {
ApplyOptions();
};
auto Partial_CGameManager_Run = Union::CreatePartialHook(CGameManager_Run, CGameManager_Run_PartialHook);



// G2A: 0x00758130 public: int __thiscall oCNpc::ActivateDialogCam(float)
// auto Ivk_oCNpc_ActivateDialogCam = Union::CreateHook(reinterpret_cast<void*>(0x00758130), &oCNpc::ActivateDialogCam_Hook);
Expand Down
43 changes: 43 additions & 0 deletions src/Gothic/Options.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace GOTHIC_NAMESPACE
{
void ApplyOptions()
{
if (GetGameVersion() != ENGINE)
{
return;
}

Union::Array<NH::Logger*> loggers = NH::LoggerFactory::GetInstance()->GetLoggers();
{
static NH::Logger* log = NH::CreateLogger("zMultilogue::GothicOptions");
zSTRING unionValue = zoptions->ReadString("ZMULTILOGUE", "LoggerLevelUnion", "INFO");
zSTRING zSpyValue = zoptions->ReadString("ZMULTILOGUE", "LoggerLevelZSpy", "DEBUG");

for (auto it = loggers.begin(); it != loggers.end(); it++)
{
auto* unionAdapter = (*it)->GetAdapter<NH::UnionConsoleLoggerAdapter>();
if (unionAdapter)
{
NH::LoggerLevel level = NH::StringToLoggerLevel(unionValue.ToChar());
if (level != unionAdapter->DEFAULT_LEVEL)
{
NH::UnionConsoleLoggerAdapter::DEFAULT_LEVEL = level;
log->Info("Logger level for UnionConsoleLoggerAdapter: {0}", unionValue.ToChar());
}
unionAdapter->SetLoggerLevel(level);
}
auto* zSpyAdapter = (*it)->GetAdapter<NH::ZSpyLoggerAdapter>();
if (zSpyAdapter)
{
NH::LoggerLevel level = NH::StringToLoggerLevel(zSpyValue.ToChar());
if (level != zSpyAdapter->DEFAULT_LEVEL)
{
NH::ZSpyLoggerAdapter::DEFAULT_LEVEL = level;
log->Info("Logger level for ZSpyLoggerAdapter: {0}", unionValue.ToChar());
}
zSpyAdapter->SetLoggerLevel(level);
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/Gothic/zMul_Helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace GOTHIC_NAMESPACE
//log->Debug("Self and other are the same.");
return;
}
log->Trace("Synching {0} with {1}", self->idx, other->idx);
// log->Trace("Synching {0} with {1}", self->idx, other->idx);
oCMsgConversation* msg = zNEW(oCMsgConversation)(oCMsgConversation::EV_WAITTILLEND,other);
int nr = other -> GetEM()->GetNumMessages();
zCEventMessage* watch = nullptr;
Expand Down
3 changes: 2 additions & 1 deletion src/Plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
#include "Gothic/zMul_Distance.hpp"
#include "Gothic/zMultilogue.hpp"
#include "Gothic/Externals.hpp"
#include "Gothic/Hooks.hpp"
#include "Gothic/Options.hpp"
#include "Gothic/Hooks.hpp"