From 09d661c331dd379e8a9b48bc6b35c8cbd8bb4bdc Mon Sep 17 00:00:00 2001 From: Eidolon Date: Mon, 18 Sep 2023 16:38:35 -0500 Subject: [PATCH] Convert d_main.cpp --- src/Sourcefile | 2 +- src/{d_main.c => d_main.cpp} | 20 ++++++++++---------- src/m_menu.h | 8 ++++++++ 3 files changed, 19 insertions(+), 11 deletions(-) rename src/{d_main.c => d_main.cpp} (98%) diff --git a/src/Sourcefile b/src/Sourcefile index fa2cf16c6..7ad7eebcf 100644 --- a/src/Sourcefile +++ b/src/Sourcefile @@ -1,6 +1,6 @@ qs22j.c string.c -d_main.c +d_main.cpp d_clisrv.c d_net.c d_netfil.c diff --git a/src/d_main.c b/src/d_main.cpp similarity index 98% rename from src/d_main.c rename to src/d_main.cpp index 64becf217..e74764f09 100644 --- a/src/d_main.c +++ b/src/d_main.cpp @@ -202,7 +202,7 @@ void D_ProcessEvents(void) continue; } - if (demo.savemode == DSM_TITLEENTRY) + if (demo.savemode == demovars_s::DSM_TITLEENTRY) { if (G_DemoTitleResponder(ev)) continue; @@ -298,7 +298,7 @@ static void D_Display(void) { for (i = 0; i <= r_splitscreen; ++i) { - R_SetViewContext(VIEWCONTEXT_PLAYER1 + i); + R_SetViewContext(static_cast(VIEWCONTEXT_PLAYER1 + i)); R_InterpolateViewRollAngle(rendertimefrac); R_CheckViewMorph(i); } @@ -972,7 +972,7 @@ void D_StartTitle(void) // In case someone exits out at the same time they start a time attack run, // reset modeattacking modeattacking = ATTACKING_NONE; - marathonmode = 0; + marathonmode = static_cast(0); // Reset GP memset(&grandprixinfo, 0, sizeof(struct grandprixinfo)); @@ -1024,7 +1024,7 @@ static void D_AddFile(char **list, const char *file) for (pnumwadfiles = 0; list[pnumwadfiles]; pnumwadfiles++) ; - newfile = malloc(strlen(file) + 1); + newfile = static_cast(malloc(strlen(file) + 1)); if (!newfile) { I_Error("No more free memory to AddFile %s",file); @@ -1169,7 +1169,7 @@ static void IdentifyVersion(void) if (ms == 1) \ D_AddFile(startupiwads, musicpath); \ else if (ms == 0) \ - I_Error("File "str" has been modified with non-music/sound lumps"); \ + I_Error("File " str " has been modified with non-music/sound lumps"); \ } MUSICTEST(SOUNDSNAME) @@ -1268,7 +1268,7 @@ void D_SRB2Main(void) // default savegame strcpy(savegamename, SAVEGAMENAME"%u.ssg"); - strcpy(liveeventbackup, "live"SAVEGAMENAME".bkp"); // intentionally not ending with .ssg + strcpy(liveeventbackup, "live" SAVEGAMENAME".bkp"); // intentionally not ending with .ssg { const char *userhome = D_Home(); //Alam: path to home @@ -1279,7 +1279,7 @@ void D_SRB2Main(void) I_Error("Please set $HOME to your home directory\n"); #else if (dedicated) - snprintf(configfile, sizeof configfile, "d"CONFIGFILENAME); + snprintf(configfile, sizeof configfile, "d" CONFIGFILENAME); else snprintf(configfile, sizeof configfile, CONFIGFILENAME); #endif @@ -1290,7 +1290,7 @@ void D_SRB2Main(void) #ifdef DEFAULTDIR snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome); if (dedicated) - snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home); + snprintf(configfile, sizeof configfile, "%s" PATHSEP "d" CONFIGFILENAME, srb2home); else snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2home); @@ -1740,9 +1740,9 @@ void D_SRB2Main(void) // user settings come before "+" parameters. if (dedicated) - COM_ImmedExecute(va("exec \"%s"PATHSEP"kartserv.cfg\"\n", srb2home)); + COM_ImmedExecute(va("exec \"%s" PATHSEP "kartserv.cfg\"\n", srb2home)); else - COM_ImmedExecute(va("exec \"%s"PATHSEP"kartexec.cfg\" -noerror\n", srb2home)); + COM_ImmedExecute(va("exec \"%s" PATHSEP "kartexec.cfg\" -noerror\n", srb2home)); if (!autostart) M_PushSpecialParameters(); // push all "+" parameters at the command buffer diff --git a/src/m_menu.h b/src/m_menu.h index 0007bd1cf..b9d2de249 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -23,6 +23,10 @@ #include "mserv.h" #include "r_skins.h" // for SKINNAMESIZE +#ifdef __cplusplus +extern "C" { +#endif + // Compatibility with old-style named NiGHTS replay files. #define OLDNREPLAYNAME @@ -587,4 +591,8 @@ void M_FreePlayerSetupColors(void); NULL\ } +#ifdef __cplusplus +} // extern "C" +#endif + #endif //__X_MENU__