From b856fa437957baeb98c4e7b51b02306e2d233fd8 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 16 Jul 2022 22:38:41 +0300 Subject: [PATCH 52/52] Disable metaserver functionality on emscripten build There is no curl functionality that it depends on. See osdn #45105 Signed-off-by: Marko Lindqvist --- client/servers.c | 23 ++++++++++++++++++++--- gen_headers/freeciv_config.h.in | 4 ++++ gen_headers/meson_freeciv_config.h.in | 4 ++++ server/meta.c | 13 +++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/client/servers.c b/client/servers.c index 8c66229d45..a013c033aa 100644 --- a/client/servers.c +++ b/client/servers.c @@ -87,6 +87,7 @@ struct server_scan { struct srv_list srvrs; int sock; +#ifdef FREECIV_META_ENABLED /* Only used for metaserver */ struct { enum server_scan_status status; @@ -97,13 +98,16 @@ struct server_scan { const char *urlpath; struct netfile_write_cb_data mem; } meta; +#endif /* FREECIV_META_ENABLED */ }; extern enum announce_type announce; -static bool begin_metaserver_scan(struct server_scan *scan); static void delete_server_list(struct server_list *server_list); +#ifdef FREECIV_META_ENABLED +static bool begin_metaserver_scan(struct server_scan *scan); + /**********************************************************************//** The server sends a stream in a registry 'ini' type format. Read it using secfile functions and fill the server_list structs. @@ -309,6 +313,7 @@ static bool begin_metaserver_scan(struct server_scan *scan) return retval; } +#endif /* FREECIV_META_ENABLED */ /**********************************************************************//** Frees everything associated with a server list including @@ -727,6 +732,12 @@ struct server_scan *server_scan_begin(enum server_scan_type type, struct server_scan *scan; bool ok = FALSE; +#ifndef FREECIV_META_ENABLED + if (type == SERVER_SCAN_GLOBAL) { + return NULL; + } +#endif /* FREECIV_META_ENABLED */ + scan = fc_calloc(1, sizeof(*scan)); scan->type = type; scan->error_func = error_func; @@ -736,6 +747,7 @@ struct server_scan *server_scan_begin(enum server_scan_type type, switch (type) { case SERVER_SCAN_GLOBAL: { +#ifdef FREECIV_META_ENABLED int thr_ret; fc_init_mutex(&scan->meta.mutex); @@ -746,12 +758,13 @@ struct server_scan *server_scan_begin(enum server_scan_type type, } else { ok = TRUE; } +#endif /* FREECIV_META_ENABLED */ } break; case SERVER_SCAN_LOCAL: ok = begin_lanserver_scan(scan); break; - default: + case SERVER_SCAN_LAST: break; } @@ -798,6 +811,7 @@ enum server_scan_status server_scan_poll(struct server_scan *scan) switch (scan->type) { case SERVER_SCAN_GLOBAL: +#ifdef FREECIV_META_ENABLED { enum server_scan_status status; @@ -807,11 +821,12 @@ enum server_scan_status server_scan_poll(struct server_scan *scan) return status; } +#endif /* FREECIV_META_ENABLED */ break; case SERVER_SCAN_LOCAL: return get_lan_server_list(scan); break; - default: + case SERVER_SCAN_LAST: break; } @@ -842,6 +857,7 @@ void server_scan_finish(struct server_scan *scan) } if (scan->type == SERVER_SCAN_GLOBAL) { +#ifdef FREECIV_META_ENABLED /* Signal metaserver scan thread to stop */ fc_allocate_mutex(&scan->meta.mutex); scan->meta.status = SCAN_STATUS_ABORT; @@ -870,6 +886,7 @@ void server_scan_finish(struct server_scan *scan) FC_FREE(scan->meta.mem.mem); scan->meta.mem.mem = NULL; } +#endif /* FREECIV_META_ENABLED */ } else { if (scan->sock >= 0) { fc_closesocket(scan->sock); diff --git a/gen_headers/freeciv_config.h.in b/gen_headers/freeciv_config.h.in index 73e48d53ef..fbadeb6562 100644 --- a/gen_headers/freeciv_config.h.in +++ b/gen_headers/freeciv_config.h.in @@ -29,6 +29,10 @@ /* Metaserver URL */ #undef FREECIV_META_URL +#ifndef __EMSCRIPTEN__ +#define FREECIV_META_ENABLED +#endif /* __EMSCRIPTEN__ */ + /* Month next version will be released */ #undef FREECIV_RELEASE_MONTH diff --git a/gen_headers/meson_freeciv_config.h.in b/gen_headers/meson_freeciv_config.h.in index 0955be1110..077762c7ec 100644 --- a/gen_headers/meson_freeciv_config.h.in +++ b/gen_headers/meson_freeciv_config.h.in @@ -48,6 +48,10 @@ /* Metaserver URL */ #mesondefine FREECIV_META_URL +#ifndef __EMSCRIPTEN__ +#define FREECIV_META_ENABLED +#endif /* __EMSCRIPTEN__ */ + /* Default modpack list URL */ #mesondefine MODPACK_LIST_URL diff --git a/server/meta.c b/server/meta.c index d5253c6beb..49248177d0 100644 --- a/server/meta.c +++ b/server/meta.c @@ -72,7 +72,9 @@ static int meta_retry_wait = 0; static char meta_patches[256] = ""; static char meta_message[256] = ""; +#ifdef FREECIV_META_ENABLED static fc_thread *meta_srv_thread = NULL; +#endif /* FREECIV_META_ENABLED */ /*********************************************************************//** The default metaserver patches for this server @@ -114,6 +116,7 @@ const char *get_meta_message_string(void) return meta_message; } +#ifdef FREECIV_META_ENABLED /*********************************************************************//** The server metaserver type *************************************************************************/ @@ -125,6 +128,7 @@ static const char *get_meta_type_string(void) return NULL; } +#endif /* FREECIV_META_ENABLED */ /*********************************************************************//** The metaserver message set by user @@ -200,6 +204,7 @@ char *meta_addr_port(void) return srvarg.metaserver_addr; } +#ifdef FREECIV_META_ENABLED /*********************************************************************//** We couldn't find or connect to the metaserver. *************************************************************************/ @@ -441,6 +446,7 @@ static bool send_to_metaserver(enum meta_flag flag) return TRUE; } +#endif /* FREECIV_META_ENABLED */ /*********************************************************************//** Stop sending updates to metaserver @@ -483,6 +489,12 @@ bool is_metaserver_open(void) *************************************************************************/ bool send_server_info_to_metaserver(enum meta_flag flag) { +#ifndef FREECIV_META_ENABLED + + return FALSE; + +#else /* FREECIV_META_ENABLED */ + static struct timer *last_send_timer = NULL; static bool want_update; @@ -541,4 +553,5 @@ bool send_server_info_to_metaserver(enum meta_flag flag) want_update = FALSE; return send_to_metaserver(flag); +#endif /* FREECIV_META_ENABLED */ } -- 2.35.1