mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-23 20:31:06 +00:00
Merge branch 'fix-masterserver-listing' into 'next'
Fix in-game masterserver listing See merge request STJr/SRB2!2603
This commit is contained in:
commit
5f66e675c9
5 changed files with 14 additions and 18 deletions
12
src/m_menu.c
12
src/m_menu.c
|
@ -11371,7 +11371,7 @@ static void M_Refresh(INT32 choice)
|
||||||
|
|
||||||
// note: this is the one case where 0 is a valid room number
|
// note: this is the one case where 0 is a valid room number
|
||||||
// because it corresponds to "All"
|
// because it corresponds to "All"
|
||||||
CL_UpdateServerList(!(ms_RoomId < 0), ms_RoomId);
|
CL_UpdateServerList(cv_masterserver_room_id.value >= 0, cv_masterserver_room_id.value);
|
||||||
|
|
||||||
// first page of servers
|
// first page of servers
|
||||||
serverlistpage = 0;
|
serverlistpage = 0;
|
||||||
|
@ -11457,7 +11457,7 @@ static void M_DrawConnectMenu(void)
|
||||||
numPages = 1;
|
numPages = 1;
|
||||||
|
|
||||||
// Room name
|
// Room name
|
||||||
if (ms_RoomId < 0)
|
if (cv_masterserver_room_id.value < 0)
|
||||||
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ConnectMenu[mp_connect_room].alphaKey,
|
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ConnectMenu[mp_connect_room].alphaKey,
|
||||||
V_YELLOWMAP, (itemOn == mp_connect_room) ? "<Select to change>" : "<Unlisted Mode>");
|
V_YELLOWMAP, (itemOn == mp_connect_room) ? "<Select to change>" : "<Unlisted Mode>");
|
||||||
else
|
else
|
||||||
|
@ -11685,7 +11685,7 @@ static void M_ConnectMenu(INT32 choice)
|
||||||
|
|
||||||
// first page of servers
|
// first page of servers
|
||||||
serverlistpage = 0;
|
serverlistpage = 0;
|
||||||
if (ms_RoomId < 0)
|
if (cv_masterserver_room_id.value < 0)
|
||||||
{
|
{
|
||||||
M_RoomMenu(0); // Select a room instead of staring at an empty list
|
M_RoomMenu(0); // Select a room instead of staring at an empty list
|
||||||
// This prevents us from returning to the modified game alert.
|
// This prevents us from returning to the modified game alert.
|
||||||
|
@ -11781,7 +11781,7 @@ static void M_ChooseRoom(INT32 choice)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (choice == 0)
|
if (choice == 0)
|
||||||
CV_SetValue(&cv_masterserver_room_id, 0);
|
CV_SetValue(&cv_masterserver_room_id, -1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CV_SetValue(&cv_masterserver_room_id, roomIds[choice-1]);
|
CV_SetValue(&cv_masterserver_room_id, roomIds[choice-1]);
|
||||||
|
@ -11853,7 +11853,7 @@ static void M_DrawServerMenu(void)
|
||||||
if (currentMenu == &MP_ServerDef)
|
if (currentMenu == &MP_ServerDef)
|
||||||
{
|
{
|
||||||
M_DrawLevelPlatterHeader(currentMenu->y - lsheadingheight/2, "Server settings", true, false);
|
M_DrawLevelPlatterHeader(currentMenu->y - lsheadingheight/2, "Server settings", true, false);
|
||||||
if (ms_RoomId < 0)
|
if (cv_masterserver_room_id.value < 0)
|
||||||
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ServerMenu[mp_server_room].alphaKey,
|
V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ServerMenu[mp_server_room].alphaKey,
|
||||||
V_YELLOWMAP, (itemOn == mp_server_room) ? "<Select to change>" : "<Unlisted Mode>");
|
V_YELLOWMAP, (itemOn == mp_server_room) ? "<Select to change>" : "<Unlisted Mode>");
|
||||||
else
|
else
|
||||||
|
@ -11949,7 +11949,7 @@ static void M_ServerOptions(INT32 choice)
|
||||||
static void M_StartServerMenu(INT32 choice)
|
static void M_StartServerMenu(INT32 choice)
|
||||||
{
|
{
|
||||||
(void)choice;
|
(void)choice;
|
||||||
ms_RoomId = -1;
|
CV_SetValue(&cv_masterserver_room_id, -1);
|
||||||
levellistmode = LLM_CREATESERVER;
|
levellistmode = LLM_CREATESERVER;
|
||||||
Newgametype_OnChange();
|
Newgametype_OnChange();
|
||||||
M_SetupNextMenu(&MP_ServerDef);
|
M_SetupNextMenu(&MP_ServerDef);
|
||||||
|
|
|
@ -663,7 +663,7 @@ void D_QuitNetGame(void)
|
||||||
if (netnodes[i].ingame)
|
if (netnodes[i].ingame)
|
||||||
HSendPacket(i, true, 0, 0);
|
HSendPacket(i, true, 0, 0);
|
||||||
#ifdef MASTERSERVER
|
#ifdef MASTERSERVER
|
||||||
if (serverrunning && ms_RoomId > 0)
|
if (serverrunning && cv_masterserver_room_id.value > 0)
|
||||||
UnregisterServer();
|
UnregisterServer();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -797,7 +797,7 @@ void SV_SpawnServer(void)
|
||||||
{
|
{
|
||||||
I_NetOpenSocket();
|
I_NetOpenSocket();
|
||||||
#ifdef MASTERSERVER
|
#ifdef MASTERSERVER
|
||||||
if (ms_RoomId > 0)
|
if (cv_masterserver_room_id.value > 0)
|
||||||
RegisterServer();
|
RegisterServer();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -426,7 +426,7 @@ HMS_register (void)
|
||||||
|
|
||||||
char *title;
|
char *title;
|
||||||
|
|
||||||
hms = HMS_connect(PROTO_V4, "rooms/%d/register", ms_RoomId);
|
hms = HMS_connect(PROTO_V4, "rooms/%d/register", cv_masterserver_room_id.value);
|
||||||
|
|
||||||
if (! hms)
|
if (! hms)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -462,7 +462,7 @@ HMS_register (void)
|
||||||
if (!hms_allow_ipv6)
|
if (!hms_allow_ipv6)
|
||||||
return ok;
|
return ok;
|
||||||
|
|
||||||
hms = HMS_connect(PROTO_V6, "rooms/%d/register", ms_RoomId);
|
hms = HMS_connect(PROTO_V6, "rooms/%d/register", cv_masterserver_room_id.value);
|
||||||
|
|
||||||
if (! hms)
|
if (! hms)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -67,9 +67,10 @@ consvar_t cv_masterserver = CVAR_INIT ("masterserver", "https://ds.ms.srb2.org/M
|
||||||
consvar_t cv_servername = CVAR_INIT_WITH_CALLBACKS ("servername", "SRB2 server", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT|CV_ALLOWLUA, NULL, Update_parameters, ServerName_CanChange);
|
consvar_t cv_servername = CVAR_INIT_WITH_CALLBACKS ("servername", "SRB2 server", CV_SAVE|CV_NETVAR|CV_CALL|CV_NOINIT|CV_ALLOWLUA, NULL, Update_parameters, ServerName_CanChange);
|
||||||
|
|
||||||
consvar_t cv_masterserver_update_rate = CVAR_INIT ("masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters);
|
consvar_t cv_masterserver_update_rate = CVAR_INIT ("masterserver_update_rate", "15", CV_SAVE|CV_CALL|CV_NOINIT, masterserver_update_rate_cons_t, Update_parameters);
|
||||||
consvar_t cv_masterserver_room_id = CVAR_INIT ("masterserver_room_id", "0", CV_CALL, CV_Unsigned, RoomId_OnChange);
|
CV_PossibleValue_t cv_masterserver_room_values[] = {{-1, "MIN"}, {999999999, "MAX"}, {0, NULL}};
|
||||||
|
consvar_t cv_masterserver_room_id = CVAR_INIT ("masterserver_room_id", "-1", CV_CALL, cv_masterserver_room_values, RoomId_OnChange);
|
||||||
|
|
||||||
INT16 ms_RoomId = 0;
|
static INT16 ms_RoomId = -1;
|
||||||
|
|
||||||
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
||||||
int ms_QueryId;
|
int ms_QueryId;
|
||||||
|
@ -449,7 +450,7 @@ void UnregisterServer(void)
|
||||||
static boolean
|
static boolean
|
||||||
Online (void)
|
Online (void)
|
||||||
{
|
{
|
||||||
return ( serverrunning && ms_RoomId > 0 );
|
return ( serverrunning && cv_masterserver_room_id.value > 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void SendPingToMasterServer(void)
|
static inline void SendPingToMasterServer(void)
|
||||||
|
|
|
@ -71,11 +71,6 @@ 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)
|
|
||||||
// == 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;
|
||||||
extern I_mutex ms_QueryId_mutex;
|
extern I_mutex ms_QueryId_mutex;
|
||||||
|
|
Loading…
Reference in a new issue