ff_i_campaign

Persistent campaign database functions.

As described in ff_x_mod_start, the X0_CAMPAIGN_DB is first checked as an environment variable, then on module.

Variables

X0_CAMPAIGN_DB: (string) Campaign name. Defaults to “X0_CAMPAIGN_DB”

References

X0_CAMPAIGN_DB

Variable name for current campaign name.

string GetCampaignName(string sSuffix = "")
Parameters:
  • sSuffix – Appended with ‘_’ separator. If empty, returns the bare campaign name.

Returns:

Return the campaign name to use

Get the campaign name saved in module’s variable X0_CAMPAIGN_DB

Source code

// @code

#include "nwnx_util"

//! @brief Variable name for current campaign name.
const string X0_CAMPAIGN_DB = "X0_CAMPAIGN_DB";


// -----------------------------------------------------------------------------

//! @brief Get the campaign name saved in module's variable :cpp:var:`X0_CAMPAIGN_DB`
//! @param sSuffix Appended with '_' separator. If empty, returns the bare campaign name.
//! @return Return the campaign name to use
string GetCampaignName(string sSuffix = "");
string GetCampaignName(string sSuffix = "")
{
  object oModule = GetModule();
  string sCampaign = NWNX_Util_GetEnvironmentVariable(X0_CAMPAIGN_DB);
  if (sCampaign == "")
    sCampaign = GetLocalString(oModule, X0_CAMPAIGN_DB);
  if (sCampaign == "")
    sCampaign = X0_CAMPAIGN_DB;

  if (sSuffix == "")
    return sCampaign;

  return sCampaign + "_" + sSuffix;
}