if(Cmd_Argc() > 1)
{
dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args());
- chat_bufferlen = chat_cursor = strlen(chat_buffer); // Izy's patch
- chat_bufferlen = (unsigned int)strlen(chat_buffer);
++ chat_bufferlen = chat_cursor = (unsigned int)strlen(chat_buffer); // Izy's patch
}
}
if(Cmd_Argc() > 1)
{
dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args());
- chat_bufferlen = chat_cursor = strlen(chat_buffer); // Izy's patch
- chat_bufferlen = (unsigned int)strlen(chat_buffer);
++ chat_bufferlen = chat_cursor = (unsigned int)strlen(chat_buffer); // Izy's patch
}
}
if(Cmd_Argc() > 1)
{
dpsnprintf(chat_buffer, sizeof(chat_buffer), "%s ", Cmd_Args());
- chat_bufferlen = chat_cursor = strlen(chat_buffer); // Izy's patch
- chat_bufferlen = (unsigned int)strlen(chat_buffer);
++ chat_bufferlen = chat_cursor = (unsigned int)strlen(chat_buffer); // Izy's patch
}
- chat_mode = -1; // command
+ chat_mode = DP_CHAT_MODE_COMMAND; // command
}
/*
//============================================================================
-int chat_mode;
+dp_chat_mode_t chat_mode;
char chat_buffer[MAX_INPUTLINE];
unsigned int chat_bufferlen = 0;
+unsigned int chat_cursor = 0;
+dp_chat_modifiers_t chat_modifiers = DP_CHAT_MODIFIERS_OFF;
static void
-Key_Message (int key, int ascii)
+dp_chat_modifiers_cloning_tool(dp_chat_modifiers_t *dest, const dp_chat_modifiers_t *src)
+{
+ *dest = *src;
+}
+
+static void
+Key_Message_Reset_All_Modifiers (void) // Added by Izy (izy from izysoftware.com)
+{
+ const dp_chat_modifiers_t off = DP_CHAT_MODIFIERS_OFF;
+ chat_modifiers = off;
+}
+
+static qboolean
+Key_Message_Modifiers_Enabled (void) // Added by Izy (izy from izysoftware.com)
+{
+ const dp_chat_modifiers_t off = DP_CHAT_MODIFIERS_OFF;
+ return memcmp(&chat_modifiers, &off, sizeof(off)) != 0;
+}
+
+typedef struct
+{
+ int key;
+ int ascii;
+ qboolean down;
+} dp_chat_fakekey_t;
+
+static void Key_Message_SendFakeKeys(const dp_chat_fakekey_t *fakekeys, const size_t count);
+
+static void
+Key_Message (int key, int ascii, qboolean down)
{
char vabuf[1024];
- if (key == K_ENTER || ascii == 10 || ascii == 13)
+ unsigned int inc; /* Added by Izy (izy from izysoftware.com) - uint */
+ size_t dec; /* Added by Izy (izy from izysoftware.com) - size_t */
+ unsigned charscounter;
+ size_t sizeofchar_to_replace;
+ const dp_chat_fakekey_t fake_backspace[] = {{K_LEFTARROW, 0, true}, {K_DEL, 0, true}};
+ const dp_chat_fakekey_t fake_del[] = {{K_DEL, 0, true}};
+
+ if(key == 133 && ascii == 0) // Added by Izy (izy from izysoftware.com)
+ chat_modifiers.ctrl = down;
+ if(key == 147 && ascii == 0 && down) // Added by Izy (izy from izysoftware.com)
+ chat_modifiers.ins = chat_modifiers.ins == false;
+
+ if(down == false) // Izy's Patch
+ return;
+
+ if (key == K_ENTER || key == K_KP_ENTER || ascii == 10 || ascii == 13)
{
- if(chat_mode < 0)
- Cmd_ExecuteString(chat_buffer, src_command, true); // not Cbuf_AddText to allow semiclons in args; however, this allows no variables then. Use aliases!
- else
- Cmd_ForwardStringToServer(va(vabuf, sizeof(vabuf), "%s %s", chat_mode ? "say_team" : "say ", chat_buffer));
+
+ switch(chat_mode)
+ {
+ case DP_CHAT_MODE_COMMAND:
+ // not Cbuf_AddText to allow semiclons in args; however, this allows no variables then. Use aliases!
+ Cmd_ExecuteString(chat_buffer, src_command, true);
+ break;
+ case DP_CHAT_MODE_SAY:
+ Cmd_ForwardStringToServer(va(vabuf, sizeof(vabuf), "%s %s", "say", chat_buffer));
+ break;
+ case DP_CHAT_MODE_SAYTEAM:
+ Cmd_ForwardStringToServer(va(vabuf, sizeof(vabuf), "%s %s", "say_team", chat_buffer));
+ break;
+ }
key_dest = key_game;
- chat_bufferlen = 0;
+ chat_bufferlen = chat_cursor = 0;
chat_buffer[0] = 0;
+ Key_Message_Reset_All_Modifiers(); // Izy
return;
}
return;
}
- // delete char before cursor
- if (key == K_BACKSPACE) // Added by Izy (izy from izysoftware.com)
- {
- if (key == K_BACKSPACE) {
- if (chat_bufferlen) {
- chat_bufferlen = (unsigned int)u8_prevbyte(chat_buffer, chat_bufferlen);
- chat_buffer[chat_bufferlen] = 0;
++ if (key == K_BACKSPACE)
++ {
+ if(chat_cursor > 0)
- {
- // Backspace is always equivalent to K_LEFTARROW + K_DEL
- #if 1 // ok, allow the quick fast case
- if(chat_cursor == chat_bufferlen)
- {
- chat_bufferlen = chat_cursor = u8_prevbyte(chat_buffer, chat_bufferlen);
- chat_buffer[chat_bufferlen] = 0;
- return;
- }
- #endif
- Key_Message_SendFakeKeys(fake_backspace, sizeof(fake_backspace)/sizeof(fake_backspace[0]));
++ {
++ if (chat_cursor == chat_bufferlen)
++ {
++ chat_bufferlen = chat_cursor = (unsigned int)u8_prevbyte(chat_buffer, chat_bufferlen);
++ chat_buffer[chat_bufferlen] = 0;
++ return;
++ }
++ Key_Message_SendFakeKeys(fake_backspace, sizeof(fake_backspace)/sizeof(fake_backspace[0]));
}
return;
}