UFO: Alien Invasion
Doxygen documentation generating
cp_mission_triggers.cpp
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2023 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 
26 #include "../../cl_shared.h"
27 #include "../../ui/ui_dataids.h" /* TEXT_STANDARD */
28 #include "cp_campaign.h"
29 #include "cp_missions.h"
30 #include "cp_mission_triggers.h"
31 #include "cp_event_callbacks.h"
32 
41 void CP_ExecuteMissionTrigger (const mission_t* mission, bool won)
42 {
43  cgi->Com_DPrintf(DEBUG_CLIENT, "Execute mission triggers\n");
44 
45  if (mission == nullptr)
46  return;
47 
48  /* we add them only here - and remove them afterwards to prevent cheating */
50 
51  if (won) {
52  if (Q_strvalid(mission->onwin)) {
53  cgi->Com_DPrintf(DEBUG_CLIENT, "...won - executing '%s'\n", mission->onwin);
54  cgi->Cmd_ExecuteString("%s", mission->onwin);
55  }
56  if (mission->mapDef && Q_strvalid(mission->mapDef->onwin)) {
57  cgi->Com_DPrintf(DEBUG_CLIENT, "...won - executing '%s'\n", mission->mapDef->onwin);
58  cgi->Cmd_ExecuteString("%s", mission->mapDef->onwin);
59  }
60  } else {
61  if (Q_strvalid(mission->onlose)) {
62  cgi->Com_DPrintf(DEBUG_CLIENT, "...lost - executing '%s'\n", mission->onlose);
63  cgi->Cmd_ExecuteString("%s", mission->onlose);
64  }
65  if (mission->mapDef && Q_strvalid(mission->mapDef->onlose)) {
66  cgi->Com_DPrintf(DEBUG_CLIENT, "...lost - executing '%s'\n", mission->mapDef->onlose);
67  cgi->Cmd_ExecuteString("%s", mission->mapDef->onlose);
68  }
69  }
70 
72 }
mission definition
Definition: cp_missions.h:86
#define Q_strvalid(string)
Definition: shared.h:141
void CP_CampaignTriggerFunctions(bool add)
Add/Remove temporary mission trigger functions.
Campaign mission triggers.
#define DEBUG_CLIENT
Definition: defines.h:59
void CP_ExecuteMissionTrigger(const mission_t *mission, bool won)
Executes console commands after a mission.
Campaign missions headers.
const cgame_import_t * cgi
char * onwin
Definition: q_shared.h:497
char * onlose
Definition: q_shared.h:498
char onlose[256]
Definition: cp_missions.h:111
Header file for single player campaign control.
char onwin[256]
Definition: cp_missions.h:110
mapDef_t * mapDef
Definition: cp_missions.h:89