fix a seg when the buffer wraps

This commit is contained in:
Bill Currie 2001-10-03 21:24:52 +00:00
parent c5bb4e903c
commit f2cc8d9640

View file

@ -98,6 +98,15 @@ Con_BufferAddText (con_buffer_t *buf, const char *text)
if (pos - buf->buffer >= buf->buffer_size) if (pos - buf->buffer >= buf->buffer_size)
pos = buf->buffer; pos = buf->buffer;
cur_line->len++; cur_line->len++;
if (pos == tail_line->text) {
if (buf->num_lines > 0)
buf->num_lines--;
tail_line->text = 0;
tail_line->len = 0;
tail_line++;
if (tail_line - buf->lines >= buf->max_lines)
tail_line = buf->lines;
}
if (c == '\n') { if (c == '\n') {
if (buf->num_lines < buf->max_lines) if (buf->num_lines < buf->max_lines)
buf->num_lines++; buf->num_lines++;
@ -108,15 +117,6 @@ Con_BufferAddText (con_buffer_t *buf, const char *text)
cur_line->text = pos; cur_line->text = pos;
cur_line->len = 0; cur_line->len = 0;
} }
if (pos == tail_line->text) {
if (buf->num_lines > 0)
buf->num_lines--;
tail_line->text = 0;
tail_line->len = 0;
tail_line++;
if (tail_line - buf->lines >= buf->max_lines)
tail_line = buf->lines;
}
} }
buf->cur_line %= buf->max_lines; buf->cur_line %= buf->max_lines;
} }