diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/client/gc_console.cpp | 97 | ||||
| -rw-r--r-- | src/game/client/gc_hooks.cpp | 7 | ||||
| -rw-r--r-- | src/game/server/gs_game_ctf.cpp | 11 | ||||
| -rw-r--r-- | src/game/server/gs_server.cpp | 4 |
4 files changed, 104 insertions, 15 deletions
diff --git a/src/game/client/gc_console.cpp b/src/game/client/gc_console.cpp index 0a4bb3d6..2eb4dc52 100644 --- a/src/game/client/gc_console.cpp +++ b/src/game/client/gc_console.cpp @@ -14,13 +14,31 @@ extern "C" { #include "gc_ui.h" #include "gc_client.h" +#include "../g_version.h" + +enum +{ + CONSOLE_CLOSED, + CONSOLE_OPENING, + CONSOLE_OPEN, + CONSOLE_CLOSING, +}; + static unsigned int console_input_len = 0; static char console_input[256] = {0}; -static int active = 0; +static int console_state = CONSOLE_CLOSED; +static float state_change_end = 0.0f; +static const float state_change_duration = 0.2f; static char backlog[256][256] = {{0}}; static int backlog_len; +static float time_now() +{ + static long long time_start = time_get(); + return float(time_get()-time_start)/float(time_freq()); +} + static void client_console_print(const char *str) { int len = strlen(str); @@ -30,7 +48,14 @@ static void client_console_print(const char *str) if (backlog_len >= 256) { - puts("console backlog full"); + static int warning = 0; + if (!warning) + { + puts("console backlog full"); + warning = 1; + } + + return; } memcpy(backlog[backlog_len], str, len); @@ -76,7 +101,7 @@ void client_console_init() void console_handle_input() { - int was_active = active; + int was_active = console_active(); for(int i = 0; i < inp_num_events(); i++) { @@ -87,7 +112,7 @@ void console_handle_input() console_toggle(); } - if (active) + if (console_active()) { if (!(e.ch >= 0 && e.ch < 32)) { @@ -119,7 +144,7 @@ void console_handle_input() } } - if (was_active || active) + if (was_active || console_active()) { inp_clear_events(); inp_clear_key_states(); @@ -128,15 +153,66 @@ void console_handle_input() void console_toggle() { - active ^= 1; + if (console_state == CONSOLE_CLOSED || console_state == CONSOLE_OPEN) + { + state_change_end = time_now()+state_change_duration; + } + else + { + float progress = state_change_end-time_now(); + float reversed_progress = state_change_duration-progress; + + state_change_end = time_now()+reversed_progress; + } + + if (console_state == CONSOLE_CLOSED || console_state == CONSOLE_CLOSING) + console_state = CONSOLE_OPENING; + else + console_state = CONSOLE_CLOSING; +} + +// only defined for 0<=t<=1 +static float console_scale_func(float t) +{ + //return t; + return cosf((1.0f-t)*M_PI*0.5f); } void console_render() { RECT screen = *ui_screen(); - float console_height = screen.h*3/5.0f; + float console_max_height = screen.h*3/5.0f; + float console_height; + + float progress = (time_now()-(state_change_end-state_change_duration))/float(state_change_duration); + + if (progress >= 1.0f) + { + if (console_state == CONSOLE_CLOSING) + console_state = CONSOLE_CLOSED; + else if (console_state == CONSOLE_OPENING) + console_state = CONSOLE_OPEN; + + progress = 1.0f; + } + + if (console_state == CONSOLE_CLOSED) + return; + + float console_height_scale; + + if (console_state == CONSOLE_OPENING) + console_height_scale = console_scale_func(progress); + else if (console_state == CONSOLE_CLOSING) + console_height_scale = console_scale_func(1.0f-progress); + else //if (console_state == CONSOLE_OPEN) + console_height_scale = console_scale_func(1.0f); + + console_height = console_height_scale*console_max_height; + gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); + gfx_texture_set(-1); gfx_quads_begin(); gfx_setcolor(0.4,0.2,0.2,0.8); @@ -155,6 +231,11 @@ void console_render() gfx_text(0, x+prompt_width, y, font_size, console_input, -1); gfx_text(0, x+prompt_width+width+1, y, font_size, "_", -1); + char buf[64]; + sprintf(buf, "Teewars v%s", TEEWARS_VERSION); + float version_width = gfx_text_width(0, font_size, buf, -1); + gfx_text(0, screen.w-version_width-5, y, font_size, buf, -1); + y -= row_height; while (y > 0.0f && backlog_index >= 0) @@ -170,6 +251,6 @@ void console_render() int console_active() { - return active; + return console_state != CONSOLE_CLOSED; } diff --git a/src/game/client/gc_hooks.cpp b/src/game/client/gc_hooks.cpp index a31b7201..3c8d801d 100644 --- a/src/game/client/gc_hooks.cpp +++ b/src/game/client/gc_hooks.cpp @@ -296,16 +296,13 @@ extern "C" void modc_render() if(client_state() == CLIENTSTATE_ONLINE) { render_game(); - if (console_active()) - console_render(); } else { menu_render(); - if (console_active()) - console_render(); - return; } + + console_render(); } extern "C" int modc_snap_input(int *data) diff --git a/src/game/server/gs_game_ctf.cpp b/src/game/server/gs_game_ctf.cpp index ee9dae08..0c54d1c5 100644 --- a/src/game/server/gs_game_ctf.cpp +++ b/src/game/server/gs_game_ctf.cpp @@ -86,6 +86,9 @@ void gameobject_ctf::tick() // CAPTURE! \o/ teamscore[fi^1] += 100; f->carrying_player->score += 5; + + dbg_msg("game", "flag_capture player='%d:%s'", f->carrying_player->client_id, server_clientname(f->carrying_player->client_id)); + for(int i = 0; i < 2; i++) flags[i]->reset(); @@ -105,7 +108,11 @@ void gameobject_ctf::tick() // return the flag if(!f->at_stand) { - close_players[i]->score += 1; + player *p = close_players[i]; + p->score += 1; + + dbg_msg("game", "flag_return player='%d:%s'", p->client_id, server_clientname(p->client_id)); + create_sound_global(SOUND_CTF_RETURN); f->reset(); } @@ -118,6 +125,8 @@ void gameobject_ctf::tick() f->at_stand = 0; f->carrying_player = close_players[i]; f->carrying_player->score += 1; + + dbg_msg("game", "flag_grab player='%d:%s'", f->carrying_player->client_id, server_clientname(f->carrying_player->client_id)); for(int c = 0; c < MAX_CLIENTS; c++) { diff --git a/src/game/server/gs_server.cpp b/src/game/server/gs_server.cpp index 67a8ad97..c1f5e130 100644 --- a/src/game/server/gs_server.cpp +++ b/src/game/server/gs_server.cpp @@ -547,7 +547,7 @@ void player::set_team(int new_team) team = new_team; die(client_id, -1); score = 0; - dbg_msg("game", "cid=%d team=%d", client_id, team); + dbg_msg("game", "team_join player='%d:%s' team=%d", client_id, server_clientname(client_id), team); } vec2 spawn_points[3][64]; @@ -1762,6 +1762,8 @@ void mods_client_enter(int client_id) char buf[512]; sprintf(buf, "%s entered and joined the %s", server_clientname(client_id), get_team_name(players[client_id].team)); send_chat(-1, -1, buf); + + dbg_msg("game", "team_join player='%d:%s' team=%d", client_id, server_clientname(client_id), players[client_id].team); } void mods_connected(int client_id) |