Maybe hopefully fix ogl masterserver crash thing

port from durr
This commit is contained in:
Alug committed 2024-06-14 04:01:30 +02:00
1 parent 1cb590ebb8
commit 5cd36e55ab
3 files changed
+78 -16

No files matched your search

+4
View File
@@ -82,6 +82,9 @@
// protocol handling
#include "d_protocol.h"
#include "z_zone.h"
#include "mserv.h"
#if defined(HAVE_SDL)
#include "SDL.h"
#if SDL_VERSION_ATLEAST(2,0,0)
@@ -10132,6 +10135,7 @@ static void M_StartServerMenu(INT32 choice)
levellistmode = LLM_CREATESERVER;
M_PrepareLevelSelect();
M_SetupNextMenu(&MP_ServerDef);
Get_rules();
M_PopupMasterServerRules();
}
+72 -16
View File
@@ -17,6 +17,7 @@
#include "doomstat.h"
#include "doomdef.h"
#include "console.h" // con_startup
#include "command.h"
#include "i_threads.h"
#include "mserv.h"
@@ -212,20 +213,50 @@ static void Command_Listserv_f(void)
}
#endif
static boolean firstmsrules = false;
static void
Get_masterserver_rules (boolean checkfirst)
{
char rules[256];
if (checkfirst)
{
boolean MSRulesExist;
Lock_state();
MSRulesExist = (MSRules != NULL);
Unlock_state();
if (MSRulesExist)
return;
}
if (HMS_fetch_rules(rules, sizeof rules))
{
Lock_state();
Z_Free(MSRules);
MSRules = Z_StrDup(rules);
if (MSRegistered == true)
{
CONS_Printf("\n");
CONS_Alert(CONS_NOTICE, "%s\n", rules);
}
firstmsrules = true;
Unlock_state();
}
}
static void
Finish_registration (void)
{
int registered;
char *rules = GetMasterServerRules();
CONS_Printf("Registering this server on the master server...\n");
if (rules)
{
CONS_Printf("\n");
CONS_Alert(CONS_NOTICE, "%s\n", rules);
}
registered = HMS_register();
Lock_state();
@@ -237,6 +268,17 @@ Finish_registration (void)
}
Unlock_state();
char *rules = GetMasterServerRules();
if (rules == NULL)
{
Get_masterserver_rules(true);
}
else
{
CONS_Printf("\n");
CONS_Alert(CONS_NOTICE, "%s\n", rules);
}
if (registered)
CONS_Printf("Master server registration successful.\n");
}
@@ -322,17 +364,10 @@ Finish_unlist (void)
static void
Finish_masterserver_change (char *api)
{
char rules[256];
HMS_set_api(api);
if (HMS_fetch_rules(rules, sizeof rules))
{
Lock_state();
Z_Free(MSRules);
MSRules = Z_StrDup(rules);
Unlock_state();
}
if (!con_startup)
Get_masterserver_rules(false);
}
#ifdef HAVE_THREADS
@@ -430,6 +465,13 @@ Change_masterserver_thread (char *api)
Finish_masterserver_change(api);
}
static void
Get_masterserver_rules_thread (void)
{
// THIS FUNC has its own lock check in it
Get_masterserver_rules(true);
}
#endif/*HAVE_THREADS*/
void RegisterServer(void)
@@ -540,6 +582,20 @@ Set_api (const char *api)
#endif
}
void
Get_rules (void)
{
#ifdef HAVE_THREADS
I_spawn_thread(
"get-masterserver-rules",
(I_thread_fn)Get_masterserver_rules_thread,
NULL
);
#else
Get_masterserver_rules(true);
#endif
}
#endif/*MASTERSERVER*/
static void
+2
View File
@@ -82,6 +82,8 @@ extern I_mutex ms_ServerList_mutex;
void RegisterServer(void);
void UnregisterServer(void);
void Get_rules(void);
void MasterClient_Ticker(void);
msg_server_t *GetShortServersList(int id);