static installation_t* CreateInstallation (const char* name, const vec2_t pos) { const installationTemplate_t* installationTemplate = INS_GetInstallationTemplateByType(INSTALLATION_UFOYARD); installation_t* installation = INS_Build(installationTemplate, pos, name); /* fake the build time */ installation->buildStart = ccs.date.day - installation->installationTemplate->buildTime; INS_UpdateInstallationData(); return installation; }
/** * @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 = GEO_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 (GEO_IsRadarOverlayActivated()) GEO_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; }