49 for (
i = 0;
i <
ccs.numEventMails;
i++) {
98 cgi->Com_Printf(
"CL_ParseEventMails: mail def \"%s\" with same name found, second ignored\n",
name);
103 eventMail = &
ccs.eventMails[
ccs.numEventMails++];
123 if (!
events->numCampaignEvents)
126 for (
i = 0;
i <
events->numCampaignEvents;
i++) {
128 if (event->interest <=
ccs.overallInterest) {
141 for (
int i = 0;
i <
ccs.numCampaignEventDefinitions;
i++) {
144 for (
int j = 0; j <
events->numCampaignEvents; j++) {
147 Sys_Error(
"Illegal tech '%s' given in events '%s'", event->tech,
events->id);
165 if (
type !=
nullptr) {
166 if (strlen(
type) <= 1)
170 value[strlen(value) - 1] =
'\0';
179 if (
type !=
nullptr) {
180 if (strlen(
type) <= 1)
184 value[strlen(value) - 1] =
'\0';
185 const char* detectedUFO =
static_cast<const char*
>(userdata);
188 return Q_streq(detectedUFO, value);
193 if (
type !=
nullptr) {
195 if (sscanf(
type,
"[%i]", &xvi) != 1)
208 if (
type !=
nullptr) {
209 if (strlen(
type) <= 1)
213 value[strlen(value) - 1] =
'\0';
224 if (
type !=
nullptr) {
227 if (sscanf(
type,
"[%i]", &nationAmount) != 1)
230 int nationBelowLimit = 0;
235 if (nationBelowLimit >= nationAmount)
244 if (
type !=
nullptr) {
246 if (sscanf(
type,
"[%i]", &xvipercent) != 1)
248 if (xvipercent < 0 || xvipercent > 100)
251 if (xvi >
ccs.curCampaign->maxAllowedXVIRateUntilLost * xvipercent / 100)
257 if (
type !=
nullptr) {
259 if (sscanf(
type,
"[%i]", &difficulty) != 1)
261 return ccs.curCampaign->difficulty == difficulty;
266 if (
type !=
nullptr) {
268 if (sscanf(
type,
"[%i]", &days) != 1)
276 if (
type !=
nullptr) {
277 if (
ccs.campaignStats.capturedAliens > 0)
283 if (
type !=
nullptr) {
289 for (
int i = 0;
i < installation->installationTemplate->maxBatteries;
i++) {
300 cgi->Com_Printf(
"unknown expression given: '%s'\n", expression);
314 for (
i = 0;
i <
ccs.numCampaignTriggerEvents;
i++) {
316 if (event->type !=
type || (!event->active && event->reactivate ==
nullptr))
324 cgi->Cmd_ExecuteString(
"%s", event->command);
329 event->active =
false;
348#define EVENTCONSTANTS_NAMESPACE "eventTrigger::"
361 const char* errhead =
"CP_ParseEventTrigger: unexpected end of file (event ";
365 cgi->Com_Printf(
"CP_ParseEventTrigger: max event def limit hit\n");
369 token =
cgi->Com_EParse(text, errhead,
name);
373 if (!*text || token[0] !=
'{') {
374 cgi->Com_Printf(
"CP_ParseEventTrigger: event def '%s' without body ignored\n",
name);
383 ccs.numCampaignTriggerEvents++;
384 event->active =
true;
388 token =
cgi->Com_EParse(text, errhead,
name);
394 cgi->Com_Printf(
"CP_ParseEventTrigger: Ignoring unknown event value '%s'\n", token);
406 for (
i = 0;
i <
ccs.numCampaignTriggerEvents;
i++) {
432 for (
i = 0;
i <
ccs.numCampaignTriggerEvents;
i++) {
435 event->active = state;
450 const char* errhead =
"CL_ParseCampaignEvents: unexpected end of file (events ";
455 cgi->Com_Printf(
"CL_ParseCampaignEvents: max events def limit hit\n");
459 token =
cgi->Com_EParse(text, errhead,
name);
463 if (!*text || token[0] !=
'{') {
464 cgi->Com_Printf(
"CL_ParseCampaignEvents: events def '%s' without body ignored\n",
name);
468 events = &
ccs.campaignEvents[
ccs.numCampaignEventDefinitions];
472 ccs.numCampaignEventDefinitions++;
476 token =
cgi->Com_EParse(text, errhead,
name);
483 cgi->Com_Printf(
"CL_ParseCampaignEvents: max events per event definition limit hit\n");
488 event = &
events->campaignEvents[
events->numCampaignEvents++];
493 token =
cgi->Com_EParse(text, errhead,
name);
500 Sys_Error(
"Illegal interest value in events definition '%s' for tech '%s'",
events->id, event->
tech);
511 cgi->Com_Printf(
"CL_EventAddMail: Could not find eventmail with id '%s'\n", eventMailId);
515 if (eventMail->
sent) {
519 if (!eventMail->
from || !eventMail->
to || !eventMail->
subject || !eventMail->
body) {
520 cgi->Com_Printf(
"CL_EventAddMail: mail with id '%s' has incomplete data\n", eventMailId);
524 if (!eventMail->
date) {
534 eventMail->
sent =
true;
539 m->eventMail = eventMail;
541 cgi->Com_Printf(
"CL_EventAddMail: Could not add message with id: %s\n", eventMailId);
555 if (
cgi->Cmd_Argc() < 2) {
556 cgi->Com_Printf(
"Usage: %s <event_mail_id>\n",
cgi->Cmd_Argv(0));
DateTime class definition.
Share stuff between the different cgame implementations.
Class describing a point of time.
memPool_t * cp_campaignPool
Header file for single player campaign control.
const cgame_import_t * cgi
const campaignEvents_t * CP_GetEventsByID(const char *name)
bool CP_TriggerEventLoadXML(xmlNode_t *p)
eventMail_t * CL_GetEventMail(const char *id)
Searches all event mails for a given id.
void CL_EventAddMail(const char *eventMailId)
Adds the event mail to the message stack. This message is going to be added to the savegame.
static linkedList_t * eventMails
static const constListEntry_t eventConstants[]
void CP_CheckCampaignEvents(campaign_t *campaign)
static int CP_CheckTriggerEvent(const char *expression, const void *userdata)
static const value_t event_vals[]
Valid event mail parameters.
void CL_ParseEventMails(const char *name, const char **text)
void CL_ParseCampaignEvents(const char *name, const char **text)
#define EVENTCONSTANTS_NAMESPACE
void CL_EventAddMail_f(void)
void CP_ParseEventTrigger(const char *name, const char **text)
void CP_FreeDynamicEventMail(void)
Make sure, that the linked list is freed with every new game.
void CP_TriggerEvent(campaignTriggerEventType_t type, const void *userdata)
Triggers a campaign event with a special type.
bool CP_TriggerEventSaveXML(xmlNode_t *p)
static const value_t eventMail_vals[]
Valid event mail parameters.
#define MAX_CAMPAIGN_TRIGGER_EVENTS
campaignTriggerEventType_t
events that are triggered by the campaign
#define MAX_CAMPAIGNEVENTS
void CP_CampaignTriggerFunctions(bool add)
Add/Remove temporary mission trigger functions.
bool INS_HasType(installationType_t type, installationStatus_t status)
Checks whether the given installation type is available.
installationType_t INS_GetType(const char *type)
#define INS_ForeachOfType(var, installationType)
uiMessageListNodeMessage_t * MS_AddNewMessage(const char *title, const char *text, messageType_t type, technology_t *pedia, bool popup, bool playSound)
Adds a new message to message stack.
const nationInfo_t * NAT_GetCurrentMonthInfo(const nation_t *const nation)
Get the current month nation stats.
#define NAT_Foreach(var)
iterates trough nations
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
technology_t * RS_GetTechByID(const char *id)
return a pointer to the technology identified by given id string
bool RS_MarkStoryLineEventResearched(const char *techID)
void CP_DateConvertLong(const DateTime &date, dateLong_t *dateLong)
Converts a date from the engine in a (longer) human-readable format.
const char * Date_GetMonthName(int month)
Returns the short monthame to the given month index.
Campaign geoscape time header.
void UP_OpenEventMail(const char *eventMailID)
int CP_GetAverageXVIRate(void)
Return the average XVI rate.
const eventRegister_t events[]
List of functions to register nodes.
void Sys_Error(const char *error,...)
#define LIST_Foreach(list, type, var)
Iterates over a linked list, it's safe to delete the returned entry from the list while looping over ...
Shared parsing functions.
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
XML tag constants for savegame.
#define SAVE_TRIGGEREVENTS_NAME
#define SAVE_TRIGGEREVENTS_STATE
#define SAVE_TRIGGEREVENTS_TRIGGEREVENT
#define SAVE_TRIGGEREVENTS_TRIGGEREVENTS
#define MEMBER_SIZEOF(TYPE, MEMBER)
#define Q_strvalid(string)
bool Q_strnull(const char *string)
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
const campaignEvents_t * events
Defines campaign events when story related technologies should be researched.
list of script aliases to register
Human readable time information in the game.
available mails for a tech - mail and mail_pre in script files
Detailed information about the nation relationship (currently per month, but could be used elsewhere)...
This is the technology parsed from research.ufo.