Created
November 23, 2025 10:41
-
-
Save Bijman/e39d5f63b68a7e4251dfe30449b3a7d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/CMakeLists.txt b/CMakeLists.txt | |
| index b7d280190..c5e12d93d 100644 | |
| --- a/CMakeLists.txt | |
| +++ b/CMakeLists.txt | |
| @@ -3,7 +3,11 @@ cmake_minimum_required(VERSION 3.5) | |
| # Version change is fine. | |
| project(SRB2 | |
| VERSION 1.6 | |
| - LANGUAGES C) | |
| + LANGUAGES C CXX) | |
| + | |
| +set(CMAKE_CXX_STANDARD 17) | |
| +set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
| +set(CMAKE_CXX_EXTENSIONS OFF) # optional but recommended: disables GNU extensions, forces pure ISO C++ | |
| if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) | |
| message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") | |
| diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt | |
| index 361386622..7e89608d5 100644 | |
| --- a/src/CMakeLists.txt | |
| +++ b/src/CMakeLists.txt | |
| @@ -2,6 +2,12 @@ | |
| # Core sources | |
| set(SRB2_CORE_SOURCES | |
| + core/memory.cpp | |
| + core/thread_pool.cpp | |
| + r_skins.c | |
| + m_curl.c | |
| + m_emotes.cpp | |
| + k_hud.c | |
| am_map.c | |
| b_bot.c | |
| command.c | |
| @@ -18,6 +24,7 @@ set(SRB2_CORE_SOURCES | |
| f_wipe.c | |
| filesrch.c | |
| g_game.c | |
| + g_demo.c | |
| g_input.c | |
| hu_stuff.c | |
| i_tcp.c | |
| @@ -44,15 +51,20 @@ set(SRB2_CORE_SOURCES | |
| screen.c | |
| sounds.c | |
| st_stuff.c | |
| - #string.c | |
| tables.c | |
| v_video.c | |
| w_wad.c | |
| y_inter.c | |
| - z_zone.c | |
| + z_zone.cpp | |
| ) | |
| set(SRB2_CORE_HEADERS | |
| + core/memory.h | |
| + core/thread_pool.h | |
| + r_skins.h | |
| + m_curl.h | |
| + m_emotes.h | |
| + k_hud.h | |
| am_map.h | |
| b_bot.h | |
| byteptr.h | |
| @@ -78,6 +90,7 @@ set(SRB2_CORE_HEADERS | |
| fastcmp.h | |
| filesrch.h | |
| g_game.h | |
| + g_demo.h | |
| g_input.h | |
| g_state.h | |
| hu_stuff.h | |
| @@ -123,18 +136,18 @@ set(SRB2_CORE_HEADERS | |
| ) | |
| set(SRB2_CORE_RENDER_SOURCES | |
| - r_bsp.c | |
| + r_bsp.cpp | |
| r_data.c | |
| - r_draw.c | |
| - r_fps.c | |
| - r_main.c | |
| - r_patch.c | |
| - r_patchrotation.c | |
| - r_plane.c | |
| - r_segs.c | |
| + r_draw.cpp | |
| + r_fps.cpp | |
| + r_main.cpp | |
| + r_patch.cpp | |
| + r_patchrotation.cpp | |
| + r_plane.cpp | |
| + r_segs.cpp | |
| r_sky.c | |
| r_splats.c | |
| - r_things.c | |
| + r_things.cpp | |
| r_portal.c | |
| r_bsp.h | |
| @@ -162,7 +175,7 @@ set(SRB2_CORE_GAME_SOURCES | |
| p_inter.c | |
| p_lights.c | |
| p_map.c | |
| - p_maputl.c | |
| + p_maputl.cpp | |
| p_mobj.c | |
| p_polyobj.c | |
| p_saveg.c | |
| @@ -478,7 +491,7 @@ if(${SRB2_CONFIG_HWRENDER}) | |
| ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c | |
| ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c | |
| ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c | |
| - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c | |
| + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.cpp | |
| ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.c | |
| ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c | |
| ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c | |
| diff --git a/src/command.h b/src/command.h | |
| index 7074158e1..dc7a29e8e 100644 | |
| --- a/src/command.h | |
| +++ b/src/command.h | |
| @@ -13,12 +13,13 @@ | |
| #ifndef __COMMAND_H__ | |
| #define __COMMAND_H__ | |
| +#include <stdio.h> | |
| +#include "doomdef.h" | |
| + | |
| #ifdef __cplusplus | |
| extern "C" { | |
| #endif | |
| -#include <stdio.h> | |
| -#include "doomdef.h" | |
| //=================================== | |
| // Command buffer & command execution | |
| diff --git a/src/d_netcmd.c b/src/d_netcmd.c | |
| index 6d90e4d4e..c3b43453b 100644 | |
| --- a/src/d_netcmd.c | |
| +++ b/src/d_netcmd.c | |
| @@ -53,6 +53,10 @@ | |
| #include "y_inter.h" | |
| #include "fastcmp.h" | |
| #include "m_perfstats.h" | |
| +#include "r_data.h" | |
| +CV_PossibleValue_t Color_cons_t[]; | |
| +#include "r_skins.h" | |
| +CV_PossibleValue_t Forceskin_cons_t[]; | |
| #ifdef NETGAME_DEVMODE | |
| #define CV_RESTRICT CV_NETVAR | |
| diff --git a/src/doomdef.h b/src/doomdef.h | |
| index 32f204f9b..136804ced 100644 | |
| --- a/src/doomdef.h | |
| +++ b/src/doomdef.h | |
| @@ -40,22 +40,45 @@ | |
| #define ASMCALL | |
| #endif | |
| +#include "doomtype.h" | |
| + | |
| +#ifdef __cplusplus /* Only when compiled as C++ */ | |
| + #include <algorithm> /* std::min, std::max, std::sort, … */ | |
| +#endif | |
| + | |
| #ifdef __cplusplus | |
| -extern "C" { | |
| + | |
| +// Force libc++ to expose std::min/std::max even when <cmath> is included first (Apple clang quirk) | |
| +#ifndef _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES | |
| +#define _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES | |
| +#endif | |
| +#ifndef _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS | |
| +#define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS | |
| #endif | |
| -#include "doomtype.h" | |
| +// Optional: only try <version> if it actually exists (newer Xcode) | |
| +#if __has_include(<version>) | |
| +#include <version> | |
| +#endif | |
| +#define _USE_MATH_DEFINES | |
| +#include <cmath> | |
| +#include <cstdarg> | |
| +#include <cstdio> | |
| +#include <cstdlib> | |
| +#include <cstddef> | |
| +#include <cstring> | |
| +#include <climits> | |
| + | |
| +extern "C" { | |
| +#else | |
| +#include <math.h> | |
| #include <stdarg.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| +#include <stddef.h> | |
| #include <string.h> | |
| - | |
| -#define _USE_MATH_DEFINES // fixes M_PI errors in r_plane.c for Visual Studio | |
| -#ifdef __cplusplus | |
| -#include <cmath> | |
| -#else | |
| -#include <math.h> | |
| +#include <limits.h> | |
| #endif | |
| #include <sys/types.h> | |
| diff --git a/src/p_local.h b/src/p_local.h | |
| index 6977cc4b1..2e72fc11b 100644 | |
| --- a/src/p_local.h | |
| +++ b/src/p_local.h | |
| @@ -14,10 +14,6 @@ | |
| #ifndef __P_LOCAL__ | |
| #define __P_LOCAL__ | |
| -#ifdef __cplusplus | |
| -extern "C" { | |
| -#endif | |
| - | |
| #include "command.h" | |
| #include "d_player.h" | |
| #include "d_think.h" | |
| @@ -28,6 +24,10 @@ extern "C" { | |
| #include "p_maputl.h" | |
| #include "doomstat.h" // MAXSPLITSCREENPLAYERS | |
| +#ifdef __cplusplus | |
| +extern "C" { | |
| +#endif | |
| + | |
| #define FLOATSPEED (FRACUNIT*4) | |
| //#define VIEWHEIGHTS "41" | |
| diff --git a/src/p_tick.h b/src/p_tick.h | |
| index a903be0fd..1a7bea312 100644 | |
| --- a/src/p_tick.h | |
| +++ b/src/p_tick.h | |
| @@ -32,12 +32,21 @@ void P_PreTicker(INT32 frames); | |
| void P_DoTeamscrambling(void); | |
| void P_RemoveThinkerDelayed(thinker_t *thinker); | |
| +#ifdef __cplusplus | |
| +extern "C" { | |
| +#endif | |
| + | |
| mobj_t *P_SetTarget2(mobj_t **mo, mobj_t *target | |
| + | |
| #ifdef PARANOIA | |
| , const char *source_file, int source_line | |
| #endif | |
| ); | |
| +#ifdef __cplusplus | |
| +} | |
| +#endif | |
| + | |
| #ifdef PARANOIA | |
| #define P_SetTarget(...) P_SetTarget2(__VA_ARGS__, __FILE__, __LINE__) | |
| #else | |
| diff --git a/src/r_draw_span.cpp b/src/r_draw_span.cpp | |
| index e5ee15463..3bf6cf731 100644 | |
| --- a/src/r_draw_span.cpp | |
| +++ b/src/r_draw_span.cpp | |
| @@ -18,7 +18,7 @@ | |
| #include <windows.h> | |
| #define local_for_thread static __thread | |
| #else | |
| -#include <threads.h> | |
| +#include <pthread.h> | |
| #define local_for_thread thread_local static | |
| #endif | |
| #else | |
| diff --git a/src/r_fps.h b/src/r_fps.h | |
| index 7ad5e9f16..8058e1b6b 100644 | |
| --- a/src/r_fps.h | |
| +++ b/src/r_fps.h | |
| @@ -15,16 +15,16 @@ | |
| #ifndef __R_FPS_H__ | |
| #define __R_FPS_H__ | |
| -#ifdef __cplusplus | |
| -extern "C" { | |
| -#endif | |
| - | |
| #include "m_fixed.h" | |
| #include "p_local.h" | |
| #include "r_state.h" | |
| #include "r_things.h" | |
| #include "m_perfstats.h" | |
| +#ifdef __cplusplus | |
| +extern "C" { | |
| +#endif | |
| + | |
| extern consvar_t cv_fpscap, cv_fpscapbg; | |
| extern ps_metric_t ps_interp_frac; | |
| diff --git a/src/r_main.h b/src/r_main.h | |
| index 04c996365..bd5a2a60f 100644 | |
| --- a/src/r_main.h | |
| +++ b/src/r_main.h | |
| @@ -14,14 +14,15 @@ | |
| #ifndef __R_MAIN__ | |
| #define __R_MAIN__ | |
| -#ifdef __cplusplus | |
| -extern "C" { | |
| -#endif | |
| #include "d_player.h" | |
| #include "r_data.h" | |
| #include "m_perfstats.h" | |
| +#ifdef __cplusplus | |
| +extern "C" { | |
| +#endif | |
| + | |
| // | |
| // POV related. | |
| // | |
| diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt | |
| index e4b0d4f37..5a5d19890 100644 | |
| --- a/src/sdl/CMakeLists.txt | |
| +++ b/src/sdl/CMakeLists.txt | |
| @@ -32,7 +32,7 @@ set(SRB2_SDL2_SOURCES | |
| hwsym_sdl.c | |
| i_main.c | |
| i_net.c | |
| - i_system.c | |
| + i_system.cpp | |
| i_ttf.c | |
| i_video.c | |
| i_threads.c | |
| diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp | |
| index 96c22061f..a2d8626f1 100644 | |
| --- a/src/sdl/i_system.cpp | |
| +++ b/src/sdl/i_system.cpp | |
| @@ -30,6 +30,7 @@ | |
| #endif | |
| #include <signal.h> | |
| +#include <poll.h> | |
| #ifdef _WIN32 | |
| #define RPC_NO_WINDOWS_H | |
| @@ -2428,7 +2429,7 @@ static const char *locateWad(void) | |
| return NULL; | |
| } | |
| -const char *I_LocateWad(void) | |
| +extern "C" const char *I_LocateWad(void) | |
| { | |
| const char *waddir; | |
| diff --git a/src/sdl/macosx/mac_resources.h b/src/sdl/macosx/mac_resources.h | |
| index 727ac9f6b..6e5eca5e9 100644 | |
| --- a/src/sdl/macosx/mac_resources.h | |
| +++ b/src/sdl/macosx/mac_resources.h | |
| @@ -1,5 +1,12 @@ | |
| #ifndef __MAC_RESOURCES_H__ | |
| #define __MAC_RESOURCES_H__ | |
| +#ifdef __cplusplus | |
| +extern "C" { | |
| +#endif | |
| void OSX_GetResourcesPath(char * buffer); | |
| -#endif | |
| \ No newline at end of file | |
| +#ifdef __cplusplus | |
| +} | |
| +#endif | |
| + | |
| +#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment