From 6ece070e314806d75fe0a6d454e05765f50eb836 Mon Sep 17 00:00:00 2001 From: Aleksey Komarov Date: Sat, 16 Dec 2023 16:41:53 +0300 Subject: [PATCH 1/4] cmake: add ENABLE_STEAM option that allow to disable steam_api linking --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 125a07b45..335ac5365 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,9 @@ cmake_minimum_required (VERSION 2.6) project(keeper) +option(ENABLE_STEAM "Enable Steam integration" ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # set default cxxflags -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++1y -Wno-sign-compare -Wno-unused-variable -Wno-shift-count-overflow -ftemplate-depth=512 -DUSE_STEAMWORKS -I /home/michal/keeperrl/extern/steamworks/public") +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++1y -Wno-sign-compare -Wno-unused-variable -Wno-shift-count-overflow -ftemplate-depth=512") # clang specific cflags if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-tautological-constant-out-of-range-compare -Wno-mismatched-tags") @@ -14,8 +15,13 @@ set(STDAFX_H_GCH "${CMAKE_CURRENT_BINARY_DIR}/stdagx.h.gch") # set debug cxxflags set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wimplicit-fallthrough -Wno-unused-function") #if ((${CMAKE_BUILD_TYPE} MATCHES "Debug") AND (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")) -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld -L ${CMAKE_CURRENT_SOURCE_DIR}/extern/steamworks/redistributable_bin/linux64/ -L /usr/local/lib -lsteam_api -Wl,-rpath=. -Wl,--gdb-index") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld -L /usr/local/lib -Wl,-rpath=. -Wl,--gdb-index") #endif() +if(ENABLE_STEAM) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_STEAMWORKS -I ${CMAKE_CURRENT_SOURCE_DIR}/extern/steamworks/public") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L ${CMAKE_CURRENT_SOURCE_DIR}/extern/steamworks/redistributable_bin/linux64/ -lsteam_api") +endif() + # additional cmake modules directory set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") @@ -67,6 +73,9 @@ add_custom_command( # rules to create `keeper` binary file(GLOB SOURCES "*.cpp" "extern/*.cpp") +if(NOT ENABLE_STEAM) + list(FILTER SOURCES EXCLUDE REGEX ".*steam_.*\\.cpp$") +endif() add_executable(keeper ${SOURCES} ${KEEPER_VERSION_H} ${CHECK_SERIAL_STAMP}) target_include_directories(keeper PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(keeper PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/extern) From cf5d1185584fe30b3dda4af33dbfbcf509d71920 Mon Sep 17 00:00:00 2001 From: Aleksey Komarov Date: Sat, 16 Dec 2023 17:34:37 +0300 Subject: [PATCH 2/4] Add stubs for MySteamInput functions that works without steam_api --- steamless_input.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 steamless_input.cpp diff --git a/steamless_input.cpp b/steamless_input.cpp new file mode 100644 index 000000000..f5d94e174 --- /dev/null +++ b/steamless_input.cpp @@ -0,0 +1,45 @@ +#ifndef USE_STEAMWORKS +#include "steam_input.h" + +void MySteamInput::init() { +} + +void MySteamInput::detectControllers() { +} + +bool MySteamInput::isPressed(ControllerKey key) { + return false; +} + +optional MySteamInput::getGlyph(ControllerKey key) { + return none; +} + +void MySteamInput::runFrame() { +} + +pair MySteamInput::getJoyPos(ControllerJoy j) { + return {0, 0}; +} + +void MySteamInput::setGameActionLayer(GameActionLayer layer) { +} + +optional MySteamInput::getEvent() { + return none; +} + +void MySteamInput::showBindingScreen() { +} + +bool MySteamInput::isRunningOnDeck() { + return false; +} + +void MySteamInput::showFloatingKeyboard(Rectangle field) { +} + +void MySteamInput::dismissFloatingKeyboard() { +} + +#endif // USE_STEAMWORKS From ad6b5cf9de8519e24a029cd5948b8edd0ee414ee Mon Sep 17 00:00:00 2001 From: Aleksey Komarov Date: Sat, 16 Dec 2023 17:37:29 +0300 Subject: [PATCH 3/4] Fix starting game without USE_STEAMWORKS --- main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 05bc1f585..996d69928 100644 --- a/main.cpp +++ b/main.cpp @@ -306,8 +306,8 @@ static int keeperMain(po::parser& commandLineFlags) { #else AppConfig appConfig(dataPath.file("appconfig-dev.txt")); #endif + steamInput = make_unique(); #ifdef USE_STEAMWORKS - steamInput = make_unique(); optional steamClient; if (appConfig.get("steamworks") > 0) { if (steam::initAPI()) { From 538e806e299a896f8050a040d8be7c0f2d7448ce Mon Sep 17 00:00:00 2001 From: Aleksey Komarov Date: Sat, 16 Dec 2023 17:40:05 +0300 Subject: [PATCH 4/4] Fix build with NDEBUG defined code from https://github.com/miki151/keeperrl/blob/f0d2a78a6ad7c2632be6d8554e4d947f980648ae/fx_base.h#L30 #define PARANOID_CHECKS //... #if defined(PARANOID_CHECKS) && !defined(NDEBUG) #define PASSERT CHECK #else #define PASSERT(...) #endif When NDEBUG defined game will just ignoring all PASSERT(...), and PASSERT(size.x >= 0 && size.y >= 0) << size.x << " " << size.y; will become just : << size.x << " " << size.y; --- fx_particle_system.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fx_particle_system.cpp b/fx_particle_system.cpp index bcd5d1f55..6efb6d80d 100644 --- a/fx_particle_system.cpp +++ b/fx_particle_system.cpp @@ -162,7 +162,9 @@ void defaultEmitParticle(AnimationContext &ctx, EmissionState &em, Particle &new } array DrawContext::quadCorners(FVec2 pos, FVec2 size, float rotation) const { +#ifndef NDEBUG PASSERT(size.x >= 0 && size.y >= 0) << size.x << " " << size.y; +#endif auto corners = FRect(pos - size * 0.5f, pos + size * 0.5f).corners(); if (rotation != 0.0f) { auto sc = sincos(rotation);