[Monitor] Yeet (#529)
This commit is contained in:
parent
77345f9944
commit
8adec3e678
@ -57,7 +57,6 @@ namespace Components
|
||||
Loader::Register(new IPCPipe());
|
||||
Loader::Register(new MapDump());
|
||||
Loader::Register(new ModList());
|
||||
Loader::Register(new Monitor());
|
||||
Loader::Register(new Network());
|
||||
Loader::Register(new Session());
|
||||
Loader::Register(new Theatre());
|
||||
|
@ -80,7 +80,6 @@ namespace Components
|
||||
#include "Modules/Console.hpp"
|
||||
#include "Modules/UIScript.hpp"
|
||||
#include "Modules/ModList.hpp"
|
||||
#include "Modules/Monitor.hpp"
|
||||
#include "Modules/Network.hpp"
|
||||
#include "Modules/Theatre.hpp"
|
||||
#include "Modules/QuickPatch.hpp"
|
||||
|
@ -277,7 +277,7 @@ namespace Components
|
||||
|
||||
void Auth::StoreKey()
|
||||
{
|
||||
if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled() && !Monitor::IsEnabled() && Auth::GuidKey.isValid())
|
||||
if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled() && Auth::GuidKey.isValid())
|
||||
{
|
||||
Proto::Auth::Certificate cert;
|
||||
cert.set_token(Auth::GuidToken.toString());
|
||||
|
@ -788,7 +788,7 @@ namespace Components
|
||||
|
||||
void Console::FreeNativeConsole()
|
||||
{
|
||||
if (!Monitor::IsEnabled() && !Flags::HasFlag("stdout") && (!Dedicated::IsEnabled() || Flags::HasFlag("console")) && !Loader::IsPerformingUnitTests())
|
||||
if (!Flags::HasFlag("stdout") && (!Dedicated::IsEnabled() || Flags::HasFlag("console")) && !Loader::IsPerformingUnitTests())
|
||||
{
|
||||
FreeConsole();
|
||||
}
|
||||
@ -919,15 +919,10 @@ namespace Components
|
||||
if (Loader::IsPerformingUnitTests()) return;
|
||||
|
||||
// External console
|
||||
if (Flags::HasFlag("stdout") || Monitor::IsEnabled())
|
||||
if (Flags::HasFlag("stdout"))
|
||||
{
|
||||
#ifndef DEBUG
|
||||
if (!Monitor::IsEnabled())
|
||||
#endif
|
||||
{
|
||||
Utils::Hook(0x4B2080, Console::StdOutPrint, HOOK_JUMP).install()->quick();
|
||||
Utils::Hook(0x43D570, Console::StdOutError, HOOK_JUMP).install()->quick();
|
||||
}
|
||||
Utils::Hook(0x4B2080, Console::StdOutPrint, HOOK_JUMP).install()->quick();
|
||||
Utils::Hook(0x43D570, Console::StdOutError, HOOK_JUMP).install()->quick();
|
||||
}
|
||||
else if (Flags::HasFlag("console") || ZoneBuilder::IsEnabled()) // ZoneBuilder uses the game's console, until the native one is adapted.
|
||||
{
|
||||
@ -936,7 +931,7 @@ namespace Components
|
||||
// Redirect input (]command)
|
||||
Utils::Hook(0x47025A, 0x4F5770, HOOK_CALL).install()->quick();
|
||||
|
||||
Utils::Hook(0x60BB68, []()
|
||||
Utils::Hook(0x60BB68, []
|
||||
{
|
||||
Console::ShowAsyncConsole();
|
||||
}, HOOK_CALL).install()->quick();
|
||||
|
@ -555,7 +555,7 @@ namespace Components
|
||||
{
|
||||
Friends::LoggedOn = false;
|
||||
|
||||
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled())
|
||||
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())
|
||||
return;
|
||||
|
||||
Friends::UIStreamFriendly = Dvar::Register<bool>("ui_streamFriendly", false, Game::DVAR_ARCHIVE, "Stream friendly UI");
|
||||
@ -720,7 +720,7 @@ namespace Components
|
||||
|
||||
Friends::~Friends()
|
||||
{
|
||||
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled()) return;
|
||||
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) return;
|
||||
|
||||
Friends::StoreFriendsList();
|
||||
|
||||
|
@ -204,7 +204,7 @@ namespace Components
|
||||
|
||||
IPCPipe::IPCPipe()
|
||||
{
|
||||
if (Dedicated::IsEnabled() || Monitor::IsEnabled() || Loader::IsPerformingUnitTests() || ZoneBuilder::IsEnabled()) return;
|
||||
if (Dedicated::IsEnabled() || Loader::IsPerformingUnitTests() || ZoneBuilder::IsEnabled()) return;
|
||||
|
||||
// Server pipe
|
||||
IPCPipe::ServerPipe.onConnect(IPCPipe::ConnectClient);
|
||||
|
@ -1,80 +0,0 @@
|
||||
#include <STDInclude.hpp>
|
||||
#undef getch
|
||||
#undef ungetch
|
||||
#include <conio.h>
|
||||
|
||||
namespace Components
|
||||
{
|
||||
bool Monitor::IsEnabled()
|
||||
{
|
||||
static std::optional<bool> flag;
|
||||
|
||||
if (!flag.has_value())
|
||||
{
|
||||
flag.emplace(Flags::HasFlag("monitor"));
|
||||
}
|
||||
|
||||
return flag.value();
|
||||
}
|
||||
|
||||
int __stdcall Monitor::EntryPoint(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nShowCmd*/)
|
||||
{
|
||||
Utils::Hook::Call<void()>(0x4D8220)(); // Dvar_Init
|
||||
Utils::Hook::Call<void()>(0x4D2280)(); // SL_Init
|
||||
Utils::Hook::Call<void()>(0x47F390)(); // Swap_Init
|
||||
Utils::Hook::Call<void()>(0x60AD10)(); // Com_InitDvars
|
||||
Utils::Hook::Call<void()>(0x420830)(); // Com_InitHunkMemory
|
||||
Utils::Hook::Call<void()>(0x4A62A0)(); // LargeLocalInit
|
||||
Utils::Hook::Call<void(unsigned int)>(0x502580)(static_cast<unsigned int>(__rdtsc())); // Netchan_Init
|
||||
Game::NET_Init();
|
||||
|
||||
Utils::Time::Interval interval;
|
||||
while (!interval.elapsed(15s))
|
||||
{
|
||||
Utils::Hook::Call<void()>(0x49F0B0)(); // Com_ClientPacketEvent
|
||||
//Session::RunFrame();
|
||||
Node::RunFrame();
|
||||
ServerList::Frame();
|
||||
|
||||
std::this_thread::sleep_for(10ms);
|
||||
}
|
||||
|
||||
auto list = ServerList::GetList();
|
||||
if (!list)
|
||||
{
|
||||
printf("1 IW4x player=0|server=0 Returned list was null\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int servers = list->size();
|
||||
int players = 0;
|
||||
|
||||
for (unsigned int i = 0; i < list->size(); ++i)
|
||||
{
|
||||
players += list->at(i).clients;
|
||||
}
|
||||
|
||||
printf("0 IW4x player=%d|server=%d Servers successfully parsed\n", players, servers);
|
||||
|
||||
Utils::Hook::Call<void()>(0x430630)(); // LargeLocalReset
|
||||
Utils::Hook::Call<void()>(0x4A0460)(); // Hunk_ClearTempMemory
|
||||
Utils::Hook::Call<void()>(0x4AB3A0)(); // Hunk_ClearTempMemoryHigh
|
||||
Utils::Hook::Call<void()>(0x4B3AD0)(); // SL_Shutdown
|
||||
Utils::Hook::Call<void()>(0x502C50)(); // Dvar_Shutdown
|
||||
|
||||
if (*Game::ip_socket && *Game::ip_socket != INVALID_SOCKET)
|
||||
{
|
||||
closesocket(*Game::ip_socket);
|
||||
}
|
||||
|
||||
WSACleanup();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Monitor::Monitor()
|
||||
{
|
||||
if (!Monitor::IsEnabled()) return;
|
||||
|
||||
Utils::Hook(0x4513DA, Monitor::EntryPoint, HOOK_JUMP).install()->quick();
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace Components
|
||||
{
|
||||
class Monitor : public Component
|
||||
{
|
||||
public:
|
||||
Monitor();
|
||||
|
||||
static bool IsEnabled();
|
||||
|
||||
private:
|
||||
static int __stdcall EntryPoint(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
|
||||
};
|
||||
}
|
@ -73,18 +73,10 @@ namespace Components
|
||||
{
|
||||
Proto::Node::List list;
|
||||
|
||||
if (Monitor::IsEnabled())
|
||||
{
|
||||
std::string nodes = Utils::IO::ReadFile("players/nodes_default.dat");
|
||||
if (nodes.empty() || !list.ParseFromString(Utils::Compression::ZLib::Decompress(nodes))) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
FileSystem::File defaultNodes("nodes_default.dat");
|
||||
if (!defaultNodes.exists() || !list.ParseFromString(Utils::Compression::ZLib::Decompress(defaultNodes.getBuffer()))) return;
|
||||
}
|
||||
FileSystem::File defaultNodes("nodes_default.dat");
|
||||
if (!defaultNodes.exists() || !list.ParseFromString(Utils::Compression::ZLib::Decompress(defaultNodes.getBuffer()))) return;
|
||||
|
||||
for (int i = 0; i < list.nodes_size(); ++i)
|
||||
for (auto i = 0; i < list.nodes_size(); ++i)
|
||||
{
|
||||
const std::string& addr = list.nodes(i);
|
||||
|
||||
@ -171,7 +163,7 @@ namespace Components
|
||||
|
||||
if (!Dedicated::IsEnabled())
|
||||
{
|
||||
if (ServerList::useMasterServer) return; // don't run node frame if master server is active
|
||||
if (ServerList::UseMasterServer) return; // don't run node frame if master server is active
|
||||
|
||||
if (*Game::clcState > 0)
|
||||
{
|
||||
@ -251,7 +243,7 @@ namespace Components
|
||||
|
||||
if (list.isnode() && (!list.port() || list.port() == address.getPort()))
|
||||
{
|
||||
if (!Dedicated::IsEnabled() && ServerList::IsOnlineList() && !ServerList::useMasterServer && list.protocol() == PROTOCOL)
|
||||
if (!Dedicated::IsEnabled() && ServerList::IsOnlineList() && !ServerList::UseMasterServer && list.protocol() == PROTOCOL)
|
||||
{
|
||||
Logger::Debug("Inserting {} into the serverlist", address.getString());
|
||||
ServerList::InsertRequest(address);
|
||||
@ -361,8 +353,7 @@ namespace Components
|
||||
Node::LoadNodes();
|
||||
};
|
||||
|
||||
if (Monitor::IsEnabled()) Network::OnStart(loadNodes);
|
||||
else Scheduler::OnGameInitialized(loadNodes, Scheduler::Pipeline::MAIN);
|
||||
Scheduler::OnGameInitialized(loadNodes, Scheduler::Pipeline::MAIN);
|
||||
|
||||
Network::OnStart([]
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace Components
|
||||
Dvar::Var ServerList::NETServerQueryLimit;
|
||||
Dvar::Var ServerList::NETServerFrames;
|
||||
|
||||
bool ServerList::useMasterServer = true;
|
||||
bool ServerList::UseMasterServer = true;
|
||||
|
||||
std::vector<ServerList::ServerInfo>* ServerList::GetList()
|
||||
{
|
||||
@ -51,7 +51,7 @@ namespace Components
|
||||
|
||||
bool ServerList::IsOnlineList()
|
||||
{
|
||||
return (Monitor::IsEnabled() || Dvar::Var("ui_netSource").get<int>() == 1);
|
||||
return (Dvar::Var("ui_netSource").get<int>() == 1);
|
||||
}
|
||||
|
||||
unsigned int ServerList::GetServerCount()
|
||||
@ -299,13 +299,13 @@ namespace Components
|
||||
{
|
||||
Logger::Print("Could not resolve address for {}:{}", masterServerName, masterPort);
|
||||
Toast::Show("cardicon_headshot", "^1Error", Utils::String::VA("Could not resolve address for %s:%u", masterServerName, masterPort), 5000);
|
||||
useMasterServer = false;
|
||||
UseMasterServer = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Toast::Show("cardicon_headshot", "Server Browser", "Fetching servers...", 3000);
|
||||
|
||||
useMasterServer = true;
|
||||
UseMasterServer = true;
|
||||
|
||||
ServerList::RefreshContainer.awatingList = true;
|
||||
ServerList::RefreshContainer.awaitTime = Game::Sys_Milliseconds();
|
||||
@ -675,7 +675,7 @@ namespace Components
|
||||
Logger::Print("We haven't received a response from the master within {} seconds!\n", (Game::Sys_Milliseconds() - ServerList::RefreshContainer.awaitTime) / 1000);
|
||||
Toast::Show("cardicon_headshot", "^1Error", "Failed to reach master server, using node servers instead.", 5000);
|
||||
|
||||
useMasterServer = false;
|
||||
UseMasterServer = false;
|
||||
Node::Synchronize();
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace Components
|
||||
static void UpdateVisibleInfo();
|
||||
|
||||
static bool GetMasterServer(const char* ip, int port, Game::netadr_t& address);
|
||||
static bool useMasterServer;
|
||||
static bool UseMasterServer;
|
||||
|
||||
private:
|
||||
enum Column
|
||||
|
@ -20,7 +20,7 @@ namespace Components
|
||||
|
||||
Console::FreeNativeConsole();
|
||||
|
||||
if (Loader::IsPerformingUnitTests() || Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled()) return;
|
||||
if (Loader::IsPerformingUnitTests() || Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) return;
|
||||
|
||||
Singleton::FirstInstance = (CreateMutexA(nullptr, FALSE, "iw4x_mutex") && GetLastError() != ERROR_ALREADY_EXISTS);
|
||||
|
||||
|
@ -144,7 +144,7 @@ namespace Components
|
||||
|
||||
Toast::Toast()
|
||||
{
|
||||
if (Dedicated::IsEnabled() || Monitor::IsEnabled() || ZoneBuilder::IsEnabled())
|
||||
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user