Simplify handling warning function
This commit is contained in:
parent
82f2f17c66
commit
b08dac2971
|
@ -45,8 +45,10 @@ namespace dcx {
|
||||||
void Warning_puts(const char *str) __attribute_nonnull();
|
void Warning_puts(const char *str) __attribute_nonnull();
|
||||||
void Warning(const char *fmt,...) __attribute_format_printf(1, 2); //print out warning message to user
|
void Warning(const char *fmt,...) __attribute_format_printf(1, 2); //print out warning message to user
|
||||||
#define Warning(F,...) dxx_call_printf_checked(Warning,Warning_puts,(),(F),##__VA_ARGS__)
|
#define Warning(F,...) dxx_call_printf_checked(Warning,Warning_puts,(),(F),##__VA_ARGS__)
|
||||||
|
#if DXX_USE_EDITOR
|
||||||
void set_warn_func(void (*f)(const char *s));//specifies the function to call with warning messages
|
void set_warn_func(void (*f)(const char *s));//specifies the function to call with warning messages
|
||||||
void clear_warn_func();//say this function no longer valid
|
void clear_warn_func();//say this function no longer valid
|
||||||
|
#endif
|
||||||
__noreturn
|
__noreturn
|
||||||
__attribute_nonnull()
|
__attribute_nonnull()
|
||||||
void Error_puts(const char *file, unsigned line, const char *func, const char *str);
|
void Error_puts(const char *file, unsigned line, const char *func, const char *str);
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
|
|
||||||
namespace dcx {
|
namespace dcx {
|
||||||
|
|
||||||
|
#if defined(WIN32) || defined(__APPLE__) || defined(__MACH__)
|
||||||
// Display a warning in a messagebox
|
// Display a warning in a messagebox
|
||||||
extern void msgbox_warning(const char *message);
|
extern void msgbox_warning(const char *message);
|
||||||
|
|
||||||
// Display an error in a messagebox
|
// Display an error in a messagebox
|
||||||
#if defined(WIN32) || defined(__APPLE__) || defined(__MACH__)
|
|
||||||
extern void msgbox_error(const char *message);
|
extern void msgbox_error(const char *message);
|
||||||
#else
|
#else
|
||||||
#define msgbox_error(M) (static_cast<void>(M))
|
#define msgbox_error(M) (static_cast<void>(M))
|
||||||
|
|
|
@ -36,12 +36,12 @@ namespace dcx {
|
||||||
|
|
||||||
#define MAX_MSG_LEN 2048
|
#define MAX_MSG_LEN 2048
|
||||||
|
|
||||||
//takes string in register, calls printf with string on stack
|
|
||||||
static void warn_printf(const char *s)
|
static void warn_printf(const char *s)
|
||||||
{
|
{
|
||||||
con_puts(CON_URGENT,s);
|
con_puts(CON_URGENT,s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DXX_USE_EDITOR
|
||||||
static void (*warn_func)(const char *s)=warn_printf;
|
static void (*warn_func)(const char *s)=warn_printf;
|
||||||
|
|
||||||
//provides a function to call with warning messages
|
//provides a function to call with warning messages
|
||||||
|
@ -55,6 +55,9 @@ void clear_warn_func()
|
||||||
{
|
{
|
||||||
warn_func = warn_printf;
|
warn_func = warn_printf;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
constexpr auto warn_func = &warn_printf;
|
||||||
|
#endif
|
||||||
|
|
||||||
static void print_exit_message(const char *exit_message, size_t len)
|
static void print_exit_message(const char *exit_message, size_t len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -900,7 +900,7 @@ static void close_editor()
|
||||||
{
|
{
|
||||||
// _MARK_("end of editor");//Nuked to compile -KRB
|
// _MARK_("end of editor");//Nuked to compile -KRB
|
||||||
|
|
||||||
#if !defined(__linux__) && !defined(__OpenBSD__)
|
#if defined(WIN32) || defined(__APPLE__) || defined(__MACH__)
|
||||||
set_warn_func(msgbox_warning);
|
set_warn_func(msgbox_warning);
|
||||||
#else
|
#else
|
||||||
clear_warn_func();
|
clear_warn_func();
|
||||||
|
|
|
@ -38,6 +38,7 @@ char copyright[] = "DESCENT COPYRIGHT (C) 1994,1995 PARALLAX SOFTWARE CORPORAT
|
||||||
char copyright[] = "DESCENT II COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPORATION";
|
char copyright[] = "DESCENT II COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPORATION";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "dxxsconf.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -63,7 +64,6 @@ char copyright[] = "DESCENT II COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPOR
|
||||||
#include "dxxerror.h"
|
#include "dxxerror.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "segment.h" //for Side_to_verts
|
|
||||||
#include "u_mem.h"
|
#include "u_mem.h"
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
#include "texmap.h"
|
#include "texmap.h"
|
||||||
|
@ -95,14 +95,11 @@ char copyright[] = "DESCENT II COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPOR
|
||||||
#endif
|
#endif
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "rbaudio.h"
|
#include "rbaudio.h"
|
||||||
#if !defined(__linux__) && !defined(__OpenBSD__)
|
|
||||||
#include "messagebox.h"
|
|
||||||
#else
|
|
||||||
#if DXX_WORDS_NEED_ALIGNMENT
|
#if DXX_WORDS_NEED_ALIGNMENT
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#if DXX_USE_EDITOR
|
#if DXX_USE_EDITOR
|
||||||
|
#include "messagebox.h"
|
||||||
#include "editor/editor.h"
|
#include "editor/editor.h"
|
||||||
#include "editor/kdefs.h"
|
#include "editor/kdefs.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
@ -111,8 +108,6 @@ char copyright[] = "DESCENT II COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPOR
|
||||||
#if DXX_USE_UDP
|
#if DXX_USE_UDP
|
||||||
#include "net_udp.h"
|
#include "net_udp.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "dxxsconf.h"
|
|
||||||
#include "dsx-ns.h"
|
#include "dsx-ns.h"
|
||||||
#include "compiler-begin.h"
|
#include "compiler-begin.h"
|
||||||
|
|
||||||
|
@ -715,16 +710,17 @@ static int main(int argc, char *argv[])
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
mem_init();
|
mem_init();
|
||||||
#if defined(__linux__) || defined(__OpenBSD__)
|
|
||||||
#if DXX_WORDS_NEED_ALIGNMENT
|
#if DXX_WORDS_NEED_ALIGNMENT
|
||||||
prctl(PR_SET_UNALIGN, PR_UNALIGN_NOPRINT, 0, 0, 0);
|
prctl(PR_SET_UNALIGN, PR_UNALIGN_NOPRINT, 0, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#if defined(WIN32) || defined(__APPLE__) || defined(__MACH__)
|
||||||
|
#if DXX_USE_EDITOR
|
||||||
set_warn_func(msgbox_warning);
|
set_warn_func(msgbox_warning);
|
||||||
#endif
|
#endif
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
void d_set_exception_handler();
|
void d_set_exception_handler();
|
||||||
d_set_exception_handler();
|
d_set_exception_handler();
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return dsx::main(argc, argv);
|
return dsx::main(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue