diff --git a/cpp/LunaHook/LunaHost/host.cpp b/cpp/LunaHook/LunaHost/host.cpp index 7aabddd4..a6646ea4 100644 --- a/cpp/LunaHook/LunaHost/host.cpp +++ b/cpp/LunaHook/LunaHost/host.cpp @@ -50,9 +50,9 @@ namespace Host::ProcessEventHandler OnConnect, OnDisconnect; Host::ThreadEventHandler OnCreate, OnDestroy; Host::HostInfoHandler OnHostInfo = 0; - bool has_consolethread = false; Host::HookInsertHandler HookInsert = 0; Host::EmbedCallback embedcallback = 0; + TextThread *consolethread = nullptr; void RemoveThreads(std::function removeIf) { std::vector threadsToRemove; @@ -218,8 +218,8 @@ namespace Host if (createconsole) { OnCreate(textThreadsByParams->try_emplace(console, console, HookParam{}, CONSOLE).first->second); + consolethread = &textThreadsByParams->at(console); Host::AddConsoleOutput(ProjectHomePage); - has_consolethread = true; } // CreatePipe(); @@ -411,7 +411,7 @@ namespace Host if (OnHostInfo) OnHostInfo(type, std::move(text)); - if (has_consolethread || (type != HOSTINFO::Console)) + if (consolethread || (type != HOSTINFO::Console)) { switch (type) { @@ -422,8 +422,8 @@ namespace Host text = L"[Game] " + text; break; } - if (has_consolethread) - GetThread(console).AddSentence(std::move(text)); + if (consolethread) + consolethread->AddSentence(std::move(text)); else if (type != HOSTINFO::Console) OnHostInfo(HOSTINFO::Console, std::move(text)); } diff --git a/cpp/LunaHook/LunaHost/textthread.cpp b/cpp/LunaHook/LunaHost/textthread.cpp index dcac2743..bb203979 100644 --- a/cpp/LunaHook/LunaHost/textthread.cpp +++ b/cpp/LunaHook/LunaHost/textthread.cpp @@ -65,8 +65,8 @@ void TextThread::Push(BYTE *data, int length) if (hp.type & FULL_STRING && converted.value().size() > 1) buffer.push_back(L'\n'); } - // else - // Host::AddConsoleOutput(INVALID_CODEPAGE); //死锁,且没必要 + else + Host::AddConsoleOutput(INVALID_CODEPAGE); UpdateFlushTime();