void LootManagerImplementation::initialize() {
	lua = new Lua();
	lua->init();

	info("Loading configuration.");

	if(!loadConfigData()) {

		loadDefaultConfig();

		info("Failed to load configuration values. Using default.");
	}

	lootGroupMap = LootGroupMap::instance();
	lootGroupMap->initialize();

	info("Loaded " + String::valueOf(lootableArmorAttachmentMods.size()) + " lootable armor attachment stat mods.", true);
	info("Loaded " + String::valueOf(lootableClothingAttachmentMods.size()) + " lootable clothing attachment stat mods.", true);
	info("Loaded " + String::valueOf(lootableArmorMods.size()) + " lootable armor stat mods.", true);
	info("Loaded " + String::valueOf(lootableClothingMods.size()) + " lootable clothing stat mods.", true);
	info("Loaded " + String::valueOf(lootableOneHandedMeleeMods.size()) + " lootable one handed melee stat mods.", true);
	info("Loaded " + String::valueOf(lootableTwoHandedMeleeMods.size()) + " lootable two handed melee stat mods.", true);
	info("Loaded " + String::valueOf(lootableUnarmedMods.size()) + " lootable unarmed stat mods.", true);
	info("Loaded " + String::valueOf(lootablePistolMods.size()) + " lootable pistol stat mods.", true);
	info("Loaded " + String::valueOf(lootableRifleMods.size()) + " lootable rifle stat mods.", true);
	info("Loaded " + String::valueOf(lootableCarbineMods.size()) + " lootable carbine stat mods.", true);
	info("Loaded " + String::valueOf(lootablePolearmMods.size()) + " lootable polearm stat mods.", true);
	info("Loaded " + String::valueOf(lootableHeavyWeaponMods.size()) + " lootable heavy weapon stat mods.", true);
	info("Loaded " + String::valueOf(lootGroupMap->countLootItemTemplates()) + " loot items.", true);
	info("Loaded " + String::valueOf(lootGroupMap->countLootGroupTemplates()) + " loot groups.", true);

	info("Initialized.");
}
void NameManager::initialize() {
	lua = new Lua();
	lua->init();

	info("loading configuration");
	if(!loadConfigData()) {

		loadDefaultConfig();

		error("Configuration error(s), using defaults");
	}

	info("initialized");

}
void ResourceManagerImplementation::initialize() {
	lua = new Lua();
	lua->init();

	if(!loadConfigData()) {

		loadDefaultConfig();

		info("***** ERROR in configuration, using default values");
	}

	resourceSpawner->init();

	startResourceSpawner();
	loadSurveyData();
}
bool Config::loadConfig() {

  QFile file("config.json");

  // Check if file exists, if not create default profile
  if(!file.exists()) {
    qDebug() << "Config file not found, loading default config...";
    loadDefaultConfig();
    saveConfig();
    return true;
  }

  // Read config data from file
  QJsonDocument json;

  if(file.open(QFile::ReadOnly)) {
    qDebug() << "Loading config data";

    QJsonParseError error;

    json = QJsonDocument().fromJson(file.readAll(), &error);

    // Check if JSON was correctly parsed
    if (error.error != QJsonParseError::NoError) {

      qDebug() << error.errorString();
      return false;
    }

    // Read JSON values
    QJsonObject object     = json.object();

    P               = object.value("P").toDouble();
    I               = object.value("I").toDouble();
    D               = object.value("D").toDouble();
    sampleRate      = object.value("sampleRate").toDouble();
    windUpPercent   = object.value("windUpPercent").toDouble();
    profileFileName = object.value("profileFileName").toString();
    serialPort      = object.value("serialPort").toString();
    baudRate        = object.value("baudRate").toInt();
  }

  return true;
}
MyTreeModel::MyTreeModel(QDomDocument document /*= QDomDocument()*/, QObject *parent /*= 0*/)
	: QAbstractItemModel(parent), domDocument(document)
{
	// discard cpp keywords from onset
	mstrlistAllIds = QList<QString>()  << "alignas"  << "alignof"  << "and"  << "and_eq"  << "asm"  << "auto"  << "bitand"  << "bitor"  << "bool"  << "break"  << "case"  << "catch"  << "char"  << "char16_t"  << "char32_t"  << "class"  << "compl"  << "concept"  << "const"  << "constexpr"  << "const_cast"  << "continue"  << "decltype"  << "default"  << "delete"  << "do"  << "double"  << "dynamic_cast"  << "else"  << "enum"  << "explicit"  << "export"  << "extern"  << "false"  << "float"  << "for"  << "friend"  << "goto"  << "if"  << "inline"  << "int"  << "long"  << "mutable"  << "namespace"  << "new"  << "noexcept"  << "not"  << "not_eq"  << "nullptr"  << "operator"  << "or"  << "or_eq"  << "private"  << "protected"  << "public"  << "register"  << "reinterpret_cast"  << "requires"  << "return"  << "short"  << "signed"  << "sizeof"  << "static"  << "static_assert"  << "static_cast"  << "struct"  << "switch"  << "template"  << "this"  << "thread_local"  << "throw"  << "true"  << "try"  << "typedef"  << "typeid"  << "typename"  << "union"  << "unsigned"  << "using"  << "virtual"  << "void"  << "volatile"  << "wchar_t"  << "while"  << "xor"  << "xor_eq";
	//
	if (!domDocument.isNull() && domDocument.documentElement().tagName().compare("WtCreator", Qt::CaseInsensitive) == 0)
	{
		// get wroot
		QDomElement wroot;
		wroot           = domDocument.documentElement();
        wRootHiddenElem = new WDomElem(wroot,0);
	}
	else
	{
		loadDefaultConfig();
	}
	
}
Exemple #6
0
int vt_initConfig(const char *pFilePath)
{
    dictionary *pIniDict;

    if ((pIniDict = iniparser_load(pFilePath)) == NULL)
    {
        CX_LOGL(CX_WARN, "Loading ini file: %s failed! Will load default config.", pFilePath);
        loadDefaultConfig();
        return VT_FAILED;
    }

    //iniparser_dump(pIniDict, stderr);

    char *pIPStr = iniparser_getstring(pIniDict, "VoIPServer:IP", VOIP_SERVER_IP_STR);
    if (inet_pton(AF_INET, pIPStr, &g_vtConfig.serverIP) != 1)
    {
        g_vtConfig.serverIP = VOIP_SERVER_IP_INT;
        CX_LOGL(CX_ERR, "inet_pton: IP %s is incorrect. Modify it to %x", pIPStr, VOIP_SERVER_IP_INT);
        return VT_FAILED;
    }

    g_vtConfig.serverIP = ntohl(g_vtConfig.serverIP);
    g_vtConfig.serverPort = iniparser_getint(pIniDict, "VoIPServer:Port", VOIP_SERVER_PORT);
    g_vtConfig.clientListenPort = iniparser_getint(pIniDict, "VoIPClient:ListenPort", CLIENT_PORT);

    pIPStr = iniparser_getstring(pIniDict, "OuterVoIPClient:IP", OUTER_CLIENT_IP_STR);
    if (inet_pton(AF_INET, pIPStr, &g_vtConfig.outerClientIP) != 1)
    {
        g_vtConfig.outerClientIP = OUTER_CLIENT_IP;
        CX_LOGL(CX_ERR, "inet_pton: IP %s is incorrect.", pIPStr);
        return VT_FAILED;
    }

    g_vtConfig.outerClientIP = ntohl(g_vtConfig.outerClientIP);
    g_vtConfig.outerClientListenPort = iniparser_getint(pIniDict, "OuterVoIPClient:ListenPort", OUTER_CLIENT_PORT);
    g_vtConfig.outClientNumber = iniparser_getint(pIniDict, "OuterVoIPClient:Number", OUTER_CLIENT_NUM);

    g_vtConfig.breakMax = iniparser_getint(pIniDict, "Debug:BreakMax", DEFAULT_BREAK_MAX);

    int index;
    char keyname[BUFF_MAX];

    for (index = 0; index < DTMF_DIGIT_AMOUNT; index++)
    {
        snprintf(keyname, BUFF_MAX, "DTMFDigitMap:Key%d", index);

        g_vtConfig.dtmfDigitMap[index] = iniparser_getint(pIniDict, keyname, 0);
    }

    for (index = 0; index < VT_ENDPT_MAX; index++)
    {
        snprintf(keyname, BUFF_MAX, "Endpt%d:Port", index);
        g_vtConfig.endptInfo[index].port = iniparser_getint(pIniDict, keyname, 0);

        snprintf(keyname, BUFF_MAX, "Endpt%d:CtrlPort", index);
        g_vtConfig.endptInfo[index].ctrlport = iniparser_getint(pIniDict, keyname, 0);

        snprintf(keyname, BUFF_MAX, "Endpt%d:Number", index);
        g_vtConfig.endptInfo[index].number = iniparser_getint(pIniDict, keyname, 0);
    }

    g_vtConfig.storeEventMax = iniparser_getint(pIniDict, "EventQueue:EventMax", DEFAULT_EVENT_QUEUE_SIZE);

    g_vtConfig.historySize = iniparser_getint(pIniDict, "Readline:HistorySize", DEFAULT_HISTORY_SIZE);

    iniparser_freedict(pIniDict);

    return VT_SUCCESS;
}
Exemple #7
0
Config::Config(std::istream & in)
{
  loadDefaultConfig();

  parseStream(in);
}