Facepunch / garrysmod-issues

Garry's Mod issue tracker
145 stars 56 forks source link

SourceTV doesn't send ServerInfo #5635

Closed RaphaelIT7 closed 11 months ago

RaphaelIT7 commented 11 months ago

Details

When SourceTV got fixed I found this bug and mentioned it here and only now I looked into it. For some reason, the Server fails to send the SVC_ServerInfonet message and because of this, it appears that it's stuck on Authenticating with Steam...

The cause of this has something todo with CBaseServer::SendPendingServerInfo() failing to call CBaseClient::SendServerInfo();. Maybe m_bSendServerInfo isn't properly set, but as far as I can tell it should be set because CBaseClient::SetSignonState is called properly with SIGNONSTATE_CONNECTED

I hope this somewhat helps to fix it, but currently I cannot connect to any HLTV server except when I host it with one Gmod Instance and then join it with another Gmod instance that was launched with -multirun.

I got it working by overriding CBaseClient::SetSignonState and CBaseServer::SendPendingServerInfo (It's bad, but it fixes the issue):

std::unordered_map<void*, bool> client;
bool hook_CBaseClient_SetSignonState(void* funky_class, int state, int spawncount)
{
    if (state == 2)
        client[funky_class] = true;

    return detour_CBaseClient_SetSignonState.GetTrampoline<CBaseClient_SetSignonState>()(funky_class, state, spawncount);;
}

CBaseClient_SendServerInfo func_CBaseClient_SendServerInfo;
void hook_CBaseServer_SendPendingServerInfo(void* funky_class)
{
    IServer* srv = (IServer*)funky_class;
    if (!srv->IsHLTV())
        return;

    for (auto&[key, value] : client)
    {
        if (value)
        {
            func_CBaseClient_SendServerInfo(key);
            value = false;
        }
    }
}

[...]

NOTE: I tested it on a local Windows DS and on a Linux DS.

Steps to reproduce

  1. Create a dedicated Server
  2. Start SourceTV
  3. Try to connect
robotboy655 commented 11 months ago

Should be fixed now.