Add build option to disable discord RPC

This commit is contained in:
Eidolon 2024-04-25 21:05:58 -05:00
parent 632d9b4d0d
commit 140a56f513
6 changed files with 22 additions and 34 deletions

View file

@ -57,6 +57,7 @@ option(
ON
)
option(SRB2_CONFIG_ENABLE_WEBM_MOVIES "Enable WebM recording support" ON)
option(SRB2_CONFIG_ENABLE_DISCORDRPC "Enable Discord RPC features" ON)
option(SRB2_CONFIG_HWRENDER "Enable hardware render (OpenGL) support" ON)
option(SRB2_CONFIG_STATIC_OPENGL "Enable static linking GL (do not do this)" OFF)
option(SRB2_CONFIG_ERRORMODE "Compile C code with warnings treated as errors." OFF)

View file

@ -259,9 +259,13 @@ target_link_libraries(SRB2SDL2 PRIVATE CURL::libcurl)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB -DHAVE_PNG -DHAVE_CURL -D_LARGEFILE64_SOURCE)
target_sources(SRB2SDL2 PRIVATE apng.c)
target_link_libraries(SRB2SDL2 PRIVATE DiscordRPC::DiscordRPC)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC -DUSE_STUN)
target_sources(SRB2SDL2 PRIVATE discord.c stun.cpp)
target_compile_definitions(SRB2SDL2 PRIVATE -DUSE_STUN)
target_sources(SRB2SDL2 PRIVATE stun.cpp)
if(SRB2_CONFIG_ENABLE_DISCORDRPC)
target_link_libraries(SRB2SDL2 PRIVATE DiscordRPC::DiscordRPC)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC)
target_sources(SRB2SDL2 PRIVATE discord.c)
endif()
target_link_libraries(SRB2SDL2 PRIVATE tcbrindle::span)
target_link_libraries(SRB2SDL2 PRIVATE glm::glm)
@ -289,29 +293,6 @@ target_link_libraries(SRB2SDL2 PRIVATE nlohmann_json::nlohmann_json)
set(SRB2_HAVE_THREADS ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS)
if(${SRB2_CONFIG_HAVE_DISCORDRPC})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(DISCORDRPC_FOUND ON)
if(${SRB2_SYSTEM_BITS} EQUAL 64)
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/include)
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win64-dynamic/lib -ldiscord-rpc")
else() # 32-bit
set(DISCORDRPC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/include)
set(DISCORDRPC_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/discord-rpc/win32-dynamic/lib -ldiscord-rpc")
endif()
else()
find_package(DiscordRPC)
endif()
if(${DISCORDRPC_FOUND})
set(SRB2_HAVE_DISCORDRPC ON)
target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC)
target_compile_definitions(SRB2SDL2 PRIVATE -DUSE_STUN)
target_sources(SRB2SDL2 PRIVATE discord.c stun.cpp)
else()
message(WARNING "You have specified that Discord Rich Presence is available but it was not found.")
endif()
endif()
if(${SRB2_CONFIG_HAVE_ZLIB})
if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES})
set(ZLIB_FOUND ON)

View file

@ -29,7 +29,6 @@
// KILL THIS WHEN WE KILL OLD OGL SUPPORT PLEASE
#include "d_netcmd.h" // kill
#include "discord.h" // kill
#include "doomstat.h" // kill
#include "s_sound.h" // kill
#include "sdl/ogl_sdl.h"
@ -121,7 +120,7 @@ static void temp_legacy_finishupdate_draws()
if (cv_ticrate.value)
SCR_DisplayTicRate();
if (netgame && (consoleplayer != serverplayer || !server_lagless))
{
if (server_lagless)

View file

@ -41,7 +41,9 @@
#include "g_party.h"
#include "k_grandprix.h" // K_CanChangeRules
#include "hu_stuff.h" // HU_AddChatText
#ifdef HAVE_DISCORDRPC
#include "discord.h" // DRPC_UpdatePresence
#endif
#include "i_net.h" // doomcom
extern "C" consvar_t cv_forcebots;
@ -559,7 +561,7 @@ fixed_t K_BotMapModifier(void)
{
constexpr INT32 complexity_scale = 10000;
constexpr fixed_t modifier_max = FRACUNIT * 2;
const fixed_t complexity_value = std::clamp<fixed_t>(
FixedDiv(K_GetTrackComplexity(), complexity_scale),
-FixedDiv(FRACUNIT, modifier_max),
@ -1378,7 +1380,7 @@ static INT32 K_HandleBotTrack(const player_t *player, ticcmd_t *cmd, botpredicti
{
turnsign = 1;
}
else
else
{
turnsign = -1;
}
@ -1514,7 +1516,7 @@ static INT32 K_HandleBotReverse(const player_t *player, ticcmd_t *cmd, botpredic
turnsign = -1; // Turn right
anglediff = AngleFixed(angle)>>FRACBITS;
}
else
else
{
turnsign = 1; // Turn left
anglediff = 360-(AngleFixed(angle)>>FRACBITS);
@ -1535,7 +1537,7 @@ static INT32 K_HandleBotReverse(const player_t *player, ticcmd_t *cmd, botpredic
{
momdiff = AngleFixed(angle)>>FRACBITS;
}
else
else
{
momdiff = 360-(AngleFixed(angle)>>FRACBITS);
}

View file

@ -5,7 +5,6 @@ target_sources(SRB2SDL2 PRIVATE
gametype.c
manual.c
sound-test.c
discord-requests.c
message-box.c
pause-game.c
pause-kick.c
@ -14,3 +13,7 @@ target_sources(SRB2SDL2 PRIVATE
pause-cheats.cpp
pause-addonoptions.cpp
)
if(SRB2_CONFIG_ENABLE_DISCORDRPC)
target_sources(SRB2SDL2 PRIVATE discord-requests.c)
endif()

View file

@ -1,5 +1,7 @@
add_subdirectory(glm)
add_subdirectory(discord-rpc)
if(SRB2_CONFIG_ENABLE_DISCORDRPC)
add_subdirectory(discord-rpc)
endif()
add_subdirectory(xmp-lite)
add_subdirectory(imgui)