Skip to content

Commit

Permalink
Merge pull request #12 from Silver-Ore-Team/feature/options
Browse files Browse the repository at this point in the history
Add .ini options to change logger level
  • Loading branch information
muczc1wek authored Oct 12, 2024
2 parents fe60057 + 5477d41 commit 566fe55
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
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"

0 comments on commit 566fe55

Please sign in to comment.