resets reticle based off current player object. and the ship's weapon configuration
| 1865 | // resets reticle based off current player object. |
| 1866 | // and the ship's weapon configuration |
| 1867 | void ResetReticle() { |
| 1868 | player *player = &Players[Player_num]; |
| 1869 | object *pobj = &Objects[player->objnum]; |
| 1870 | |
| 1871 | ASSERT(player->objnum >= 0); |
| 1872 | |
| 1873 | // Make sure we're not resetting a non-existent object |
| 1874 | if (!pobj || (pobj->type != OBJ_PLAYER && pobj->type != OBJ_GHOST && pobj->type != OBJ_OBSERVER)) |
| 1875 | return; |
| 1876 | |
| 1877 | poly_model *pm = &Poly_models[Objects[player->objnum].rtype.pobj_info.model_num]; |
| 1878 | otype_wb_info *prim_wb = &Ships[player->ship_index].static_wb[player->weapon[PW_PRIMARY].index]; |
| 1879 | otype_wb_info *sec_wb = &Ships[player->ship_index].static_wb[player->weapon[PW_SECONDARY].index]; |
| 1880 | dynamic_wb_info *prim_dyn_wb = &pobj->dynamic_wb[player->weapon[PW_PRIMARY].index]; |
| 1881 | |
| 1882 | int i, j; |
| 1883 | |
| 1884 | // assign reticle elements to the Ret_prim_xx array. |
| 1885 | // create battery mask |
| 1886 | Ret_prim_mask = 0; |
| 1887 | |
| 1888 | // iterate through all battery masks to determine which gun points occupy the primary weapon |
| 1889 | // on the player ship! |
| 1890 | for (j = 0; j < prim_wb->num_masks; j++) { |
| 1891 | for (i = 0; i < pm->poly_wb[0].num_gps; i++) { |
| 1892 | if (prim_wb->gp_fire_masks[j] & (1 << i)) { |
| 1893 | Ret_prim_mask |= (1 << i); |
| 1894 | } else if ((prim_dyn_wb->flags & DWBF_QUAD) && (prim_wb->gp_quad_fire_mask & (1 << i))) { |
| 1895 | Ret_prim_mask |= (1 << i); |
| 1896 | } |
| 1897 | } |
| 1898 | } |
| 1899 | |
| 1900 | if (player->weapon[PW_PRIMARY].index == MASSDRIVER_INDEX && (Ret_prim_mask & (1 << 0))) { |
| 1901 | // special hack for mass driver weapons |
| 1902 | Ret_prim_mask &= (~(1 << 0)); |
| 1903 | Ret_prim_mask |= RETMASK_FLAG_AUXPRIMARY0; |
| 1904 | } |
| 1905 | |
| 1906 | // iterate through all battery masks to determine which gun points occupy the secondary weapon |
| 1907 | // on the player ship! |
| 1908 | Ret_sec_mask = 0; |
| 1909 | |
| 1910 | for (j = 0; j < sec_wb->num_masks; j++) { |
| 1911 | for (i = 0; i < pm->poly_wb[0].num_gps; i++) { |
| 1912 | if (sec_wb->gp_fire_masks[j] & (1 << i)) |
| 1913 | Ret_sec_mask |= (1 << i); |
| 1914 | } |
| 1915 | } |
| 1916 | } |
| 1917 | |
| 1918 | // creates the reticle display bitmap mask to be used by the reticle renderer. |
| 1919 | static inline uint16_t reticle_mask(object *pobj, otype_wb_info *static_wb, int wb_index) { |
no outgoing calls
no test coverage detected