UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_basedefence_callbacks.cpp File Reference

Header file for menu callback functions used for basedefence menu. More...

#include "../../cl_shared.h"
#include "../../ui/ui_dataids.h"
#include "cp_campaign.h"
#include "cp_basedefence_callbacks.h"
#include "cp_fightequip_callbacks.h"
#include "cp_mapfightequip.h"
#include "cp_ufo.h"
#include "cp_missions.h"

Go to the source code of this file.

Functions

static aircraftItemType_t BDEF_GetItemTypeFromID (const char *type)
 returns the itemtype index from a string identifier More...
 
static const char * BDEF_GetIDFromItemType (aircraftItemType_t type)
 returns the string identifier from an itemtype index More...
 
static void BDEF_UpdateAircraftItemList (const aircraftSlot_t *slot)
 Update the list of item you can choose. More...
 
static void BDEF_SelectItem_f (void)
 Show item description in bdef menu. More...
 
static void BDEF_AddSlotToSlotList (const aircraftSlot_t *slot, linkedList_t **slotList)
 
static void BDEF_FillSlotList (const baseWeapon_t *batteries, int maxBatteries, linkedList_t **slotList)
 
static void BDEF_BaseDefenceMenuUpdate_f (void)
 Fills the battery list, descriptions, and weapons in slots of the basedefence equip menu. More...
 
static void BDEF_AddItem_f (void)
 add item to a base defence slot (installation too) More...
 
static void BDEF_RemoveItem_f (void)
 add item to a base defence slot (installation too) More...
 
static void BDEF_RemoveBattery_f (void)
 Remove a defence system from base. More...
 
static void BDEF_AddBattery_f (void)
 Adds a defence system to base. More...
 
static void BDEF_SetAutoFire (baseWeapon_t *weapon, bool state)
 Function to turn on/off autofire of a base weapon. More...
 
static void BDEF_UpdateActiveBattery_f (void)
 Updates the active defences counter. More...
 
static void BDEF_ChangeAutoFire (void)
 Menu callback for changing autofire state Command: basedef_autofire <0|1> More...
 
void BDEF_InitCallbacks (void)
 
void BDEF_ShutdownCallbacks (void)
 

Variables

static const cmdList_t baseDefenseCmds []
 

Detailed Description

Header file for menu callback functions used for basedefence menu.

Definition in file cp_basedefence_callbacks.cpp.

Function Documentation

static void BDEF_AddBattery_f ( void  )
static
static void BDEF_AddSlotToSlotList ( const aircraftSlot_t slot,
linkedList_t **  slotList 
)
static
static void BDEF_ChangeAutoFire ( void  )
static
static void BDEF_FillSlotList ( const baseWeapon_t batteries,
int  maxBatteries,
linkedList_t **  slotList 
)
static
static const char* BDEF_GetIDFromItemType ( aircraftItemType_t  type)
static

returns the string identifier from an itemtype index

Parameters
[in]typeDefence type

Definition at line 52 of file cp_basedefence_callbacks.cpp.

References AC_ITEM_BASE_LASER, and AC_ITEM_BASE_MISSILE.

Referenced by BDEF_AddItem_f(), and BDEF_RemoveItem_f().

static aircraftItemType_t BDEF_GetItemTypeFromID ( const char *  type)
static

returns the itemtype index from a string identifier

Parameters
[in]typeDefence type identifier string

Definition at line 38 of file cp_basedefence_callbacks.cpp.

References AC_ITEM_BASE_LASER, AC_ITEM_BASE_MISSILE, MAX_ACITEMS, and Q_streq.

Referenced by BDEF_AddItem_f(), BDEF_RemoveItem_f(), and BDEF_SelectItem_f().

void BDEF_InitCallbacks ( void  )

Definition at line 694 of file cp_basedefence_callbacks.cpp.

References cgi.

Referenced by CP_AddCampaignCallbackCommands().

static void BDEF_RemoveBattery_f ( void  )
static

Remove a defence system from base.

Note
1st argument is the basedefence system type to destroy (sa basedefenceType_t).
2nd argument is the idx of the base in which you want the battery to be destroyed.
if the first argument is BASEDEF_RANDOM, the type of the battery to destroy is randomly selected
the building must already be removed from ccs.buildings[baseIdx][]

Definition at line 477 of file cp_basedefence_callbacks.cpp.

References B_DEFENCE_LASER, B_DEFENCE_MISSILE, B_GetCount(), B_GetFoundedBaseByIDX(), B_GetNextBuildingByType(), B_STATUS_WORKING, BASEDEF_LASER, BASEDEF_MISSILE, BASEDEF_RANDOM, BDEF_RemoveBattery(), building_s::buildingStatus, cgi, cgame_import_s::Cmd_Argv(), MAX_VAR, base_s::name, base_s::numBatteries, base_s::numLasers, Q_streq, Q_strncpyz(), and type.

static void BDEF_SetAutoFire ( baseWeapon_t weapon,
bool  state 
)
static

Function to turn on/off autofire of a base weapon.

Parameters
[in,out]weaponPointer to the weapon to turn off
[in]stateNew status for autofire
Note
on turning off it also reset the target so the defence weapon stop shoting

Definition at line 612 of file cp_basedefence_callbacks.cpp.

References _, baseWeapon_s::autofire, cgi, cgame_import_s::Cvar_Set(), and baseWeapon_s::target.

Referenced by BDEF_ChangeAutoFire().

void BDEF_ShutdownCallbacks ( void  )

Definition at line 699 of file cp_basedefence_callbacks.cpp.

References cgi.

Referenced by CP_RemoveCampaignCallbackCommands().

static void BDEF_UpdateAircraftItemList ( const aircraftSlot_t slot)
static

Update the list of item you can choose.

Parameters
[in]slotPointer to aircraftSlot where items can be equiped

Definition at line 68 of file cp_basedefence_callbacks.cpp.

References _, AII_GetCraftitemTechsByType(), AIM_SelectableCraftItem(), cgi, TEXT_LIST, and aircraftSlot_s::type.

Referenced by BDEF_FillSlotList().

Variable Documentation

const cmdList_t baseDefenseCmds[]
static
Initial value:
= {
{"add_battery", BDEF_AddBattery_f, "Add a new battery to base"},
{"remove_battery", BDEF_RemoveBattery_f, "Remove a battery from base"},
{"basedef_updatemenu", BDEF_BaseDefenceMenuUpdate_f, "Inits base defence menu"},
{"basedef_selectitem", BDEF_SelectItem_f, nullptr},
{"basedef_additem", BDEF_AddItem_f, "Add item to slot"},
{"basedef_removeitem", BDEF_RemoveItem_f, "Remove item from slot"},
{"basedef_autofire", BDEF_ChangeAutoFire, "Change autofire option for selected defence system"},
{"basedef_updatebatteries", BDEF_UpdateActiveBattery_f, "Updates the active defence systems counters"},
{nullptr, nullptr, nullptr}
}
static void BDEF_AddItem_f(void)
add item to a base defence slot (installation too)
static void BDEF_BaseDefenceMenuUpdate_f(void)
Fills the battery list, descriptions, and weapons in slots of the basedefence equip menu...
static void BDEF_RemoveBattery_f(void)
Remove a defence system from base.
static void BDEF_ChangeAutoFire(void)
Menu callback for changing autofire state Command: basedef_autofire <0|1>
static void BDEF_RemoveItem_f(void)
add item to a base defence slot (installation too)
static void BDEF_AddBattery_f(void)
Adds a defence system to base.
static void BDEF_UpdateActiveBattery_f(void)
Updates the active defences counter.
static void BDEF_SelectItem_f(void)
Show item description in bdef menu.

Definition at line 683 of file cp_basedefence_callbacks.cpp.