Merge pull request #91 from Rackover/fix_rcon_party_lobby

Fix rcon not working properly on party servers
This commit is contained in:
Dss0 2021-07-15 23:15:11 +02:00 committed by GitHub
commit f534a09e35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -121,7 +121,7 @@ namespace Components
}
bool Network::Address::isValid()
{
return (this->getType() != Game::netadrtype_t::NA_BAD && this->getType() >= Game::netadrtype_t::NA_BOT && this->getType() <= Game::netadrtype_t::NA_IP);
return (this->getType() != Game::netadrtype_t::NA_BAD && this->getType() >= Game::netadrtype_t::NA_BOT && this->getType() <= Game::netadrtype_t::NA_IP && this->address.ip.full != 0);
}
void Network::Handle(const std::string& packet, Utils::Slot<Network::Callback> callback)
{

View File

@ -25,9 +25,14 @@ namespace Components
}
else
{
if (!RCon::Password.empty() && *reinterpret_cast<int*>(0xB2C540) >= 5) // Get our state
auto addr = reinterpret_cast<Game::netadr_t*>(0xA5EA44);
if (!RCon::Password.empty())
{
Network::Address target(reinterpret_cast<Game::netadr_t*>(0xA5EA44));
Network::Address target(addr);
if (!target.isValid())
{
target = Party::Target();
}
if (target.isValid())
{
@ -71,6 +76,7 @@ namespace Components
Dvar::OnInit([]()
{
Dvar::Register<const char*>("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon");
Dvar::Register<bool>("log_rcon_requests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log");
});
Network::Handle("rcon", [](Network::Address address, const std::string& _data)
@ -107,9 +113,12 @@ namespace Components
static std::string outputBuffer;
outputBuffer.clear();
#ifdef DEBUG
Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data());
#ifndef DEBUG
if (Dvar::Var("log_rcon_requests").get<bool>())
#endif
{
Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data());
}
Logger::PipeOutput([](const std::string& output)
{