about summary refs log tree commit diff
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/client/ec_client.c32
-rw-r--r--src/engine/client/ec_inp.c20
-rw-r--r--src/engine/e_config_variables.h3
-rw-r--r--src/engine/e_console.c46
-rw-r--r--src/engine/e_console.h1
-rw-r--r--src/engine/e_if_inp.h8
-rw-r--r--src/engine/server/es_server.c2
7 files changed, 73 insertions, 39 deletions
diff --git a/src/engine/client/ec_client.c b/src/engine/client/ec_client.c
index 56c817a6..17ea72b5 100644
--- a/src/engine/client/ec_client.c
+++ b/src/engine/client/ec_client.c
@@ -1306,26 +1306,6 @@ static void client_run()
 			}
 		}
 
-		/* screenshot button */
-		if(inp_key_down(config.key_screenshot))
-			gfx_screenshot();
-
-		/* some debug keys */
-		/*
-		if(config.debug)
-		{
-			if(inp_key_pressed(KEY_F1))
-				inp_mouse_mode_absolute();
-			if(inp_key_pressed(KEY_F2))
-				inp_mouse_mode_relative();
-
-			if(inp_key_pressed(KEY_F5))
-			{
-				ack_game_tick = -1;
-				client_send_input();
-			}
-		}*/
-
 		/* panic quit button */
 		if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_pressed('Q'))
 			break;
@@ -1455,12 +1435,23 @@ static void con_ping(void *result, void *user_data)
 	ping_start_time = time_get();
 }
 
+static void con_screenshot(void *result, void *user_data)
+{
+	gfx_screenshot();
+}
+
 static void client_register_commands()
 {
 	MACRO_REGISTER_COMMAND("quit", "", con_quit, 0x0);
 	MACRO_REGISTER_COMMAND("connect", "s", con_connect, 0x0);
 	MACRO_REGISTER_COMMAND("disconnect", "", con_disconnect, 0x0);
 	MACRO_REGISTER_COMMAND("ping", "", con_ping, 0x0);
+	MACRO_REGISTER_COMMAND("screenshot", "", con_screenshot, 0x0);
+}
+
+void client_save_line(const char *line)
+{
+	engine_config_write_line(line);	
 }
 
 int editor_main(int argc, char **argv);
@@ -1485,6 +1476,7 @@ int main(int argc, char **argv)
 	if(engine_config_write_start() == 0)
 	{
 		config_save();
+		modc_save_config();
 		engine_config_write_stop();
 	}
 	
diff --git a/src/engine/client/ec_inp.c b/src/engine/client/ec_inp.c
index 3e0bfef7..88942959 100644
--- a/src/engine/client/ec_inp.c
+++ b/src/engine/client/ec_inp.c
@@ -56,12 +56,13 @@ enum
 static INPUT_EVENT input_events[INPUT_BUFFER_SIZE];
 static int num_events = 0;
 
-static void add_event(char c, int key)
+static void add_event(char c, int key, int flags)
 {
 	if(num_events != INPUT_BUFFER_SIZE)
 	{
 		input_events[num_events].ch = c;
 		input_events[num_events].key = key;
+		input_events[num_events].flags = flags;
 		num_events++;
 	}
 }
@@ -87,17 +88,18 @@ INPUT_EVENT inp_get_event(int index)
 	return input_events[index];
 }
 
-
 static void char_callback(int character, int action)
 {
 	if(action == GLFW_PRESS && character < 256)
-		add_event((char)character, 0);
+		add_event((char)character, 0, 0);
 }
 
 static void key_callback(int key, int action)
 {
 	if(action == GLFW_PRESS)
-		add_event(0, key);
+		add_event(0, key, INPFLAG_PRESS);
+	else
+		add_event(0, key, INPFLAG_RELEASE);
 	
 	if(action == GLFW_PRESS)
 		input_count[input_current^1][key].presses++;
@@ -109,7 +111,9 @@ static void key_callback(int key, int action)
 static void mousebutton_callback(int button, int action)
 {
 	if(action == GLFW_PRESS)
-		add_event(0, KEY_MOUSE_FIRST+button);
+		add_event(0, KEY_MOUSE_FIRST+button, INPFLAG_PRESS);
+	else
+		add_event(0, KEY_MOUSE_FIRST+button, INPFLAG_RELEASE);
 		
 	if(action == GLFW_PRESS)
 		input_count[input_current^1][KEY_MOUSE_FIRST+button].presses++;
@@ -136,7 +140,8 @@ static void mousewheel_callback(int pos)
 			input_count[input_current^1][KEY_MOUSE_WHEEL_UP].releases++;
 		}
 		
-		add_event(0, KEY_MOUSE_WHEEL_UP);
+		add_event(0, KEY_MOUSE_WHEEL_UP, INPFLAG_PRESS);
+		add_event(0, KEY_MOUSE_WHEEL_UP, INPFLAG_RELEASE);
 	}
 	else if(pos < 0)
 	{
@@ -146,7 +151,8 @@ static void mousewheel_callback(int pos)
 			input_count[input_current^1][KEY_MOUSE_WHEEL_DOWN].releases++;
 		}	
 
-		add_event(0, KEY_MOUSE_WHEEL_DOWN);
+		add_event(0, KEY_MOUSE_WHEEL_DOWN, INPFLAG_PRESS);
+		add_event(0, KEY_MOUSE_WHEEL_DOWN, INPFLAG_RELEASE);
 	}
 	glfwSetMouseWheel(0);
 }
diff --git a/src/engine/e_config_variables.h b/src/engine/e_config_variables.h
index 9b3f5cf3..66684f86 100644
--- a/src/engine/e_config_variables.h
+++ b/src/engine/e_config_variables.h
@@ -42,11 +42,8 @@ MACRO_CONFIG_INT(gfx_fsaa_samples, 0, 0, 16)
 MACRO_CONFIG_INT(gfx_refresh_rate, 0, 0, 0)
 MACRO_CONFIG_INT(gfx_debug_resizable, 0, 0, 0)
 
-MACRO_CONFIG_INT(key_screenshot, 267, 32, 512)
 MACRO_CONFIG_INT(inp_mousesens, 100, 5, 100000)
 
-/*MACRO_CONFIG_STR(masterserver, 128, "master.teewars.com")*/
-
 MACRO_CONFIG_STR(sv_name, 128, "unnamed server")
 MACRO_CONFIG_STR(sv_bindaddr, 128, "")
 MACRO_CONFIG_INT(sv_port, 8303, 0, 0)
diff --git a/src/engine/e_console.c b/src/engine/e_console.c
index 27add750..778fb1a4 100644
--- a/src/engine/e_console.c
+++ b/src/engine/e_console.c
@@ -340,10 +340,14 @@ void console_print(const char *str)
 		print_callback(str);
 }
 
-void console_execute_line(const char *str)
+
+void console_execute_line_stroked(int stroke, const char *str)
 {
 	LEXER_RESULT result;
 	int error;
+	char strokestr[8] = {'0', 0};
+	if(stroke)
+		strokestr[0] = '1';
 
 	if ((error = lex(str, &result)))
 		printf("ERROR: %d\n", error);
@@ -355,16 +359,36 @@ void console_execute_line(const char *str)
 
 		command = console_find_command(name);
 
-		if (command)
+		if(command)
 		{
-			if (console_validate(command, &result))
+			int is_stroke_command = 0;
+			if(name[0] == '+')
 			{
-				char buf[256];
-				str_format(buf, sizeof(buf), "Invalid arguments... Usage: %s %s", command->name, command->params);
-				console_print(buf);
+				/* insert the stroke direction token */
+				int i;
+				for(i = result.num_tokens-2; i > 1; i--)
+				{
+					result.tokens[i+1] = result.tokens[i];
+				}
+				
+				result.tokens[1].type = TOKEN_INT;
+				result.tokens[1].stored_string = strokestr;
+				result.num_tokens++;
+
+				is_stroke_command = 1;
+			}
+			
+			if(stroke || is_stroke_command)
+			{
+				if (console_validate(command, &result))
+				{
+					char buf[256];
+					str_format(buf, sizeof(buf), "Invalid arguments... Usage: %s %s", command->name, command->params);
+					console_print(buf);
+				}
+				else
+					command->callback(&result, command->user_data);
 			}
-			else
-				command->callback(&result, command->user_data);
 		}
 		else
 		{
@@ -375,6 +399,12 @@ void console_execute_line(const char *str)
 	}
 }
 
+void console_execute_line(const char *str)
+{
+	console_execute_line_stroked(1, str);
+}
+
+
 void console_execute_file(const char *filename)
 {
 	IOHANDLE file;
diff --git a/src/engine/e_console.h b/src/engine/e_console.h
index 730779f8..44df7a38 100644
--- a/src/engine/e_console.h
+++ b/src/engine/e_console.h
@@ -19,6 +19,7 @@ typedef struct COMMAND_t
 void console_init();
 void console_register(COMMAND *cmd);
 void console_execute_line(const char *str);
+void console_execute_line_stroked(int stroke, const char *str);
 void console_execute_file(const char *filename);
 void console_print(const char *str);
 void console_register_print_callback(void (*callback)(const char *));
diff --git a/src/engine/e_if_inp.h b/src/engine/e_if_inp.h
index b95f1177..8e0ea2c2 100644
--- a/src/engine/e_if_inp.h
+++ b/src/engine/e_if_inp.h
@@ -10,8 +10,16 @@
 /*
 	Structure: INPUT_EVENT
 */
+enum
+{
+	INPFLAG_PRESS=1,
+	INPFLAG_RELEASE=2,
+	INPFLAG_REPEAT=4
+};
+
 typedef struct
 {
+	int flags;
 	char ch;
 	int key;
 } INPUT_EVENT;
diff --git a/src/engine/server/es_server.c b/src/engine/server/es_server.c
index a177ced8..abf6bf21 100644
--- a/src/engine/server/es_server.c
+++ b/src/engine/server/es_server.c
@@ -716,8 +716,8 @@ static void server_process_client_packet(NETPACKET *packet)
 					server_send_msg(cid);
 					
 					clients[cid].authed = 1;
-					dbg_msg("server", "cid=%d authed", cid);
 					server_send_rcon_line(cid, "Authentication successful. Remote console access granted.");
+					dbg_msg("server", "cid=%d authed", cid);
 				}
 				else
 				{