/** * @brief Constructs a new installation. */ static void INS_BuildInstallation_f (void) { const installationTemplate_t *installationTemplate; if (cgi->Cmd_Argc() < 1) { Com_Printf("Usage: %s <installationType>\n", cgi->Cmd_Argv(0)); return; } /* We shouldn't build more installations than the actual limit */ if (B_GetInstallationLimit() <= INS_GetCount()) return; installationTemplate = INS_GetInstallationTemplateByID(cgi->Cmd_Argv(1)); if (!installationTemplate) { Com_Printf("The installation type %s passed for %s is not valid.\n", cgi->Cmd_Argv(1), cgi->Cmd_Argv(0)); return; } assert(installationTemplate->cost >= 0); if (ccs.credits - installationTemplate->cost > 0) { /* set up the installation */ installation_t *installation = INS_Build(installationTemplate, ccs.newBasePos, cgi->Cvar_GetString("mn_installation_title")); CP_UpdateCredits(ccs.credits - installationTemplate->cost); /* this cvar is used for disabling the installation build button on geoscape if MAX_INSTALLATIONS was reached */ cgi->Cvar_SetValue("mn_installation_count", INS_GetCount()); const nation_t *nation = MAP_GetNation(installation->pos); if (nation) Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("A new installation has been built: %s (nation: %s)"), installation->name, _(nation->name)); else Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("A new installation has been built: %s"), installation->name); MSO_CheckAddNewMessage(NT_INSTALLATION_BUILDSTART, _("Installation building"), cp_messageBuffer, MSG_CONSTRUCTION); } else { if (installationTemplate->type == INSTALLATION_RADAR) { if (MAP_IsRadarOverlayActivated()) MAP_SetOverlay("radar"); } if (ccs.mapAction == MA_NEWINSTALLATION) ccs.mapAction = MA_NONE; CP_Popup(_("Notice"), _("Not enough credits to set up a new installation.")); } ccs.mapAction = MA_NONE; }
/** * @brief Perform actions when a new UFO is detected. * @param[in] ufocraft Pointer to the UFO that has just been detected. */ void UFO_DetectNewUFO (aircraft_t *ufocraft) { if (ufocraft->detected) return; /* Make this UFO detected */ ufocraft->detected = qtrue; if (!ufocraft->detectionIdx) { ufocraft->detectionIdx = ++ccs.campaignStats.ufosDetected; } ufocraft->lastSpotted = ccs.date; /* If this is the first UFO on geoscape, activate radar */ if (!MAP_IsRadarOverlayActivated()) MAP_SetOverlay("radar"); MAP_UpdateGeoscapeDock(); }
/** * @brief Selects installation type to build */ static void INS_SelectType_f (void) { if (cgi->Cmd_Argc() < 2) return; const char *id = cgi->Cmd_Argv(1); if (ccs.mapAction == MA_NEWINSTALLATION) { MAP_ResetAction(); return; } const installationTemplate_t *tpl = INS_GetInstallationTemplateByID(id); if (!tpl) { Com_Printf("Invalid installation template\n"); return; } if (INS_GetCount() >= B_GetInstallationLimit()) { Com_Printf("Maximum number of installations reached\n"); return; } if (tpl->tech != NULL && !RS_IsResearched_ptr(tpl->tech)) { Com_Printf("This type of installation is not yet researched\n"); return; } if (tpl->once && INS_HasType(tpl->type, INSTALLATION_NOT_USED)) { Com_Printf("Cannot build more of this installation\n"); return; } ccs.mapAction = MA_NEWINSTALLATION; /* show radar overlay (if not already displayed) */ if (tpl->type == INSTALLATION_RADAR && !MAP_IsRadarOverlayActivated()) MAP_SetOverlay("radar"); INS_SetInstallationTitle(tpl->type); cgi->Cvar_Set("mn_installation_type", tpl->id); }
/** * @brief Constructs a new base. * @sa B_NewBase */ static void B_BuildBase_f (void) { const nation_t *nation; const campaign_t *campaign = ccs.curCampaign; if (ccs.mapAction == MA_NEWBASE) ccs.mapAction = MA_NONE; if (ccs.credits - campaign->basecost > 0) { const char *baseName = mn_base_title->string; base_t *base; /* there may be no " in the base name */ if (!Com_IsValidName(baseName)) baseName = _("Base"); base = B_Build(campaign, ccs.newBasePos, baseName); if (!base) cgi->Com_Error(ERR_DROP, "Cannot build base"); CP_UpdateCredits(ccs.credits - campaign->basecost); nation = MAP_GetNation(base->pos); if (nation) Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("A new base has been built: %s (nation: %s)"), mn_base_title->string, _(nation->name)); else Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("A new base has been built: %s"), mn_base_title->string); MS_AddNewMessage(_("Base built"), cp_messageBuffer, MSG_CONSTRUCTION); /* First base */ if (ccs.campaignStats.basesBuilt == 1) B_SetUpFirstBase(campaign, base); cgi->Cvar_SetValue("mn_base_count", B_GetCount()); B_SelectBase(base); } else { if (MAP_IsRadarOverlayActivated()) MAP_SetOverlay("radar"); CP_PopupList(_("Notice"), _("Not enough credits to set up a new base.")); } }