mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 04:11:18 +00:00
Basically, update master server code to v2
Removes rooms, replaced with cv_advertise and "Advertise" on the host menu. According to the new API, SRB2APPLICATION is sent instead of MODID. A contact field was added, but there is no means of accessing it or setting it. As a slight change, the server list will be populated even on an outdated version of the game. (The new API was designed with this in mind.) The update alert is still presented first of course.
This commit is contained in:
parent
55dccfe801
commit
901ea3c18b
9 changed files with 277 additions and 696 deletions
109
src/d_clisrv.c
109
src/d_clisrv.c
|
@ -1973,57 +1973,30 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node)
|
||||||
M_SortServerList();
|
M_SortServerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
void CL_UpdateServerList (void)
|
||||||
struct Fetch_servers_ctx
|
|
||||||
{
|
{
|
||||||
int room;
|
SL_ClearServerList(0);
|
||||||
int id;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
if (!netgame && I_NetOpenSocket)
|
||||||
Fetch_servers_thread (struct Fetch_servers_ctx *ctx)
|
|
||||||
{
|
|
||||||
msg_server_t *server_list;
|
|
||||||
|
|
||||||
server_list = GetShortServersList(ctx->room, ctx->id);
|
|
||||||
|
|
||||||
if (server_list)
|
|
||||||
{
|
{
|
||||||
I_lock_mutex(&ms_QueryId_mutex);
|
if (I_NetOpenSocket())
|
||||||
{
|
{
|
||||||
if (ctx->id != ms_QueryId)
|
netgame = true;
|
||||||
{
|
multiplayer = true;
|
||||||
free(server_list);
|
|
||||||
server_list = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
I_unlock_mutex(ms_QueryId_mutex);
|
|
||||||
|
|
||||||
if (server_list)
|
|
||||||
{
|
|
||||||
I_lock_mutex(&m_menu_mutex);
|
|
||||||
{
|
|
||||||
if (m_waiting_mode == M_WAITING_SERVERS)
|
|
||||||
m_waiting_mode = M_NOT_WAITING;
|
|
||||||
}
|
|
||||||
I_unlock_mutex(m_menu_mutex);
|
|
||||||
|
|
||||||
I_lock_mutex(&ms_ServerList_mutex);
|
|
||||||
{
|
|
||||||
ms_ServerList = server_list;
|
|
||||||
}
|
|
||||||
I_unlock_mutex(ms_ServerList_mutex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(ctx);
|
// search for local servers
|
||||||
|
if (netgame)
|
||||||
|
SendAskInfo(BROADCASTADDR);
|
||||||
}
|
}
|
||||||
#endif/*defined (MASTERSERVER) && defined (HAVE_THREADS)*/
|
|
||||||
|
|
||||||
void CL_QueryServerList (msg_server_t *server_list)
|
void CL_QueryServerList (msg_server_t *server_list)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
||||||
|
CL_UpdateServerList();
|
||||||
|
|
||||||
for (i = 0; server_list[i].header.buffer[0]; i++)
|
for (i = 0; server_list[i].header.buffer[0]; i++)
|
||||||
{
|
{
|
||||||
// Make sure MS version matches our own, to
|
// Make sure MS version matches our own, to
|
||||||
|
@ -2052,62 +2025,6 @@ void CL_QueryServerList (msg_server_t *server_list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CL_UpdateServerList(boolean internetsearch, INT32 room)
|
|
||||||
{
|
|
||||||
(void)internetsearch;
|
|
||||||
(void)room;
|
|
||||||
|
|
||||||
SL_ClearServerList(0);
|
|
||||||
|
|
||||||
if (!netgame && I_NetOpenSocket)
|
|
||||||
{
|
|
||||||
if (I_NetOpenSocket())
|
|
||||||
{
|
|
||||||
netgame = true;
|
|
||||||
multiplayer = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// search for local servers
|
|
||||||
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 */
|
|
||||||
m_waiting_mode = M_WAITING_SERVERS;
|
|
||||||
|
|
||||||
I_lock_mutex(&ms_QueryId_mutex);
|
|
||||||
{
|
|
||||||
ctx->id = ms_QueryId;
|
|
||||||
}
|
|
||||||
I_unlock_mutex(ms_QueryId_mutex);
|
|
||||||
|
|
||||||
ctx->room = room;
|
|
||||||
|
|
||||||
I_spawn_thread("fetch-servers", (I_thread_fn)Fetch_servers_thread, ctx);
|
|
||||||
#else
|
|
||||||
msg_server_t *server_list;
|
|
||||||
|
|
||||||
server_list = GetShortServersList(room, 0);
|
|
||||||
|
|
||||||
if (server_list)
|
|
||||||
{
|
|
||||||
CL_QueryServerList(server_list);
|
|
||||||
free(server_list);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif/*MASTERSERVER*/
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // ifndef NONET
|
#endif // ifndef NONET
|
||||||
|
|
||||||
static void M_ConfirmConnect(event_t *ev)
|
static void M_ConfirmConnect(event_t *ev)
|
||||||
|
@ -3755,7 +3672,7 @@ void D_QuitNetGame(void)
|
||||||
if (nodeingame[i])
|
if (nodeingame[i])
|
||||||
HSendPacket(i, true, 0, 0);
|
HSendPacket(i, true, 0, 0);
|
||||||
#ifdef MASTERSERVER
|
#ifdef MASTERSERVER
|
||||||
if (serverrunning && ms_RoomId > 0)
|
if (serverrunning && cv_advertise.value)
|
||||||
UnregisterServer();
|
UnregisterServer();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -4017,7 +3934,7 @@ boolean SV_SpawnServer(void)
|
||||||
{
|
{
|
||||||
I_NetOpenSocket();
|
I_NetOpenSocket();
|
||||||
#ifdef MASTERSERVER
|
#ifdef MASTERSERVER
|
||||||
if (ms_RoomId > 0)
|
if (cv_advertise.value)
|
||||||
RegisterServer();
|
RegisterServer();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -587,7 +587,7 @@ void CL_Reset(void);
|
||||||
void CL_ClearPlayer(INT32 playernum);
|
void CL_ClearPlayer(INT32 playernum);
|
||||||
void CL_RemovePlayer(INT32 playernum, INT32 reason);
|
void CL_RemovePlayer(INT32 playernum, INT32 reason);
|
||||||
void CL_QueryServerList(msg_server_t *list);
|
void CL_QueryServerList(msg_server_t *list);
|
||||||
void CL_UpdateServerList(boolean internetsearch, INT32 room);
|
void CL_UpdateServerList(void);
|
||||||
// Is there a game running
|
// Is there a game running
|
||||||
boolean Playing(void);
|
boolean Playing(void);
|
||||||
|
|
||||||
|
|
12
src/d_main.c
12
src/d_main.c
|
@ -69,7 +69,6 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
|
||||||
#include "m_cheat.h"
|
#include "m_cheat.h"
|
||||||
#include "y_inter.h"
|
#include "y_inter.h"
|
||||||
#include "p_local.h" // chasecam
|
#include "p_local.h" // chasecam
|
||||||
#include "mserv.h" // ms_RoomId
|
|
||||||
#include "m_misc.h" // screenshot functionality
|
#include "m_misc.h" // screenshot functionality
|
||||||
#include "dehacked.h" // Dehacked list test
|
#include "dehacked.h" // Dehacked list test
|
||||||
#include "m_cond.h" // condition initialization
|
#include "m_cond.h" // condition initialization
|
||||||
|
@ -1424,17 +1423,6 @@ void D_SRB2Main(void)
|
||||||
CONS_Printf("ST_Init(): Init status bar.\n");
|
CONS_Printf("ST_Init(): Init status bar.\n");
|
||||||
ST_Init();
|
ST_Init();
|
||||||
|
|
||||||
if (M_CheckParm("-room"))
|
|
||||||
{
|
|
||||||
if (!M_IsNextParm())
|
|
||||||
I_Error("usage: -room <room_id>\nCheck the Master Server's webpage for room ID numbers.\n");
|
|
||||||
ms_RoomId = atoi(M_GetNextParm());
|
|
||||||
|
|
||||||
#ifdef UPDATE_ALERT
|
|
||||||
GetMODVersion_Console();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up splitscreen players before joining!
|
// Set up splitscreen players before joining!
|
||||||
if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm()))
|
if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "p_tick.h"
|
#include "p_tick.h"
|
||||||
#include "m_menu.h" // gametype_cons_t
|
#include "m_menu.h" // gametype_cons_t
|
||||||
#include "r_things.h" // skins
|
#include "r_things.h" // skins
|
||||||
#include "mserv.h" // ms_RoomId
|
#include "mserv.h" // cv_advertise
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
#include "byteptr.h"
|
#include "byteptr.h"
|
||||||
|
|
||||||
|
@ -505,14 +505,13 @@ void DRPC_UpdatePresence(void)
|
||||||
// Server info
|
// Server info
|
||||||
if (netgame)
|
if (netgame)
|
||||||
{
|
{
|
||||||
switch (ms_RoomId)
|
if (cv_advertise.value)
|
||||||
{
|
{
|
||||||
case -1: discordPresence.state = "Private"; break; // Private server
|
discordPresence.state = "Public";
|
||||||
case 33: discordPresence.state = "Standard"; break;
|
}
|
||||||
case 28: discordPresence.state = "Casual"; break;
|
else
|
||||||
case 38: discordPresence.state = "Custom Gametypes"; break;
|
{
|
||||||
case 31: discordPresence.state = "OLDC"; break;
|
discordPresence.state = "Private";
|
||||||
default: discordPresence.state = "Unknown Room"; break; // HOW
|
|
||||||
}
|
}
|
||||||
|
|
||||||
discordPresence.partyId = server_context; // Thanks, whoever gave us Mumble support, for implementing the EXACT thing Discord wanted for this field!
|
discordPresence.partyId = server_context; // Thanks, whoever gave us Mumble support, for implementing the EXACT thing Discord wanted for this field!
|
||||||
|
|
252
src/http-mserv.c
252
src/http-mserv.c
|
@ -11,7 +11,7 @@
|
||||||
/*
|
/*
|
||||||
Documentation available here.
|
Documentation available here.
|
||||||
|
|
||||||
<http://mb.srb2.org/MS/tools/api/v1/>
|
<https://ms.kartkrew.org/tools/api/2/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CURL
|
#ifdef HAVE_CURL
|
||||||
|
@ -141,7 +141,7 @@ HMS_connect (const char *format, ...)
|
||||||
if (cv_masterserver_token.string[0])
|
if (cv_masterserver_token.string[0])
|
||||||
{
|
{
|
||||||
quack_token = curl_easy_escape(curl, cv_masterserver_token.string, 0);
|
quack_token = curl_easy_escape(curl, cv_masterserver_token.string, 0);
|
||||||
token_length = ( sizeof "?token="-1 )+ strlen(quack_token);
|
token_length = ( sizeof "&token="-1 )+ strlen(quack_token);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -156,7 +156,9 @@ HMS_connect (const char *format, ...)
|
||||||
seek = strlen(hms_api) + 1;/* + '/' */
|
seek = strlen(hms_api) + 1;/* + '/' */
|
||||||
|
|
||||||
va_start (ap, format);
|
va_start (ap, format);
|
||||||
url = malloc(seek + vsnprintf(0, 0, format, ap) + token_length + 1);
|
url = malloc(seek + vsnprintf(0, 0, format, ap) +
|
||||||
|
sizeof "?v=2" - 1 +
|
||||||
|
token_length + 1);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
sprintf(url, "%s/", hms_api);
|
sprintf(url, "%s/", hms_api);
|
||||||
|
@ -169,6 +171,9 @@ HMS_connect (const char *format, ...)
|
||||||
seek += vsprintf(&url[seek], format, ap);
|
seek += vsprintf(&url[seek], format, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
|
strcpy(&url[seek], "?v=2");
|
||||||
|
seek += sizeof "?v=2" - 1;
|
||||||
|
|
||||||
if (quack_token)
|
if (quack_token)
|
||||||
sprintf(&url[seek], "?token=%s", quack_token);
|
sprintf(&url[seek], "?token=%s", quack_token);
|
||||||
|
|
||||||
|
@ -258,117 +263,6 @@ HMS_end (struct HMS_buffer *buffer)
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
HMS_fetch_rooms (int joining, int query_id)
|
|
||||||
{
|
|
||||||
struct HMS_buffer *hms;
|
|
||||||
int ok;
|
|
||||||
|
|
||||||
int doing_shit;
|
|
||||||
|
|
||||||
char *id;
|
|
||||||
char *title;
|
|
||||||
char *room_motd;
|
|
||||||
|
|
||||||
int id_no;
|
|
||||||
|
|
||||||
char *p;
|
|
||||||
char *end;
|
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
(void)query_id;
|
|
||||||
|
|
||||||
hms = HMS_connect("rooms");
|
|
||||||
|
|
||||||
if (! hms)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (HMS_do(hms))
|
|
||||||
{
|
|
||||||
doing_shit = 1;
|
|
||||||
|
|
||||||
p = hms->buffer;
|
|
||||||
|
|
||||||
for (i = 0; i < NUM_LIST_ROOMS && ( end = strstr(p, "\n\n\n") );)
|
|
||||||
{
|
|
||||||
*end = '\0';
|
|
||||||
|
|
||||||
id = strtok(p, "\n");
|
|
||||||
title = strtok(0, "\n");
|
|
||||||
room_motd = strtok(0, "");
|
|
||||||
|
|
||||||
if (id && title && room_motd)
|
|
||||||
{
|
|
||||||
id_no = atoi(id);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Don't show the 'All' room if hosting. And it's a hack like this
|
|
||||||
because I'm way too lazy to add another feature to the MS.
|
|
||||||
*/
|
|
||||||
if (joining || id_no != 0)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
I_lock_mutex(&ms_QueryId_mutex);
|
|
||||||
{
|
|
||||||
if (query_id != ms_QueryId)
|
|
||||||
doing_shit = 0;
|
|
||||||
}
|
|
||||||
I_unlock_mutex(ms_QueryId_mutex);
|
|
||||||
|
|
||||||
if (! doing_shit)
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
room_list[i].header.buffer[0] = 1;
|
|
||||||
|
|
||||||
room_list[i].id = id_no;
|
|
||||||
strlcpy(room_list[i].name, title, sizeof room_list[i].name);
|
|
||||||
strlcpy(room_list[i].motd, room_motd, sizeof room_list[i].motd);
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = ( end + 3 );/* skip the three linefeeds */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doing_shit)
|
|
||||||
room_list[i].header.buffer[0] = 0;
|
|
||||||
|
|
||||||
ok = 1;
|
|
||||||
|
|
||||||
if (doing_shit)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
I_lock_mutex(&m_menu_mutex);
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
for (i = 0; room_list[i].header.buffer[0]; i++)
|
|
||||||
{
|
|
||||||
if(*room_list[i].name != '\0')
|
|
||||||
{
|
|
||||||
MP_RoomMenu[i+1].text = room_list[i].name;
|
|
||||||
roomIds[i] = room_list[i].id;
|
|
||||||
MP_RoomMenu[i+1].status = IT_STRING|IT_CALL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef HAVE_THREADS
|
|
||||||
I_unlock_mutex(m_menu_mutex);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ok = 0;
|
|
||||||
|
|
||||||
HMS_end(hms);
|
|
||||||
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
HMS_register (void)
|
HMS_register (void)
|
||||||
{
|
{
|
||||||
|
@ -377,29 +271,26 @@ HMS_register (void)
|
||||||
|
|
||||||
char post[256];
|
char post[256];
|
||||||
|
|
||||||
char *title;
|
char *contact;
|
||||||
|
|
||||||
hms = HMS_connect("rooms/%d/register", ms_RoomId);
|
hms = HMS_connect(
|
||||||
|
"games/%s/%d/servers/register", SRB2APPLICATION, MODVERSION);
|
||||||
|
|
||||||
if (! hms)
|
if (! hms)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
title = curl_easy_escape(hms->curl, cv_servername.string, 0);
|
contact = curl_easy_escape(hms->curl, cv_server_contact.string, 0);
|
||||||
|
|
||||||
snprintf(post, sizeof post,
|
snprintf(post, sizeof post,
|
||||||
"port=%d&"
|
"port=%d&"
|
||||||
"title=%s&"
|
"contact=%s",
|
||||||
"version=%d.%d",
|
|
||||||
|
|
||||||
current_port,
|
current_port,
|
||||||
|
|
||||||
title,
|
contact
|
||||||
|
|
||||||
VERSION,
|
|
||||||
SUBVERSION
|
|
||||||
);
|
);
|
||||||
|
|
||||||
curl_free(title);
|
curl_free(contact);
|
||||||
|
|
||||||
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
|
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
|
||||||
|
|
||||||
|
@ -473,19 +364,13 @@ HMS_list_servers (void)
|
||||||
{
|
{
|
||||||
struct HMS_buffer *hms;
|
struct HMS_buffer *hms;
|
||||||
|
|
||||||
char *p;
|
hms = HMS_connect("games/%s/%d/servers", SRB2APPLICATION, MODVERSION);
|
||||||
|
|
||||||
hms = HMS_connect("servers");
|
|
||||||
|
|
||||||
if (! hms)
|
if (! hms)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (HMS_do(hms))
|
if (HMS_do(hms))
|
||||||
{
|
{
|
||||||
p = &hms->buffer[strlen(hms->buffer)];
|
|
||||||
while (*--p == '\n')
|
|
||||||
;
|
|
||||||
|
|
||||||
CONS_Printf("%s\n", hms->buffer);
|
CONS_Printf("%s\n", hms->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,35 +378,24 @@ HMS_list_servers (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_server_t *
|
msg_server_t *
|
||||||
HMS_fetch_servers (msg_server_t *list, int room_number, int query_id)
|
HMS_fetch_servers (msg_server_t *list, int query_id)
|
||||||
{
|
{
|
||||||
struct HMS_buffer *hms;
|
struct HMS_buffer *hms;
|
||||||
|
|
||||||
int doing_shit;
|
int doing_shit;
|
||||||
|
|
||||||
char local_version[9];
|
|
||||||
|
|
||||||
char *room;
|
|
||||||
|
|
||||||
char *address;
|
char *address;
|
||||||
char *port;
|
char *port;
|
||||||
char *title;
|
char *contact;
|
||||||
char *version;
|
|
||||||
|
|
||||||
char *end;
|
char *end;
|
||||||
char *section_end;
|
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
(void)query_id;
|
(void)query_id;
|
||||||
|
|
||||||
if (room_number > 0)
|
hms = HMS_connect("games/%s/%d/servers", SRB2APPLICATION, MODVERSION);
|
||||||
{
|
|
||||||
hms = HMS_connect("rooms/%d/servers", room_number);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
hms = HMS_connect("servers");
|
|
||||||
|
|
||||||
if (! hms)
|
if (! hms)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -530,81 +404,51 @@ HMS_fetch_servers (msg_server_t *list, int room_number, int query_id)
|
||||||
{
|
{
|
||||||
doing_shit = 1;
|
doing_shit = 1;
|
||||||
|
|
||||||
snprintf(local_version, sizeof local_version,
|
|
||||||
"%d.%d",
|
|
||||||
VERSION,
|
|
||||||
SUBVERSION
|
|
||||||
);
|
|
||||||
|
|
||||||
p = hms->buffer;
|
p = hms->buffer;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
do
|
while (i < MAXSERVERLIST && ( end = strchr(p, '\n') ))
|
||||||
{
|
{
|
||||||
section_end = strstr(p, "\n\n");
|
*end = '\0';
|
||||||
|
|
||||||
room = strtok(p, "\n");
|
address = strtok(p, " ");
|
||||||
|
port = strtok(0, " ");
|
||||||
|
contact = strtok(0, "");
|
||||||
|
|
||||||
p = strtok(0, "");
|
if (address && port)
|
||||||
|
|
||||||
if (! p)
|
|
||||||
break;
|
|
||||||
|
|
||||||
while (i < MAXSERVERLIST && ( end = strchr(p, '\n') ))
|
|
||||||
{
|
{
|
||||||
*end = '\0';
|
|
||||||
|
|
||||||
address = strtok(p, " ");
|
|
||||||
port = strtok(0, " ");
|
|
||||||
title = strtok(0, " ");
|
|
||||||
version = strtok(0, "");
|
|
||||||
|
|
||||||
if (address && port && title && version)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
I_lock_mutex(&ms_QueryId_mutex);
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
{
|
{
|
||||||
if (query_id != ms_QueryId)
|
if (query_id != ms_QueryId)
|
||||||
doing_shit = 0;
|
doing_shit = 0;
|
||||||
}
|
}
|
||||||
I_unlock_mutex(ms_QueryId_mutex);
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
|
||||||
if (! doing_shit)
|
if (! doing_shit)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (strcmp(version, local_version) == 0)
|
strlcpy(list[i].ip, address, sizeof list[i].ip);
|
||||||
{
|
strlcpy(list[i].port, port, sizeof list[i].port);
|
||||||
strlcpy(list[i].ip, address, sizeof list[i].ip);
|
|
||||||
strlcpy(list[i].port, port, sizeof list[i].port);
|
|
||||||
strlcpy(list[i].name, title, sizeof list[i].name);
|
|
||||||
strlcpy(list[i].version, version, sizeof list[i].version);
|
|
||||||
|
|
||||||
list[i].room = atoi(room);
|
if (contact)
|
||||||
|
|
||||||
list[i].header.buffer[0] = 1;
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (end == section_end)/* end of list for this room */
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
p = ( end + 1 );/* skip server delimiter */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
section_end = 0;/* malformed so quit the parsing */
|
strlcpy(list[i].contact, contact, sizeof list[i].contact);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list[i].header.buffer[0] = 1;
|
||||||
|
|
||||||
|
i++;
|
||||||
|
|
||||||
|
p = ( end + 1 );/* skip server delimiter */
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (! doing_shit)
|
{
|
||||||
|
/* malformed so quit the parsing */
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
p = ( section_end + 2 );
|
|
||||||
}
|
}
|
||||||
while (section_end) ;
|
|
||||||
|
|
||||||
if (doing_shit)
|
if (doing_shit)
|
||||||
list[i].header.buffer[0] = 0;
|
list[i].header.buffer[0] = 0;
|
||||||
|
@ -626,7 +470,7 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size)
|
||||||
char *version;
|
char *version;
|
||||||
char *version_name;
|
char *version_name;
|
||||||
|
|
||||||
hms = HMS_connect("versions/%d", MODID);
|
hms = HMS_connect("games/%s/version", SRB2APPLICATION);
|
||||||
|
|
||||||
if (! hms)
|
if (! hms)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
516
src/m_menu.c
516
src/m_menu.c
|
@ -182,7 +182,6 @@ static void M_StopMessage(INT32 choice);
|
||||||
|
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
static void M_HandleServerPage(INT32 choice);
|
static void M_HandleServerPage(INT32 choice);
|
||||||
static void M_RoomMenu(INT32 choice);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Prototyping is fun, innit?
|
// Prototyping is fun, innit?
|
||||||
|
@ -190,6 +189,9 @@ static void M_RoomMenu(INT32 choice);
|
||||||
// NEEDED FUNCTION PROTOTYPES GO HERE
|
// NEEDED FUNCTION PROTOTYPES GO HERE
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
|
void M_SetWaitingMode(int mode);
|
||||||
|
int M_GetWaitingMode(void);
|
||||||
|
|
||||||
// the haxor message menu
|
// the haxor message menu
|
||||||
menu_t MessageDef;
|
menu_t MessageDef;
|
||||||
|
|
||||||
|
@ -263,7 +265,6 @@ static void M_ConnectMenu(INT32 choice);
|
||||||
static void M_ConnectMenuModChecks(INT32 choice);
|
static void M_ConnectMenuModChecks(INT32 choice);
|
||||||
static void M_Refresh(INT32 choice);
|
static void M_Refresh(INT32 choice);
|
||||||
static void M_Connect(INT32 choice);
|
static void M_Connect(INT32 choice);
|
||||||
static void M_ChooseRoom(INT32 choice);
|
|
||||||
#endif
|
#endif
|
||||||
static void M_StartOfflineServerMenu(INT32 choice);
|
static void M_StartOfflineServerMenu(INT32 choice);
|
||||||
static void M_StartServer(INT32 choice);
|
static void M_StartServer(INT32 choice);
|
||||||
|
@ -372,7 +373,6 @@ static void M_OGL_DrawColorMenu(void);
|
||||||
static void M_DrawMPMainMenu(void);
|
static void M_DrawMPMainMenu(void);
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
static void M_DrawConnectMenu(void);
|
static void M_DrawConnectMenu(void);
|
||||||
static void M_DrawRoomMenu(void);
|
|
||||||
#endif
|
#endif
|
||||||
static void M_DrawJoystick(void);
|
static void M_DrawJoystick(void);
|
||||||
static void M_DrawSetupMultiPlayerMenu(void);
|
static void M_DrawSetupMultiPlayerMenu(void);
|
||||||
|
@ -1017,7 +1017,7 @@ static menuitem_t MP_MainMenu[] =
|
||||||
static menuitem_t MP_ServerMenu[] =
|
static menuitem_t MP_ServerMenu[] =
|
||||||
{
|
{
|
||||||
{IT_STRING|IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 10},
|
{IT_STRING|IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 10},
|
||||||
{IT_STRING|IT_CALL, NULL, "Room...", M_RoomMenu, 20},
|
{IT_STRING|IT_CVAR, NULL, "Advertise", &cv_advertise, 20},
|
||||||
{IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Server Name", &cv_servername, 30},
|
{IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Server Name", &cv_servername, 30},
|
||||||
|
|
||||||
{IT_STRING|IT_CVAR, NULL, "Game Type", &cv_newgametype, 68},
|
{IT_STRING|IT_CVAR, NULL, "Game Type", &cv_newgametype, 68},
|
||||||
|
@ -1047,54 +1047,30 @@ static menuitem_t MP_PlayerSetupMenu[] =
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
static menuitem_t MP_ConnectMenu[] =
|
static menuitem_t MP_ConnectMenu[] =
|
||||||
{
|
{
|
||||||
{IT_STRING | IT_CALL, NULL, "Room...", M_RoomMenu, 4},
|
{IT_STRING | IT_CVAR, NULL, "Sort By", &cv_serversort, 4},
|
||||||
{IT_STRING | IT_CVAR, NULL, "Sort By", &cv_serversort, 12},
|
{IT_STRING | IT_KEYHANDLER, NULL, "Page", M_HandleServerPage, 12},
|
||||||
{IT_STRING | IT_KEYHANDLER, NULL, "Page", M_HandleServerPage, 20},
|
{IT_STRING | IT_CALL, NULL, "Refresh", M_Refresh, 20},
|
||||||
{IT_STRING | IT_CALL, NULL, "Refresh", M_Refresh, 28},
|
|
||||||
|
|
||||||
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 48-4},
|
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 36},
|
||||||
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 60-4},
|
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 48},
|
||||||
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 72-4},
|
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 60},
|
||||||
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 84-4},
|
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 72},
|
||||||
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 96-4},
|
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 84},
|
||||||
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 108-4},
|
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 96},
|
||||||
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 120-4},
|
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 108},
|
||||||
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 132-4},
|
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 120},
|
||||||
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 144-4},
|
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 132},
|
||||||
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 156-4},
|
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 144},
|
||||||
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 168-4},
|
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 156},
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
mp_connect_room,
|
|
||||||
mp_connect_sort,
|
mp_connect_sort,
|
||||||
mp_connect_page,
|
mp_connect_page,
|
||||||
mp_connect_refresh,
|
mp_connect_refresh,
|
||||||
FIRSTSERVERLINE
|
FIRSTSERVERLINE
|
||||||
};
|
};
|
||||||
|
|
||||||
menuitem_t MP_RoomMenu[] =
|
|
||||||
{
|
|
||||||
{IT_STRING | IT_CALL, NULL, "<Offline Mode>", M_ChooseRoom, 9},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 18},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 27},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 36},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 45},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 54},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 63},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 72},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 81},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 90},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 99},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 108},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 117},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 126},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 135},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 144},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 153},
|
|
||||||
{IT_DISABLED, NULL, "", M_ChooseRoom, 162},
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
@ -1992,17 +1968,6 @@ menu_t MP_ConnectDef =
|
||||||
0,
|
0,
|
||||||
M_CancelConnect
|
M_CancelConnect
|
||||||
};
|
};
|
||||||
menu_t MP_RoomDef =
|
|
||||||
{
|
|
||||||
"M_MULTI",
|
|
||||||
sizeof (MP_RoomMenu)/sizeof (menuitem_t),
|
|
||||||
&MP_ConnectDef,
|
|
||||||
MP_RoomMenu,
|
|
||||||
M_DrawRoomMenu,
|
|
||||||
27, 32,
|
|
||||||
0,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
menu_t MP_PlayerSetupDef =
|
menu_t MP_PlayerSetupDef =
|
||||||
{
|
{
|
||||||
|
@ -3392,30 +3357,6 @@ void M_SetupNextMenu(menu_t *menudef)
|
||||||
{
|
{
|
||||||
INT16 i;
|
INT16 i;
|
||||||
|
|
||||||
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
|
||||||
if (currentMenu == &MP_RoomDef || currentMenu == &MP_ConnectDef)
|
|
||||||
{
|
|
||||||
I_lock_mutex(&ms_QueryId_mutex);
|
|
||||||
{
|
|
||||||
ms_QueryId++;
|
|
||||||
}
|
|
||||||
I_unlock_mutex(ms_QueryId_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentMenu == &MP_ConnectDef)
|
|
||||||
{
|
|
||||||
I_lock_mutex(&ms_ServerList_mutex);
|
|
||||||
{
|
|
||||||
if (ms_ServerList)
|
|
||||||
{
|
|
||||||
free(ms_ServerList);
|
|
||||||
ms_ServerList = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
I_unlock_mutex(ms_ServerList_mutex);
|
|
||||||
}
|
|
||||||
#endif/*HAVE_THREADS*/
|
|
||||||
|
|
||||||
if (currentMenu->quitroutine)
|
if (currentMenu->quitroutine)
|
||||||
{
|
{
|
||||||
// If you're going from a menu to itself, why are you running the quitroutine? You're not quitting it! -SH
|
// If you're going from a menu to itself, why are you running the quitroutine? You're not quitting it! -SH
|
||||||
|
@ -8406,7 +8347,118 @@ static void M_EndGame(INT32 choice)
|
||||||
// Connect Menu
|
// Connect Menu
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
#define SERVERHEADERHEIGHT 44
|
void
|
||||||
|
M_SetWaitingMode (int mode)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&m_menu_mutex);
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
m_waiting_mode = mode;
|
||||||
|
}
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_unlock_mutex(m_menu_mutex);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
M_GetWaitingMode (void)
|
||||||
|
{
|
||||||
|
int mode;
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&m_menu_mutex);
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
mode = m_waiting_mode;
|
||||||
|
}
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_unlock_mutex(m_menu_mutex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MASTERSERVER
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
static void
|
||||||
|
Spawn_masterserver_thread (const char *name, void (*thread)(int*))
|
||||||
|
{
|
||||||
|
int *id = malloc(sizeof *id);
|
||||||
|
|
||||||
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
|
{
|
||||||
|
*id = ms_QueryId;
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
|
||||||
|
I_spawn_thread(name, (I_thread_fn)thread, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
Same_instance (int id)
|
||||||
|
{
|
||||||
|
int okay;
|
||||||
|
|
||||||
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
|
{
|
||||||
|
okay = ( id == ms_QueryId );
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
|
||||||
|
return okay;
|
||||||
|
}
|
||||||
|
#endif/*HAVE_THREADS*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
Fetch_servers_thread (int *id)
|
||||||
|
{
|
||||||
|
msg_server_t * server_list;
|
||||||
|
|
||||||
|
(void)id;
|
||||||
|
|
||||||
|
M_SetWaitingMode(M_WAITING_SERVERS);
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
server_list = GetShortServersList(*id);
|
||||||
|
#else
|
||||||
|
server_list = GetShortServersList(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (server_list)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
if (Same_instance(*id))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
M_SetWaitingMode(M_NOT_WAITING);
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&ms_ServerList_mutex);
|
||||||
|
{
|
||||||
|
ms_ServerList = server_list;
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_ServerList_mutex);
|
||||||
|
#else
|
||||||
|
CL_QueryServerList(server_list);
|
||||||
|
free(server_list);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(server_list);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
free(id);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif/*MASTERSERVER*/
|
||||||
|
|
||||||
|
#define SERVERHEADERHEIGHT 36
|
||||||
#define SERVERLINEHEIGHT 12
|
#define SERVERLINEHEIGHT 12
|
||||||
|
|
||||||
#define S_LINEY(n) currentMenu->y + SERVERHEADERHEIGHT + (n * SERVERLINEHEIGHT)
|
#define S_LINEY(n) currentMenu->y + SERVERHEADERHEIGHT + (n * SERVERLINEHEIGHT)
|
||||||
|
@ -8478,77 +8530,18 @@ static void M_Refresh(INT32 choice)
|
||||||
if (rendermode == render_soft)
|
if (rendermode == render_soft)
|
||||||
I_FinishUpdate(); // page flip or blit buffer
|
I_FinishUpdate(); // page flip or blit buffer
|
||||||
|
|
||||||
// note: this is the one case where 0 is a valid room number
|
|
||||||
// because it corresponds to "All"
|
|
||||||
CL_UpdateServerList(!(ms_RoomId < 0), ms_RoomId);
|
|
||||||
|
|
||||||
// first page of servers
|
// first page of servers
|
||||||
serverlistpage = 0;
|
serverlistpage = 0;
|
||||||
}
|
|
||||||
|
|
||||||
static INT32 menuRoomIndex = 0;
|
#ifdef MASTERSERVER
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
static void M_DrawRoomMenu(void)
|
Spawn_masterserver_thread("fetch-servers", Fetch_servers_thread);
|
||||||
{
|
#else/*HAVE_THREADS*/
|
||||||
static int frame = -12;
|
Fetch_servers_thread(NULL);
|
||||||
int dot_frame;
|
#endif/*HAVE_THREADS*/
|
||||||
char text[4];
|
#else/*MASTERSERVER*/
|
||||||
|
CL_UpdateServerList();
|
||||||
const char *rmotd;
|
#endif/*MASTERSERVER*/
|
||||||
const char *waiting_message;
|
|
||||||
|
|
||||||
int dots;
|
|
||||||
|
|
||||||
if (m_waiting_mode)
|
|
||||||
{
|
|
||||||
dot_frame = frame / 4;
|
|
||||||
dots = dot_frame + 3;
|
|
||||||
|
|
||||||
strcpy(text, " ");
|
|
||||||
|
|
||||||
if (dots > 0)
|
|
||||||
{
|
|
||||||
if (dot_frame < 0)
|
|
||||||
dot_frame = 0;
|
|
||||||
|
|
||||||
strncpy(&text[dot_frame], "...", min(dots, 3 - dot_frame));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (++frame == 12)
|
|
||||||
frame = -12;
|
|
||||||
|
|
||||||
currentMenu->menuitems[0].text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
// use generic drawer for cursor, items and title
|
|
||||||
M_DrawGenericMenu();
|
|
||||||
|
|
||||||
V_DrawString(currentMenu->x - 16, currentMenu->y, highlightflags, M_GetText("Select a room"));
|
|
||||||
|
|
||||||
if (m_waiting_mode == M_NOT_WAITING)
|
|
||||||
{
|
|
||||||
M_DrawTextBox(144, 24, 20, 20);
|
|
||||||
|
|
||||||
if (itemOn == 0)
|
|
||||||
rmotd = M_GetText("Don't connect to the Master Server.");
|
|
||||||
else
|
|
||||||
rmotd = room_list[itemOn-1].motd;
|
|
||||||
|
|
||||||
rmotd = V_WordWrap(0, 20*8, 0, rmotd);
|
|
||||||
V_DrawString(144+8, 32, V_ALLOWLOWERCASE|V_RETURN8, rmotd);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_waiting_mode)
|
|
||||||
{
|
|
||||||
// Display a little "please wait" message.
|
|
||||||
M_DrawTextBox(52, BASEVIDHEIGHT/2-10, 25, 3);
|
|
||||||
if (m_waiting_mode == M_WAITING_VERSION)
|
|
||||||
waiting_message = "Checking for updates...";
|
|
||||||
else
|
|
||||||
waiting_message = "Fetching room info...";
|
|
||||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, waiting_message);
|
|
||||||
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2)+12, 0, "Please wait.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M_DrawConnectMenu(void)
|
static void M_DrawConnectMenu(void)
|
||||||
|
@ -8557,6 +8550,7 @@ static void M_DrawConnectMenu(void)
|
||||||
const char *gt = "Unknown";
|
const char *gt = "Unknown";
|
||||||
const char *spd = "";
|
const char *spd = "";
|
||||||
INT32 numPages = (serverlistcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE;
|
INT32 numPages = (serverlistcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE;
|
||||||
|
int waiting;
|
||||||
|
|
||||||
for (i = FIRSTSERVERLINE; i < min(localservercount, SERVERS_PER_PAGE)+FIRSTSERVERLINE; i++)
|
for (i = FIRSTSERVERLINE; i < min(localservercount, SERVERS_PER_PAGE)+FIRSTSERVERLINE; i++)
|
||||||
MP_ConnectMenu[i].status = IT_STRING | IT_SPACE;
|
MP_ConnectMenu[i].status = IT_STRING | IT_SPACE;
|
||||||
|
@ -8564,20 +8558,12 @@ static void M_DrawConnectMenu(void)
|
||||||
if (!numPages)
|
if (!numPages)
|
||||||
numPages = 1;
|
numPages = 1;
|
||||||
|
|
||||||
// Room name
|
|
||||||
if (ms_RoomId < 0)
|
|
||||||
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ConnectMenu[mp_connect_room].alphaKey,
|
|
||||||
highlightflags, (itemOn == mp_connect_room) ? "<Select to change>" : "<Offline Mode>");
|
|
||||||
else
|
|
||||||
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ConnectMenu[mp_connect_room].alphaKey,
|
|
||||||
highlightflags, room_list[menuRoomIndex].name);
|
|
||||||
|
|
||||||
// Page num
|
// Page num
|
||||||
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ConnectMenu[mp_connect_page].alphaKey,
|
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ConnectMenu[mp_connect_page].alphaKey,
|
||||||
highlightflags, va("%u of %d", serverlistpage+1, numPages));
|
highlightflags, va("%u of %d", serverlistpage+1, numPages));
|
||||||
|
|
||||||
// Horizontal line!
|
// Horizontal line!
|
||||||
V_DrawFill(1, currentMenu->y+40, 318, 1, 0);
|
V_DrawFill(1, currentMenu->y+32, 318, 1, 0);
|
||||||
|
|
||||||
if (serverlistcount <= 0)
|
if (serverlistcount <= 0)
|
||||||
V_DrawString(currentMenu->x,currentMenu->y+SERVERHEADERHEIGHT, 0, "No servers found");
|
V_DrawString(currentMenu->x,currentMenu->y+SERVERHEADERHEIGHT, 0, "No servers found");
|
||||||
|
@ -8623,11 +8609,20 @@ static void M_DrawConnectMenu(void)
|
||||||
|
|
||||||
M_DrawGenericMenu();
|
M_DrawGenericMenu();
|
||||||
|
|
||||||
if (m_waiting_mode)
|
waiting = M_GetWaitingMode();
|
||||||
|
|
||||||
|
if (waiting)
|
||||||
{
|
{
|
||||||
|
const char *message;
|
||||||
|
|
||||||
|
if (waiting == M_WAITING_VERSION)
|
||||||
|
message = "Checking for updates...";
|
||||||
|
else
|
||||||
|
message = "Searching for servers...";
|
||||||
|
|
||||||
// Display a little "please wait" message.
|
// Display a little "please wait" message.
|
||||||
M_DrawTextBox(52, BASEVIDHEIGHT/2-10, 25, 3);
|
M_DrawTextBox(52, BASEVIDHEIGHT/2-10, 25, 3);
|
||||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, "Searching for servers...");
|
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, message);
|
||||||
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2)+12, 0, "Please wait.");
|
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2)+12, 0, "Please wait.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8711,76 +8706,42 @@ void M_SortServerList(void)
|
||||||
|
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
#ifdef UPDATE_ALERT
|
#ifdef UPDATE_ALERT
|
||||||
static boolean M_CheckMODVersion(int id)
|
static void M_CheckMODVersion(int id)
|
||||||
{
|
{
|
||||||
char updatestring[500];
|
char updatestring[500];
|
||||||
const char *updatecheck = GetMODVersion(id);
|
const char *updatecheck = GetMODVersion(id);
|
||||||
if(updatecheck)
|
if(updatecheck)
|
||||||
{
|
{
|
||||||
sprintf(updatestring, UPDATE_ALERT_STRING, VERSIONSTRING, updatecheck);
|
sprintf(updatestring, UPDATE_ALERT_STRING, VERSIONSTRING, updatecheck);
|
||||||
|
#ifdef HAVE_THREADS
|
||||||
|
I_lock_mutex(&m_menu_mutex);
|
||||||
|
#endif
|
||||||
M_StartMessage(updatestring, NULL, MM_NOTHING);
|
M_StartMessage(updatestring, NULL, MM_NOTHING);
|
||||||
return false;
|
#ifdef HAVE_THREADS
|
||||||
} else
|
I_unlock_mutex(m_menu_mutex);
|
||||||
return true;
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif/*UPDATE_ALERT*/
|
#endif/*UPDATE_ALERT*/
|
||||||
|
|
||||||
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
#if defined (UPDATE_ALERT) && defined (HAVE_THREADS)
|
||||||
static void
|
static void
|
||||||
Check_new_version_thread (int *id)
|
Check_new_version_thread (int *id)
|
||||||
{
|
{
|
||||||
int hosting;
|
M_SetWaitingMode(M_WAITING_VERSION);
|
||||||
int okay;
|
|
||||||
|
|
||||||
okay = 0;
|
M_CheckMODVersion(*id);
|
||||||
|
|
||||||
#ifdef UPDATE_ALERT
|
if (Same_instance(*id))
|
||||||
if (M_CheckMODVersion(*id))
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
I_lock_mutex(&ms_QueryId_mutex);
|
Fetch_servers_thread(id);
|
||||||
{
|
|
||||||
okay = ( *id == ms_QueryId );
|
|
||||||
}
|
|
||||||
I_unlock_mutex(ms_QueryId_mutex);
|
|
||||||
|
|
||||||
if (okay)
|
|
||||||
{
|
|
||||||
I_lock_mutex(&m_menu_mutex);
|
|
||||||
{
|
|
||||||
m_waiting_mode = M_WAITING_ROOMS;
|
|
||||||
hosting = ( currentMenu->prevMenu == &MP_ServerDef );
|
|
||||||
}
|
|
||||||
I_unlock_mutex(m_menu_mutex);
|
|
||||||
|
|
||||||
GetRoomsList(hosting, *id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
I_lock_mutex(&ms_QueryId_mutex);
|
free(id);
|
||||||
{
|
|
||||||
okay = ( *id == ms_QueryId );
|
|
||||||
}
|
|
||||||
I_unlock_mutex(ms_QueryId_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (okay)
|
|
||||||
{
|
|
||||||
I_lock_mutex(&m_menu_mutex);
|
|
||||||
{
|
|
||||||
if (m_waiting_mode)
|
|
||||||
{
|
|
||||||
m_waiting_mode = M_NOT_WAITING;
|
|
||||||
MP_RoomMenu[0].text = "<Offline Mode>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
I_unlock_mutex(m_menu_mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(id);
|
|
||||||
}
|
}
|
||||||
#endif/*defined (MASTERSERVER) && defined (HAVE_THREADS)*/
|
#endif/*defined (UPDATE_ALERT) && defined (HAVE_THREADS)*/
|
||||||
|
|
||||||
static void M_ConnectMenu(INT32 choice)
|
static void M_ConnectMenu(INT32 choice)
|
||||||
{
|
{
|
||||||
|
@ -8790,16 +8751,37 @@ static void M_ConnectMenu(INT32 choice)
|
||||||
|
|
||||||
// first page of servers
|
// first page of servers
|
||||||
serverlistpage = 0;
|
serverlistpage = 0;
|
||||||
if (ms_RoomId < 0)
|
M_SetupNextMenu(&MP_ConnectDef);
|
||||||
{
|
|
||||||
M_RoomMenu(0); // Select a room instead of staring at an empty list
|
|
||||||
// This prevents us from returning to the modified game alert.
|
|
||||||
currentMenu->prevMenu = &MP_MainDef;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
M_SetupNextMenu(&MP_ConnectDef);
|
|
||||||
itemOn = 0;
|
itemOn = 0;
|
||||||
|
|
||||||
|
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
||||||
|
I_lock_mutex(&ms_QueryId_mutex);
|
||||||
|
{
|
||||||
|
ms_QueryId++;
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_QueryId_mutex);
|
||||||
|
|
||||||
|
I_lock_mutex(&ms_ServerList_mutex);
|
||||||
|
{
|
||||||
|
if (ms_ServerList)
|
||||||
|
{
|
||||||
|
free(ms_ServerList);
|
||||||
|
ms_ServerList = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
I_unlock_mutex(ms_ServerList_mutex);
|
||||||
|
|
||||||
|
#ifdef UPDATE_ALERT
|
||||||
|
Spawn_masterserver_thread("check-new-version", Check_new_version_thread);
|
||||||
|
#else/*UPDATE_ALERT*/
|
||||||
|
Spawn_masterserver_thread("fetch-servers", Fetch_servers_thread);
|
||||||
|
#endif/*UPDATE_ALERT*/
|
||||||
|
#else/*defined (MASTERSERVER) && defined (HAVE_THREADS)*/
|
||||||
|
#ifdef UPDATE_ALERT
|
||||||
|
M_CheckMODVersion(0);
|
||||||
|
#endif/*UPDATE_ALERT*/
|
||||||
M_Refresh(0);
|
M_Refresh(0);
|
||||||
|
#endif/*defined (MASTERSERVER) && defined (HAVE_THREADS)*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M_ConnectMenuModChecks(INT32 choice)
|
static void M_ConnectMenuModChecks(INT32 choice)
|
||||||
|
@ -8815,96 +8797,6 @@ static void M_ConnectMenuModChecks(INT32 choice)
|
||||||
|
|
||||||
M_ConnectMenu(-1);
|
M_ConnectMenu(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 roomIds[NUM_LIST_ROOMS];
|
|
||||||
|
|
||||||
static void M_RoomMenu(INT32 choice)
|
|
||||||
{
|
|
||||||
INT32 i;
|
|
||||||
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
|
||||||
int *id;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
(void)choice;
|
|
||||||
|
|
||||||
// Display a little "please wait" message.
|
|
||||||
M_DrawTextBox(52, BASEVIDHEIGHT/2-10, 25, 3);
|
|
||||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, "Fetching room info...");
|
|
||||||
V_DrawCenteredString(BASEVIDWIDTH/2, (BASEVIDHEIGHT/2)+12, 0, "Please wait.");
|
|
||||||
I_OsPolling();
|
|
||||||
I_UpdateNoBlit();
|
|
||||||
if (rendermode == render_soft)
|
|
||||||
I_FinishUpdate(); // page flip or blit buffer
|
|
||||||
|
|
||||||
for (i = 1; i < NUM_LIST_ROOMS+1; ++i)
|
|
||||||
MP_RoomMenu[i].status = IT_DISABLED;
|
|
||||||
memset(roomIds, 0, sizeof(roomIds));
|
|
||||||
|
|
||||||
MP_RoomDef.prevMenu = currentMenu;
|
|
||||||
M_SetupNextMenu(&MP_RoomDef);
|
|
||||||
|
|
||||||
#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);
|
|
||||||
|
|
||||||
I_lock_mutex(&ms_QueryId_mutex);
|
|
||||||
{
|
|
||||||
*id = ms_QueryId;
|
|
||||||
}
|
|
||||||
I_unlock_mutex(ms_QueryId_mutex);
|
|
||||||
|
|
||||||
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/*MASTERSERVER*/
|
|
||||||
}
|
|
||||||
|
|
||||||
static void M_ChooseRoom(INT32 choice)
|
|
||||||
{
|
|
||||||
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
|
||||||
I_lock_mutex(&ms_QueryId_mutex);
|
|
||||||
{
|
|
||||||
ms_QueryId++;
|
|
||||||
}
|
|
||||||
I_unlock_mutex(ms_QueryId_mutex);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (choice == 0)
|
|
||||||
ms_RoomId = -1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ms_RoomId = roomIds[choice-1];
|
|
||||||
menuRoomIndex = choice - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
serverlistpage = 0;
|
|
||||||
/*
|
|
||||||
We were on the Multiplayer menu? That means that we must have been trying to
|
|
||||||
view the server browser, but we hadn't selected a room yet. So we need to go
|
|
||||||
to the browser next, not back there.
|
|
||||||
*/
|
|
||||||
if (currentMenu->prevMenu == &MP_MainDef)
|
|
||||||
M_SetupNextMenu(&MP_ConnectDef);
|
|
||||||
else
|
|
||||||
M_SetupNextMenu(currentMenu->prevMenu);
|
|
||||||
if (currentMenu == &MP_ConnectDef)
|
|
||||||
M_Refresh(0);
|
|
||||||
}
|
|
||||||
#endif //NONET
|
#endif //NONET
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
@ -9120,21 +9012,6 @@ static void M_DrawServerMenu(void)
|
||||||
{
|
{
|
||||||
M_DrawLevelSelectOnly(false, false);
|
M_DrawLevelSelectOnly(false, false);
|
||||||
M_DrawGenericMenu();
|
M_DrawGenericMenu();
|
||||||
|
|
||||||
#ifndef NONET
|
|
||||||
// Room name
|
|
||||||
if (currentMenu == &MP_ServerDef)
|
|
||||||
{
|
|
||||||
#define mp_server_room 1
|
|
||||||
if (ms_RoomId < 0)
|
|
||||||
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ServerMenu[mp_server_room].alphaKey,
|
|
||||||
highlightflags, (itemOn == mp_server_room) ? "<Select to change>" : "<LAN Mode>");
|
|
||||||
else
|
|
||||||
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ServerMenu[mp_server_room].alphaKey,
|
|
||||||
highlightflags, room_list[menuRoomIndex].name);
|
|
||||||
#undef mp_server_room
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M_MapChange(INT32 choice)
|
static void M_MapChange(INT32 choice)
|
||||||
|
@ -9164,7 +9041,6 @@ static void M_StartServerMenu(INT32 choice)
|
||||||
(void)choice;
|
(void)choice;
|
||||||
levellistmode = LLM_CREATESERVER;
|
levellistmode = LLM_CREATESERVER;
|
||||||
M_PrepareLevelSelect();
|
M_PrepareLevelSelect();
|
||||||
ms_RoomId = -1;
|
|
||||||
M_SetupNextMenu(&MP_ServerDef);
|
M_SetupNextMenu(&MP_ServerDef);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,6 @@ typedef enum
|
||||||
M_NOT_WAITING,
|
M_NOT_WAITING,
|
||||||
|
|
||||||
M_WAITING_VERSION,
|
M_WAITING_VERSION,
|
||||||
M_WAITING_ROOMS,
|
|
||||||
M_WAITING_SERVERS,
|
M_WAITING_SERVERS,
|
||||||
}
|
}
|
||||||
M_waiting_mode_t;
|
M_waiting_mode_t;
|
||||||
|
@ -175,9 +174,6 @@ typedef struct menuitem_s
|
||||||
|
|
||||||
extern menuitem_t PlayerMenu[MAXSKINS];
|
extern menuitem_t PlayerMenu[MAXSKINS];
|
||||||
|
|
||||||
extern menuitem_t MP_RoomMenu[];
|
|
||||||
extern UINT32 roomIds[NUM_LIST_ROOMS];
|
|
||||||
|
|
||||||
typedef struct menu_s
|
typedef struct menu_s
|
||||||
{
|
{
|
||||||
const char *menutitlepic;
|
const char *menutitlepic;
|
||||||
|
|
35
src/mserv.c
35
src/mserv.c
|
@ -67,10 +67,11 @@ static CV_PossibleValue_t masterserver_update_rate_cons_t[] = {
|
||||||
|
|
||||||
consvar_t cv_masterserver = {"masterserver", "https://mb.srb2.org/MS/0", CV_SAVE|CV_CALL, NULL, MasterServer_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_masterserver = {"masterserver", "https://mb.srb2.org/MS/0", CV_SAVE|CV_CALL, NULL, MasterServer_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_servername = {"servername", "SRB2Kart server", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Update_parameters, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_servername = {"servername", "SRB2Kart server", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Update_parameters, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
consvar_t cv_server_contact = {"server_contact", "", CV_SAVE|CV_CALL|CV_NOINIT, NULL, Update_parameters, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
consvar_t cv_masterserver_update_rate = {"masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_masterserver_update_rate = {"masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
INT16 ms_RoomId = -1;
|
consvar_t cv_advertise = {"advertise", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
||||||
int ms_QueryId;
|
int ms_QueryId;
|
||||||
|
@ -82,10 +83,6 @@ I_mutex ms_ServerList_mutex;
|
||||||
|
|
||||||
UINT16 current_port = 0;
|
UINT16 current_port = 0;
|
||||||
|
|
||||||
// Room list is an external variable now.
|
|
||||||
// Avoiding having to get info ten thousand times...
|
|
||||||
msg_rooms_t room_list[NUM_LIST_ROOMS+1]; // +1 for easy test
|
|
||||||
|
|
||||||
/** Adds variables and commands relating to the master server.
|
/** Adds variables and commands relating to the master server.
|
||||||
*
|
*
|
||||||
* \sa cv_masterserver, cv_servername,
|
* \sa cv_masterserver, cv_servername,
|
||||||
|
@ -99,7 +96,9 @@ void AddMServCommands(void)
|
||||||
CV_RegisterVar(&cv_masterserver_timeout);
|
CV_RegisterVar(&cv_masterserver_timeout);
|
||||||
CV_RegisterVar(&cv_masterserver_debug);
|
CV_RegisterVar(&cv_masterserver_debug);
|
||||||
CV_RegisterVar(&cv_masterserver_token);
|
CV_RegisterVar(&cv_masterserver_token);
|
||||||
|
CV_RegisterVar(&cv_advertise);
|
||||||
CV_RegisterVar(&cv_servername);
|
CV_RegisterVar(&cv_servername);
|
||||||
|
CV_RegisterVar(&cv_server_contact);
|
||||||
#ifdef MASTERSERVER
|
#ifdef MASTERSERVER
|
||||||
COM_AddCommand("listserv", Command_Listserv_f);
|
COM_AddCommand("listserv", Command_Listserv_f);
|
||||||
#endif
|
#endif
|
||||||
|
@ -120,14 +119,14 @@ static void WarnGUI (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NUM_LIST_SERVER MAXSERVERLIST
|
#define NUM_LIST_SERVER MAXSERVERLIST
|
||||||
msg_server_t *GetShortServersList(INT32 room, int id)
|
msg_server_t *GetShortServersList(int id)
|
||||||
{
|
{
|
||||||
msg_server_t *server_list;
|
msg_server_t *server_list;
|
||||||
|
|
||||||
// +1 for easy test
|
// +1 for easy test
|
||||||
server_list = malloc(( NUM_LIST_SERVER + 1 ) * sizeof *server_list);
|
server_list = malloc(( NUM_LIST_SERVER + 1 ) * sizeof *server_list);
|
||||||
|
|
||||||
if (HMS_fetch_servers(server_list, room, id))
|
if (HMS_fetch_servers(server_list, id))
|
||||||
return server_list;
|
return server_list;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -137,17 +136,6 @@ msg_server_t *GetShortServersList(INT32 room, int id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INT32 GetRoomsList(boolean hosting, int id)
|
|
||||||
{
|
|
||||||
if (HMS_fetch_rooms( ! hosting, id))
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WarnGUI();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef UPDATE_ALERT
|
#ifdef UPDATE_ALERT
|
||||||
char *GetMODVersion(int id)
|
char *GetMODVersion(int id)
|
||||||
{
|
{
|
||||||
|
@ -181,15 +169,6 @@ char *GetMODVersion(int id)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Console only version of the above (used before game init)
|
|
||||||
void GetMODVersion_Console(void)
|
|
||||||
{
|
|
||||||
char buffer[16];
|
|
||||||
|
|
||||||
if (HMS_compare_mod_version(buffer, sizeof buffer) > 0)
|
|
||||||
I_Error(UPDATE_ALERT_STRING_CONSOLE, VERSIONSTRING, buffer);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
|
@ -460,7 +439,7 @@ void UnregisterServer(void)
|
||||||
static boolean
|
static boolean
|
||||||
Online (void)
|
Online (void)
|
||||||
{
|
{
|
||||||
return ( serverrunning && ms_RoomId > 0 );
|
return ( serverrunning && cv_advertise.value );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void SendPingToMasterServer(void)
|
static inline void SendPingToMasterServer(void)
|
||||||
|
|
28
src/mserv.h
28
src/mserv.h
|
@ -16,9 +16,6 @@
|
||||||
|
|
||||||
#include "i_threads.h"
|
#include "i_threads.h"
|
||||||
|
|
||||||
// lowered from 32 due to menu changes
|
|
||||||
#define NUM_LIST_ROOMS 16
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
#endif
|
#endif
|
||||||
|
@ -35,19 +32,10 @@ typedef struct
|
||||||
msg_header_t header;
|
msg_header_t header;
|
||||||
char ip[16];
|
char ip[16];
|
||||||
char port[8];
|
char port[8];
|
||||||
char name[32];
|
char contact[32];
|
||||||
INT32 room;
|
|
||||||
char version[8]; // format is: x.yy.z (like 1.30.2 or 1.31)
|
char version[8]; // format is: x.yy.z (like 1.30.2 or 1.31)
|
||||||
} ATTRPACK msg_server_t;
|
} ATTRPACK msg_server_t;
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
msg_header_t header;
|
|
||||||
INT32 id;
|
|
||||||
char name[32];
|
|
||||||
char motd[255];
|
|
||||||
} ATTRPACK msg_rooms_t;
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
msg_header_t header;
|
msg_header_t header;
|
||||||
|
@ -65,15 +53,13 @@ typedef struct
|
||||||
// ================================ GLOBALS ===============================
|
// ================================ GLOBALS ===============================
|
||||||
|
|
||||||
extern consvar_t cv_masterserver, cv_servername;
|
extern consvar_t cv_masterserver, cv_servername;
|
||||||
|
extern consvar_t cv_server_contact;
|
||||||
extern consvar_t cv_masterserver_update_rate;
|
extern consvar_t cv_masterserver_update_rate;
|
||||||
extern consvar_t cv_masterserver_timeout;
|
extern consvar_t cv_masterserver_timeout;
|
||||||
extern consvar_t cv_masterserver_debug;
|
extern consvar_t cv_masterserver_debug;
|
||||||
extern consvar_t cv_masterserver_token;
|
extern consvar_t cv_masterserver_token;
|
||||||
|
|
||||||
// < 0 to not connect (usually -1) (offline mode)
|
extern consvar_t cv_advertise;
|
||||||
// == 0 to show all rooms, not a valid hosting room
|
|
||||||
// anything else is whatever room the MS assigns to that number (online mode)
|
|
||||||
extern INT16 ms_RoomId;
|
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
extern int ms_QueryId;
|
extern int ms_QueryId;
|
||||||
|
@ -88,24 +74,20 @@ void UnregisterServer(void);
|
||||||
|
|
||||||
void MasterClient_Ticker(void);
|
void MasterClient_Ticker(void);
|
||||||
|
|
||||||
msg_server_t *GetShortServersList(INT32 room, int id);
|
msg_server_t *GetShortServersList(int id);
|
||||||
INT32 GetRoomsList(boolean hosting, int id);
|
|
||||||
#ifdef UPDATE_ALERT
|
#ifdef UPDATE_ALERT
|
||||||
char *GetMODVersion(int id);
|
char *GetMODVersion(int id);
|
||||||
void GetMODVersion_Console(void);
|
|
||||||
#endif
|
#endif
|
||||||
extern msg_rooms_t room_list[NUM_LIST_ROOMS+1];
|
|
||||||
|
|
||||||
void AddMServCommands(void);
|
void AddMServCommands(void);
|
||||||
|
|
||||||
/* HTTP */
|
/* HTTP */
|
||||||
void HMS_set_api (char *api);
|
void HMS_set_api (char *api);
|
||||||
int HMS_fetch_rooms (int joining, int id);
|
|
||||||
int HMS_register (void);
|
int HMS_register (void);
|
||||||
int HMS_unlist (void);
|
int HMS_unlist (void);
|
||||||
int HMS_update (void);
|
int HMS_update (void);
|
||||||
void HMS_list_servers (void);
|
void HMS_list_servers (void);
|
||||||
msg_server_t * HMS_fetch_servers (msg_server_t *list, int room, int id);
|
msg_server_t * HMS_fetch_servers (msg_server_t *list, int id);
|
||||||
int HMS_compare_mod_version (char *buffer, size_t size_of_buffer);
|
int HMS_compare_mod_version (char *buffer, size_t size_of_buffer);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue