Skip to content

Commit

Permalink
Merge branch 'master' into for-0.56.0/sync
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Jan 20, 2025
2 parents 47400a2 + 45d6aa1 commit b30415a
Show file tree
Hide file tree
Showing 44 changed files with 1,038 additions and 939 deletions.
64 changes: 6 additions & 58 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,58 +93,6 @@ endif()
if(NOT DAEMON_EXTERNAL_APP)
option(BUILD_CLIENT "Engine client executable, required to play" ON)
option(BUILD_SERVER "Engine server executable, required to host servers" ON)

## About the different ways to host/play games:
## Native DLL: no sandboxing, no cleaning up but debugger support. Use for dev.
## NaCl exe: sandboxing, no leaks, slightly slower, hard to debug. Use for regular players.
## Native exe: no sandboxing, no leaks, hard to debug. Might be used by server owners for perf.
## see VirtualMachine.h for code

# can be loaded by daemon with vm.[sc]game.type 3
option(BUILD_GAME_NATIVE_DLL "Build the shared library files, mostly useful for debugging changes locally." ON)

# can be loaded by daemon with vm.[sc]game.type 2
option(BUILD_GAME_NATIVE_EXE "Build native executable, which might be used for better performances by server owners" OFF)

# The NaCl SDK only runs on amd64 or i686.
if (CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME
AND (ARCH STREQUAL "amd64" OR ARCH STREQUAL "i686"))
# can be loaded by daemon with vm.[sc]game.type 0 or 1
option(BUILD_GAME_NACL "Build the NaCl \"pexe\" and \"nexe\" gamelogic modules for enabled architecture targets, required to host mods." OFF)

set(NACL_ALL_TARGETS "amd64;i686;armhf")
set(BUILD_GAME_NACL_TARGETS "all" CACHE STRING "Enabled NaCl \"nexe\" architecture targets, values: ${NACL_ALL_TARGETS}, all, native, none.")
mark_as_advanced(BUILD_GAME_NACL_TARGETS)

if (BUILD_GAME_NACL_TARGETS STREQUAL "all")
set(NACL_TARGETS "${NACL_ALL_TARGETS}")
elseif (BUILD_GAME_NACL_TARGETS STREQUAL "native")
set(NACL_TARGETS "${ARCH}")
elseif (BUILD_GAME_NACL_TARGETS STREQUAL "none")
set(NACL_TARGETS "")
else()
set(NACL_TARGETS "${BUILD_GAME_NACL_TARGETS}")
endif()

foreach(NACL_TARGET ${NACL_TARGETS})
set(IS_NACL_VALID_TARGET OFF)
foreach(NACL_VALID_TARGET ${NACL_ALL_TARGETS})
if(NACL_TARGET STREQUAL NACL_VALID_TARGET)
set(IS_NACL_VALID_TARGET ON)
endif()
endforeach()

if (NOT IS_NACL_VALID_TARGET)
message(FATAL_ERROR "Invalid NaCl target ${NACL_TARGET}, must be one of ${NACL_ALL_TARGETS}")
endif()
endforeach()
else()
set(BUILD_GAME_NACL OFF)
set(NACL_TARGETS "")
endif()

set(NACL_TARGETS "${NACL_TARGETS}" PARENT_SCOPE)

option(BUILD_TTY_CLIENT "Engine client with no graphical display" ON)
option(BUILD_DUMMY_APP "Stripped-down engine executable, mostly used to ease incremental porting and debugging" OFF)
mark_as_advanced(BUILD_DUMMY_APP)
Expand Down Expand Up @@ -415,9 +363,8 @@ function(ADD_PRECOMPILED_HEADER Target)
set(Header ${COMMON_DIR}/Common.h)

# Compiler-specific PCH support
try_c_cxx_flag(PCH "-pch")

if (PCH)
if ((DAEMON_CXX_COMPILER_GCC_COMPATIBILITY OR DAEMON_CXX_COMPILER_Clang_COMPATIBILITY)
AND NOT DAEMON_CXX_COMPILER_ICC)
# CMAKE_CXX_COMPILER_ARG1 is used with compilers using subcommands.
# For example when doing: cmake -D'CMAKE_CXX_COMPILER'='zig;c++'
# CMAKE_CXX_COMPILER will be "zig",
Expand All @@ -433,10 +380,11 @@ function(ADD_PRECOMPILED_HEADER Target)
add_dependencies(${Target} ${Target}-pch)

# PNaCl clang doesn't support -include-pch properly
if (DAEMON_CXX_COMPILER_NAME STREQUAL "PNaCl")
set_property(TARGET ${Target} APPEND PROPERTY COMPILE_OPTIONS "-include;${OBJ_DIR}/${Target}.h;-Winvalid-pch")
else()
if (DAEMON_CXX_COMPILER_Clang_COMPATIBILITY
AND NOT DAEMON_CXX_COMPILER_PNaCl)
set_property(TARGET ${Target} APPEND PROPERTY COMPILE_OPTIONS "-include-pch;${OBJ_DIR}/${Target}.h.gch")
else()
set_property(TARGET ${Target} APPEND PROPERTY COMPILE_OPTIONS "-include;${OBJ_DIR}/${Target}.h;-Winvalid-pch")
endif()
elseif (MSVC)
# /Fp sets the PCH path used by either of the /Yc and /Yu options.
Expand Down
14 changes: 10 additions & 4 deletions cmake/DaemonCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ foreach(lang C;CXX)
if (DAEMON_${lang}_COMPILER_Clang_COMPATIBILITY)
if (NOT DAEMON_${lang}_COMPILER_NAME STREQUAL "Clang")
set(DAEMON_${lang}_COMPILER_EXTENDED_VERSION
"${DAEMON_${lang}_COMPILER_VERSION}/clang-${DAEMON_${lang}_COMPILER_Clang_VERSION}")
"${DAEMON_${lang}_COMPILER_VERSION}/Clang_${DAEMON_${lang}_COMPILER_Clang_VERSION}")
endif()
elseif (DAEMON_${lang}_COMPILER_GCC_COMPATIBILITY)
if (NOT DAEMON_${lang}_COMPILER_NAME STREQUAL "GCC")
Expand All @@ -213,7 +213,7 @@ foreach(lang C;CXX)
# GCC we are looking for.
if ("${CUSTOM_${lang}_GCC_OUTPUT}" MATCHES "\ngcc version ")
set(DAEMON_${lang}_COMPILER_EXTENDED_VERSION
"${DAEMON_${lang}_COMPILER_VERSION}/gcc-${DAEMON_${lang}_COMPILER_GCC_VERSION}")
"${DAEMON_${lang}_COMPILER_VERSION}/GCC_${DAEMON_${lang}_COMPILER_GCC_VERSION}")
endif()
endif()
endif()
Expand All @@ -225,11 +225,17 @@ foreach(lang C;CXX)
endif()

set(DAEMON_${lang}_COMPILER_STRING
"${DAEMON_${lang}_COMPILER_NAME} ${DAEMON_${lang}_COMPILER_EXTENDED_VERSION} ${DAEMON_${lang}_COMPILER_BASENAME}")
"${DAEMON_${lang}_COMPILER_NAME}_${DAEMON_${lang}_COMPILER_EXTENDED_VERSION}:${DAEMON_${lang}_COMPILER_BASENAME}")

if (CMAKE_CXX_COMPILER_ARG1)
set(DAEMON_${lang}_COMPILER_STRING "${DAEMON_${lang}_COMPILER_STRING}:${CMAKE_CXX_COMPILER_ARG1}")
endif()

message(STATUS "Detected ${${lang}_NAME} compiler: ${DAEMON_${lang}_COMPILER_STRING}")

add_definitions(-DDAEMON_${lang}_COMPILER_${DAEMON_${lang}_COMPILER_NAME}=1)
set(compiler_var_name "DAEMON_${lang}_COMPILER_${DAEMON_${lang}_COMPILER_NAME}")
set(${compiler_var_name} ON)
add_definitions(-D${compiler_var_name}=1)

# Preprocessor definitions containing '#' may not be passed on the compiler
# command line because many compilers do not support it.
Expand Down
2 changes: 1 addition & 1 deletion cmake/DaemonCompiler/DaemonCompiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif

// Make the compilation succeeds if architecture is supported.
int main(int, char**) {
int main(int argc, char** argv) {
return 0;
}
4 changes: 2 additions & 2 deletions cmake/DaemonFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,9 @@ elseif (NOT NACL)

if (ARCH STREQUAL "amd64")
# K8 or EM64T minimum: AMD Athlon 64 ClawHammer, Intel Xeon Nocona, Intel Pentium 4 model F (Prescott revision EO), VIA Nano.
if ("${DAEMON_CXX_COMPILER_NAME}" STREQUAL "ICC")
if (DAEMON_CXX_COMPILER_ICC)
set(GCC_GENERIC_ARCH "pentium4")
elseif ("${DAEMON_CXX_COMPILER_NAME}" STREQUAL "Zig")
elseif (DAEMON_CXX_COMPILER_Zig)
set(GCC_GENERIC_ARCH "x86_64")
else()
set(GCC_GENERIC_ARCH "x86-64")
Expand Down
53 changes: 52 additions & 1 deletion cmake/DaemonGame.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,73 @@

include_directories(${MOUNT_DIR} ${LIB_DIR} ${LIB_DIR}/zlib)

## About the different ways to host/play games:
## Native DLL: no sandboxing, no cleaning up but debugger support. Use for dev.
## NaCl exe: sandboxing, no leaks, slightly slower, hard to debug. Use for regular players.
## Native exe: no sandboxing, no leaks, hard to debug. Might be used by server owners for perf.
## See VirtualMachine.h for code.

# can be loaded by daemon with vm.[sc]game.type 3
option(BUILD_GAME_NATIVE_DLL "Build the shared library files, mostly useful for debugging changes locally." ON)

# can be loaded by daemon with vm.[sc]game.type 2
option(BUILD_GAME_NATIVE_EXE "Build native executable, which might be used for better performances by server owners" OFF)

include(DaemonPlatform)

# Do not report unused native compiler if native vms are not built.
# If only NACL vms are built, this will be reported in chainloaded build.
if (BUILD_GAME_NATIVE_DLL OR BUILD_GAME_NATIVE_EXE OR NACL)
include(DaemonPlatform)
include(DaemonNacl)
include(DaemonFlags)
endif()

# Function to setup all the Sgame/Cgame libraries
include(CMakeParseArguments)

# The NaCl SDK only runs on amd64 or i686.
if (CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME
AND (ARCH STREQUAL "amd64" OR ARCH STREQUAL "i686"))
# can be loaded by daemon with vm.[sc]game.type 0 or 1
option(BUILD_GAME_NACL "Build the NaCl \"pexe\" and \"nexe\" gamelogic modules for enabled architecture targets, required to host mods." OFF)

set(NACL_ALL_TARGETS "amd64;i686;armhf")
set(BUILD_GAME_NACL_TARGETS "all" CACHE STRING "Enabled NaCl \"nexe\" architecture targets, values: ${NACL_ALL_TARGETS}, all, native, none.")
mark_as_advanced(BUILD_GAME_NACL_TARGETS)

if (BUILD_GAME_NACL_TARGETS STREQUAL "all")
set(NACL_TARGETS "${NACL_ALL_TARGETS}")
elseif (BUILD_GAME_NACL_TARGETS STREQUAL "native")
set(NACL_TARGETS "${ARCH}")
elseif (BUILD_GAME_NACL_TARGETS STREQUAL "none")
set(NACL_TARGETS "")
else()
set(NACL_TARGETS "${BUILD_GAME_NACL_TARGETS}")
endif()

foreach(NACL_TARGET ${NACL_TARGETS})
set(IS_NACL_VALID_TARGET OFF)
foreach(NACL_VALID_TARGET ${NACL_ALL_TARGETS})
if(NACL_TARGET STREQUAL NACL_VALID_TARGET)
set(IS_NACL_VALID_TARGET ON)
endif()
endforeach()

if (NOT IS_NACL_VALID_TARGET)
message(FATAL_ERROR "Invalid NaCl target ${NACL_TARGET}, must be one of ${NACL_ALL_TARGETS}")
endif()
endforeach()
else()
set(BUILD_GAME_NACL OFF)
set(NACL_TARGETS "")
endif()

function(GAMEMODULE)
# ParseArguments setup
set(oneValueArgs NAME)
set(multiValueArgs DEFINITIONS FLAGS FILES LIBS)
cmake_parse_arguments(GAMEMODULE "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if (NOT NACL)
if (BUILD_GAME_NATIVE_DLL)
add_library(${GAMEMODULE_NAME}-native-dll MODULE ${PCH_FILE} ${GAMEMODULE_FILES} ${SHAREDLIST_${GAMEMODULE_NAME}} ${SHAREDLIST} ${COMMONLIST})
Expand Down
1 change: 1 addition & 0 deletions src.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ set(RENDERERLIST
)

set(GLSLSOURCELIST
${ENGINE_DIR}/renderer/glsl_source/common.glsl
${ENGINE_DIR}/renderer/glsl_source/common_cp.glsl
${ENGINE_DIR}/renderer/glsl_source/shaderProfiler_vp.glsl
${ENGINE_DIR}/renderer/glsl_source/shaderProfiler_fp.glsl
Expand Down
14 changes: 14 additions & 0 deletions src/engine/client/ClientApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ class ClientApplication : public Application {
// Don't set this for TTY applications as they really aren't DPI aware. Let them scale.
SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "system");
#endif

#if defined(__linux__) && defined(BUILD_GRAPHICAL_CLIENT)
// identify the game by its name in certain
// volume control / power control applets,
// for example, the one found on KDE:
// "Unvanquished is currently blocking sleep."
// instead of "My SDL application ..."
// this feature was introduced in SDL 2.0.22
SDL_SetHint("SDL_APP_NAME", PRODUCT_NAME);
// SDL_hints.h: #define SDL_HINT_APP_NAME "SDL_APP_NAME"
// don't use the macro here, in case
// SDL doesn't use current headers.
#endif

Hunk_Init();

Com_Init();
Expand Down
9 changes: 0 additions & 9 deletions src/engine/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2219,12 +2219,6 @@ static bool CL_InitRef()
refimport_t ri;
refexport_t *ret;

ri.Cmd_AddCommand = Cmd_AddCommand;
ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
ri.Cmd_Argc = Cmd_Argc;
ri.Cmd_Argv = Cmd_Argv;
ri.Cmd_QuoteString = Cmd_QuoteString;

ri.Milliseconds = Sys::Milliseconds;
ri.RealTime = Com_RealTime;

Expand Down Expand Up @@ -2474,18 +2468,15 @@ void CL_Shutdown()

Cmd_RemoveCommand( "cmd" );
Cmd_RemoveCommand( "configstrings" );
Cmd_RemoveCommand( "userinfo" );
Cmd_RemoveCommand( "snd_restart" );
Cmd_RemoveCommand( "vid_restart" );
Cmd_RemoveCommand( "disconnect" );
Cmd_RemoveCommand( "connect" );
Cmd_RemoveCommand( "localservers" );
Cmd_RemoveCommand( "globalservers" );
Cmd_RemoveCommand( "rcon" );
Cmd_RemoveCommand( "ping" );
Cmd_RemoveCommand( "serverstatus" );
Cmd_RemoveCommand( "showip" );
Cmd_RemoveCommand( "model" );

CL_ClearKeyBinding();
CL_ClearInput();
Expand Down
32 changes: 25 additions & 7 deletions src/engine/framework/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ struct cmdlineArgs_t {
cmdlineArgs_t()
: homePath(Application::GetTraits().defaultHomepath), libPath(FS::DefaultLibPath()),
reset_config(false), use_crash_handlers(true),
use_curses(Application::GetTraits().useCurses) {}
use_curses(Application::GetTraits().useCurses),
allowStartNewInstance(true), allowForwardToExistingInstance(true) {}

std::string homePath;
std::string libPath;
Expand All @@ -500,6 +501,8 @@ struct cmdlineArgs_t {
bool reset_config;
bool use_crash_handlers;
bool use_curses;
bool allowStartNewInstance;
bool allowForwardToExistingInstance;

std::unordered_map<std::string, std::string> cvars;
std::string commands;
Expand Down Expand Up @@ -574,6 +577,8 @@ static void ParseCmdline(int argc, char** argv, cmdlineArgs_t& cmdlineArgs)
" -libpath <path> set the path containing additional executables and libraries\n"
" -pakpath <path> add another path from which dpk files are loaded\n"
" -resetconfig reset all cvars and keybindings to their default value\n"
" -noforward do not forward commands to an existing existance; instead exit with error\n"
" -forward-only just forward commands; exit with error if no existing instance\n"
#ifdef USE_CURSES
" -curses activate the curses interface\n"
#endif
Expand Down Expand Up @@ -623,6 +628,12 @@ static void ParseCmdline(int argc, char** argv, cmdlineArgs_t& cmdlineArgs)
i++;
} else if (!strcmp(argv[i], "-resetconfig")) {
cmdlineArgs.reset_config = true;
} else if (!strcmp(argv[i], "-noforward")) {
cmdlineArgs.allowForwardToExistingInstance = false;
cmdlineArgs.allowStartNewInstance = true;
} else if (!strcmp(argv[i], "-forward-only")) {
cmdlineArgs.allowForwardToExistingInstance = true;
cmdlineArgs.allowStartNewInstance = false;
}
else if (!strcmp(argv[i], "-nocrashhandler")) {
cmdlineArgs.use_crash_handlers = false;
Expand Down Expand Up @@ -748,18 +759,25 @@ static void Init(int argc, char** argv)
singletonSocketPath = GetSingletonSocketPath();
if (ConnectSingletonSocket()) {
Log::Notice("Existing instance found");
if (!cmdlineArgs.commands.empty()) {
Log::Notice("Forwarding commands to existing instance");
WriteSingletonSocket(cmdlineArgs.commands);
} else
Log::Notice("No commands given, exiting...");
if (cmdlineArgs.allowForwardToExistingInstance) {
if (!cmdlineArgs.commands.empty()) {
Log::Notice("Forwarding commands to existing instance");
WriteSingletonSocket(cmdlineArgs.commands);
} else {
Log::Notice("No commands given, exiting...");
}
}
#ifdef _WIN32
CloseHandle(singletonSocket);
#else
close(singletonSocket);
#endif
CON_Shutdown();
OSExit(0);
OSExit(cmdlineArgs.allowForwardToExistingInstance ? 0 : 1);
} else if (!cmdlineArgs.allowStartNewInstance) {
Log::Notice("Command forwarding requested, but no existing instance found");
CON_Shutdown();
OSExit(1);
}

// Create the singleton socket
Expand Down
6 changes: 3 additions & 3 deletions src/engine/qcommon/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ void Info_Print( const char *s )
*o = 0;
}

Log::Notice( key );
Log::defaultLogger.WithoutSuppression().Notice( key );

if ( !*s )
{
Log::Notice( "MISSING VALUE" );
Log::defaultLogger.WithoutSuppression().Notice( "MISSING VALUE" );
return;
}

Expand All @@ -147,7 +147,7 @@ void Info_Print( const char *s )
s++;
}

Log::Notice( "%s", value );
Log::defaultLogger.WithoutSuppression().Notice( value );
}
}

Expand Down
Loading

0 comments on commit b30415a

Please sign in to comment.