mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 15:32:33 +00:00
Merge branch 'add-room-id-cvar' into 'next'
Add CVar for changing room ID See merge request STJr/SRB2!2487
This commit is contained in:
commit
ad0a2717bb
4 changed files with 19 additions and 4 deletions
|
@ -1600,7 +1600,7 @@ void D_SRB2Main(void)
|
|||
{
|
||||
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());
|
||||
CV_SetValue(&cv_masterserver_room_id, atoi(M_GetNextParm()));
|
||||
|
||||
#ifdef UPDATE_ALERT
|
||||
GetMODVersion_Console();
|
||||
|
|
|
@ -11783,10 +11783,10 @@ static void M_ChooseRoom(INT32 choice)
|
|||
#endif
|
||||
|
||||
if (choice == 0)
|
||||
ms_RoomId = -1;
|
||||
CV_SetValue(&cv_masterserver_room_id, 0);
|
||||
else
|
||||
{
|
||||
ms_RoomId = roomIds[choice-1];
|
||||
CV_SetValue(&cv_masterserver_room_id, roomIds[choice-1]);
|
||||
menuRoomIndex = choice - 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ static boolean ServerName_CanChange (const char*);
|
|||
static void Update_parameters (void);
|
||||
|
||||
static void MasterServer_OnChange(void);
|
||||
static void RoomId_OnChange(void);
|
||||
|
||||
static CV_PossibleValue_t masterserver_update_rate_cons_t[] = {
|
||||
{2, "MIN"},
|
||||
|
@ -66,8 +67,9 @@ 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_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);
|
||||
|
||||
INT16 ms_RoomId = -1;
|
||||
INT16 ms_RoomId = 0;
|
||||
|
||||
#if defined (MASTERSERVER) && defined (HAVE_THREADS)
|
||||
int ms_QueryId;
|
||||
|
@ -92,6 +94,7 @@ void AddMServCommands(void)
|
|||
{
|
||||
CV_RegisterVar(&cv_masterserver);
|
||||
CV_RegisterVar(&cv_masterserver_update_rate);
|
||||
CV_RegisterVar(&cv_masterserver_room_id);
|
||||
CV_RegisterVar(&cv_masterserver_timeout);
|
||||
CV_RegisterVar(&cv_masterserver_debug);
|
||||
CV_RegisterVar(&cv_masterserver_token);
|
||||
|
@ -534,6 +537,17 @@ Update_parameters (void)
|
|||
#endif/*MASTERSERVER*/
|
||||
}
|
||||
|
||||
static void RoomId_OnChange(void)
|
||||
{
|
||||
if (ms_RoomId != cv_masterserver_room_id.value)
|
||||
{
|
||||
UnregisterServer();
|
||||
ms_RoomId = cv_masterserver_room_id.value;
|
||||
if (Online())
|
||||
RegisterServer();
|
||||
}
|
||||
}
|
||||
|
||||
static void MasterServer_OnChange(void)
|
||||
{
|
||||
#ifdef MASTERSERVER
|
||||
|
|
|
@ -66,6 +66,7 @@ typedef struct
|
|||
|
||||
extern consvar_t cv_masterserver, cv_servername;
|
||||
extern consvar_t cv_masterserver_update_rate;
|
||||
extern consvar_t cv_masterserver_room_id;
|
||||
extern consvar_t cv_masterserver_timeout;
|
||||
extern consvar_t cv_masterserver_debug;
|
||||
extern consvar_t cv_masterserver_token;
|
||||
|
|
Loading…
Reference in a new issue