Skip to content

Commit 959a453

Browse files
authored
Merge pull request #159 from jcoby/enable-console-logging
Enable console logging if MONO or LOGGER is defined
2 parents 86a6c13 + 96ce6d2 commit 959a453

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ if(NOT MSVC) # GCC/clang or compatible, hopefully
66
option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored compiler warnings/errors (GCC/Clang only; esp. useful with ninja)." OFF)
77
endif()
88

9+
option(LOGGER "Enable logging to the terminal" OFF)
10+
911
set(CMAKE_CXX_STANDARD 17)
1012
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1113
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -97,6 +99,11 @@ if(WIN32)
9799
endif()
98100
endif()
99101

102+
if(LOGGER)
103+
message("Enabling Logging")
104+
add_definitions(-DLOGGER)
105+
endif()
106+
100107
include_directories("lib" "Descent3" ${PLATFORM_INCLUDES})
101108

102109
# file(GLOB_RECURSE INCS "*.h")

Descent3/init.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Descent 3
2+
* Descent 3
33
* Copyright (C) 2024 Parallax Software
44
*
55
* This program is free software: you can redistribute it and/or modify
@@ -1153,7 +1153,7 @@ void PreInitD3Systems() {
11531153

11541154
debugging = (FindArg("-debug") != 0);
11551155

1156-
#ifdef MONO
1156+
#ifdef LOGGER
11571157
console_output = true;
11581158
#endif
11591159
#ifndef MACINTOSH
@@ -2151,7 +2151,7 @@ void InitD3Systems1(bool editor) {
21512151
#if 0
21522152
//CD Check goes here
21532153
//#if ( defined(RELEASE) && (!defined(DEMO)) && (!defined(GAMEGAUGE)) )
2154-
if( (!FindArg("-dedicated")) )
2154+
if( (!FindArg("-dedicated")) )
21552155
PreGameCdCheck();
21562156
#endif
21572157

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ Build steps below assume you have already cloned the repository and entered it l
2828
Requires Visual Studio C++ Tools (cmake and nmake)
2929
```sh
3030
cmake --preset win
31-
cmake --build --preset win --config [Debug/Release]
31+
cmake --build --preset win --config [Debug/Release] -D LOGGER=[ON|OFF]
3232
```
3333

3434
#### Building - MacOS
3535
```sh
3636
brew bundle install
3737
cmake --preset mac
38-
cmake --build --preset mac --config [Debug/Release]
38+
cmake --build --preset mac --config [Debug/Release] -D LOGGER=[ON|OFF]
3939
```
4040

4141
#### Building - Linux
@@ -44,7 +44,7 @@ sudo dpkg --add-architecture i386
4444
sudo apt update
4545
sudo apt install -y --no-install-recommends ninja-build cmake g++ libsdl1.2-dev libsdl-image1.2-dev libncurses-dev libxext6:i386
4646
cmake --preset linux
47-
cmake --build --preset linux --config [Debug/Release]
47+
cmake --build --preset linux --config [Debug/Release] -D LOGGER=[ON|OFF]
4848
```
4949

5050
## Contributing

lib/debug.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Descent 3
2+
* Descent 3
33
* Copyright (C) 2024 Parallax Software
44
*
55
* This program is free software: you can redistribute it and/or modify
@@ -166,7 +166,7 @@ bool Debug_ConsoleInit();
166166
void Debug_ConsoleOpen(int n, int row, int col, int width, int height, char *title);
167167
void Debug_ConsoleClose(int n);
168168
void Debug_ConsolePrintf(int n, char *format, ...);
169-
void Debug_ConsolePrintf(int n, int row, int col, char *format, ...);
169+
void Debug_ConsolePrintfAt(int n, int row, int col, char *format, ...);
170170
void Debug_ConsoleRedirectMessages(int virtual_window, int physical_window);
171171
// DEBUGGING MACROS
172172
// Break into the debugger, if this feature was enabled in Debug_init()

lib/mono.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Descent 3
2+
* Descent 3
33
* Copyright (C) 2024 Parallax Software
44
*
55
* This program is free software: you can redistribute it and/or modify
@@ -66,12 +66,12 @@
6666
#include "debug.h"
6767
void nw_InitTCPLogging(char *ip, unsigned short port);
6868
void nw_TCPPrintf(int n, char *format, ...);
69-
#if (!defined(RELEASE)) && defined(MONO)
69+
#if (!defined(RELEASE)) && defined(LOGGER)
7070
extern bool Debug_print_block;
7171
// Prints a formatted string to the debug window
7272
#define mprintf(args) Debug_ConsolePrintf args
7373
// Prints a formatted string on window n at row, col.
74-
#define mprintf_at(args) Debug_ConsolePrintf args
74+
#define mprintf_at(args) Debug_ConsolePrintfAt args
7575
#define DebugBlockPrint(args) \
7676
do { \
7777
if (Debug_print_block) \

linux/lnxmono.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Descent 3
2+
* Descent 3
33
* Copyright (C) 2024 Parallax Software
44
*
55
* This program is free software: you can redistribute it and/or modify
@@ -554,7 +554,7 @@ void Debug_ConsolePrintf(int n, char *format, ...) {
554554
}
555555
}
556556

557-
void Debug_ConsolePrintf(int n, int row, int col, char *format, ...) {
557+
void Debug_ConsolePrintfAt(int n, int row, int col, char *format, ...) {
558558
if (!Mono_initialized)
559559
return;
560560

0 commit comments

Comments
 (0)