From 1e6d60ac40e4cf1da742856e3c86e7e859d4acd1 Mon Sep 17 00:00:00 2001 From: Akari Date: Mon, 7 Feb 2011 12:56:40 +0200 Subject: [PATCH] interactive input, makefile, con_print mutex --- console.c | 26 +++++++++++++++++++++++--- keys.c | 15 ++++++++++++++- makefile.inc | 2 +- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/console.c b/console.c index 9856e8e3..7f9e4489 100644 --- a/console.c +++ b/console.c @@ -29,6 +29,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // for u8_encodech #include "ft2.h" +#include + float con_cursorspeed = 4; // lines up from bottom to display @@ -1041,12 +1043,19 @@ Con_MaskPrint extern cvar_t timestamps; extern cvar_t timeformat; extern qboolean sys_nostdout; + +// -- Akari: attempted to make this somewhat thread safe.... works.... sometimes + +pthread_mutex_t con_print_mutex = PTHREAD_MUTEX_INITIALIZER; + void Con_MaskPrint(int additionalmask, const char *msg) { static int mask = 0; static int index = 0; static char line[MAX_INPUTLINE]; + pthread_mutex_lock(&con_print_mutex); + for (;*msg;msg++) { Con_Rcon_AddChar(*msg); @@ -1313,6 +1322,8 @@ void Con_MaskPrint(int additionalmask, const char *msg) mask = 0; } } + + pthread_mutex_unlock(&con_print_mutex); } /* @@ -1736,11 +1747,20 @@ void Con_DrawNotify (void) // LordHavoc: speedup, and other improvements if (chat_mode < 0) - dpsnprintf(temptext, sizeof(temptext), "]%s%s", chat_buffer, cursor); + dpsnprintf(temptext, sizeof(temptext), "]%s%c", chat_buffer, cursor); + else if(chat_mode == 2) + { + if(chat_buffer[0] == '#' || chat_buffer[0] == '&') //Channels are yellow, nicks are green + dpsnprintf(temptext, sizeof(temptext), "(IRC)target:^3%s^7%c", chat_buffer, cursor); + else + dpsnprintf(temptext, sizeof(temptext), "(IRC)target:^2%s^7%c", chat_buffer, cursor); + } + else if(chat_mode == 3) + dpsnprintf(temptext, sizeof(temptext), "(IRC)message:%s%c", chat_buffer, cursor); else if(chat_mode) - dpsnprintf(temptext, sizeof(temptext), "say_team:%s%s", chat_buffer, cursor); + dpsnprintf(temptext, sizeof(temptext), "say_team:%s%c", chat_buffer, cursor); else - dpsnprintf(temptext, sizeof(temptext), "say:%s%s", chat_buffer, cursor); + dpsnprintf(temptext, sizeof(temptext), "say:%s%c", chat_buffer, cursor); // FIXME word wrap inputsize = (numChatlines ? con_chatsize : con_notifysize).value; diff --git a/keys.c b/keys.c index 87663328..5a4b694f 100644 --- a/keys.c +++ b/keys.c @@ -1164,6 +1164,10 @@ unsigned int chat_bufferlen = 0; extern int Nicks_CompleteChatLine(char *buffer, size_t size, unsigned int pos); +extern void Irc_SetLastChannel(const char *value); +extern const char* Irc_GetLastChannel(); +extern void Irc_SendMessage(const char *msg); + static void Key_Message (int key, int ascii) { @@ -1171,10 +1175,19 @@ Key_Message (int key, int ascii) { if(chat_mode < 0) Cmd_ExecuteString(chat_buffer, src_command); // not Cbuf_AddText to allow semiclons in args; however, this allows no variables then. Use aliases! + else if(chat_mode == 2) + Irc_SetLastChannel(chat_buffer); + else if(chat_mode == 3) + Irc_SendMessage(chat_buffer); else Cmd_ForwardStringToServer(va("%s %s", chat_mode ? "say_team" : "say ", chat_buffer)); - key_dest = key_game; + //after IRC target input, go to message input + if(chat_mode != 2) + key_dest = key_game; + else + chat_mode = 3; + chat_bufferlen = 0; chat_buffer[0] = 0; return; diff --git a/makefile.inc b/makefile.inc index a85df801..1c67d604 100644 --- a/makefile.inc +++ b/makefile.inc @@ -213,7 +213,7 @@ DO_CC=$(CC) $(CFLAGS) -c $< -o $@ # Link LDFLAGS_DEBUG=-g -ggdb $(OPTIM_DEBUG) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=debug LDFLAGS_PROFILE=-g -pg -fprofile-arcs $(OPTIM_RELEASE) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=profile -LDFLAGS_RELEASE=$(OPTIM_RELEASE) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=release +LDFLAGS_RELEASE=$(OPTIM_RELEASE) -DSVNREVISION=`test -d .svn && svnversion || echo -` -DBUILDTYPE=release -lircclient ##### UNIX specific variables ##### -- 2.39.2