Merge branch 'fix-nocurl' into 'master'

Fix NOCURL compiling

See merge request KartKrew/Kart-Public!197
This commit is contained in:
Sal 2020-08-19 20:36:14 -04:00
commit a335d6b583
5 changed files with 91 additions and 36 deletions

View file

@ -1820,7 +1820,7 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node)
M_SortServerList(); M_SortServerList();
} }
#ifdef HAVE_THREADS #if defined (MASTERSERVER) && defined (HAVE_THREADS)
struct Fetch_servers_ctx struct Fetch_servers_ctx
{ {
int room; int room;
@ -1865,7 +1865,7 @@ Fetch_servers_thread (struct Fetch_servers_ctx *ctx)
free(ctx); free(ctx);
} }
#endif/*HAVE_THREADS*/ #endif/*defined (MASTERSERVER) && defined (HAVE_THREADS)*/
void CL_QueryServerList (msg_server_t *server_list) void CL_QueryServerList (msg_server_t *server_list)
{ {
@ -1902,9 +1902,8 @@ void CL_QueryServerList (msg_server_t *server_list)
void CL_UpdateServerList(boolean internetsearch, INT32 room) void CL_UpdateServerList(boolean internetsearch, INT32 room)
{ {
#ifdef HAVE_THREADS (void)internetsearch;
struct Fetch_servers_ctx *ctx; (void)room;
#endif
SL_ClearServerList(0); SL_ClearServerList(0);
@ -1921,9 +1920,12 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room)
if (netgame) if (netgame)
SendAskInfo(BROADCASTADDR); SendAskInfo(BROADCASTADDR);
#ifdef MASTERSERVER
if (internetsearch) if (internetsearch)
{ {
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
struct Fetch_servers_ctx *ctx;
ctx = malloc(sizeof *ctx); ctx = malloc(sizeof *ctx);
/* This called from M_Refresh so I don't use a mutex */ /* This called from M_Refresh so I don't use a mutex */
@ -1950,6 +1952,7 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room)
} }
#endif #endif
} }
#endif/*MASTERSERVER*/
} }
#endif // ifndef NONET #endif // ifndef NONET
@ -3423,8 +3426,10 @@ void D_QuitNetGame(void)
for (i = 0; i < MAXNETNODES; i++) for (i = 0; i < MAXNETNODES; i++)
if (nodeingame[i]) if (nodeingame[i])
HSendPacket(i, true, 0, 0); HSendPacket(i, true, 0, 0);
#ifdef MASTERSERVER
if (serverrunning && ms_RoomId > 0) if (serverrunning && ms_RoomId > 0)
UnregisterServer(); UnregisterServer();
#endif
} }
else if (servernode > 0 && servernode < MAXNETNODES && nodeingame[(UINT8)servernode]) else if (servernode > 0 && servernode < MAXNETNODES && nodeingame[(UINT8)servernode])
{ {
@ -3672,8 +3677,10 @@ boolean SV_SpawnServer(void)
if (netgame && I_NetOpenSocket) if (netgame && I_NetOpenSocket)
{ {
I_NetOpenSocket(); I_NetOpenSocket();
#ifdef MASTERSERVER
if (ms_RoomId > 0) if (ms_RoomId > 0)
RegisterServer(); RegisterServer();
#endif
} }
// non dedicated server just connect to itself // non dedicated server just connect to itself
@ -5391,7 +5398,9 @@ FILESTAMP
GetPackets(); GetPackets();
FILESTAMP FILESTAMP
#ifdef MASTERSERVER
MasterClient_Ticker(); MasterClient_Ticker();
#endif
if (client) if (client)
{ {
@ -5448,7 +5457,9 @@ FILESTAMP
// client send the command after a receive of the server // client send the command after a receive of the server
// the server send before because in single player is beter // the server send before because in single player is beter
#ifdef MASTERSERVER
MasterClient_Ticker(); // Acking the Master Server MasterClient_Ticker(); // Acking the Master Server
#endif
if (client) if (client)
{ {

View file

@ -681,4 +681,10 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
/// Hardware renderer: OpenGL /// Hardware renderer: OpenGL
#define GL_SHADERS #define GL_SHADERS
#ifdef HAVE_CURL
#define MASTERSERVER
#else
#undef UPDATE_ALERT
#endif
#endif // __DOOMDEF__ #endif // __DOOMDEF__

View file

@ -14,7 +14,9 @@ Documentation available here.
<http://mb.srb2.org/MS/tools/api/v1/> <http://mb.srb2.org/MS/tools/api/v1/>
*/ */
#ifdef HAVE_CURL
#include <curl/curl.h> #include <curl/curl.h>
#endif
#include "doomdef.h" #include "doomdef.h"
#include "d_clisrv.h" #include "d_clisrv.h"
@ -49,6 +51,8 @@ consvar_t cv_masterserver_token = {
NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */ NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
}; };
#ifdef MASTERSERVER
static int hms_started; static int hms_started;
static char *hms_api; static char *hms_api;
@ -666,10 +670,14 @@ HMS_set_api (char *api)
#endif #endif
} }
#endif/*MASTERSERVER*/
static void static void
MasterServer_Debug_OnChange (void) MasterServer_Debug_OnChange (void)
{ {
#ifdef MASTERSERVER
/* TODO: change to 'latest-log.txt' for log files revision. */ /* TODO: change to 'latest-log.txt' for log files revision. */
if (cv_masterserver_debug.value) if (cv_masterserver_debug.value)
CONS_Printf("Master server debug messages will appear in log.txt\n"); CONS_Printf("Master server debug messages will appear in log.txt\n");
#endif
} }

View file

@ -3310,7 +3310,7 @@ void M_SetupNextMenu(menu_t *menudef)
{ {
INT16 i; INT16 i;
#ifdef HAVE_THREADS #if defined (MASTERSERVER) && defined (HAVE_THREADS)
if (currentMenu == &MP_RoomDef || currentMenu == &MP_ConnectDef) if (currentMenu == &MP_RoomDef || currentMenu == &MP_ConnectDef)
{ {
I_lock_mutex(&ms_QueryId_mutex); I_lock_mutex(&ms_QueryId_mutex);
@ -3392,7 +3392,7 @@ void M_Ticker(void)
setmodeneeded = vidm_previousmode + 1; setmodeneeded = vidm_previousmode + 1;
} }
#ifdef HAVE_THREADS #if defined (MASTERSERVER) && defined (HAVE_THREADS)
I_lock_mutex(&ms_ServerList_mutex); I_lock_mutex(&ms_ServerList_mutex);
{ {
if (ms_ServerList) if (ms_ServerList)
@ -8603,8 +8603,9 @@ static boolean M_CheckMODVersion(int id)
} else } else
return true; return true;
} }
#endif/*UPDATE_ALERT*/
#ifdef HAVE_THREADS #if defined (MASTERSERVER) && defined (HAVE_THREADS)
static void static void
Check_new_version_thread (int *id) Check_new_version_thread (int *id)
{ {
@ -8613,7 +8614,9 @@ Check_new_version_thread (int *id)
okay = 0; okay = 0;
#ifdef UPDATE_ALERT
if (M_CheckMODVersion(*id)) if (M_CheckMODVersion(*id))
#endif
{ {
I_lock_mutex(&ms_QueryId_mutex); I_lock_mutex(&ms_QueryId_mutex);
{ {
@ -8657,8 +8660,7 @@ Check_new_version_thread (int *id)
free(id); free(id);
} }
#endif/*HAVE_THREADS*/ #endif/*defined (MASTERSERVER) && defined (HAVE_THREADS)*/
#endif/*UPDATE_ALERT*/
static void M_ConnectMenu(INT32 choice) static void M_ConnectMenu(INT32 choice)
{ {
@ -8699,7 +8701,7 @@ UINT32 roomIds[NUM_LIST_ROOMS];
static void M_RoomMenu(INT32 choice) static void M_RoomMenu(INT32 choice)
{ {
INT32 i; INT32 i;
#ifdef HAVE_THREADS #if defined (MASTERSERVER) && defined (HAVE_THREADS)
int *id; int *id;
#endif #endif
@ -8721,9 +8723,14 @@ static void M_RoomMenu(INT32 choice)
MP_RoomDef.prevMenu = currentMenu; MP_RoomDef.prevMenu = currentMenu;
M_SetupNextMenu(&MP_RoomDef); M_SetupNextMenu(&MP_RoomDef);
#ifdef UPDATE_ALERT #ifdef MASTERSERVER
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
#ifdef UPDATE_ALERT
m_waiting_mode = M_WAITING_VERSION; m_waiting_mode = M_WAITING_VERSION;
#else/*UPDATE_ALERT*/
m_waiting_mode = M_WAITING_ROOMS;
#endif/*UPDATE_ALERT*/
MP_RoomMenu[0].text = ""; MP_RoomMenu[0].text = "";
id = malloc(sizeof *id); id = malloc(sizeof *id);
@ -8737,17 +8744,19 @@ static void M_RoomMenu(INT32 choice)
I_spawn_thread("check-new-version", I_spawn_thread("check-new-version",
(I_thread_fn)Check_new_version_thread, id); (I_thread_fn)Check_new_version_thread, id);
#else/*HAVE_THREADS*/ #else/*HAVE_THREADS*/
#ifdef UPDATE_ALERT
if (M_CheckMODVersion(0)) if (M_CheckMODVersion(0))
#endif/*UPDATE_ALERT*/
{ {
GetRoomsList(currentMenu->prevMenu == &MP_ServerDef, 0); GetRoomsList(currentMenu->prevMenu == &MP_ServerDef, 0);
} }
#endif/*HAVE_THREADS*/ #endif/*HAVE_THREADS*/
#endif/*UPDATE_ALERT*/ #endif/*MASTERSERVER*/
} }
static void M_ChooseRoom(INT32 choice) static void M_ChooseRoom(INT32 choice)
{ {
#ifdef HAVE_THREADS #if defined (MASTERSERVER) && defined (HAVE_THREADS)
I_lock_mutex(&ms_QueryId_mutex); I_lock_mutex(&ms_QueryId_mutex);
{ {
ms_QueryId++; ms_QueryId++;

View file

@ -23,6 +23,8 @@
#include "m_menu.h" #include "m_menu.h"
#include "z_zone.h" #include "z_zone.h"
#ifdef MASTERSERVER
static int MSId; static int MSId;
static int MSRegisteredId = -1; static int MSRegisteredId = -1;
@ -43,11 +45,14 @@ static I_cond MSCond;
# define Unlock_state() # define Unlock_state()
#endif/*HAVE_THREADS*/ #endif/*HAVE_THREADS*/
static void Update_parameters (void);
#ifndef NONET #ifndef NONET
static void Command_Listserv_f(void); static void Command_Listserv_f(void);
#endif #endif
#endif/*MASTERSERVER*/
static void Update_parameters (void);
static void MasterServer_OnChange(void); static void MasterServer_OnChange(void);
static CV_PossibleValue_t masterserver_update_rate_cons_t[] = { static CV_PossibleValue_t masterserver_update_rate_cons_t[] = {
@ -63,7 +68,7 @@ consvar_t cv_masterserver_update_rate = {"masterserver_update_rate", "15", CV_SA
INT16 ms_RoomId = -1; INT16 ms_RoomId = -1;
#ifdef HAVE_THREADS #if defined (MASTERSERVER) && defined (HAVE_THREADS)
int ms_QueryId; int ms_QueryId;
I_mutex ms_QueryId_mutex; I_mutex ms_QueryId_mutex;
@ -91,10 +96,14 @@ void AddMServCommands(void)
CV_RegisterVar(&cv_masterserver_debug); CV_RegisterVar(&cv_masterserver_debug);
CV_RegisterVar(&cv_masterserver_token); CV_RegisterVar(&cv_masterserver_token);
CV_RegisterVar(&cv_servername); CV_RegisterVar(&cv_servername);
#ifdef MASTERSERVER
COM_AddCommand("listserv", Command_Listserv_f); COM_AddCommand("listserv", Command_Listserv_f);
#endif #endif
#endif
} }
#ifdef MASTERSERVER
static void WarnGUI (void) static void WarnGUI (void)
{ {
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
@ -395,6 +404,7 @@ Change_masterserver_thread (char *api)
void RegisterServer(void) void RegisterServer(void)
{ {
#ifdef MASTERSERVER
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
I_spawn_thread( I_spawn_thread(
"register-server", "register-server",
@ -404,6 +414,7 @@ void RegisterServer(void)
#else #else
Finish_registration(); Finish_registration();
#endif #endif
#endif/*MASTERSERVER*/
} }
static void UpdateServer(void) static void UpdateServer(void)
@ -421,6 +432,7 @@ static void UpdateServer(void)
void UnregisterServer(void) void UnregisterServer(void)
{ {
#ifdef MASTERSERVER
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
I_spawn_thread( I_spawn_thread(
"unlist-server", "unlist-server",
@ -430,6 +442,7 @@ void UnregisterServer(void)
#else #else
Finish_unlist(); Finish_unlist();
#endif #endif
#endif/*MASTERSERVER*/
} }
static boolean static boolean
@ -465,9 +478,33 @@ static inline void SendPingToMasterServer(void)
} }
} }
void MasterClient_Ticker(void)
{
#ifdef MASTERSERVER
SendPingToMasterServer();
#endif
}
static void
Set_api (const char *api)
{
#ifdef HAVE_THREADS
I_spawn_thread(
"change-masterserver",
(I_thread_fn)Change_masterserver_thread,
strdup(api)
);
#else
HMS_set_api(strdup(api));
#endif
}
#endif/*MASTERSERVER*/
static void static void
Update_parameters (void) Update_parameters (void)
{ {
#ifdef MASTERSERVER
int registered; int registered;
int delayed; int delayed;
@ -487,29 +524,12 @@ Update_parameters (void)
if (! delayed && registered) if (! delayed && registered)
UpdateServer(); UpdateServer();
} }
} #endif/*MASTERSERVER*/
void MasterClient_Ticker(void)
{
SendPingToMasterServer();
}
static void
Set_api (const char *api)
{
#ifdef HAVE_THREADS
I_spawn_thread(
"change-masterserver",
(I_thread_fn)Change_masterserver_thread,
strdup(api)
);
#else
HMS_set_api(strdup(api));
#endif
} }
static void MasterServer_OnChange(void) static void MasterServer_OnChange(void)
{ {
#ifdef MASTERSERVER
UnregisterServer(); UnregisterServer();
/* /*
@ -527,4 +547,5 @@ static void MasterServer_OnChange(void)
if (Online()) if (Online())
RegisterServer(); RegisterServer();
#endif/*MASTERSERVER*/
} }