Big net::msg conversion
This commit is contained in:
+56
-66
@@ -49,10 +49,7 @@ int con_current; // where next message will be printed
|
||||
int con_x; // offset in current line for next print
|
||||
char *con_text = NULL;
|
||||
|
||||
convar con_notifytime{"con_notifytime", "3"}; //seconds
|
||||
convar con_logcenterprint{"con_logcenterprint", "1"}; //johnfitz
|
||||
|
||||
char con_lastcenterstring[1024]; //johnfitz
|
||||
|
||||
#define NUM_CON_TIMES 4
|
||||
float con_times[NUM_CON_TIMES]; // realtime time the line was generated
|
||||
@@ -74,7 +71,12 @@ namespace console {
|
||||
int total_lines{0}; // total lines in console scrollback
|
||||
int back_scroll{0}; // lines up from bottom to display
|
||||
|
||||
std::string last_center_string{};
|
||||
|
||||
namespace {
|
||||
convar notify_time{"con_notifytime", "3"}; //seconds
|
||||
convar log_center_print{"con_logcenterprint", "1"}; //johnfitz
|
||||
|
||||
void _toggle_console() {
|
||||
toggle_console();
|
||||
}
|
||||
@@ -150,9 +152,6 @@ namespace console {
|
||||
int l;
|
||||
static int cr;
|
||||
int mask;
|
||||
bool boundary;
|
||||
|
||||
//console::back_scroll = 0; //johnfitz -- better console scrolling
|
||||
|
||||
std::istringstream ss{text};
|
||||
|
||||
@@ -171,7 +170,7 @@ namespace console {
|
||||
break;
|
||||
}
|
||||
|
||||
boundary = true;
|
||||
bool boundary = true;
|
||||
|
||||
while (!ss.eof()) {
|
||||
const int c = ss.peek();
|
||||
@@ -292,8 +291,8 @@ namespace console {
|
||||
|
||||
info("Console initialized.\n");
|
||||
|
||||
con_notifytime.inscribe();
|
||||
con_logcenterprint.inscribe(); //johnfitz
|
||||
notify_time.inscribe();
|
||||
log_center_print.inscribe(); //johnfitz
|
||||
|
||||
command::add("toggleconsole", _toggle_console);
|
||||
command::add("messagemode", _message_mode);
|
||||
@@ -444,6 +443,49 @@ namespace console {
|
||||
SCR_EndLoadingPlaque();
|
||||
memset(con_times, 0, sizeof(con_times));
|
||||
}
|
||||
|
||||
void check_resize() {
|
||||
int i, j;
|
||||
|
||||
const int width = (vid.conwidth >> 3) - 2; //johnfitz -- use vid.conwidth instead of vid.width
|
||||
|
||||
if (width == con_linewidth)
|
||||
return;
|
||||
|
||||
const int oldwidth = con_linewidth;
|
||||
con_linewidth = width;
|
||||
const int oldtotallines = total_lines;
|
||||
total_lines = con_buffersize / con_linewidth; //johnfitz -- con_buffersize replaces CON_TEXTSIZE
|
||||
int numlines = oldtotallines;
|
||||
|
||||
if (total_lines < numlines)
|
||||
numlines = total_lines;
|
||||
|
||||
int numchars = oldwidth;
|
||||
|
||||
if (con_linewidth < numchars)
|
||||
numchars = con_linewidth;
|
||||
|
||||
const int mark = Hunk_LowMark(); //johnfitz
|
||||
char *tbuf = (char *) Hunk_Alloc(con_buffersize); //johnfitz
|
||||
|
||||
std::memcpy(tbuf, con_text, con_buffersize); //johnfitz -- con_buffersize replaces CON_TEXTSIZE
|
||||
std::memset(con_text, ' ', con_buffersize); //johnfitz -- con_buffersize replaces CON_TEXTSIZE
|
||||
|
||||
for (i = 0; i < numlines; i++) {
|
||||
for (j = 0; j < numchars; j++) {
|
||||
con_text[(total_lines - 1 - i) * con_linewidth + j] =
|
||||
tbuf[((con_current - i + oldtotallines) % oldtotallines) * oldwidth + j];
|
||||
}
|
||||
}
|
||||
|
||||
Hunk_FreeToLowMark(mark); //johnfitz
|
||||
|
||||
Con_ClearNotify();
|
||||
|
||||
back_scroll = 0;
|
||||
con_current = total_lines - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -488,58 +530,6 @@ void Con_ClearNotify(void) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Con_CheckResize
|
||||
|
||||
If the line width has changed, reformat the buffer.
|
||||
================
|
||||
*/
|
||||
void Con_CheckResize(void) {
|
||||
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
|
||||
char *tbuf; //johnfitz -- tbuf no longer a static array
|
||||
int mark; //johnfitz
|
||||
|
||||
width = (vid.conwidth >> 3) - 2; //johnfitz -- use vid.conwidth instead of vid.width
|
||||
|
||||
if (width == con_linewidth)
|
||||
return;
|
||||
|
||||
oldwidth = con_linewidth;
|
||||
con_linewidth = width;
|
||||
oldtotallines = console::total_lines;
|
||||
console::total_lines = con_buffersize / con_linewidth; //johnfitz -- con_buffersize replaces CON_TEXTSIZE
|
||||
numlines = oldtotallines;
|
||||
|
||||
if (console::total_lines < numlines)
|
||||
numlines = console::total_lines;
|
||||
|
||||
numchars = oldwidth;
|
||||
|
||||
if (con_linewidth < numchars)
|
||||
numchars = con_linewidth;
|
||||
|
||||
mark = Hunk_LowMark(); //johnfitz
|
||||
tbuf = (char *) Hunk_Alloc(con_buffersize); //johnfitz
|
||||
|
||||
std::memcpy(tbuf, con_text, con_buffersize); //johnfitz -- con_buffersize replaces CON_TEXTSIZE
|
||||
std::memset(con_text, ' ', con_buffersize); //johnfitz -- con_buffersize replaces CON_TEXTSIZE
|
||||
|
||||
for (i = 0; i < numlines; i++) {
|
||||
for (j = 0; j < numchars; j++) {
|
||||
con_text[(console::total_lines - 1 - i) * con_linewidth + j] =
|
||||
tbuf[((con_current - i + oldtotallines) % oldtotallines) * oldwidth + j];
|
||||
}
|
||||
}
|
||||
|
||||
Hunk_FreeToLowMark(mark); //johnfitz
|
||||
|
||||
Con_ClearNotify();
|
||||
|
||||
console::back_scroll = 0;
|
||||
con_current = console::total_lines - 1;
|
||||
}
|
||||
|
||||
|
||||
// borrowed from uhexen2 by S.A. for new procs, LOG_Init, LOG_Close
|
||||
|
||||
@@ -569,15 +559,15 @@ Con_LogCenterPrint -- johnfitz -- echo centerprint message to the console
|
||||
==================
|
||||
*/
|
||||
void Con_LogCenterPrint(const char *str) {
|
||||
if (!strcmp(str, con_lastcenterstring))
|
||||
if (str == console::last_center_string)
|
||||
return; //ignore duplicates
|
||||
|
||||
if (cl.gametype == GAME_DEATHMATCH && con_logcenterprint.value != 2)
|
||||
if (cl.gametype == GAME_DEATHMATCH && console::log_center_print.value != 2)
|
||||
return; //don't log in deathmatch
|
||||
|
||||
strcpy(con_lastcenterstring, str);
|
||||
console::last_center_string = str;
|
||||
|
||||
if (con_logcenterprint.value) {
|
||||
if (console::log_center_print.value != 0) {
|
||||
console::info("%s", Con_Quakebar(40));
|
||||
console::center_print(40, "%s\n", str);
|
||||
console::info("%s", Con_Quakebar(40));
|
||||
@@ -931,7 +921,7 @@ void Con_DrawNotify(void) {
|
||||
if (time == 0)
|
||||
continue;
|
||||
time = realtime - time;
|
||||
if (time > con_notifytime.value)
|
||||
if (time > console::notify_time.value)
|
||||
continue;
|
||||
text = con_text + (i % console::total_lines) * con_linewidth;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user