diff --git a/CMakeLists.txt b/CMakeLists.txt index 78f276f5..34a1224f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ if(NOT MSVC) # GCC/clang or compatible, hopefully option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with ninja)." OFF) endif() +option(LOGGER "Enable logging to the terminal" OFF) + set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -97,6 +99,11 @@ if(WIN32) endif() endif() +if(LOGGER) + message("Enabling Logging") + add_definitions(-DLOGGER) +endif() + include_directories("lib" "Descent3" ${PLATFORM_INCLUDES}) # file(GLOB_RECURSE INCS "*.h") diff --git a/Descent3/init.cpp b/Descent3/init.cpp index abdad587..da83633f 100644 --- a/Descent3/init.cpp +++ b/Descent3/init.cpp @@ -1,5 +1,5 @@ /* -* Descent 3 +* Descent 3 * Copyright (C) 2024 Parallax Software * * This program is free software: you can redistribute it and/or modify @@ -1153,7 +1153,7 @@ void PreInitD3Systems() { debugging = (FindArg("-debug") != 0); -#ifdef MONO +#ifdef LOGGER console_output = true; #endif #ifndef MACINTOSH @@ -2151,7 +2151,7 @@ void InitD3Systems1(bool editor) { #if 0 //CD Check goes here //#if ( defined(RELEASE) && (!defined(DEMO)) && (!defined(GAMEGAUGE)) ) - if( (!FindArg("-dedicated")) ) + if( (!FindArg("-dedicated")) ) PreGameCdCheck(); #endif diff --git a/README.md b/README.md index e3d20d71..b66852cb 100644 --- a/README.md +++ b/README.md @@ -28,14 +28,14 @@ Build steps below assume you have already cloned the repository and entered it l Requires Visual Studio C++ Tools (cmake and nmake) ```sh cmake --preset win -cmake --build --preset win --config [Debug/Release] +cmake --build --preset win --config [Debug/Release] -D LOGGER=[ON|OFF] ``` #### Building - MacOS ```sh brew bundle install cmake --preset mac -cmake --build --preset mac --config [Debug/Release] +cmake --build --preset mac --config [Debug/Release] -D LOGGER=[ON|OFF] ``` #### Building - Linux @@ -44,7 +44,7 @@ sudo dpkg --add-architecture i386 sudo apt update sudo apt install -y --no-install-recommends ninja-build cmake g++ libsdl1.2-dev libsdl-image1.2-dev libncurses-dev libxext6:i386 cmake --preset linux -cmake --build --preset linux --config [Debug/Release] +cmake --build --preset linux --config [Debug/Release] -D LOGGER=[ON|OFF] ``` ## Contributing diff --git a/lib/debug.h b/lib/debug.h index 58a3541d..52dd8160 100644 --- a/lib/debug.h +++ b/lib/debug.h @@ -1,5 +1,5 @@ /* -* Descent 3 +* Descent 3 * Copyright (C) 2024 Parallax Software * * This program is free software: you can redistribute it and/or modify @@ -166,7 +166,7 @@ bool Debug_ConsoleInit(); void Debug_ConsoleOpen(int n, int row, int col, int width, int height, char *title); void Debug_ConsoleClose(int n); void Debug_ConsolePrintf(int n, char *format, ...); -void Debug_ConsolePrintf(int n, int row, int col, char *format, ...); +void Debug_ConsolePrintfAt(int n, int row, int col, char *format, ...); void Debug_ConsoleRedirectMessages(int virtual_window, int physical_window); // DEBUGGING MACROS // Break into the debugger, if this feature was enabled in Debug_init() diff --git a/lib/mono.h b/lib/mono.h index c5b65707..89c1706a 100644 --- a/lib/mono.h +++ b/lib/mono.h @@ -1,5 +1,5 @@ /* -* Descent 3 +* Descent 3 * Copyright (C) 2024 Parallax Software * * This program is free software: you can redistribute it and/or modify @@ -66,12 +66,12 @@ #include "debug.h" void nw_InitTCPLogging(char *ip, unsigned short port); void nw_TCPPrintf(int n, char *format, ...); -#if (!defined(RELEASE)) && defined(MONO) +#if (!defined(RELEASE)) && defined(LOGGER) extern bool Debug_print_block; // Prints a formatted string to the debug window #define mprintf(args) Debug_ConsolePrintf args // Prints a formatted string on window n at row, col. -#define mprintf_at(args) Debug_ConsolePrintf args +#define mprintf_at(args) Debug_ConsolePrintfAt args #define DebugBlockPrint(args) \ do { \ if (Debug_print_block) \ diff --git a/linux/lnxmono.cpp b/linux/lnxmono.cpp index 8ebf1ac6..d25c437e 100644 --- a/linux/lnxmono.cpp +++ b/linux/lnxmono.cpp @@ -1,5 +1,5 @@ /* -* Descent 3 +* Descent 3 * Copyright (C) 2024 Parallax Software * * This program is free software: you can redistribute it and/or modify @@ -554,7 +554,7 @@ void Debug_ConsolePrintf(int n, char *format, ...) { } } -void Debug_ConsolePrintf(int n, int row, int col, char *format, ...) { +void Debug_ConsolePrintfAt(int n, int row, int col, char *format, ...) { if (!Mono_initialized) return;