diff --git a/Quake/cl_main.c b/Quake/cl_main.c index b0883d5b..e1d71486 100644 --- a/Quake/cl_main.c +++ b/Quake/cl_main.c @@ -112,6 +112,9 @@ This is also called on Host_Error, so it shouldn't cause any errors */ void CL_Disconnect (void) { + if (key_dest == key_message) + Key_EndChat (); // don't get stuck in chat mode + // stop sounds (especially looping!) S_StopAllSounds (true); BGM_Stop(); diff --git a/Quake/client.h b/Quake/client.h index 3621dff4..07175e34 100644 --- a/Quake/client.h +++ b/Quake/client.h @@ -321,9 +321,6 @@ void CL_UpdateTEnts (void); void CL_ClearState (void); -float CL_KeyState (kbutton_t *key); -const char *Key_KeynumToString (int keynum); - // // cl_demo.c // diff --git a/Quake/console.c b/Quake/console.c index 369332fc..616c9b05 100644 --- a/Quake/console.c +++ b/Quake/console.c @@ -37,14 +37,15 @@ float con_cursorspeed = 4; #define CON_TEXTSIZE 65536 //johnfitz -- new default size #define CON_MINSIZE 16384 //johnfitz -- old default, now the minimum size -int con_buffersize; //johnfitz -- user can now override default + +int con_buffersize; //johnfitz -- user can now override default qboolean con_forcedup; // because no entities to refresh -int con_totallines; // total lines in console scrollback -int con_backscroll; // lines up from bottom to display -int con_current; // where next message will be printed -int con_x; // offset in current line for next print +int con_totallines; // total lines in console scrollback +int con_backscroll; // lines up from bottom to display +int con_current; // where next message will be printed +int con_x; // offset in current line for next print char *con_text = NULL; cvar_t con_notifytime = {"con_notifytime","3",CVAR_NONE}; //seconds @@ -54,16 +55,12 @@ char con_lastcenterstring[1024]; //johnfitz #define NUM_CON_TIMES 4 float con_times[NUM_CON_TIMES]; // realtime time the line was generated - // for transparent notify lines + // for transparent notify lines int con_vislines; qboolean con_debuglog = false; -extern char key_lines[32][MAXCMDLINE]; -extern int edit_line; -extern int key_linepos; - qboolean con_initialized; extern void M_Menu_Main_f (void); @@ -108,7 +105,7 @@ extern int history_line; //johnfitz void Con_ToggleConsole_f (void) { - if (key_dest == key_console) + if (key_dest == key_console/* || (key_dest == key_game && con_forcedup)*/) { if (cls.state == ca_connected) { @@ -139,7 +136,7 @@ void Con_ToggleConsole_f (void) Con_Clear_f ================ */ -void Con_Clear_f (void) +static void Con_Clear_f (void) { if (con_text) Q_memset (con_text, ' ', con_buffersize); //johnfitz -- con_buffersize replaces CON_TEXTSIZE @@ -151,7 +148,7 @@ void Con_Clear_f (void) Con_Dump_f -- johnfitz -- adapted from quake2 source ================ */ -void Con_Dump_f (void) +static void Con_Dump_f (void) { int l, x; const char *line; @@ -235,7 +232,7 @@ void Con_ClearNotify (void) { int i; - for (i=0 ; i= 2) { - va_start (argptr,fmt); + va_start (argptr, fmt); q_vsnprintf (msg, sizeof(msg), fmt, argptr); va_end (argptr); - Con_Printf ("%s", msg); } } @@ -625,9 +622,9 @@ void Con_SafePrintf (const char *fmt, ...) { va_list argptr; char msg[1024]; - int temp; + int temp; - va_start (argptr,fmt); + va_start (argptr, fmt); q_vsnprintf (msg, sizeof(msg), fmt, argptr); va_end (argptr); @@ -652,7 +649,7 @@ void Con_CenterPrintf (int linewidth, const char *fmt, ...) char *src, *dst; int len, s; - va_start (argptr,fmt); + va_start (argptr, fmt); q_vsnprintf (msg, sizeof(msg), fmt, argptr); va_end (argptr); @@ -1064,19 +1061,16 @@ Con_DrawNotify Draws the last few lines of output transparently over the game top ================ */ -extern char chat_buffer[]; - void Con_DrawNotify (void) { - int x, v; - char *text; - int i; + int i, x, v; + const char *text; float time; GL_SetCanvas (CANVAS_CONSOLE); //johnfitz v = vid.conheight; //johnfitz - for (i= con_current-NUM_CON_TIMES+1 ; i<=con_current ; i++) + for (i = con_current-NUM_CON_TIMES+1; i <= con_current; i++) { if (i < 0) continue; @@ -1090,8 +1084,8 @@ void Con_DrawNotify (void) clearnotify = 0; - for (x = 0 ; x < con_linewidth ; x++) - Draw_Character ( (x+1)<<3, v, text[x]); + for (x = 0; x < con_linewidth; x++) + Draw_Character ((x+1)<<3, v, text[x]); v += 8; @@ -1100,37 +1094,32 @@ void Con_DrawNotify (void) if (key_dest == key_message) { - // modified by S.A to support longer lines - - char c[MAXCMDLINE+1]; // extra space == +1 - const char *say_prompt; - int say_length, len; - clearnotify = 0; - x = 0; - if (team_message) - say_prompt = "say_team:"; - else - say_prompt = "say:"; - - say_length = strlen(say_prompt); - - Draw_String (8, v, say_prompt); //johnfitz - - text = strcpy(c, chat_buffer); - len = strlen(chat_buffer); - text[len] = ' '; - text[len+1] = 0; - if (len >= con_linewidth - say_length) - text += 1 + len + say_length - con_linewidth; - - while(*text) + if (chat_team) { - Draw_Character ( (x+say_length+2)<<3, v, *text); //johnfitz - x++; text++; + Draw_String (8, v, "say_team:"); + x = 11; } - Draw_Character ( (x+say_length+1)<<3, v, 10+((int)(realtime*con_cursorspeed)&1)); + else + { + Draw_String (8, v, "say:"); + x = 6; + } + + text = Key_GetChatBuffer(); + i = Key_GetChatMsgLen(); + if (i > con_linewidth - x - 1) + text += i - con_linewidth + x + 1; + + while (*text) + { + Draw_Character (x<<3, v, *text); + x++; + text++; + } + + Draw_Character (x<<3, v, 10 + ((int)(realtime*con_cursorspeed)&1)); v += 8; scr_tileclear_updates = 0; //johnfitz @@ -1145,8 +1134,6 @@ The input line scrolls horizontally if typing goes beyond the right edge ================ */ extern qpic_t *pic_ovr, *pic_ins; //johnfitz -- new cursor handling -extern double key_blinktime; -extern int key_insert; void Con_DrawInput (void) { @@ -1184,8 +1171,8 @@ The typing input line at the bottom should only be drawn if typing is allowed void Con_DrawConsole (int lines, qboolean drawinput) { int i, x, y, j, sb, rows; + const char *text; char ver[32]; - char *text; if (lines <= 0) return; diff --git a/Quake/console.h b/Quake/console.h index 0598818d..24616b85 100644 --- a/Quake/console.h +++ b/Quake/console.h @@ -39,13 +39,11 @@ void Con_DrawCharacter (int cx, int line, int num); void Con_CheckResize (void); void Con_Init (void); void Con_DrawConsole (int lines, qboolean drawinput); -void Con_Print (const char *txt); void Con_Printf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2))); void Con_Warning (const char *fmt, ...) __attribute__((__format__(__printf__,1,2))); //johnfitz void Con_DPrintf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2))); void Con_DPrintf2 (const char *fmt, ...) __attribute__((__format__(__printf__,1,2))); //johnfitz void Con_SafePrintf (const char *fmt, ...) __attribute__((__format__(__printf__,1,2))); -void Con_Clear_f (void); void Con_DrawNotify (void); void Con_ClearNotify (void); void Con_ToggleConsole_f (void); diff --git a/Quake/host.c b/Quake/host.c index cfec14eb..a790a985 100644 --- a/Quake/host.c +++ b/Quake/host.c @@ -93,7 +93,6 @@ Max_Edicts_f -- johnfitz static void Max_Edicts_f (cvar_t *var) { //TODO: clamp it here? - if (cls.state == ca_connected || sv.active) Con_Printf ("Changes to max_edicts will not take effect until the next time a map is loaded.\n"); } @@ -686,10 +685,8 @@ void _Host_Frame (float time) if (!Host_FilterTime (time)) return; // don't run too fast, or packets will flood out -// Force key_dest - Key_ForceDest (); - // get new key events + Key_ForceDest (); Sys_SendKeyEvents (); // allow mice or other external controllers to add commands diff --git a/Quake/keys.c b/Quake/keys.c index 8037d692..40db42f7 100644 --- a/Quake/keys.c +++ b/Quake/keys.c @@ -466,33 +466,45 @@ void Key_Console (int key) //============================================================================ -char chat_buffer[MAXCMDLINE]; -qboolean team_message = false; +qboolean chat_team = false; +static char chat_buffer[MAXCMDLINE]; +static int chat_bufferlen = 0; + +const char *Key_GetChatBuffer (void) +{ + return chat_buffer; +} + +int Key_GetChatMsgLen (void) +{ + return chat_bufferlen; +} + +void Key_EndChat (void) +{ + key_dest = key_game; + chat_bufferlen = 0; + chat_buffer[0] = 0; +} void Key_Message (int key) { - static int chat_bufferlen = 0; - if (key == K_ENTER) { - if (team_message) + if (chat_team) Cbuf_AddText ("say_team \""); else Cbuf_AddText ("say \""); Cbuf_AddText(chat_buffer); Cbuf_AddText("\"\n"); - key_dest = key_game; - chat_bufferlen = 0; - chat_buffer[0] = 0; + Key_EndChat (); return; } if (key == K_ESCAPE) { - key_dest = key_game; - chat_bufferlen = 0; - chat_buffer[0] = 0; + Key_EndChat (); return; } @@ -1051,19 +1063,16 @@ void Key_ForceDest (void) IN_Activate(); key_dest = key_game; } - return; + break; case key_game: - case key_message: if (cls.state != ca_connected) { forced = true; - if (key_dest == key_message) - Key_Message(K_ESCAPE); IN_Deactivate(vid.type == MODE_WINDOWED); key_dest = key_console; - return; + break; } - /* fallthrough */ + /* fallthrough */ default: forced = false; break; diff --git a/Quake/keys.h b/Quake/keys.h index 61b2fe19..ab483579 100644 --- a/Quake/keys.h +++ b/Quake/keys.h @@ -142,23 +142,36 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define K_MOUSE5 242 +#define MAXCMDLINE 256 + typedef enum {key_game, key_console, key_message, key_menu} keydest_t; -#define MAXCMDLINE 256 - extern keydest_t key_dest; -extern char *keybindings[256]; +extern char *keybindings[256]; extern int key_repeats[256]; extern int key_count; // incremented every key event extern int key_lastpress; +extern char key_lines[32][MAXCMDLINE]; +extern int edit_line; +extern int key_linepos; +extern int key_insert; +extern double key_blinktime; + void Key_Event (int key, qboolean down); void Key_Init (void); void Key_WriteBindings (FILE *f); -void Key_SetBinding (int keynum, const char *binding); void Key_ClearStates (void); void Key_ForceDest (void); +void Key_SetBinding (int keynum, const char *binding); +const char *Key_KeynumToString (int keynum); + +extern qboolean chat_team; +void Key_EndChat (void); +const char *Key_GetChatBuffer (void); +int Key_GetChatMsgLen (void); + void History_Init (void); void History_Shutdown (void);