Beispiel #1
0
bool CzString::operator==	(const CzString &op)
{
	if (Data == NULL)
		return false;

	if (AutoHash && op.isAutohash())
	{
		if (DataHash == op.getHash())
			return true;
	}
	else
	{
		if (strcmp(op.c_str(), Data) == 0)
			return true;
	}
	return false;
}
Beispiel #2
0
int CzMarket::LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node)
{
	// Process market attributes
	CzString* public_key = NULL;
	CzString* simulate = NULL;

	if (EventsManager == NULL)
		EventsManager = new CzEventManager();

	for (CzXmlNode::_AttribIterator it = node->attribs_begin(); it != node->attribs_end(); it++)
	{
		unsigned int name_hash = (*it)->getName().getHash();

		if (name_hash == CzHashes::Name_Hash)
			setName((*it)->getValue().c_str());
		else
		if (name_hash == CzHashes::Tag_Hash)
			setTag((*it)->getValue().c_str());
		else
		if (name_hash == CzHashes::OnError_Hash)
			EventsManager->addEvent("OnError", (*it)->getValue().c_str(), true);
		else
		if (name_hash == CzHashes::OnUnavailable_Hash)
			EventsManager->addEvent("OnUnavailable", (*it)->getValue().c_str(), true);
		else
		if (name_hash == CzHashes::OnComplete_Hash)
			EventsManager->addEvent("OnComplete", (*it)->getValue().c_str(), true);
		else
		if (name_hash == CzHashes::OnBillingDisabled_Hash)
			EventsManager->addEvent("OnBillingDisabled", (*it)->getValue().c_str(), true);
		else
		if (name_hash == CzHashes::OnRefund_Hash)
			EventsManager->addEvent("OnRefund", (*it)->getValue().c_str(), true);
		else
		if (name_hash == CzHashes::AndroidPublicKey_Hash)
			public_key = &(*it)->getValue();
		else
		if (name_hash == CzHashes::Simulate_Hash)
			simulate = &(*it)->getValue();
	}

	CzScene* scene = NULL;
	if (parent != NULL && parent->getClassTypeHash() == CzHashes::Scene_Hash)
		scene = (CzScene*)parent;

	Init(public_key->c_str());

	// Process products
	eCzDeviceType os = PLATFORM_SYS->getDeviceType();
	for (CzXmlNode::_Iterator it2 = node->begin(); it2 != node->end(); ++it2)
	{
		bool valid = false;
		CzMarketProduct* product = new CzMarketProduct();

		unsigned int name_hash = (*it2)->GetName().getHash();
		if (name_hash == CzHashes::Product_Hash)
		{
			for (CzXmlNode::_AttribIterator it = (*it2)->attribs_begin(); it != (*it2)->attribs_end(); ++it)
			{
				unsigned int attrib_hash = (*it)->getName().getHash();

				if (attrib_hash == CzHashes::Name_Hash)
				{
					// Search for the product
					CzMarketProduct* p = findProductByName((*it)->getValue().getHash());
					if (p == NULL)
					{
						product->Name = (*it)->getValue();
						valid = true;
					}
					else
					{
						CzDebug::Log(CZ_DEBUG_CHANNEL_WARNING, "Market - Product with this name already exists - ", (*it)->getValue().c_str(), DebugInfo.c_str());
						valid = false;
						break;
					}
				}
				else
				if (attrib_hash == CzHashes::iOSId_Hash)
				{
					if (os == CzDeviceType_iPhone || os == CzDeviceType_iPad)
						product->ProductID = (*it)->getValue();
				}
				else
				if (attrib_hash == CzHashes::AndroidId_Hash)
				{
					if (os == CzDeviceType_Android)
						product->ProductID = (*it)->getValue();
				}
				else
				if (attrib_hash == CzHashes::Consumable_Hash)
					product->Consumable = (*it)->getValueAsBool();
				else
				if (attrib_hash == CzHashes::Price_Hash)
					product->Price = (*it)->getValueAsFloat();
			}
		}
		if (valid)
		{
			addProduct(product);
			product->Load();
		}
		else
			delete product;
	}

	if (simulate != NULL)
		PLATFORM_MARKET->setSimulation(simulate->getHash());

	if (scene != NULL)
		return scene->getResourceManager()->addResource(this) ? 1 : 0;
	else
		return CZ_GLOBAL_RESOURCES->getResourceManager()->addResource(this) ? 1 : 0;

	return 1;
}