diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/client/game_client.cpp | 2 | ||||
| -rw-r--r-- | src/game/client/menu2.cpp | 96 | ||||
| -rw-r--r-- | src/game/game_variables.h | 4 | ||||
| -rw-r--r-- | src/game/server/game_server.cpp | 49 |
4 files changed, 92 insertions, 59 deletions
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp index 1708e0da..70635e10 100644 --- a/src/game/client/game_client.cpp +++ b/src/game/client/game_client.cpp @@ -1604,7 +1604,7 @@ static void render_player( { //gfx_pretty_text_color float a = 1; - if(config.cl_nameplates == 1) + if(config.cl_nameplates_always != 0) a = clamp(1-powf(distance(local_target_pos, position)/200.0f,16.0f), 0.0f, 1.0f); const char *name = client_datas[info.clientid].name; diff --git a/src/game/client/menu2.cpp b/src/game/client/menu2.cpp index ecb36907..5e3a6836 100644 --- a/src/game/client/menu2.cpp +++ b/src/game/client/menu2.cpp @@ -1081,6 +1081,18 @@ static void menu2_render_settings_player(RECT main_view) config.autoswitch_weapons ^= 1; ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); + if (ui2_do_button(&config.cl_nameplates, "Show name plates", config.cl_nameplates, &button, ui2_draw_checkbox, 0)) + config.cl_nameplates ^= 1; + + if(config.cl_nameplates) + { + ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); + ui2_vsplit_l(&button, 15.0f, 0, &button); + if (ui2_do_button(&config.cl_nameplates_always, "Always show name plates", config.cl_nameplates_always, &button, ui2_draw_checkbox, 0)) + config.cl_nameplates_always ^= 1; + } + + ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); if (ui2_do_button(&config.player_color_body, "Custom colors", config.player_use_custom_color, &button, ui2_draw_checkbox, 0)) @@ -1214,11 +1226,11 @@ static void menu2_render_settings_controls(RECT main_view) ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); ui2_vsplit_l(&button, 110.0f, &label, &button); ui2_do_label(&label, "Mouse sens.", 18.0f, -1); + ui2_hmargin(&button, 2.0f, &button); config.inp_mousesens = (int)(ui2_do_scrollbar_h(&config.inp_mousesens, &button, config.inp_mousesens/500.0f)*500.0f); //*key.key = ui2_do_key_reader(key.key, &button, *key.key); ui2_hsplit_t(&main_view, 20.0f, 0, &main_view); } - typedef struct { @@ -1379,6 +1391,47 @@ static void menu2_render_settings_graphics(RECT main_view) config.gfx_high_detail ^= 1; } +static void menu2_render_settings_sound(RECT main_view) +{ + RECT button; + ui2_vsplit_l(&main_view, 300.0f, &main_view, 0); + + ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); + if (ui2_do_button(&config.snd_enable, "Use Sounds", config.snd_enable, &button, ui2_draw_checkbox, 0)) + config.snd_enable ^= 1; + + if(!config.snd_enable) + return; + + // sample rate box + { + char buf[64]; + sprintf(buf, "%d", config.snd_rate); + ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); + ui2_do_label(&button, "Sample Rate", 18.0, -1); + ui2_vsplit_l(&button, 110.0f, 0, &button); + ui2_vsplit_l(&button, 180.0f, &button, 0); + ui2_do_edit_box(&config.snd_rate, &button, buf, sizeof(buf)); + config.snd_rate = atoi(buf); + + if(config.snd_rate < 1) + config.snd_rate = 1; + } + + // volume slider + { + RECT button, label; + ui2_hsplit_t(&main_view, 5.0f, &button, &main_view); + ui2_hsplit_t(&main_view, 20.0f, &button, &main_view); + ui2_vsplit_l(&button, 110.0f, &label, &button); + ui2_hmargin(&button, 2.0f, &button); + ui2_do_label(&label, "Sound Volume", 18.0f, -1); + config.snd_volume = (int)(ui2_do_scrollbar_h(&config.snd_volume, &button, config.snd_volume/100.0f)*100.0f); + ui2_hsplit_t(&main_view, 20.0f, 0, &main_view); + } +} + + static void menu2_render_settings(RECT main_view) { static int settings_page = 0; @@ -1415,6 +1468,8 @@ static void menu2_render_settings(RECT main_view) {} else if(settings_page == 3) menu2_render_settings_graphics(main_view); + else if(settings_page == 4) + menu2_render_settings_sound(main_view); } static void menu2_render_news(RECT main_view) @@ -1573,11 +1628,8 @@ int menu2_render() if(popup == POPUP_NONE) { // do tab bar - RECT bottom_bar; ui2_hsplit_t(&screen, 26.0f, &tab_bar, &main_view); - ui2_hsplit_b(&main_view, 26.0f, &main_view, &bottom_bar); ui2_vmargin(&tab_bar, 20.0f, &tab_bar); - ui2_margin(&bottom_bar, 20.0f, &bottom_bar); menu2_render_menubar(tab_bar); // render current page @@ -1711,42 +1763,6 @@ int menu2_render() return 0; } -/* -int menu2_render_popup(const char *caption, const char *text, const char *button_text) -{ - float tw; - - float w = 700; - float h = 300; - float x = 800/2-w/2; - float y = 600/2-h/2; - - gfx_blend_normal(); - - gfx_texture_set(-1); - gfx_quads_begin(); - gfx_setcolor(0,0,0,0.50f); - draw_round_rect(x, y, w, h, 40.0f); - gfx_quads_end(); - - tw = gfx_pretty_text_width(48.0f, caption, -1); - ui_do_label(x+w/2-tw/2, y+20, caption, 48.0f); - - tw = gfx_pretty_text_width(32.0f, text, -1); - gfx_pretty_text(x+w/2-tw/2, y+130, 32.0f, text, -1); - - if(button_text) - { - static int back_button = 0; - if(ui_do_button(&back_button, button_text, 0, x+w/2-100, y+220, 200, 48, draw_teewars_button, 0)) - return 1; - if(inp_key_down(KEY_ESC) || inp_key_down(KEY_ENTER)) - return 1; - } - - return 0; -}*/ - void modmenu_render() { static int mouse_x = 0; diff --git a/src/game/game_variables.h b/src/game/game_variables.h index f5cfb523..71297d69 100644 --- a/src/game/game_variables.h +++ b/src/game/game_variables.h @@ -24,7 +24,6 @@ MACRO_CONFIG_INT(key_console, 256+2, 32, 512) MACRO_CONFIG_INT(key_remoteconsole, 256+3, 32, 512) MACRO_CONFIG_INT(autoswitch_weapons, 0, 0, 1) -MACRO_CONFIG_INT(scroll_weapon, 1, 0, 1) MACRO_CONFIG_INT(scorelimit, 20, 0, 1000) MACRO_CONFIG_INT(timelimit, 0, 0, 1000) @@ -34,7 +33,8 @@ MACRO_CONFIG_INT(restart, 0, 0, 120) MACRO_CONFIG_INT(dbg_bots, 0, 0, 7) MACRO_CONFIG_INT(cl_predict, 1, 0, 1) -MACRO_CONFIG_INT(cl_nameplates, 0, 0, 2) +MACRO_CONFIG_INT(cl_nameplates, 0, 0, 1) +MACRO_CONFIG_INT(cl_nameplates_always, 0, 0, 1) MACRO_CONFIG_STR(sv_maprotation, 512, "") MACRO_CONFIG_INT(sv_powerups, 1, 0, 1) diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp index 378a00ab..96183457 100644 --- a/src/game/server/game_server.cpp +++ b/src/game/server/game_server.cpp @@ -390,6 +390,10 @@ void player::reset() emote_stop = 0; damage_taken_tick = 0; attack_tick = 0; + + active_weapon = WEAPON_GUN; + last_weapon = WEAPON_HAMMER; + wanted_weapon = WEAPON_GUN; } void player::destroy() { } @@ -398,6 +402,8 @@ void player::set_weapon(int w) { last_weapon = active_weapon; active_weapon = w; + if(active_weapon < 0 || active_weapon >= NUM_WEAPONS) + active_weapon = 0; } void player::respawn() @@ -439,7 +445,7 @@ bool try_spawntype(int t, vec2 *outpos) void player::try_respawn() { vec2 spawnpos = vec2(100.0f, -60.0f); - + // get spawn point if(gameobj->gametype == GAMETYPE_CTF) { @@ -477,7 +483,6 @@ void player::try_respawn() core.vel = vec2(0,0); core.hooked_player = -1; - health = 10; armor = 0; jumped = 0; @@ -498,7 +503,6 @@ void player::try_respawn() //weapons[WEAPON_SNIPER].got = true; //weapons[WEAPON_SNIPER].ammo = data->weapons[WEAPON_SNIPER].maxammo; - active_weapon = WEAPON_GUN; last_weapon = WEAPON_HAMMER; wanted_weapon = WEAPON_GUN; @@ -554,6 +558,7 @@ int player::handle_ninja() { // time's up, return active_weapon = last_weapon; + set_weapon(active_weapon); return 0; } @@ -634,11 +639,14 @@ int player::handle_ninja() } return MODIFIER_RETURNFLAGS_OVERRIDEVELOCITY | MODIFIER_RETURNFLAGS_OVERRIDEPOSITION | MODIFIER_RETURNFLAGS_OVERRIDEGRAVITY; } + return 0; } int player::handle_sniper() { + return 0; + struct input_count button = count_input(previnput.fire, input.fire); if (button.releases) { @@ -731,34 +739,42 @@ int player::handle_weapons() // select weapon int next = count_input(previnput.next_weapon, input.next_weapon).presses; int prev = count_input(previnput.prev_weapon, input.prev_weapon).presses; - while(next) // next weapon selection + + if(next < 128) // make sure we only try sane stuff { - wanted_weapon = (wanted_weapon+1)%NUM_WEAPONS; - if(weapons[wanted_weapon].got) - next--; + while(next) // next weapon selection + { + wanted_weapon = (wanted_weapon+1)%NUM_WEAPONS; + if(weapons[wanted_weapon].got) + next--; + } } - while(prev) // prev weapon selection + if(prev < 128) // make sure we only try sane stuff { - wanted_weapon = (wanted_weapon-1)<0?NUM_WEAPONS-1:wanted_weapon-1; - if(weapons[wanted_weapon].got) - prev--; + while(prev) // prev weapon selection + { + wanted_weapon = (wanted_weapon-1)<0?NUM_WEAPONS-1:wanted_weapon-1; + if(weapons[wanted_weapon].got) + prev--; + } } if(input.wanted_weapon) // direct weapon selection wanted_weapon = input.wanted_weapon-1; + if(wanted_weapon < 0 || wanted_weapon >= NUM_WEAPONS) + wanted_weapon = 0; // switch weapon if wanted if(data->weapons[active_weapon].duration <= 0) { - if(wanted_weapon != active_weapon && wanted_weapon >= 0 && wanted_weapon < NUM_WEAPONS && weapons[wanted_weapon].got) + if(wanted_weapon != -1 && wanted_weapon != active_weapon && wanted_weapon >= 0 && wanted_weapon < NUM_WEAPONS && weapons[wanted_weapon].got) { if(active_weapon != wanted_weapon) create_sound(pos, SOUND_WEAPON_SWITCH); - last_weapon = active_weapon; - active_weapon = wanted_weapon; + set_weapon(wanted_weapon); } } @@ -892,6 +908,7 @@ int player::handle_weapons() target->core.vel += dir * 25.0f + vec2(0,-5.0f); } } + if (data->weapons[active_weapon].ammoregentime) { // If equipped and not active, regen ammo? @@ -912,6 +929,7 @@ int player::handle_weapons() weapons[active_weapon].ammoregenstart = -1; } } + return 0; } @@ -921,7 +939,7 @@ void player::tick() // this is to prevent initial weird clicks if(num_inputs < 2) previnput = input; - + // do latency stuff { CLIENT_INFO info; @@ -1007,7 +1025,6 @@ void player::tick_defered() if(events&COREEVENT_HOOK_ATTACH_GROUND) create_sound(pos, SOUND_HOOK_ATTACH_GROUND, mask); //if(events&COREEVENT_HOOK_RETRACT) snd_play_random(CHN_WORLD, SOUND_PLAYER_JUMP, 1.0f, pos); - } if(team == -1) |