26 #include "../../cl_shared.h"
27 #include "../../../shared/parse.h"
28 #include "../../../common/binaryexpressionparser.h"
70 cgi->LIST_Delete(&eventMails);
97 cgi->Com_Printf(
"CL_ParseEventMails: mail def \"%s\" with same name found, second ignored\n", name);
146 Sys_Error(
"Illegal tech '%s' given in events '%s'", event->tech, events->
id);
163 type =
Q_strstart(expression,
"installation");
164 if (type !=
nullptr) {
165 if (strlen(type) <= 1)
169 value[strlen(value) - 1] =
'\0';
178 if (type !=
nullptr) {
179 if (strlen(type) <= 1)
183 value[strlen(value) - 1] =
'\0';
184 const char* detectedUFO =
static_cast<const char*
>(userdata);
187 return Q_streq(detectedUFO, value);
192 if (type !=
nullptr) {
194 if (sscanf(type,
"[%i]", &xvi) != 1)
207 if (type !=
nullptr) {
208 if (strlen(type) <= 1)
212 value[strlen(value) - 1] =
'\0';
222 type =
Q_strstart(expression,
"nationhappiness");
223 if (type !=
nullptr) {
226 if (sscanf(type,
"[%i]", &nationAmount) != 1)
229 int nationBelowLimit = 0;
234 if (nationBelowLimit >= nationAmount)
243 if (type !=
nullptr) {
245 if (sscanf(type,
"[%i]", &xvipercent) != 1)
247 if (xvipercent < 0 || xvipercent > 100)
256 if (type !=
nullptr) {
258 if (sscanf(type,
"[%i]", &difficulty) != 1)
265 if (type !=
nullptr) {
267 if (sscanf(type,
"[%i]", &days) != 1)
276 type =
Q_strstart(expression,
"alienscaptured");
277 if (type !=
nullptr) {
283 type =
Q_strstart(expression,
"samsitearmed");
284 if (type !=
nullptr) {
290 for (
int i = 0;
i < installation->installationTemplate->maxBatteries;
i++) {
301 cgi->Com_Printf(
"unknown expression given: '%s'\n", expression);
317 if (event->type != type || (!event->active && event->reactivate ==
nullptr))
325 cgi->Cmd_ExecuteString(
"%s", event->command);
330 event->active =
false;
349 #define EVENTCONSTANTS_NAMESPACE "eventTrigger::"
362 const char* errhead =
"CP_ParseEventTrigger: unexpected end of file (event ";
366 cgi->Com_Printf(
"CP_ParseEventTrigger: max event def limit hit\n");
374 if (!*text || token[0] !=
'{') {
375 cgi->Com_Printf(
"CP_ParseEventTrigger: event def '%s' without body ignored\n", name);
379 cgi->Com_RegisterConstList(eventConstants);
385 event->active =
true;
394 if (!
cgi->Com_ParseBlockToken(name, text, event, event_vals,
cp_campaignPool, token)) {
395 cgi->Com_Printf(
"CP_ParseEventTrigger: Ignoring unknown event value '%s'\n", token);
399 cgi->Com_UnregisterConstList(eventConstants);
451 const char* errhead =
"CL_ParseCampaignEvents: unexpected end of file (events ";
456 cgi->Com_Printf(
"CL_ParseCampaignEvents: max events def limit hit\n");
464 if (!*text || token[0] !=
'{') {
465 cgi->Com_Printf(
"CL_ParseCampaignEvents: events def '%s' without body ignored\n", name);
484 cgi->Com_Printf(
"CL_ParseCampaignEvents: max events per event definition limit hit\n");
501 Sys_Error(
"Illegal interest value in events definition '%s' for tech '%s'", events->
id, event->
tech);
512 cgi->Com_Printf(
"CL_EventAddMail: Could not find eventmail with id '%s'\n", eventMailId);
516 if (eventMail->
sent) {
520 if (!eventMail->
from || !eventMail->
to || !eventMail->
subject || !eventMail->
body) {
521 cgi->Com_Printf(
"CL_EventAddMail: mail with id '%s' has incomplete data\n", eventMailId);
525 if (!eventMail->
date) {
535 eventMail->
sent =
true;
542 cgi->Com_Printf(
"CL_EventAddMail: Could not add message with id: %s\n", eventMailId);
556 if (
cgi->Cmd_Argc() < 2) {
list of script aliases to register
bool Q_strnull(const char *string)
int numCampaignEventDefinitions
int CP_GetAverageXVIRate(void)
Return the average XVI rate.
const nationInfo_t * NAT_GetCurrentMonthInfo(const nation_t *const nation)
Get the current month nation stats.
installationType_t INS_GetType(const char *type)
XML tag constants for savegame.
bool Date_IsDue(const date_t *date)
Checks whether a given date is equal or earlier than the current campaign date.
void Sys_Error(const char *error,...)
int numCampaignTriggerEvents
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
QGL_EXTERN GLint GLenum type
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...
#define SAVE_TRIGGEREVENTS_TRIGGEREVENT
void UP_OpenEventMail(const char *eventMailID)
void CL_EventAddMail(const char *eventMailId)
Adds the event mail to the message stack. This message is going to be added to the savegame...
bool INS_HasType(installationType_t type, installationStatus_t status)
Checks whether the given installation type is available.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
#define EVENTCONSTANTS_NAMESPACE
#define SAVE_TRIGGEREVENTS_NAME
#define INS_ForeachOfType(var, installationType)
#define MAX_CAMPAIGNEVENTS
bool CP_TriggerEventSaveXML(xmlNode_t *p)
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.
memPool_t * cp_campaignPool
Defines campaign events when story related technologies should be researched.
const char * Date_GetMonthName(int month)
Returns the short monthame to the given month index.
#define Q_strvalid(string)
void CL_ParseCampaignEvents(const char *name, const char **text)
void CP_CampaignTriggerFunctions(bool add)
Add/Remove temporary mission trigger functions.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
static const constListEntry_t eventConstants[]
#define NAT_Foreach(var)
iterates trough nations
bool RS_MarkStoryLineEventResearched(const char *techID)
void CP_ParseEventTrigger(const char *name, const char **text)
static int CP_CheckTriggerEvent(const char *expression, const void *userdata)
#define SAVE_TRIGGEREVENTS_TRIGGEREVENTS
void CL_EventAddMail_f(void)
const cgame_import_t * cgi
This is the technology parsed from research.ufo.
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
int maxAllowedXVIRateUntilLost
Engine-side time information in the game.
campaignEvent_t campaignEvents[MAX_CAMPAIGNEVENTS]
void CP_TriggerEvent(campaignTriggerEventType_t type, const void *userdata)
Triggers a campaign event with a special type.
const campaignEvents_t * CP_GetEventsByID(const char *name)
Campaign geoscape time header.
static const value_t event_vals[]
Valid event mail parameters.
technology_t * RS_GetTechByID(const char *id)
return a pointer to the technology identified by given id string
struct eventMail_s * eventMail
void CP_FreeDynamicEventMail(void)
Make sure, that the linked list is freed with every new game.
available mails for a tech - mail and mail_pre in script files
campaignEvents_t campaignEvents[MAX_CAMPAIGNS]
eventMail_t eventMails[MAX_EVENTMAILS]
const eventRegister_t events[]
List of functions to register nodes.
Human readable time information in the game.
void CP_CheckCampaignEvents(campaign_t *campaign)
#define MAX_CAMPAIGN_TRIGGER_EVENTS
xmlNode_t *IMPORT * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
campaignTriggerEvent_t campaignTriggerEvents[MAX_CAMPAIGN_TRIGGER_EVENTS]
void CP_DateConvertLong(const date_t *date, dateLong_t *dateLong)
Converts a date from the engine in a (longer) human-readable format.
#define MEMBER_SIZEOF(TYPE, MEMBER)
#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 ...
static linkedList_t * eventMails
Header file for single player campaign control.
xmlNode_t *IMPORT * XML_AddNode(xmlNode_t *parent, const char *name)
#define SAVE_TRIGGEREVENTS_STATE
const char *IMPORT * Com_EParse(const char **text, const char *errhead, const char *errinfo)
char *IMPORT * PoolStrDup(const char *in, memPool_t *pool, const int tagNum)
const campaignEvents_t * events
eventMail_t * CL_GetEventMail(const char *id)
Searches all event mails for a given id.
bool CP_TriggerEventLoadXML(xmlNode_t *p)
campaignTriggerEventType_t
events that are triggered by the campaign
void CL_ParseEventMails(const char *name, const char **text)
const char *IMPORT * Cmd_Argv(int n)
static const value_t eventMail_vals[]
Valid event mail parameters.
const char *IMPORT * XML_GetString(xmlNode_t *parent, const char *name)
xmlNode_t *IMPORT * XML_GetNode(xmlNode_t *parent, const char *name)
Detailed information about the nation relationship (currently per month, but could be used elsewhere)...