Fix $myservers(1) to only return registered server refnums
When $myservers() is called with an argument of 1 it is supposed to only return the refnums of servers that are registered (ie. those which it is legal to send a command to). This is the way EPIC works, and it was always intended to work this way in BX too. Also fix the warning about a NULL itsname - we use our name for the server if it isn't registered yet. Remove the slightly bogus use of strncat() while we're here, by removing the temporary stack buffer and just directly creating the result string with m_s3cat().
This commit is contained in:
@@ -1903,7 +1903,7 @@ BUILT_IN_FUNCTION(function_channels, input)
|
||||
|
||||
BUILT_IN_FUNCTION(function_servers, input)
|
||||
{
|
||||
return create_server_list(input); /* DONT USE RETURN_STR HERE! */
|
||||
RETURN_MSTR(create_server_list(input)); /* DONT USE RETURN_STR HERE! */
|
||||
}
|
||||
|
||||
BUILT_IN_FUNCTION(function_pid, input)
|
||||
|
||||
@@ -2622,32 +2622,24 @@ extern char *BX_create_server_list (char *input)
|
||||
{
|
||||
int i;
|
||||
int do_read = 0;
|
||||
char *value = NULL;
|
||||
char buffer[BIG_BUFFER_SIZE + 1];
|
||||
if (input && *input && *input == '1')
|
||||
char *value = NULL;
|
||||
|
||||
if (input && *input == '1')
|
||||
do_read = 1;
|
||||
*buffer = '\0';
|
||||
|
||||
for (i = 0; i < number_of_servers; i++)
|
||||
{
|
||||
if (server_list[i].read != -1)
|
||||
if (do_read)
|
||||
{
|
||||
if (do_read)
|
||||
{
|
||||
strncat(buffer, ltoa(i), BIG_BUFFER_SIZE);
|
||||
strncat(buffer, space, BIG_BUFFER_SIZE);
|
||||
continue;
|
||||
}
|
||||
if (server_list[i].itsname)
|
||||
{
|
||||
strncat(buffer, server_list[i].itsname, BIG_BUFFER_SIZE);
|
||||
strncat(buffer, space, BIG_BUFFER_SIZE);
|
||||
}
|
||||
else
|
||||
yell("Warning: server_list[%d].itsname is null and it shouldnt be", i);
|
||||
|
||||
if (is_server_connected(i))
|
||||
m_s3cat(&value, " ", ltoa(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_server_open(i))
|
||||
m_s3cat(&value, " ", get_server_itsname(i));
|
||||
}
|
||||
}
|
||||
malloc_strcpy(&value, buffer);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user