From 8c2a8461db64e92ac09f202589009ee05c69626d Mon Sep 17 00:00:00 2001 From: fusion32 Date: Tue, 18 Nov 2025 15:17:29 -0300 Subject: fix problem with connection input + allow login server to query worlds There was a small problem with how we computed the size of the packet "header". It was unlikely to manifest tho, because it's at the beginning of a TCP message and TCP segments aren't that small, unless the whole message is that small. I'm also allowing login servers to query for world information to allow a basic form of `STATUS` to be implemented. --- src/connections.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/connections.cc') diff --git a/src/connections.cc b/src/connections.cc index b851954..b148292 100644 --- a/src/connections.cc +++ b/src/connections.cc @@ -189,9 +189,9 @@ void CheckConnectionInput(TConnection *Connection, int Events){ int ReadSize = Connection->RWSize; if(ReadSize == 0){ if(Connection->RWPosition < 2){ - ReadSize = 2 - Connection->RWPosition; + ReadSize = 2; }else{ - ReadSize = 6 - Connection->RWPosition; + ReadSize = 6; } ASSERT(ReadSize > 0); } @@ -392,7 +392,8 @@ void CheckConnectionQueryRequest(TConnection *Connection){ SendQueryFailed(Connection); } }else if(Connection->ApplicationType == APPLICATION_TYPE_LOGIN){ - if(QueryType == QUERY_LOGIN_ACCOUNT){ + // TODO(fusion): Probably have a custom query for querying world status? + if(QueryType == QUERY_LOGIN_ACCOUNT || QueryType == QUERY_GET_WORLDS){ ProcessQuery(Connection); }else{ LOG_ERR("Invalid LOGIN query %d (%s) from %s", @@ -599,7 +600,7 @@ void ProcessConnections(void){ } for(int i = 0; i < g_Config.MaxConnections; i += 1){ - if(g_Connections[i].State == CONNECTION_FREE || g_Connections[i].Socket == -1){ + if(g_Connections[i].State == CONNECTION_FREE){ continue; } -- cgit v1.2.3