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();
}
#ifdef HAVE_THREADS
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
struct Fetch_servers_ctx
{
int room;
@ -1865,7 +1865,7 @@ Fetch_servers_thread (struct Fetch_servers_ctx *ctx)
free(ctx);
}
#endif/*HAVE_THREADS*/
#endif/*defined (MASTERSERVER) && defined (HAVE_THREADS)*/
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)
{
#ifdef HAVE_THREADS
struct Fetch_servers_ctx *ctx;
#endif
(void)internetsearch;
(void)room;
SL_ClearServerList(0);
@ -1921,9 +1920,12 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room)
if (netgame)
SendAskInfo(BROADCASTADDR);
#ifdef MASTERSERVER
if (internetsearch)
{
#ifdef HAVE_THREADS
struct Fetch_servers_ctx *ctx;
ctx = malloc(sizeof *ctx);
/* 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/*MASTERSERVER*/
}
#endif // ifndef NONET
@ -3423,8 +3426,10 @@ void D_QuitNetGame(void)
for (i = 0; i < MAXNETNODES; i++)
if (nodeingame[i])
HSendPacket(i, true, 0, 0);
#ifdef MASTERSERVER
if (serverrunning && ms_RoomId > 0)
UnregisterServer();
#endif
}
else if (servernode > 0 && servernode < MAXNETNODES && nodeingame[(UINT8)servernode])
{
@ -3672,8 +3677,10 @@ boolean SV_SpawnServer(void)
if (netgame && I_NetOpenSocket)
{
I_NetOpenSocket();
#ifdef MASTERSERVER
if (ms_RoomId > 0)
RegisterServer();
#endif
}
// non dedicated server just connect to itself
@ -5391,7 +5398,9 @@ FILESTAMP
GetPackets();
FILESTAMP
#ifdef MASTERSERVER
MasterClient_Ticker();
#endif
if (client)
{
@ -5448,7 +5457,9 @@ FILESTAMP
// client send the command after a receive of the server
// the server send before because in single player is beter
#ifdef MASTERSERVER
MasterClient_Ticker(); // Acking the Master Server
#endif
if (client)
{

View file

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

View file

@ -14,7 +14,9 @@ Documentation available here.
<http://mb.srb2.org/MS/tools/api/v1/>
*/
#ifdef HAVE_CURL
#include <curl/curl.h>
#endif
#include "doomdef.h"
#include "d_clisrv.h"
@ -49,6 +51,8 @@ consvar_t cv_masterserver_token = {
NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
};
#ifdef MASTERSERVER
static int hms_started;
static char *hms_api;
@ -666,10 +670,14 @@ HMS_set_api (char *api)
#endif
}
#endif/*MASTERSERVER*/
static void
MasterServer_Debug_OnChange (void)
{
#ifdef MASTERSERVER
/* TODO: change to 'latest-log.txt' for log files revision. */
if (cv_masterserver_debug.value)
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;
#ifdef HAVE_THREADS
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
if (currentMenu == &MP_RoomDef || currentMenu == &MP_ConnectDef)
{
I_lock_mutex(&ms_QueryId_mutex);
@ -3392,7 +3392,7 @@ void M_Ticker(void)
setmodeneeded = vidm_previousmode + 1;
}
#ifdef HAVE_THREADS
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
I_lock_mutex(&ms_ServerList_mutex);
{
if (ms_ServerList)
@ -8603,8 +8603,9 @@ static boolean M_CheckMODVersion(int id)
} else
return true;
}
#endif/*UPDATE_ALERT*/
#ifdef HAVE_THREADS
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
static void
Check_new_version_thread (int *id)
{
@ -8613,7 +8614,9 @@ Check_new_version_thread (int *id)
okay = 0;
#ifdef UPDATE_ALERT
if (M_CheckMODVersion(*id))
#endif
{
I_lock_mutex(&ms_QueryId_mutex);
{
@ -8657,8 +8660,7 @@ Check_new_version_thread (int *id)
free(id);
}
#endif/*HAVE_THREADS*/
#endif/*UPDATE_ALERT*/
#endif/*defined (MASTERSERVER) && defined (HAVE_THREADS)*/
static void M_ConnectMenu(INT32 choice)
{
@ -8699,7 +8701,7 @@ UINT32 roomIds[NUM_LIST_ROOMS];
static void M_RoomMenu(INT32 choice)
{
INT32 i;
#ifdef HAVE_THREADS
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
int *id;
#endif
@ -8721,9 +8723,14 @@ static void M_RoomMenu(INT32 choice)
MP_RoomDef.prevMenu = currentMenu;
M_SetupNextMenu(&MP_RoomDef);
#ifdef UPDATE_ALERT
#ifdef MASTERSERVER
#ifdef HAVE_THREADS
#ifdef UPDATE_ALERT
m_waiting_mode = M_WAITING_VERSION;
#else/*UPDATE_ALERT*/
m_waiting_mode = M_WAITING_ROOMS;
#endif/*UPDATE_ALERT*/
MP_RoomMenu[0].text = "";
id = malloc(sizeof *id);
@ -8737,17 +8744,19 @@ static void M_RoomMenu(INT32 choice)
I_spawn_thread("check-new-version",
(I_thread_fn)Check_new_version_thread, id);
#else/*HAVE_THREADS*/
#ifdef UPDATE_ALERT
if (M_CheckMODVersion(0))
#endif/*UPDATE_ALERT*/
{
GetRoomsList(currentMenu->prevMenu == &MP_ServerDef, 0);
}
#endif/*HAVE_THREADS*/
#endif/*UPDATE_ALERT*/
#endif/*MASTERSERVER*/
}
static void M_ChooseRoom(INT32 choice)
{
#ifdef HAVE_THREADS
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
I_lock_mutex(&ms_QueryId_mutex);
{
ms_QueryId++;

View file

@ -23,6 +23,8 @@
#include "m_menu.h"
#include "z_zone.h"
#ifdef MASTERSERVER
static int MSId;
static int MSRegisteredId = -1;
@ -43,11 +45,14 @@ static I_cond MSCond;
# define Unlock_state()
#endif/*HAVE_THREADS*/
static void Update_parameters (void);
#ifndef NONET
static void Command_Listserv_f(void);
#endif
#endif/*MASTERSERVER*/
static void Update_parameters (void);
static void MasterServer_OnChange(void);
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;
#ifdef HAVE_THREADS
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
int ms_QueryId;
I_mutex ms_QueryId_mutex;
@ -91,10 +96,14 @@ void AddMServCommands(void)
CV_RegisterVar(&cv_masterserver_debug);
CV_RegisterVar(&cv_masterserver_token);
CV_RegisterVar(&cv_servername);
#ifdef MASTERSERVER
COM_AddCommand("listserv", Command_Listserv_f);
#endif
#endif
}
#ifdef MASTERSERVER
static void WarnGUI (void)
{
#ifdef HAVE_THREADS
@ -395,6 +404,7 @@ Change_masterserver_thread (char *api)
void RegisterServer(void)
{
#ifdef MASTERSERVER
#ifdef HAVE_THREADS
I_spawn_thread(
"register-server",
@ -404,6 +414,7 @@ void RegisterServer(void)
#else
Finish_registration();
#endif
#endif/*MASTERSERVER*/
}
static void UpdateServer(void)
@ -421,6 +432,7 @@ static void UpdateServer(void)
void UnregisterServer(void)
{
#ifdef MASTERSERVER
#ifdef HAVE_THREADS
I_spawn_thread(
"unlist-server",
@ -430,6 +442,7 @@ void UnregisterServer(void)
#else
Finish_unlist();
#endif
#endif/*MASTERSERVER*/
}
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
Update_parameters (void)
{
#ifdef MASTERSERVER
int registered;
int delayed;
@ -487,29 +524,12 @@ Update_parameters (void)
if (! delayed && registered)
UpdateServer();
}
}
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
#endif/*MASTERSERVER*/
}
static void MasterServer_OnChange(void)
{
#ifdef MASTERSERVER
UnregisterServer();
/*
@ -527,4 +547,5 @@ static void MasterServer_OnChange(void)
if (Online())
RegisterServer();
#endif/*MASTERSERVER*/
}