MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / RenderReticle

Function RenderReticle

Descent3/hud.cpp:1998–2041  ·  view source on GitHub ↗

renders the reticle

Source from the content-addressed store, hash-verified

1996
1997// renders the reticle
1998void RenderReticle() {
1999 static uint16_t primary_index_last_frame = 0xffff;
2000 static bool quad_primary_last_frame = false;
2001 player *player = &Players[Player_num];
2002 object *pobj = &Objects[player->objnum];
2003 ship *ship = &Ships[player->ship_index];
2004 player_weapon *prim_pw = &player->weapon[PW_PRIMARY];
2005 player_weapon *sec_pw = &player->weapon[PW_SECONDARY];
2006 int prim_wb_index = prim_pw->index;
2007 int sec_wb_index = sec_pw->index;
2008 otype_wb_info *prim_wb = &ship->static_wb[prim_wb_index];
2009 otype_wb_info *sec_wb = &ship->static_wb[sec_wb_index];
2010 dynamic_wb_info *prim_dyn_wb = &pobj->dynamic_wb[prim_wb_index];
2011
2012 int cx = Ret_x_off + (FIXED_SCREEN_WIDTH >> 1);
2013 int cy = Ret_y_off + (FIXED_SCREEN_HEIGHT >> 1) + 6;
2014 int rw = RET_IMAGE_WIDTH;
2015 int rh = RET_IMAGE_HEIGHT;
2016
2017 // quad weapon check hack (any weapon states that change should be noted here.)
2018 if (prim_dyn_wb->flags & DWBF_QUAD) {
2019 if (!quad_primary_last_frame || primary_index_last_frame != prim_wb_index) {
2020 ResetReticle();
2021 }
2022 quad_primary_last_frame = true;
2023 } else {
2024 if (quad_primary_last_frame) {
2025 ResetReticle();
2026 }
2027 quad_primary_last_frame = false;
2028 }
2029
2030 primary_index_last_frame = prim_wb_index;
2031
2032 // determine which primary batteries are open.
2033 draw_reticle_sub(cx, cy, rw, rh, reticle_mask(pobj, prim_wb, prim_wb_index), Ret_prim_mask, Ret_prim_wb);
2034 draw_reticle_sub(cx, cy, rw, rh, reticle_mask(pobj, sec_wb, sec_wb_index), Ret_sec_mask, Ret_sec_wb);
2035
2036 if (Reticle_elem_array[RET_LGUNSIGHT].bmp_off > -1)
2037 RenderHUDQuad(cx - rw, cy - rh / 2, rw, rh, 0, 0, 1, 1, Reticle_elem_array[RET_LGUNSIGHT].bmp_off, 192);
2038
2039 if (Reticle_elem_array[RET_RGUNSIGHT].bmp_off > -1)
2040 RenderHUDQuad(cx, cy - rh / 2, rw, rh, 0, 0, 1, 1, Reticle_elem_array[RET_RGUNSIGHT].bmp_off, 192);
2041}
2042
2043// renders missile reticle
2044void RenderMissileReticle() {

Callers 1

RenderHUDFrameFunction · 0.85

Calls 4

ResetReticleFunction · 0.85
draw_reticle_subFunction · 0.85
reticle_maskFunction · 0.85
RenderHUDQuadFunction · 0.85

Tested by

no test coverage detected