Open source remastering of the Freespace 2 engine
missionweaponchoice.cpp File Reference

Go to the source code of this file.


struct  wl_bitmap_group
struct  wl_buttons
struct  wl_ship_class_info
struct  wl_icon_info
struct  carried_icon


#define IS_LIST_PRIMARY(x)   (Weapon_info[x].subtype != WP_MISSILE)
#define IS_LIST_SECONDARY(x)   (Weapon_info[x].subtype == WP_MISSILE)
#define WL_BUTTON_RESET   4
#define WL_BUTTON_DUMMY   5
#define WEAPON_DESC_WIPE_TIME   1.5f


typedef struct wl_bitmap_group wl_bitmap_group
typedef struct wl_ship_class_info wl_ship_class_info
typedef struct wl_icon_info wl_icon_info
typedef struct carried_icon carried_icon


void draw_wl_icons ()
void wl_draw_ship_weapons (int index)
void wl_pick_icon_from_list (int index)
void pick_from_ship_slot (int num)
void start_weapon_animation (int weapon_class)
void stop_weapon_animation ()
int wl_get_pilot_subsys_index (p_object *pobjp)
void wl_reset_to_defaults ()
void wl_set_selected_slot (int slot_num)
void wl_maybe_reset_selected_slot ()
void wl_maybe_reset_selected_weapon_class ()
void wl_render_icon_count (int num, int x, int y)
void wl_render_weapon_desc ()
void wl_apply_current_loadout_to_all_ships_in_current_wing ()
void wl_reset_carried_icon ()
int wl_icon_being_carried ()
void wl_set_carried_icon (int from_bank, int from_slot, int weapon_class)
const char * wl_tooltip_handler (const char *str)
int wl_carried_icon_moved ()
void weapon_button_do (int i)
void weapon_check_buttons ()
void wl_redraw_pressed_buttons ()
void weapon_buttons_init ()
void wl_render_overhead_view (float frametime)
int wl_get_ship_class (int wl_slot)
int eval_weapon_flag_for_game_type (int weapon_flags)
void wl_set_disabled_weapons (int ship_class)
void maybe_select_wl_slot (int block, int slot)
void maybe_select_new_weapon (int index)
void maybe_select_new_ship_weapon (int index)
void wl_init_pool (team_data *td)
void wl_unload_all_anims ()
void wl_load_icons (int weapon_class)
void wl_load_all_icons ()
void wl_unload_icons ()
void wl_init_ship_class_data ()
void wl_free_ship_class_data ()
void wl_reset_selected_slot ()
int wl_calc_ballistic_fit (int wi_index, int capacity)
int wl_calc_missile_fit (int wi_index, int capacity)
void wl_get_ship_class_weapons (int ship_class, int *wep, int *wep_count)
void wl_get_ship_weapons (int ship_index, int *wep, int *wep_count)
void wl_get_parseobj_weapons (int sa_index, int ship_class, int *wep, int *wep_count)
void wl_cull_illegal_weapons (int ship_class, int *wep, int *wep_count)
void wl_get_default_weapons (int ship_class, int slot_num, int *wep, int *wep_count)
void wl_add_index_to_list (int wi_index)
void wl_remove_weps_from_pool (int *wep, int *wep_count, int ship_class)
void wl_fill_slots ()
void wl_init_icon_lists ()
void wl_set_team_pointers (int team)
void wl_reset_team_pointers ()
void weapon_select_init_team (int team_num)
void weapon_select_close_team ()
void weapon_select_common_init ()
void weapon_select_init ()
void wl_dump_carried_icon ()
int drop_icon_on_slot (int bank_num)
void maybe_drop_icon_on_slot (int bank_num)
void do_mouse_over_list_weapon (int index)
int do_mouse_over_ship_weapon (int index)
void wl_maybe_flash_button ()
void weapon_select_render (float frametime)
void wl_render_weapon_desc (float frametime)
void wl_weapon_desc_start_wipe ()
void weapon_select_do (float frametime)
void weapon_select_close ()
void wl_render_icon (int index, int x, int y, int num, int draw_num_flag, int hot_mask, int hot_bank_mask, int select_mask)
void draw_wl_icon_with_number (int list_count, int weapon_class)
int wl_slots_all_empty (wss_unit *slot)
int wl_update_ship_weapons (int objnum, wss_unit *slot)
void wl_update_parse_object_weapons (p_object *pobjp, wss_unit *slot)
void wl_bash_ship_weapons (ship_weapon *swp, wss_unit *slot)
void wl_swap_weapons (int ship_slot, int from_bank, int to_bank)
void wl_saturate_bank (int ship_slot, int bank)
int wl_swap_slot_slot (int from_bank, int to_bank, int ship_slot, int *sound, net_player *pl)
int wl_dump_to_list (int from_bank, int to_list, int ship_slot, int *sound)
int wl_grab_from_list (int from_list, int to_bank, int ship_slot, int *sound, net_player *pl)
int wl_swap_list_slot (int from_list, int to_bank, int ship_slot, int *sound, net_player *pl)
void wl_synch_interface ()
int wl_apply (int mode, int from_bank, int from_list, int to_bank, int to_list, int ship_slot, int player_index, bool dont_play_sound)
int wl_drop (int from_bank, int from_list, int to_bank, int to_list, int ship_slot, int player_index, bool dont_play_sound)


int Multi_ping_timestamp
int Weapon_select_open = 0
int anim_timer_start
int Weapon_select_overlay_id = -1
int Weapon_select_background_bitmap
UI_WINDOW Weapon_ui_window
wl_ship_class_info Wl_ships [MAX_SHIP_CLASSES]
wl_icon_info Wl_icons_teams [MAX_TVT_TEAMS][MAX_WEAPON_TYPES]
wl_icon_infoWl_icons = NULL
int Plist_start
int Plist_size
int Slist_start
int Slist_size
int Weapon_title_max_width [GR_NUM_RESOLUTIONS] = { 200, 320 }

Macro Definition Documentation


Definition at line 44 of file missionweaponchoice.cpp.


Definition at line 45 of file missionweaponchoice.cpp.

#define IS_LIST_PRIMARY (   x)    (Weapon_info[x].subtype != WP_MISSILE)

Definition at line 47 of file missionweaponchoice.cpp.

#define IS_LIST_SECONDARY (   x)    (Weapon_info[x].subtype == WP_MISSILE)

Definition at line 48 of file missionweaponchoice.cpp.


Definition at line 82 of file missionweaponchoice.cpp.


Definition at line 209 of file missionweaponchoice.cpp.


Definition at line 83 of file missionweaponchoice.cpp.


Definition at line 84 of file missionweaponchoice.cpp.


Definition at line 80 of file missionweaponchoice.cpp.


Definition at line 72 of file missionweaponchoice.cpp.


Definition at line 360 of file missionweaponchoice.cpp.


Definition at line 359 of file missionweaponchoice.cpp.

#define WEAPON_DESC_WIPE_TIME   1.5f

Definition at line 358 of file missionweaponchoice.cpp.


Definition at line 77 of file missionweaponchoice.cpp.


Definition at line 75 of file missionweaponchoice.cpp.


Definition at line 74 of file missionweaponchoice.cpp.


Definition at line 76 of file missionweaponchoice.cpp.


Definition at line 405 of file missionweaponchoice.cpp.


Definition at line 94 of file missionweaponchoice.cpp.

#define WL_BUTTON_DUMMY   5

Definition at line 92 of file missionweaponchoice.cpp.


Definition at line 93 of file missionweaponchoice.cpp.

#define WL_BUTTON_RESET   4

Definition at line 91 of file missionweaponchoice.cpp.


Definition at line 88 of file missionweaponchoice.cpp.


Definition at line 87 of file missionweaponchoice.cpp.


Definition at line 90 of file missionweaponchoice.cpp.


Definition at line 89 of file missionweaponchoice.cpp.

Typedef Documentation

typedef struct carried_icon carried_icon
typedef struct wl_icon_info wl_icon_info

Function Documentation

void do_mouse_over_list_weapon ( int  index)

Definition at line 2172 of file missionweaponchoice.cpp.

int do_mouse_over_ship_weapon ( int  index)

Mouse over ship weapon

indexBank index on ship (0..6)
0 icon was not dropped on a slot
1 icon was dropped on a slot

Definition at line 2196 of file missionweaponchoice.cpp.

void draw_wl_icon_with_number ( int  list_count,
int  weapon_class 

Draw icon with number

list_countlist position on screen (0-7)
weapon_classclass of weapon

Definition at line 3076 of file missionweaponchoice.cpp.

void draw_wl_icons ( )

Draw the weapon icons that are available

Definition at line 3098 of file missionweaponchoice.cpp.

int drop_icon_on_slot ( int  bank_num)

Drop the Carried_wl_icon onto the specified slot. The slot numbering is:

0->2: primary weapons 3-6: secondary weapons

These are the slots that exist beside the overhead view of the ship. on the weapons loadout screen.

Definition at line 2121 of file missionweaponchoice.cpp.

int eval_weapon_flag_for_game_type ( int  weapon_flags)

Return true if weapon_flags indicates a weapon that is legal for use in current game type. Function added by MK on 9/6/99 to support separate legal loadouts for dogfight missions. name changed by Goober5000 to better reflect what it actually does

Definition at line 1089 of file missionweaponchoice.cpp.

void maybe_drop_icon_on_slot ( int  bank_num)

Definition at line 2156 of file missionweaponchoice.cpp.

void maybe_select_new_ship_weapon ( int  index)

Change to the weapon that corresponds to the ship weapon slot

indexindex of bank (0..2 primary, 0..6 secondary)

Definition at line 1198 of file missionweaponchoice.cpp.

void maybe_select_new_weapon ( int  index)

Change to the weapon that corresponds to index in the weapon list

indexweapon icon index

Definition at line 1164 of file missionweaponchoice.cpp.

void maybe_select_wl_slot ( int  block,
int  slot 

A slot index was clicked on, maybe change Selected_wl_slot

Definition at line 1143 of file missionweaponchoice.cpp.

void pick_from_ship_slot ( int  num)

Pick from ship slot

numindex into shipb banks (0..2 primary, 3..6 secondary)

Definition at line 3170 of file missionweaponchoice.cpp.

void start_weapon_animation ( int  weapon_class)

Start the current weapon animation from playing.

Definition at line 3324 of file missionweaponchoice.cpp.

void stop_weapon_animation ( )
void weapon_button_do ( int  i)

Definition at line 567 of file missionweaponchoice.cpp.

void weapon_buttons_init ( )

Definition at line 668 of file missionweaponchoice.cpp.

void weapon_check_buttons ( )

Check if any weapons loadout screen buttons have been pressed, and call weapon_button_do() if they have.

Definition at line 631 of file missionweaponchoice.cpp.

void weapon_select_close ( )

Free the bitmap slot and memory that was allocated to store the mask bitmap.

Weapon_select_open is cleared when this function completes.

Definition at line 2860 of file missionweaponchoice.cpp.

void weapon_select_close_team ( )

Close out what weapon_select_init_team() set up but only when we are not acutally in the weapon select screen - taylor

Definition at line 1918 of file missionweaponchoice.cpp.

void weapon_select_common_init ( )

This init is called even before the weapons loadout screen is entered. It is called when the briefing state is entered.

Definition at line 1931 of file missionweaponchoice.cpp.

void weapon_select_do ( float  frametime)

Calls to common_ functions are made for those functions which are common to the ship select and briefing screens.

Definition at line 2449 of file missionweaponchoice.cpp.

void weapon_select_init ( )

Called to load the bitmaps and set up the mask regions for the weapon loadout screen. common_select_init() is called to load the animations and bitmaps which are in common with the ship select and briefing screens.

The Weapon_select_open flag is set to 1 when weapon_select_init() completes successfully

Definition at line 1960 of file missionweaponchoice.cpp.

void weapon_select_init_team ( int  team_num)

Initialize team specific weapon select data structures

Definition at line 1901 of file missionweaponchoice.cpp.

void weapon_select_render ( float  frametime)

Definition at line 2262 of file missionweaponchoice.cpp.

void wl_add_index_to_list ( int  wi_index)

Add a weapon_class to ui lists

Definition at line 1709 of file missionweaponchoice.cpp.

int wl_apply ( int  mode,
int  from_bank,
int  from_list,
int  to_bank,
int  to_list,
int  ship_slot,
int  player_index,
bool  dont_play_sound 

Definition at line 3856 of file missionweaponchoice.cpp.

void wl_apply_current_loadout_to_all_ships_in_current_wing ( )

Definition at line 3960 of file missionweaponchoice.cpp.

void wl_bash_ship_weapons ( ship_weapon swp,
wss_unit slot 

Bash ship weapons, based on what is stored in the stored weapons loadout

Wss_slots[] is assumed to be correctly set

Definition at line 3397 of file missionweaponchoice.cpp.

int wl_calc_ballistic_fit ( int  wi_index,
int  capacity 

Determine how many ballistics of type 'wi_index' will fit into capacity - Goober5000

Definition at line 1502 of file missionweaponchoice.cpp.

int wl_calc_missile_fit ( int  wi_index,
int  capacity 

Determine how many missiles of type 'wi_index' will fit into capacity

Definition at line 1518 of file missionweaponchoice.cpp.

int wl_carried_icon_moved ( )

Determine if the carried icon has moved

Definition at line 527 of file missionweaponchoice.cpp.

void wl_cull_illegal_weapons ( int  ship_class,
int wep,
int wep_count 

Ensure that there aren't any bogus weapons assigned by default

Definition at line 1637 of file missionweaponchoice.cpp.

void wl_draw_ship_weapons ( int  index)

Draw the icons for the weapons that are currently on the selected ship

indexSlot to draw weapons for

Definition at line 3030 of file missionweaponchoice.cpp.

int wl_drop ( int  from_bank,
int  from_list,
int  to_bank,
int  to_list,
int  ship_slot,
int  player_index,
bool  dont_play_sound 

Definition at line 3918 of file missionweaponchoice.cpp.

void wl_dump_carried_icon ( )

Definition at line 2095 of file missionweaponchoice.cpp.

int wl_dump_to_list ( int  from_bank,
int  to_list,
int  ship_slot,
int sound 

Definition at line 3649 of file missionweaponchoice.cpp.

void wl_fill_slots ( )

Init the weapons portion of Wss_slots[] and the ui data in Wl_slots[]

It is assumed that Wl_pool[] has been initialized, and Wss_slots[].ship_class is correctly set

Definition at line 1819 of file missionweaponchoice.cpp.

void wl_free_ship_class_data ( )

Free any allocated ship-class specific data

Definition at line 1367 of file missionweaponchoice.cpp.

void wl_get_default_weapons ( int  ship_class,
int  slot_num,
int wep,
int wep_count 

Get the weapons info that should be on ship by default

Definition at line 1665 of file missionweaponchoice.cpp.

void wl_get_parseobj_weapons ( int  sa_index,
int  ship_class,
int wep,
int wep_count 

Set wep and wep_count from a ship which sits in the ship arrivals list at index sa_index

Definition at line 1595 of file missionweaponchoice.cpp.

int wl_get_pilot_subsys_index ( p_object pobjp)
the index for the pilot subsystem in the parse object

Definition at line 541 of file missionweaponchoice.cpp.

int wl_get_ship_class ( int  wl_slot)

Definition at line 1077 of file missionweaponchoice.cpp.

void wl_get_ship_class_weapons ( int  ship_class,
int wep,
int wep_count 

Fill out the weapons for this ship_class

Definition at line 1531 of file missionweaponchoice.cpp.

void wl_get_ship_weapons ( int  ship_index,
int wep,
int wep_count 

Fill out the wep[] and wep_count[] arrays for a ship

Definition at line 1561 of file missionweaponchoice.cpp.

int wl_grab_from_list ( int  from_list,
int  to_bank,
int  ship_slot,
int sound,
net_player pl 

Definition at line 3674 of file missionweaponchoice.cpp.

int wl_icon_being_carried ( )

Is an icon being carried?

Definition at line 497 of file missionweaponchoice.cpp.

void wl_init_icon_lists ( )

Set up the primary and secondary icons lists that hold the weapons the player can choose from

Definition at line 1847 of file missionweaponchoice.cpp.

void wl_init_pool ( team_data td)

Initialize Wl_pool[] to mission default

Definition at line 1228 of file missionweaponchoice.cpp.

void wl_init_ship_class_data ( )

init ship-class specific data

Definition at line 1351 of file missionweaponchoice.cpp.

void wl_load_all_icons ( )

Load all the icons for weapons in the pool

Definition at line 1293 of file missionweaponchoice.cpp.

void wl_load_icons ( int  weapon_class)

Load the icons for a specific ship class

Definition at line 1255 of file missionweaponchoice.cpp.

void wl_maybe_flash_button ( )

Maybe flash a button if player hasn't done anything for a while

Definition at line 2249 of file missionweaponchoice.cpp.

void wl_maybe_reset_selected_slot ( )

Called whenever it is possible that the current selected slot has had it's ship disappear

Definition at line 1428 of file missionweaponchoice.cpp.

void wl_maybe_reset_selected_weapon_class ( )

If Selected_wl_class is -1, choose the first weapon available from the pool for an animation

  • on second thought, choose the first weapon that is oin the ship, then go to the pools

Definition at line 1451 of file missionweaponchoice.cpp.

void wl_pick_icon_from_list ( int  index)

Determine if an icon from the scrollable weapon list can be picked up (for drag and drop).

It calculates the difference in x & y between the icon and the mouse, so we can move the icon with the mouse in a realistic way


Definition at line 3126 of file missionweaponchoice.cpp.

void wl_redraw_pressed_buttons ( )

Redraw any weapon loadout buttons that are pressed down. This function is needed since we sometimes need to draw pressed buttons last to ensure the entire button gets drawn (and not overlapped by other buttons)

Definition at line 650 of file missionweaponchoice.cpp.

void wl_remove_weps_from_pool ( int wep,
int wep_count,
int  ship_class 

Remove the weapons specified by wep[] and wep_count[] from Wl_pool[].

Definition at line 1736 of file missionweaponchoice.cpp.

void wl_render_icon ( int  index,
int  x,
int  y,
int  num,
int  draw_num_flag,
int  hot_mask,
int  hot_bank_mask,
int  select_mask 

Render icon

indexindex into Wl_icons[], identifying which weapon to draw
xx screen position to draw icon at
yy screen position to draw icon at
numcount for weapon
draw_num_flag0 if not to draw count for weapon, nonzero otherwise
hot_maskvalue that should match Hot_weapon_icon to show mouse is over
hot_bank_maskvalue that should match Hot_weapon_bank_icon to show mouse is over
select_maskvalue that should match Selected_wl_class to show icon is selected

Definition at line 2927 of file missionweaponchoice.cpp.

void wl_render_icon_count ( int  num,
int  x,
int  y 

Renders the number next to the weapon icon

numthe actual count to be printed
xx screen position OF THE ICON (NOT where you want the text, this is calculated to prevent overlapping)
yy screen position OF THE ICON (NOT where you want the text, this is calculated to prevent overlapping)

Definition at line 2899 of file missionweaponchoice.cpp.

void wl_render_overhead_view ( float  frametime)

Definition at line 713 of file missionweaponchoice.cpp.

void wl_render_weapon_desc ( )
void wl_render_weapon_desc ( float  frametime)

Draw the weapon description text

this wipes in

Definition at line 2275 of file missionweaponchoice.cpp.

void wl_reset_carried_icon ( )

Reset the data inside Carried_wl_icon

Definition at line 486 of file missionweaponchoice.cpp.

void wl_reset_selected_slot ( )

Set selected slot to first placed ship

Definition at line 1394 of file missionweaponchoice.cpp.

void wl_reset_team_pointers ( )

Reset the necessary pointers to defaults

Definition at line 1888 of file missionweaponchoice.cpp.

void wl_reset_to_defaults ( )

Reset the weapons loadout to the defaults in the mission

Definition at line 3378 of file missionweaponchoice.cpp.

void wl_saturate_bank ( int  ship_slot,
int  bank 

Utility function used to put back overflow into the weapons pool

Definition at line 3475 of file missionweaponchoice.cpp.

void wl_set_carried_icon ( int  from_bank,
int  from_slot,
int  weapon_class 

Set carried icon data

Definition at line 509 of file missionweaponchoice.cpp.

void wl_set_disabled_weapons ( int  ship_class)

Go through the possible weapons to choose from, and flag some as disabled since that ship class cannot use that kind of weapon. The weapon filter is specified in ships.tbl, where each ship has a list of all the possible weapons it can use.

Definition at line 1109 of file missionweaponchoice.cpp.

void wl_set_selected_slot ( int  slot_num)

Call when Selected_wl_slot needs to be changed

Definition at line 1490 of file missionweaponchoice.cpp.

void wl_set_team_pointers ( int  team)

Set the necessary pointers

Definition at line 1878 of file missionweaponchoice.cpp.

int wl_slots_all_empty ( wss_unit slot)

Determine if this slot has no weapons

Definition at line 3212 of file missionweaponchoice.cpp.

int wl_swap_list_slot ( int  from_list,
int  to_bank,
int  ship_slot,
int sound,
net_player pl 

Definition at line 3763 of file missionweaponchoice.cpp.

int wl_swap_slot_slot ( int  from_bank,
int  to_bank,
int  ship_slot,
int sound,
net_player pl 

Definition at line 3503 of file missionweaponchoice.cpp.

void wl_swap_weapons ( int  ship_slot,
int  from_bank,
int  to_bank 

Utility function for swapping two banks

Definition at line 3448 of file missionweaponchoice.cpp.

void wl_synch_interface ( )

Update any interface data that may be dependent on Wss_slots[]


Definition at line 3852 of file missionweaponchoice.cpp.

const char* wl_tooltip_handler ( const char *  str)

Definition at line 458 of file missionweaponchoice.cpp.

void wl_unload_all_anims ( )

Free source anim data if allocated

Definition at line 1246 of file missionweaponchoice.cpp.

void wl_unload_icons ( )

Frees the bitmaps used for weapon icons

Definition at line 1318 of file missionweaponchoice.cpp.

void wl_update_parse_object_weapons ( p_object pobjp,
wss_unit slot 

Set the Pilot subsystem of a parse_object to the weapons that are setup for the wing_block,wing_slot ship

pobjpPointer to parse object that references Pilot subsystem
slotPointer to slot object

Definition at line 3258 of file missionweaponchoice.cpp.

int wl_update_ship_weapons ( int  objnum,
wss_unit slot 

Change a ship's weapons based on the information contained in the Weapon_data[] structure that is filled in during weapon loadout

-1 if the player ship has no weapons
0 if function finished without errors

Definition at line 3231 of file missionweaponchoice.cpp.

void wl_weapon_desc_start_wipe ( )

Re-inits wiping vars and causes the current text to wipe in again

Definition at line 2381 of file missionweaponchoice.cpp.

Variable Documentation

int anim_timer_start

Definition at line 77 of file missionshipchoice.cpp.

int Multi_ping_timestamp

Definition at line 30 of file fredstubs.cpp.

Definition at line 340 of file missionweaponchoice.cpp.

int Plist_size

Definition at line 341 of file missionweaponchoice.cpp.

int Plist_start

Definition at line 341 of file missionweaponchoice.cpp.

Definition at line 343 of file missionweaponchoice.cpp.

int Slist_size

Definition at line 344 of file missionweaponchoice.cpp.

int Slist_start

Definition at line 344 of file missionweaponchoice.cpp.

int Weapon_select_background_bitmap

Definition at line 193 of file missionweaponchoice.cpp.

int Weapon_select_open = 0

Definition at line 60 of file missionweaponchoice.cpp.

int Weapon_select_overlay_id = -1

Definition at line 98 of file missionweaponchoice.cpp.

Initial value:
= {
{ "Reset", 1337, 580, 337, UI_XSTR_COLOR_GREEN, -1, &Buttons[0][WL_BUTTON_RESET].button },
{ "Lock", 1270, 602, 364, UI_XSTR_COLOR_GREEN, -1, &Buttons[0][WL_BUTTON_MULTI_LOCK].button }
{ "Reset", 1337, 938, 546, UI_XSTR_COLOR_GREEN, -1, &Buttons[1][WL_BUTTON_RESET].button },
{ "Lock", 1270, 964, 584, UI_XSTR_COLOR_GREEN, -1, &Buttons[1][WL_BUTTON_MULTI_LOCK].button }
Definition: ui.h:160

Definition at line 406 of file missionweaponchoice.cpp.

int Weapon_title_max_width[GR_NUM_RESOLUTIONS] = { 200, 320 }

Definition at line 366 of file missionweaponchoice.cpp.

UI_WINDOW Weapon_ui_window

Definition at line 205 of file missionweaponchoice.cpp.

wl_icon_info* Wl_icons = NULL

Definition at line 338 of file missionweaponchoice.cpp.

Definition at line 337 of file missionweaponchoice.cpp.

Definition at line 326 of file missionweaponchoice.cpp.