chat fixed again

origin
stpohle 23 years ago
parent 1f4ef0357b
commit 83045c7d2c

@ -19,7 +19,7 @@ chat_findfreeline ()
i = chat.lastline;
if (i >= CHAT_MAX_LINES) {
memcpy (chat.lines[1], chat.lines[0], 255 * (CHAT_MAX_LINES - 1));
memcpy (&chat.lines[1], &chat.lines[0], sizeof (chat.lines[1]) * (CHAT_MAX_LINES - 1));
i = CHAT_MAX_LINES - 1;
}
else
@ -34,8 +34,8 @@ chat_cleanup ()
{
int i;
for (i = 0; i < CHAT_MAX_LINES; i++) {
if (chat.linestatus[i] > 0)
chat.linestatus[i] = -1;
if (chat.lines[i].status > 0)
chat.lines[i].status = -1;
}
}
@ -45,8 +45,8 @@ chat_addline (char *text)
int l;
l = chat_findfreeline ();
chat.linestatus[l] = 0;
strncpy (chat.lines[l], text, 255);
chat.lines[l].status = 0;
strncpy (chat.lines[l].text, text, 255);
chat.lineschanged = 1;
}
@ -55,8 +55,8 @@ chat_addstatusline (char *text)
{
int l;
l = chat_findfreeline ();
chat.linestatus[l] = 1;
strncpy (chat.lines[l], text, 255);
chat.lines[l].status = 1;
strncpy (chat.lines[l].text, text, 255);
chat.lineschanged = 1;
}
@ -216,23 +216,23 @@ chat_loop (SDL_Event * event)
font_setcolor (255, 255, 255, 0);
y = chat.window.y + 4;
l = chat.startline;
while (y < (chat.window.y + chat.window.h - 32) && chat.lines[l][0] != 0) {
if (chat.linestatus[l] < 0) {
while (y < (chat.window.y + chat.window.h - 32) && chat.lines[l].text[0] != 0) {
if (chat.lines[l].status < 0) {
l++;
}
else {
for (p1 = 0; (p1 < maxchar && chat.lines[l][p2] != 0); p1++)
text[p1] = chat.lines[l][p2++];
for (p1 = 0; (p1 < maxchar && chat.lines[l].text[p2] != 0); p1++)
text[p1] = chat.lines[l].text[p2++];
text[p1] = 0;
font_draw (chat.window.x + 4, y, text, 0);
if (chat.lines[l][p2] == 0) { // the end of the line
if (chat.lines[l].text[p2] == 0) { // the end of the line
l++;
p2 = 0;
}
y = y + font[0].size.y;
}
}
if (chat.lines[l][0] != 0) {
if (chat.lines[l].text[0] != 0) {
chat.startline++;
chat.changed = 1;
chat.lineschanged = 1;

@ -15,8 +15,10 @@ struct __chat {
SDL_Surface *oldscreen;
short int startline;
short int lastline;
char lines[CHAT_MAX_LINES][255];
short int linestatus[CHAT_MAX_LINES];
struct {
char text[255];
int status;
} lines[CHAT_MAX_LINES];
signed char lineschanged;
_keybinput input;
} typedef _chat;

@ -31,7 +31,7 @@ game_init (int argc, char **argv)
keybinput_new (&chat.input);
for (i = 0; i < CHAT_MAX_LINES; i++)
chat.lines[i][0] = 0;
chat.lines[i].text[0] = 0;
bman.maxplayer = MAX_PLAYERS;
bman.net_ai_family = PF_INET;

Loading…
Cancel
Save