i_system.c -> cpp, disable mumble

This commit is contained in:
Eidolon 2023-10-14 15:22:19 -05:00
parent 61a021ce4a
commit 2d614781eb
7 changed files with 48 additions and 15 deletions

View file

@ -32,6 +32,7 @@
#include "r_picformats.h" #include "r_picformats.h"
#include "r_things.h" // R_Char2Frame #include "r_things.h" // R_Char2Frame
#include "r_sky.h" #include "r_sky.h"
#include "s_sound.h"
#include "fastcmp.h" #include "fastcmp.h"
#include "lua_script.h" // Reluctantly included for LUA_EvalMath #include "lua_script.h" // Reluctantly included for LUA_EvalMath
#include "d_clisrv.h" #include "d_clisrv.h"

View file

@ -23,6 +23,7 @@
#include "k_menu.h" // gametype_cons_t #include "k_menu.h" // gametype_cons_t
#include "r_things.h" // skins #include "r_things.h" // skins
#include "mserv.h" // cv_advertise #include "mserv.h" // cv_advertise
#include "s_sound.h"
#include "z_zone.h" #include "z_zone.h"
#include "byteptr.h" #include "byteptr.h"
#include "stun.h" #include "stun.h"

View file

@ -24,6 +24,7 @@
#include "p_local.h" #include "p_local.h"
#include "p_mobj.h" #include "p_mobj.h"
#include "r_textures.h" #include "r_textures.h"
#include "s_sound.h"
#include "w_wad.h" #include "w_wad.h"
#include "z_zone.h" #include "z_zone.h"

View file

@ -7,6 +7,7 @@
#include "../i_video.h" // I_UpdateNoBlit #include "../i_video.h" // I_UpdateNoBlit
#include "../m_misc.h" // NUMLOGIP #include "../m_misc.h" // NUMLOGIP
#include "../f_finale.h" // g_wipeskiprender #include "../f_finale.h" // g_wipeskiprender
#include "../s_sound.h"
menuitem_t PLAY_MP_JoinIP[] = menuitem_t PLAY_MP_JoinIP[] =
{ {

View file

@ -30,6 +30,7 @@
#include "m_cond.h" #include "m_cond.h"
#include "k_kart.h" #include "k_kart.h"
#include "m_random.h" #include "m_random.h"
#include "s_sound.h"
#if 0 #if 0
#include "k_kart.h" // K_KartResetPlayerColor #include "k_kart.h" // K_KartResetPlayerColor
#endif #endif

View file

@ -7,7 +7,7 @@ target_sources(SRB2SDL2 PRIVATE
rhi_gl3_core_platform.hpp rhi_gl3_core_platform.hpp
i_threads.c i_threads.c
i_net.c i_net.c
i_system.c i_system.cpp
i_main.cpp i_main.cpp
i_video.cpp i_video.cpp
dosstr.c dosstr.c
@ -92,6 +92,9 @@ endif()
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER) target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXER -DSOUND=SOUND_MIXER)
target_compile_definitions(SRB2SDL2 PRIVATE -DDIRECTFULLSCREEN -DHAVE_SDL) target_compile_definitions(SRB2SDL2 PRIVATE -DDIRECTFULLSCREEN -DHAVE_SDL)
# NOMUMBLE till WRITE* macros are fixed for C++ or mumble integration is rewritten
target_compile_definitions(SRB2SDL2 PRIVATE -DNOMUMBLE)
#### Installation #### #### Installation ####
if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin) if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin)
install(TARGETS SRB2SDL2 install(TARGETS SRB2SDL2

View file

@ -23,6 +23,8 @@
/// \file /// \file
/// \brief SRB2 system stuff for SDL /// \brief SRB2 system stuff for SDL
#include <thread>
#include <signal.h> #include <signal.h>
#ifdef _WIN32 #ifdef _WIN32
@ -168,6 +170,8 @@ static char returnWadPath[256];
#include "../d_net.h" #include "../d_net.h"
#include "../g_game.h" #include "../g_game.h"
#include "../filesrch.h" #include "../filesrch.h"
#include "../s_sound.h"
#include "../core/thread_pool.h"
#include "endtxt.h" #include "endtxt.h"
#include "sdlmain.h" #include "sdlmain.h"
@ -194,6 +198,8 @@ static char returnWadPath[256];
#include "../byteptr.h" #include "../byteptr.h"
#endif #endif
static std::thread::id g_main_thread_id;
/** \brief SDL info about joysticks /** \brief SDL info about joysticks
*/ */
SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS]; SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS];
@ -350,7 +356,7 @@ static void I_ShowErrorMessageBox(const char *messagefordevelopers, boolean dump
// which should fail gracefully if it can't put a message box up // which should fail gracefully if it can't put a message box up
// on the target system // on the target system
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"Dr. Robotnik's Ring Racers "VERSIONSTRING" Error", "Dr. Robotnik's Ring Racers " VERSIONSTRING " Error",
finalmessage, NULL); finalmessage, NULL);
// Note that SDL_ShowSimpleMessageBox does *not* require SDL to be // Note that SDL_ShowSimpleMessageBox does *not* require SDL to be
@ -423,6 +429,14 @@ static void I_ReportSignal(int num, int coredumped)
#ifndef NEWSIGNALHANDLER #ifndef NEWSIGNALHANDLER
FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num)
{ {
if (g_main_thread_id != std::this_thread::get_id())
{
// Do not attempt any sort of recovery if this signal triggers off the main thread
signal(num, SIG_DFL);
raise(num);
exit(-2);
}
D_QuitNetGame(); // Fix server freezes D_QuitNetGame(); // Fix server freezes
CL_AbortDownloadResume(); CL_AbortDownloadResume();
G_DirtyGameData(); G_DirtyGameData();
@ -799,6 +813,8 @@ static inline void I_ShutdownConsole(void){}
// //
static void I_RegisterSignals (void) static void I_RegisterSignals (void)
{ {
g_main_thread_id = std::this_thread::get_id();
#ifdef SIGINT #ifdef SIGINT
signal(SIGINT , quit_handler); signal(SIGINT , quit_handler);
#endif #endif
@ -910,7 +926,7 @@ void I_OutputMsg(const char *fmt, ...)
return; return;
} }
ReadConsoleOutputCharacter(co, oldLines, oldLength, coordNextWrite, &bytesWritten); ReadConsoleOutputCharacter(co, (LPSTR)oldLines, oldLength, coordNextWrite, &bytesWritten);
// Move to where we what to print - which is where we would've been, // Move to where we what to print - which is where we would've been,
// had console input not been in the way, // had console input not been in the way,
@ -1251,7 +1267,8 @@ const char *I_GetJoyName(INT32 joyindex)
tempname = SDL_JoystickNameForIndex(joyindex); tempname = SDL_JoystickNameForIndex(joyindex);
if (tempname) if (tempname)
{ {
strncpy(joyname, tempname, 255); strncpy(joyname, tempname, 254);
joyname[254] = 0;
} }
return joyname; return joyname;
@ -1267,7 +1284,7 @@ const char *I_GetJoyName(INT32 joyindex)
#define DEG2RAD (0.017453292519943295769236907684883l) // TAU/360 or PI/180 #define DEG2RAD (0.017453292519943295769236907684883l) // TAU/360 or PI/180
#define MUMBLEUNIT (64.0f) // FRACUNITS in a Meter #define MUMBLEUNIT (64.0f) // FRACUNITS in a Meter
static struct { static struct mumble_s {
#ifdef WINMUMBLE #ifdef WINMUMBLE
UINT32 uiVersion; UINT32 uiVersion;
DWORD uiTick; DWORD uiTick;
@ -1300,7 +1317,7 @@ static void I_SetupMumble(void)
if (!hMap) if (!hMap)
return; return;
mumble = MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(*mumble)); mumble = static_cast<mumble_s*>(MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(*mumble)));
if (!mumble) if (!mumble)
CloseHandle(hMap); CloseHandle(hMap);
#elif defined (HAVE_SHM) #elif defined (HAVE_SHM)
@ -1587,6 +1604,8 @@ INT32 I_StartupSystem(void)
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
I_start_threads(); I_start_threads();
I_AddExitFunc(I_stop_threads); I_AddExitFunc(I_stop_threads);
I_ThreadPoolInit();
I_AddExitFunc(I_ThreadPoolShutdown);
#endif #endif
I_StartupConsole(); I_StartupConsole();
#ifdef NEWSIGNALHANDLER #ifdef NEWSIGNALHANDLER
@ -1693,6 +1712,12 @@ void I_Error(const char *error, ...)
va_list argptr; va_list argptr;
char buffer[8192]; char buffer[8192];
if (std::this_thread::get_id() != g_main_thread_id)
{
// Do not attempt a graceful shutdown. Errors off the main thread are unresolvable.
exit(-2);
}
// recursive error detecting // recursive error detecting
if (shutdowning) if (shutdowning)
{ {
@ -1728,7 +1753,7 @@ void I_Error(const char *error, ...)
// on the target system // on the target system
if (!M_CheckParm("-dedicated")) if (!M_CheckParm("-dedicated"))
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"Dr. Robotnik's Ring Racers "VERSIONSTRING" Recursive Error", "Dr. Robotnik's Ring Racers " VERSIONSTRING " Recursive Error",
buffer, NULL); buffer, NULL);
W_Shutdown(); W_Shutdown();
@ -2074,7 +2099,7 @@ const char *I_ClipboardPaste(void)
*/ */
static boolean isWadPathOk(const char *path) static boolean isWadPathOk(const char *path)
{ {
char *wad3path = malloc(256); char *wad3path = static_cast<char*>(malloc(256));
if (!wad3path) if (!wad3path)
return false; return false;