Clean up mono functions

This commit is contained in:
GravisZro
2024-05-24 12:16:29 -04:00
parent 9cf9781369
commit 644cb177ce
3 changed files with 13 additions and 10 deletions

View File

@@ -43,6 +43,7 @@
*
* $NoKeywords: $
*/
#include "mono.h"
#include <cassert>
#include <cstdarg>
@@ -52,6 +53,7 @@
#include <csignal>
#include "debug.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -75,7 +77,7 @@ static SOCKET tcp_log_sock;
static struct sockaddr_in tcp_log_addr;
static char tcp_log_buffer[MAX_TCPLOG_LEN];
static int Console_fd = -1;
static bool Mono_initialized = 0;
static bool Mono_initialized = false;
static bool Mono_use_real = false;
static bool Mono_use_window_remote = false;
static int Debug_logfile = 0;
@@ -366,13 +368,13 @@ void Debug_ConsoleExit() {
#define MAX_ARGS 30
#define MAX_CHARS_PER_ARG 100
extern char GameArgs[MAX_ARGS][MAX_CHARS_PER_ARG];
int FindArg(const char *which);
extern int FindArg(const char *which);
bool Debug_ConsoleInit() {
int n = 0;
if (Mono_initialized)
return 1;
return true;
// Only use monochrome if D3_MONO environment var is set
atexit(Debug_ConsoleExit);
@@ -380,7 +382,7 @@ bool Debug_ConsoleInit() {
Console_fd = open("/dev/omono", O_WRONLY);
if (Console_fd >= 0) {
Mono_use_real = true;
Mono_initialized = 1;
Mono_initialized = true;
}
int arg;
@@ -396,11 +398,11 @@ bool Debug_ConsoleInit() {
port = atoi(port_ptr);
if (nw_InitTCPLogging(address, port)) {
Mono_use_window_remote = true;
Mono_initialized = 1;
Mono_initialized = true;
}
}
}
return 1;
return true;
}
void Debug_ConsoleRedirectMessages(int virtual_window, int physical_window) {

View File

@@ -64,7 +64,7 @@
#ifndef _MONO_H
#define _MONO_H
#include "debug.h"
void nw_InitTCPLogging(char *ip, uint16_t port);
bool nw_InitTCPLogging(char *ip, uint16_t port);
void nw_TCPPrintf(int n, char *format, ...);
#if (!defined(RELEASE)) && defined(LOGGER)
extern bool Debug_print_block;

View File

@@ -126,11 +126,11 @@ SOCKET tcp_log_sock;
SOCKADDR_IN tcp_log_addr;
char tcp_log_buffer[MAX_TCPLOG_LEN];
void nw_InitTCPLogging(char *ip, uint16_t port) {
bool nw_InitTCPLogging(char *ip, uint16_t port) {
int addrlen = sizeof(SOCKADDR_IN);
tcp_log_sock = socket(AF_INET, SOCK_STREAM, 0);
if (INVALID_SOCKET == tcp_log_sock) {
return;
return false;
}
memset(&tcp_log_addr, 0, sizeof(SOCKADDR_IN));
@@ -139,7 +139,7 @@ void nw_InitTCPLogging(char *ip, uint16_t port) {
tcp_log_addr.sin_port = 0;
if (SOCKET_ERROR == bind(tcp_log_sock, (SOCKADDR *)&tcp_log_addr, sizeof(sockaddr))) {
return;
return false;
}
unsigned long arg = 1;
ioctlsocket(tcp_log_sock, FIONBIO, &arg);
@@ -147,6 +147,7 @@ void nw_InitTCPLogging(char *ip, uint16_t port) {
tcp_log_addr.sin_addr.s_addr = inet_addr(ip);
tcp_log_addr.sin_port = htons(port);
connect(tcp_log_sock, (SOCKADDR *)&tcp_log_addr, addrlen);
return true;
}
void nw_TCPPrintf(int n, char *format, ...) {