diff options
| -rw-r--r-- | src/engine/client/inp.c | 14 | ||||
| -rw-r--r-- | src/engine/interface.h | 1 | ||||
| -rw-r--r-- | src/engine/server/server.c | 3 | ||||
| -rw-r--r-- | src/game/client/menu2.cpp | 2 |
4 files changed, 18 insertions, 2 deletions
diff --git a/src/engine/client/inp.c b/src/engine/client/inp.c index ce973246..2a82196c 100644 --- a/src/engine/client/inp.c +++ b/src/engine/client/inp.c @@ -20,6 +20,8 @@ static struct static unsigned char input_state[2][1024] = {{0}, {0}}; static int input_current = 0; +static unsigned int last_release = 0; +static unsigned int release_delta = -1; void inp_mouse_relative(int *x, int *y) { @@ -72,7 +74,14 @@ static void mousebutton_callback(int button, int action) if(action == GLFW_PRESS) input_count[input_current^1][KEY_MOUSE_FIRST+button].presses++; if(action == GLFW_RELEASE) + { + if(button == 0) + { + release_delta = time_get() - last_release; + last_release = time_get(); + } input_count[input_current^1][KEY_MOUSE_FIRST+button].releases++; + } input_state[input_current^1][KEY_MOUSE_FIRST+button] = action; } @@ -134,6 +143,11 @@ void inp_mouse_mode_relative() glfwDisable(GLFW_MOUSE_CURSOR); } +int inp_mouse_doubleclick() +{ + return release_delta < (time_freq() >> 2); +} + int inp_key_presses(int key) { return input_count[input_current][key].presses; diff --git a/src/engine/interface.h b/src/engine/interface.h index 684e7987..1a4b7d73 100644 --- a/src/engine/interface.h +++ b/src/engine/interface.h @@ -751,6 +751,7 @@ void inp_update(); void inp_init(); void inp_mouse_mode_absolute(); void inp_mouse_mode_relative(); +int inp_mouse_doubleclick(); int inp_key_presses(int key); int inp_key_releases(int key); diff --git a/src/engine/server/server.c b/src/engine/server/server.c index e8bc544f..ef4c9b04 100644 --- a/src/engine/server/server.c +++ b/src/engine/server/server.c @@ -388,12 +388,11 @@ static int new_client_callback(int cid, void *user) static int del_client_callback(int cid, void *user) { + mods_client_drop(cid); clients[cid].state = SRVCLIENT_STATE_EMPTY; clients[cid].name[0] = 0; clients[cid].clan[0] = 0; snapstorage_purge_all(&clients[cid].snapshots); - - mods_client_drop(cid); return 0; } diff --git a/src/game/client/menu2.cpp b/src/game/client/menu2.cpp index 0b19ccfc..9a157859 100644 --- a/src/game/client/menu2.cpp +++ b/src/game/client/menu2.cpp @@ -918,6 +918,8 @@ static void menu2_render_serverbrowser(RECT main_view) new_selected = item_index; dbg_msg("dbg", "addr = %s", item->address); strncpy(config.ui_server_address, item->address, sizeof(config.ui_server_address)); + if(inp_mouse_doubleclick()) + client_connect(config.ui_server_address); } for(int c = 0; c < num_cols; c++) |