Beispiel #1
0
void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
{
	auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name));
	object->id = ArtifactID(index);
	object->iconIndex = object->id;

	assert(artifacts[index] == nullptr); // ensure that this id was not loaded before
	artifacts[index] = object;

	VLC->modh->identifiers.requestIdentifier(scope, "object", "artifact", [=](si32 index)
	{
		JsonNode conf;
		conf.setMeta(scope);

		VLC->objtypeh->loadSubObject(object->identifier, conf, Obj::ARTIFACT, object->id.num);

		if (!object->advMapDef.empty())
		{
			JsonNode templ;
			templ.setMeta(scope);
			templ["animation"].String() = object->advMapDef;

			// add new template.
			// Necessary for objects added via mods that don't have any templates in H3
			VLC->objtypeh->getHandlerFor(Obj::ARTIFACT, object->id)->addTemplate(templ);
		}
		// object does not have any templates - this is not usable object (e.g. pseudo-art like lock)
		if (VLC->objtypeh->getHandlerFor(Obj::ARTIFACT, object->id)->getTemplates().empty())
			VLC->objtypeh->removeSubObject(Obj::ARTIFACT, object->id);
	});
	registerObject(scope, "artifact", name, object->id);
}
void CObjectClassesHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
{
	auto object = loadFromJson(data);
	objects[object->id] = object;

	VLC->modh->identifiers.registerObject(scope, "object", name, object->id);
}
Beispiel #3
0
void CObjectClassesHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
{
	auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name));
	assert(objects[index] == nullptr); // ensure that this id was not loaded before
	objects[index] = object;
	VLC->modh->identifiers.registerObject(scope, "object", name, object->id);
}
Beispiel #4
0
void CHeroClassHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
{
	auto object = loadFromJson(data);
	object->id = heroClasses.size();

	heroClasses.push_back(object);

	VLC->modh->identifiers.registerObject(scope, "heroClass", name, object->id);
}
Beispiel #5
0
void CHeroClassHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
{
	auto object = loadFromJson(data);
	object->id = index;

	assert(heroClasses[index] == nullptr); // ensure that this id was not loaded before
	heroClasses[index] = object;

	VLC->modh->identifiers.registerObject(scope, "heroClass", name, object->id);
}
Beispiel #6
0
void CHeroHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
{
	auto object = loadFromJson(data);
	object->ID = HeroTypeID(heroes.size());
	object->imageIndex = heroes.size() + 10; // 2 special frames + some extra portraits

	heroes.push_back(object);

	VLC->modh->identifiers.registerObject(scope, "hero", name, object->ID.getNum());
}
Beispiel #7
0
void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
{
	auto object = loadFromJson(data);
	object->id = ArtifactID(artifacts.size());
	object->iconIndex = object->id + 5;

	artifacts.push_back(object);

	VLC->modh->identifiers.registerObject(scope, "artifact", name, object->id);
}
Beispiel #8
0
void CArtHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
{
	auto object = loadFromJson(data);
	object->id = ArtifactID(index);
	object->iconIndex = object->id;

	assert(artifacts[index] == nullptr); // ensure that this id was not loaded before
	artifacts[index] = object;

	VLC->modh->identifiers.registerObject(scope, "artifact", name, object->id);
}
Beispiel #9
0
void CHeroHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
{
	auto object = loadFromJson(data);
	object->ID = HeroTypeID(index);
	object->imageIndex = index;

	assert(heroes[index] == nullptr); // ensure that this id was not loaded before
	heroes[index] = object;

	VLC->modh->identifiers.registerObject(scope, "hero", name, object->ID.getNum());
}
Beispiel #10
0
void CTownHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
{
	auto object = loadFromJson(data);
	object->index = factions.size();
	if (object->town)
	{
		auto & info = object->town->clientInfo;
		info.icons[0][0] = 8 + object->index * 4 + 0;
		info.icons[0][1] = 8 + object->index * 4 + 1;
		info.icons[1][0] = 8 + object->index * 4 + 2;
		info.icons[1][1] = 8 + object->index * 4 + 3;
	}

	factions.push_back(object);

	VLC->modh->identifiers.registerObject(scope, "faction", name, object->index);
}
Beispiel #11
0
void CHeroClassHandler::loadObject(std::string scope, std::string name, const JsonNode & data)
{
	auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name));
	object->id = heroClasses.size();

	heroClasses.push_back(object);

	VLC->modh->identifiers.requestIdentifier(scope, "object", "hero", [=](si32 index)
	{
		JsonNode classConf = data["mapObject"];
		classConf["heroClass"].String() = name;
		classConf.setMeta(scope);
		VLC->objtypeh->loadSubObject(name, classConf, index, object->id);
	});

	VLC->modh->identifiers.registerObject(scope, "heroClass", name, object->id);
}
Beispiel #12
0
void CHeroClassHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
{
	auto object = loadFromJson(data, normalizeIdentifier(scope, "core", name));
	object->id = index;

	assert(heroClasses[index] == nullptr); // ensure that this id was not loaded before
	heroClasses[index] = object;

	VLC->modh->identifiers.requestIdentifier(scope, "object", "hero", [=](si32 index)
	{
		JsonNode classConf = data["mapObject"];
		classConf["heroClass"].String() = name;
		classConf.setMeta(scope);
		VLC->objtypeh->loadSubObject(name, classConf, index, object->id);
	});

	VLC->modh->identifiers.registerObject(scope, "heroClass", name, object->id);
}
Beispiel #13
0
void CTownHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index)
{
	auto object = loadFromJson(data);
	object->index = index;
	if (object->town)
	{
		auto & info = object->town->clientInfo;
		info.icons[0][0] = (GameConstants::F_NUMBER + object->index) * 2 + 0;
		info.icons[0][1] = (GameConstants::F_NUMBER + object->index) * 2 + 1;
		info.icons[1][0] = object->index * 2 + 0;
		info.icons[1][1] = object->index * 2 + 1;
	}

	assert(factions[index] == nullptr); // ensure that this id was not loaded before
	factions[index] = object;

	VLC->modh->identifiers.registerObject(scope, "faction", name, object->index);
}
Beispiel #14
0
  bool miner::init(const MinerConfig& config) {
    if (!config.extraMessages.empty()) {
      std::string buff;
      if (!Common::loadFileToString(config.extraMessages, buff)) {
        logger(ERROR, BRIGHT_RED) << "Failed to load file with extra messages: " << config.extraMessages; 
        return false; 
      }
      std::vector<std::string> extra_vec;
      boost::split(extra_vec, buff, boost::is_any_of("\n"), boost::token_compress_on );
      m_extra_messages.resize(extra_vec.size());
      for(size_t i = 0; i != extra_vec.size(); i++) {
        boost::algorithm::trim(extra_vec[i]);
        if(!extra_vec[i].size())
          continue;
        std::string buff = Common::base64Decode(extra_vec[i]);
        if(buff != "0")
          m_extra_messages[i] = buff;
      }
      m_config_folder_path = boost::filesystem::path(config.extraMessages).parent_path().string();
      m_config = boost::value_initialized<decltype(m_config)>();

      std::string filebuf;
      if (Common::loadFileToString(m_config_folder_path + "/" + CryptoNote::parameters::MINER_CONFIG_FILE_NAME, filebuf)) {
        loadFromJson(m_config, filebuf);
      }

      logger(INFO) << "Loaded " << m_extra_messages.size() << " extra messages, current index " << m_config.current_extra_message_index;
    }

    if(!config.startMining.empty()) {
      if (!m_currency.parseAccountAddressString(config.startMining, m_mine_address)) {
        logger(ERROR) << "Target account address " << config.startMining << " has wrong format, starting daemon canceled";
        return false;
      }
      m_threads_total = 1;
      m_do_mining = true;
      if(config.miningThreads > 0) {
        m_threads_total = config.miningThreads;
      }
    }

    return true;
  }
Beispiel #15
0
int LevelManager::getLastLevelNumber()
{
	std::string jsonStr = cocos2d::UserDefault::getInstance()->getStringForKey("gameLevels");
	if(!jsonStr.empty())
		loadFromJson(jsonStr);

	int i = 1;
	for(auto imap : mInstance->mLevels) {
		if(imap.second == 0 && i == 1) {
			currentLevelNumber = 1;
			return 1;
		}
		i++;
		if(imap.second == 0) {
			currentLevelNumber = i;
			return i;
		}
	}
	return 0;
}
	SyntaxHighlighter::Keywords::Keywords(const QJsonObject& o) {
		loadFromJson(o);
	}
	// ------------------ SyntaxHighlighter ------------------
	SyntaxHighlighter::TextFormat::TextFormat(const QJsonObject& o) {
		loadFromJson(o);
	}