Use con_puts instead of con_printf where possible
This commit is contained in:
parent
9a189bcfd1
commit
335cabcc79
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "pstypes.h"
|
||||
#include "dxxsconf.h"
|
||||
#include "fmtcheck.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
|
@ -33,7 +34,9 @@ typedef struct console_buffer
|
|||
} __pack__ console_buffer;
|
||||
|
||||
void con_init(void);
|
||||
void con_puts(int level, const char *str) __attribute_nonnull();
|
||||
void con_printf(int level, const char *fmt, ...) __attribute_format_printf(2, 3);
|
||||
#define con_printf(A1,F,...) dxx_call_printf_checked(con_printf,con_puts,(A1),(F),##__VA_ARGS__)
|
||||
void con_showup(void);
|
||||
|
||||
#endif
|
||||
|
|
14
common/include/fmtcheck.h
Normal file
14
common/include/fmtcheck.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include "dxxsconf.h"
|
||||
|
||||
#define _dxx_call_printf_unwrap_args(...) , ## __VA_ARGS__
|
||||
#define _dxx_call_printf_delete_comma2(A,...) __VA_ARGS__
|
||||
#define _dxx_call_printf_delete_comma(A,...) _dxx_call_printf_delete_comma2( A , ## __VA_ARGS__ )
|
||||
|
||||
#define dxx_call_printf_checked(V,P,A,FMT,...) \
|
||||
( \
|
||||
(sizeof(#__VA_ARGS__) == 1) ? \
|
||||
(P(_dxx_call_printf_delete_comma(1 _dxx_call_printf_unwrap_args A, FMT))) : \
|
||||
(V(_dxx_call_printf_delete_comma(1 _dxx_call_printf_unwrap_args A, FMT) ,##__VA_ARGS__)) \
|
||||
)
|
|
@ -35,7 +35,7 @@ static char warn_message[MAX_MSG_LEN];
|
|||
//takes string in register, calls printf with string on stack
|
||||
void warn_printf(const char *s)
|
||||
{
|
||||
con_printf(CON_URGENT, "%s",s);
|
||||
con_puts(CON_URGENT,s);
|
||||
}
|
||||
|
||||
static void (*warn_func)(const char *s)=warn_printf;
|
||||
|
@ -58,7 +58,7 @@ static void print_exit_message(const char *exit_message)
|
|||
{
|
||||
(*ErrorPrintFunc)(exit_message);
|
||||
}
|
||||
con_printf(CON_CRITICAL, "%s",exit_message);
|
||||
con_puts(CON_CRITICAL, exit_message);
|
||||
}
|
||||
|
||||
//terminates with error code 1, printing message
|
||||
|
|
|
@ -25,7 +25,7 @@ static PHYSFS_file *gamelog_fp=NULL;
|
|||
static struct console_buffer con_buffer[CON_LINES_MAX];
|
||||
static int con_state = CON_STATE_CLOSED, con_scroll_offset = 0, con_size = 0;
|
||||
|
||||
static void con_add_buffer_line(int priority, char *buffer)
|
||||
static void con_add_buffer_line(int priority, const char *buffer)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
|
@ -45,7 +45,7 @@ static void con_add_buffer_line(int priority, char *buffer)
|
|||
}
|
||||
}
|
||||
|
||||
void con_printf(int priority, const char *fmt, ...)
|
||||
void (con_printf)(int priority, const char *fmt, ...)
|
||||
{
|
||||
va_list arglist;
|
||||
char buffer[CON_LINE_LENGTH];
|
||||
|
@ -76,7 +76,14 @@ void con_printf(int priority, const char *fmt, ...)
|
|||
}
|
||||
while (*p1);
|
||||
*p2 = 0;
|
||||
con_puts(priority, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void con_puts(int priority, const char *buffer)
|
||||
{
|
||||
if (priority <= ((int)GameArg.DbgVerbose))
|
||||
{
|
||||
/* add given string to con_buffer */
|
||||
con_add_buffer_line(priority, buffer);
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ static void err_printf(PHYSFS_file *my_file, const char * format, ... )
|
|||
vsnprintf(message,sizeof(message),format,args);
|
||||
va_end(args);
|
||||
|
||||
con_printf(CON_CRITICAL, "%s", message);
|
||||
con_puts(CON_CRITICAL, message);
|
||||
PHYSFSX_printf(my_file, "%s", message);
|
||||
Errors_in_mine++;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ static void warning_printf(PHYSFS_file *my_file, const char * format, ... )
|
|||
vsnprintf(message,sizeof(message),format,args);
|
||||
va_end(args);
|
||||
|
||||
con_printf(CON_URGENT, "%s", message);
|
||||
con_puts(CON_URGENT, message);
|
||||
PHYSFSX_printf(my_file, "%s", message);
|
||||
}
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ static int HUD_init_message_literal_worth_showing(int class_flag, const char *me
|
|||
|
||||
if (HUD_color == -1)
|
||||
HUD_color = BM_XRGB(0,28,0);
|
||||
con_printf(CON_HUD, "%s", message);
|
||||
con_puts(CON_HUD, message);
|
||||
|
||||
if (Newdemo_state == ND_STATE_RECORDING )
|
||||
newdemo_record_hud_message( message );
|
||||
|
|
Loading…
Reference in a new issue