From 8c2a40408570446989f4441f94f3e18adf18a65b Mon Sep 17 00:00:00 2001 From: zicodxx <> Date: Sun, 24 Jan 2010 17:38:13 +0000 Subject: [PATCH] Rewrote code for showing Cloak-effect on Cockpit and Statusbar, because it became bugged with changed order of function calls do_cloaked_stuff() and render_gauges(); Fixed cockpit switches for Guided missile when Player is in Rear-View - the original code never considered that --- CHANGELOG.txt | 4 ++ main/gauges.c | 103 ++++++++++++++++++++------------------------------ 2 files changed, 46 insertions(+), 61 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 4e306d620..ca5cf4b03 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D1X-Rebirth Changelog +20100124 +-------- +main/gauges.c: Rewrote code for showing Cloak-effect on Cockpit and Statusbar, because it became bugged with changed order of function calls do_cloaked_stuff() and render_gauges() + 20100123 -------- main/gamecntl.c, main/inferno.c, main/menu.c: Move the editor call out of the Function_mode loop, for later overhaul diff --git a/main/gauges.c b/main/gauges.c index c50441f3f..45f38b2a2 100644 --- a/main/gauges.c +++ b/main/gauges.c @@ -271,7 +271,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define SB_SECONDARY_W_BOX_LEFT_L 169 #define SB_SECONDARY_W_BOX_TOP_L 154 #define SB_SECONDARY_W_BOX_RIGHT_L (SB_SECONDARY_W_BOX_LEFT_L+54) -#define SB_SECONDARY_W_BOX_BOT_L (153+43) +#define SB_SECONDARY_W_BOX_BOT_L (153+42) #define SB_SECONDARY_W_BOX_LEFT_H 338 #define SB_SECONDARY_W_BOX_TOP_H 381 @@ -335,11 +335,9 @@ static int old_shields = -1; static int old_flags = -1; static int old_weapon[2] = {-1, -1}; static int old_ammo_count[2] = {-1, -1}; -static int old_cloak = 0; static int old_lives = -1; static int old_prox = -1; static int invulnerable_frame = 0; -static int cloak_fade_state; //0=steady, -1 fading out, 1 fading in int weapon_box_states[2]; fix weapon_box_fade_values[2]; int Color_0_31_0 = -1; @@ -1500,13 +1498,10 @@ void init_gauges() old_energy = -1; old_shields = -1; old_flags = -1; - old_cloak = -1; old_lives = -1; old_weapon[0] = old_weapon[1] = -1; old_ammo_count[0] = old_ammo_count[1] = -1; - - cloak_fade_state = 0; } void draw_energy_bar(int energy) @@ -1562,11 +1557,10 @@ void draw_shield_bar(int shield) #define CLOAK_FADE_WAIT_TIME 0x400 -void draw_player_ship(int cloak_state,int old_cloak_state,int x, int y) +void draw_player_ship(int cloak_state,int x, int y) { static fix cloak_fade_timer=0; static int cloak_fade_value=GR_FADE_LEVELS-1; - static int refade = 0; grs_bitmap *bm = NULL; #ifdef NETWORK @@ -1581,67 +1575,56 @@ void draw_player_ship(int cloak_state,int old_cloak_state,int x, int y) PIGGY_PAGE_IN(Gauges[GAUGE_SHIPS+Player_num]); bm = &GameBitmaps[Gauges[GAUGE_SHIPS+Player_num].index]; } - - if (old_cloak_state==-1 && cloak_state) - cloak_fade_value=0; - - if (!cloak_state) { - cloak_fade_value=GR_FADE_LEVELS-1; - cloak_fade_state = 0; - } - - if (cloak_state==1 && old_cloak_state==0) - cloak_fade_state = -1; - - if ((Players[Player_num].cloak_time+CLOAK_TIME_MAX-GameTime < F1_0*3 && //doing "about-to-uncloak" effect - Players[Player_num].cloak_time+CLOAK_TIME_MAX-GameTime > F1_0) && - cloak_state) + if (cloak_state) { - if (cloak_fade_state==0) - cloak_fade_state = 2; - } - + static int step = 0; + + if (GameTime-Players[Player_num].cloak_time < F1_0) + { + step = -2; + } + else if (Players[Player_num].cloak_time+CLOAK_TIME_MAX-GameTime <= F1_0*3) + { + if (cloak_fade_value >= (GR_FADE_LEVELS-1)) + { + step = -2; + } + else if (cloak_fade_value <= 0) + { + step = 2; + } + } + else + { + step = 0; + cloak_fade_value = 0; + } - if (cloak_fade_state) cloak_fade_timer -= FrameTime; - while (cloak_fade_state && cloak_fade_timer < 0) { - - cloak_fade_timer += CLOAK_FADE_WAIT_TIME; - cloak_fade_value += cloak_fade_state; - - if (cloak_fade_value >= GR_FADE_LEVELS-1) { - cloak_fade_value = GR_FADE_LEVELS-1; - if (cloak_fade_state == 2 && cloak_state) - cloak_fade_state = -2; - else - cloak_fade_state = 0; + while (cloak_fade_timer < 0) + { + cloak_fade_timer += CLOAK_FADE_WAIT_TIME; + cloak_fade_value += step; } - else if (cloak_fade_value <= 0) { + + if (cloak_fade_value > (GR_FADE_LEVELS-1)) + cloak_fade_value = (GR_FADE_LEVELS-1); + if (cloak_fade_value <= 0) cloak_fade_value = 0; - if (cloak_fade_state == -2) - cloak_fade_state = 2; - else - cloak_fade_state = 0; - } } - - // To fade out both pages in a paged mode. - if (refade) refade = 0; - else if (cloak_state && old_cloak_state && !cloak_fade_state && !refade) { - cloak_fade_state = -1; - refade = 1; + else + { + cloak_fade_timer = 0; + cloak_fade_value = GR_FADE_LEVELS-1; } - + gr_set_current_canvas(NULL); - hud_bitblt( HUD_SCALE_X(x), HUD_SCALE_Y(y), bm); - Gr_scanline_darkening_level = cloak_fade_value; - gr_rect(HUD_SCALE_X(x), HUD_SCALE_Y(y), HUD_SCALE_X(x+bm->bm_w), HUD_SCALE_Y(y+bm->bm_h)); + gr_rect(HUD_SCALE_X(x-3), HUD_SCALE_Y(y-3), HUD_SCALE_X(x+bm->bm_w+3), HUD_SCALE_Y(y+bm->bm_h+3)); Gr_scanline_darkening_level = GR_FADE_LEVELS; - gr_set_current_canvas( NULL ); } @@ -2381,7 +2364,7 @@ void render_gauges() draw_numerical_display(shields, energy); if (!PlayerCfg.HudMode) show_bomb_count(HUD_SCALE_X(BOMB_COUNT_X), HUD_SCALE_Y(BOMB_COUNT_Y), gr_find_closest_color(0, 0, 0), 0, 0); - draw_player_ship(cloak, old_cloak, SHIP_GAUGE_X, SHIP_GAUGE_Y); + draw_player_ship(cloak, SHIP_GAUGE_X, SHIP_GAUGE_Y); if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) { draw_invulnerable_ship(); @@ -2425,7 +2408,7 @@ void render_gauges() if (!PlayerCfg.HudMode) show_bomb_count(HUD_SCALE_X(SB_BOMB_COUNT_X), HUD_SCALE_Y(SB_BOMB_COUNT_Y), gr_find_closest_color(0, 0, 0), 0, 0); - draw_player_ship(cloak, old_cloak, SB_SHIP_GAUGE_X, SB_SHIP_GAUGE_Y); + draw_player_ship(cloak, SB_SHIP_GAUGE_X, SB_SHIP_GAUGE_Y); if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) { @@ -2479,9 +2462,7 @@ void render_gauges() sb_show_score_added(); } } else - draw_player_ship(cloak, old_cloak, SB_SHIP_GAUGE_X, SB_SHIP_GAUGE_Y); - - old_cloak = cloak; + draw_player_ship(cloak, SB_SHIP_GAUGE_X, SB_SHIP_GAUGE_Y); } // ---------------------------------------------------------------------------------------------------------