From 0fea2b97a4f631724b9b610ad8d1eaad44a74385 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Mon, 17 Jul 2017 12:59:49 +1000 Subject: [PATCH] Remove exported function create_server_list() The guts of this function doesn't need to be in server.c - it only uses extern server functions so it makes sense just to move it into the body of function_servers(), the only caller. That means it's no longer accessible for loadable modules, but it isn't much use for them anyway. They can always directly access the server list if they need that info. (Requires rolling the module table version). --- Changelog | 2 ++ include/module.h | 3 +-- include/modval.h | 1 - include/server.h | 1 - source/functions.c | 24 +++++++++++++++++++++++- source/modules.c | 1 - source/server.c | 26 -------------------------- 7 files changed, 26 insertions(+), 32 deletions(-) diff --git a/Changelog b/Changelog index cb2277c..0fc2f01 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ [Changes 1.2.2] +* Remove exported function create_server_list(). (caf) + * Fix $myservers(1) to only return registered server refnums, so it now works the way EPIC does which was always the intention. (caf) diff --git a/include/module.h b/include/module.h index 8a7c878..e4ca2ec 100644 --- a/include/module.h +++ b/include/module.h @@ -10,7 +10,7 @@ * if we change the table below, we change this module number to the * current date (YYYYMMDDxx where xx is a serial number). */ -#define MODULE_VERSION 2017071002UL +#define MODULE_VERSION 2017071701UL #include "struct.h" @@ -253,7 +253,6 @@ enum FUNCTION_VALUE ADD_TO_SERVER_LIST, BUILD_SERVER_LIST, DISPLAY_SERVER_LIST, - CREATE_SERVER_LIST, PARSE_SERVER_INFO, SERVER_LIST_SIZE, /* misc server/nickname functions */ diff --git a/include/modval.h b/include/modval.h index 5b0758e..77a95fd 100644 --- a/include/modval.h +++ b/include/modval.h @@ -499,7 +499,6 @@ extern Function_ptr *global; #define add_to_server_list (*(void (*)(char *, int , char *, char *, char *, int , int ))global[ADD_TO_SERVER_LIST]) #define build_server_list (*(int (*)(char *))global[BUILD_SERVER_LIST]) #define display_server_list (*(void (*)(void ))global[DISPLAY_SERVER_LIST]) -#define create_server_list (*(char *(*)(char *))global[CREATE_SERVER_LIST]) #define parse_server_info (*(void (*)(char *, char **, char **, char **, char **))global[PARSE_SERVER_INFO]) #define server_list_size (*(int (*)(void ))global[SERVER_LIST_SIZE]) diff --git a/include/server.h b/include/server.h index be23ba9..c70b471 100644 --- a/include/server.h +++ b/include/server.h @@ -216,7 +216,6 @@ extern SGroup *server_group_list; char *BX_get_server_itsname (int); char *get_server_pass (int); int BX_find_in_server_list (char *, int); - char *BX_create_server_list (char *); void BX_set_server_motd (int, int); int BX_get_server_motd (int); int BX_get_server_operator (int); diff --git a/source/functions.c b/source/functions.c index 5c60c6c..ab916e5 100644 --- a/source/functions.c +++ b/source/functions.c @@ -1903,7 +1903,29 @@ BUILT_IN_FUNCTION(function_channels, input) BUILT_IN_FUNCTION(function_servers, input) { - RETURN_MSTR(create_server_list(input)); /* DONT USE RETURN_STR HERE! */ + const int n_servers = server_list_size(); + int i; + int do_read = 0; + char *value = NULL; + + if (input && *input == '1') + do_read = 1; + + for (i = 0; i < n_servers; i++) + { + if (do_read) + { + if (is_server_connected(i)) + m_s3cat(&value, " ", ltoa(i)); + } + else + { + if (is_server_open(i)) + m_s3cat(&value, " ", get_server_itsname(i)); + } + } + + RETURN_MSTR(value); } BUILT_IN_FUNCTION(function_pid, input) diff --git a/source/modules.c b/source/modules.c index 5a12d32..18b73e2 100644 --- a/source/modules.c +++ b/source/modules.c @@ -248,7 +248,6 @@ static int already_done = 0; global_table[ADD_TO_SERVER_LIST] = (Function_ptr) BX_add_to_server_list; global_table[BUILD_SERVER_LIST] = (Function_ptr) BX_build_server_list; global_table[DISPLAY_SERVER_LIST] = (Function_ptr) BX_display_server_list; - global_table[CREATE_SERVER_LIST] = (Function_ptr) BX_create_server_list; global_table[PARSE_SERVER_INFO] = (Function_ptr) BX_parse_server_info; global_table[SERVER_LIST_SIZE] = (Function_ptr) BX_server_list_size; /* misc server/nickname functions */ diff --git a/source/server.c b/source/server.c index 1d1022b..36e2313 100644 --- a/source/server.c +++ b/source/server.c @@ -2618,32 +2618,6 @@ extern void BX_close_all_server (void) } } -extern char *BX_create_server_list (char *input) -{ - int i; - int do_read = 0; - char *value = NULL; - - if (input && *input == '1') - do_read = 1; - - for (i = 0; i < number_of_servers; i++) - { - if (do_read) - { - if (is_server_connected(i)) - m_s3cat(&value, " ", ltoa(i)); - } - else - { - if (is_server_open(i)) - m_s3cat(&value, " ", get_server_itsname(i)); - } - } - - return value; -} - void BX_server_disconnect(int i, char *args) { char *message;