Kill the old mserv, long live HMS!

This commit is contained in:
James R 2020-04-13 22:23:01 -07:00
parent 7255d360e1
commit 1201e89132
5 changed files with 86 additions and 968 deletions

View file

@ -1764,10 +1764,6 @@ static void SendAskInfo(INT32 node, boolean viams)
// now allowed traffic from the host to us in, so once the MS relays // now allowed traffic from the host to us in, so once the MS relays
// our address to the host, it'll be able to speak to us. // our address to the host, it'll be able to speak to us.
HSendPacket(node, false, 0, sizeof (askinfo_pak)); HSendPacket(node, false, 0, sizeof (askinfo_pak));
// Also speak to the MS.
if (viams && node != 0 && node != BROADCASTADDR)
SendAskInfoViaMS(node, asktime);
} }
serverelem_t serverlist[MAXSERVERLIST]; serverelem_t serverlist[MAXSERVERLIST];
@ -1830,7 +1826,6 @@ void CL_UpdateServerList(boolean internetsearch, INT32 room)
if (!netgame && I_NetOpenSocket) if (!netgame && I_NetOpenSocket)
{ {
MSCloseUDPSocket(); // Tidy up before wiping the slate.
if (I_NetOpenSocket()) if (I_NetOpenSocket())
{ {
netgame = true; netgame = true;
@ -2567,7 +2562,6 @@ static void Command_connect(void)
} }
else if (I_NetOpenSocket) else if (I_NetOpenSocket)
{ {
MSCloseUDPSocket(); // Tidy up before wiping the slate.
I_NetOpenSocket(); I_NetOpenSocket();
netgame = true; netgame = true;
multiplayer = true; multiplayer = true;
@ -3637,7 +3631,6 @@ boolean SV_SpawnServer(void)
SV_GenContext(); SV_GenContext();
if (netgame && I_NetOpenSocket) if (netgame && I_NetOpenSocket)
{ {
MSCloseUDPSocket(); // Tidy up before wiping the slate.
I_NetOpenSocket(); I_NetOpenSocket();
if (ms_RoomId > 0) if (ms_RoomId > 0)
RegisterServer(); RegisterServer();

View file

@ -27,14 +27,6 @@ Documentation available here.
#define Blame( ... ) \ #define Blame( ... ) \
CONS_Printf("\x85" __VA_ARGS__) CONS_Printf("\x85" __VA_ARGS__)
consvar_t cv_http_masterserver = {
"http_masterserver",
"https://mb.srb2.org/MS/0",
CV_SAVE,
NULL, NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
};
consvar_t cv_masterserver_debug = { consvar_t cv_masterserver_debug = {
"masterserver_debug", "Off", CV_SAVE, CV_OnOff, "masterserver_debug", "Off", CV_SAVE, CV_OnOff,
NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */ NULL, 0, NULL, NULL, 0, 0, NULL/* C90 moment */
@ -108,13 +100,13 @@ HMS_connect (const char *format, ...)
return NULL; return NULL;
} }
seek = strlen(cv_http_masterserver.string) + 1;/* + '/' */ seek = strlen(ms_API) + 1;/* + '/' */
va_start (ap, format); va_start (ap, format);
url = ZZ_Alloc(seek + vsnprintf(0, 0, format, ap) + 1); url = ZZ_Alloc(seek + vsnprintf(0, 0, format, ap) + 1);
va_end (ap); va_end (ap);
sprintf(url, "%s/", cv_http_masterserver.string); sprintf(url, "%s/", ms_API);
va_start (ap, format); va_start (ap, format);
vsprintf(&url[seek], format, ap); vsprintf(&url[seek], format, ap);
@ -200,15 +192,10 @@ HMS_end (struct HMS_buffer *buffer)
} }
int int
HMS_in_use (void)
{
return cv_http_masterserver.string[0];
}
void
HMS_fetch_rooms (int joining) HMS_fetch_rooms (int joining)
{ {
struct HMS_buffer *hms; struct HMS_buffer *hms;
int ok;
char *id; char *id;
char *title; char *title;
@ -248,9 +235,15 @@ HMS_fetch_rooms (int joining)
} }
room_list[i].header.buffer[0] = 0; room_list[i].header.buffer[0] = 0;
ok = 1;
} }
else
ok = 0;
HMS_end(hms); HMS_end(hms);
return ok;
} }
int int
@ -312,10 +305,11 @@ HMS_unlist (void)
Z_Free(hms_server_token); Z_Free(hms_server_token);
} }
void int
HMS_update (void) HMS_update (void)
{ {
struct HMS_buffer *hms; struct HMS_buffer *hms;
int ok;
char post[256]; char post[256];
@ -334,8 +328,10 @@ HMS_update (void)
curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post); curl_easy_setopt(hms->curl, CURLOPT_POSTFIELDS, post);
HMS_do(hms); ok = HMS_do(hms);
HMS_end(hms); HMS_end(hms);
return ok;
} }
void void
@ -359,7 +355,7 @@ HMS_list_servers (void)
HMS_end(hms); HMS_end(hms);
} }
void msg_server_t *
HMS_fetch_servers (msg_server_t *list, int room_number) HMS_fetch_servers (msg_server_t *list, int room_number)
{ {
struct HMS_buffer *hms; struct HMS_buffer *hms;
@ -452,22 +448,27 @@ HMS_fetch_servers (msg_server_t *list, int room_number)
list[i].header.buffer[0] = 0; list[i].header.buffer[0] = 0;
} }
else
list = NULL;
HMS_end(hms); HMS_end(hms);
return list;
} }
const char * int
HMS_compare_mod_version (void) HMS_compare_mod_version (char *buffer, size_t buffer_size)
{ {
static char buffer[16];
struct HMS_buffer *hms; struct HMS_buffer *hms;
int ok;
char *version; char *version;
char *version_name; char *version_name;
hms = HMS_connect("versions/%d", MODID); hms = HMS_connect("versions/%d", MODID);
ok = 0;
if (HMS_do(hms)) if (HMS_do(hms))
{ {
version = strtok(hms->buffer, " "); version = strtok(hms->buffer, " ");
@ -477,17 +478,15 @@ HMS_compare_mod_version (void)
{ {
if (atoi(version) != MODVERSION) if (atoi(version) != MODVERSION)
{ {
strlcpy(buffer, version_name, sizeof buffer); strlcpy(buffer, version_name, buffer_size);
version_name = buffer; ok = 1;
} }
else else
version_name = NULL; ok = -1;
} }
} }
else
version_name = NULL;
HMS_end(hms); HMS_end(hms);
return version_name; return ok;
} }

View file

@ -2892,7 +2892,6 @@ boolean M_Responder(event_t *ev)
//make sure the game doesn't still think we're in a netgame. //make sure the game doesn't still think we're in a netgame.
if (!Playing() && netgame && multiplayer) if (!Playing() && netgame && multiplayer)
{ {
MSCloseUDPSocket(); // Clean up so we can re-open the connection later.
netgame = false; netgame = false;
multiplayer = false; multiplayer = false;
} }

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team. // Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2018 by Sonic Team Junior. // Copyright (C) 1999-2018 by Sonic Team Junior.
// Copyright (C) 2020 by James R.
// //
// This program is free software distributed under the // This program is free software distributed under the
// terms of the GNU General Public License, version 2. // terms of the GNU General Public License, version 2.
@ -13,7 +14,7 @@
#ifndef _MSERV_H_ #ifndef _MSERV_H_
#define _MSERV_H_ #define _MSERV_H_
#define MASTERSERVERS21 // MasterServer v2.1 #define HMS123311 // don't mess with nights, man
// lowered from 32 due to menu changes // lowered from 32 due to menu changes
#define NUM_LIST_ROOMS 16 #define NUM_LIST_ROOMS 16
@ -64,21 +65,14 @@ typedef struct
// ================================ GLOBALS =============================== // ================================ GLOBALS ===============================
extern consvar_t cv_masterserver, cv_servername; extern consvar_t cv_masterserver, cv_servername;
extern consvar_t cv_http_masterserver;
extern consvar_t cv_masterserver_debug; extern consvar_t cv_masterserver_debug;
extern char *ms_API;
// < 0 to not connect (usually -1) (offline mode) // < 0 to not connect (usually -1) (offline mode)
// == 0 to show all rooms, not a valid hosting room // == 0 to show all rooms, not a valid hosting room
// anything else is whatever room the MS assigns to that number (online mode) // anything else is whatever room the MS assigns to that number (online mode)
INT16 ms_RoomId; extern INT16 ms_RoomId;
const char *GetMasterServerPort(void);
const char *GetMasterServerIP(void);
void MSOpenUDPSocket(void);
void MSCloseUDPSocket(void);
void SendAskInfoViaMS(INT32 node, tic_t asktime);
void RegisterServer(void); void RegisterServer(void);
void UnregisterServer(void); void UnregisterServer(void);