Skip to content

Commit 0cea513

Browse files
committed
fix subscription state for gsi
1 parent 9a56726 commit 0cea513

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/game/shared/gamestate/gamestate.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class CHTTPServerThread : public CThread
156156
m_SubscribedClientIds.erase( clientId );
157157
for ( std::size_t i = 0; i < size; i++ )
158158
{
159-
if ( *static_cast<int64_t*>( m_connectedClients[i]->userdata() ) == clientId )
159+
if ( GetClientId( *m_connectedClients[i] ) == clientId )
160160
{
161161
m_connectedClients[i] = m_connectedClients[size - 1];
162162
m_connectedClients.pop_back();
@@ -329,9 +329,19 @@ class CHTTPServerThread : public CThread
329329
data["d"] = pEvent->m_strParams;
330330
}
331331
const bool bUnprivileged = m_UnprivilegedMethods.find( pEvent->m_strEvent ) != m_UnprivilegedMethods.end();
332+
bool bNeedsSubscription = false;
333+
if ( !V_stricmp( pEvent->m_strEvent.c_str(), "gsi" ) )
334+
{
335+
bNeedsSubscription = true;
336+
}
332337
for ( auto conn : m_connectedClients )
333338
{
334-
if ( conn && ( bUnprivileged || m_iPrivilegedClientId == *static_cast<int64_t*>( conn->userdata() ) ) )
339+
if ( !conn )
340+
{
341+
continue;
342+
}
343+
int64_t clientId = GetClientId( *conn );
344+
if ( ( bUnprivileged || m_iPrivilegedClientId == clientId ) && ( !bNeedsSubscription || m_SubscribedClientIds.find(clientId) != m_SubscribedClientIds.end() ) )
335345
{
336346
conn->send_text( data.dump() );
337347
}

0 commit comments

Comments
 (0)