UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_ufo_callbacks.cpp
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 */
24 
25 #include "../../cl_shared.h"
26 #include "cp_ufo_callbacks.h"
27 #include "cp_campaign.h"
28 #include "cp_geoscape.h"
29 #include "cp_ufo.h"
30 #include "cp_popup.h"
31 
35 static void UFO_GeoSelectUFO_f (void)
36 {
37  if (cgi->Cmd_Argc() < 2) {
38  return;
39  }
40 
41  const int index = atoi(cgi->Cmd_Argv(1));
42  if (index < 0 || index >= ccs.numUFOs)
43  return;
44  aircraft_t* aircraft = UFO_GetByIDX(index);
45  if (aircraft == nullptr)
46  return;
47 
48  if (!GEO_IsUFOSelected(aircraft))
49  GEO_SelectUFO(aircraft);
52 }
53 
54 static const cmdList_t ufoCallbacks[] = {
55  {"geo_ufo_select", UFO_GeoSelectUFO_f, nullptr},
56  {nullptr, nullptr, nullptr}
57 };
58 
59 void UFO_InitCallbacks (void)
60 {
61  cgi->Cmd_TableAddList(ufoCallbacks);
62 }
63 
65 {
66  cgi->Cmd_TableRemoveList(ufoCallbacks);
67 }
void UFO_InitCallbacks(void)
void CL_DisplayPopupInterceptUFO(aircraft_t *ufo)
Display the popup_intercept.
Definition: cp_popup.cpp:237
const cgame_import_t * cgi
ccs_t ccs
Definition: cp_campaign.cpp:62
Definition: cmd.h:86
Header for Geoscape management.
QGL_EXTERN GLuint index
Definition: r_gl.h:110
aircraft_t * UFO_GetByIDX(const int idx)
returns the UFO on the geoscape with a certain index
Definition: cp_ufo.cpp:85
void UFO_ShutdownCallbacks(void)
Header file for menu related console command callbacks.
#define GEO_IsUFOSelected(ufo)
Definition: cp_geoscape.h:53
int numUFOs
Definition: cp_campaign.h:355
void GEO_SelectUFO(aircraft_t *ufo)
Select the specified ufo on the geoscape.
Header file for single player campaign control.
An aircraft with all it's data.
Definition: cp_aircraft.h:114
static void UFO_GeoSelectUFO_f(void)
Select ufo on Geoscape.
const char *IMPORT * Cmd_Argv(int n)
static const cmdList_t ufoCallbacks[]