Ejemplo n.º 1
0
	static void setMissingPropertiesToDefault( RepXCollection& collection, RepXReaderWriter& editor, const RepXDefaultEntry* defaults, PxU32 numDefaults )
	{
		FoundationWrapper wrapper( collection.getAllocator() );
		//Release all strings at once, instead of piece by piece
		RepXMemoryAllocatorImpl alloc( collection.getAllocator() );
		//build a hashtable of the initial default value strings.
		TNameOffsetMap nameOffsets( wrapper );
		for ( PxU32 idx = 0; idx < numDefaults; ++idx )
		{
			const RepXDefaultEntry& item( defaults[idx] );
			size_t nameLen = 0;
			const char* periodPtr = nextPeriod (item.name);
			for ( ; periodPtr && *periodPtr; ++periodPtr ) if( *periodPtr == '.' )	break;
			if ( periodPtr == NULL || *periodPtr != '.' ) continue;
			nameLen = periodPtr - item.name;
			char* newMem = (char*)alloc.allocate( PxU32(nameLen + 1) );
			memcpy( newMem, item.name, nameLen );
			newMem[nameLen] = 0;
		
			if ( nameOffsets.find( newMem ) )
				alloc.deallocate( (PxU8*)newMem );
			else
				nameOffsets.insert( newMem, idx );
		}
		//Run through each collection item, and recursively find it and its children
		//If an object's name is in the hash map, check and add any properties that don't exist.
		//else return.
		for ( const RepXCollectionItem* item = collection.begin(), *end = collection.end(); item != end; ++ item )
		{
			RepXCollectionItem theItem( *item );
			setMissingPropertiesToDefault( theItem.mDescriptor, editor, defaults, numDefaults, nameOffsets );
		}
	}
Ejemplo n.º 2
0
void CShop::LoadShopItemDefinitions() {
	// Load the definitions for the shop items. Include classname (for spawing),
	// display name and description, modal name (for image display), and cost
	int numDecls = declManager->GetNumDecls( DECL_ENTITYDEF );
	for( int i = 0; i < numDecls; i++ ) {
		const idDecl *decl = declManager->DeclByIndex( DECL_ENTITYDEF, i, false );
		idStr name = idStr( decl->GetName() );
		if( name.Icmpn( "ShopItem", 8 ) == 0 ) {
			const idDecl *shopDecl = declManager->DeclByIndex( DECL_ENTITYDEF, i, true );
			const idDeclEntityDef *entityDef = static_cast<const idDeclEntityDef *>( shopDecl );
			const idDict &dict = entityDef->dict;
			const char *displayName = dict.GetString( "displayName", "" );
			const char *displayDesc = dict.GetString( "displayDesc", "" );
			//const char* itemClassname = dict.GetString("itemClassname", "");
			const char *image = dict.GetString( "image", "" );
			int cost = dict.GetInt( "price", "0" );
			bool stackable = dict.GetBool( "stackable", "0" ); // grayman (#2376)
			idStr id = name;
			id.StripLeadingOnce( "shopitem_" );
			id = "atdm:" + id;
			CShopItemPtr theItem( new CShopItem( id, displayName, displayDesc, cost, image, 0 ) );
			theItem->SetStackable( stackable ); // grayman (#2376)
			// Add all "itemClassname*" spawnargs to the list
			for( const idKeyValue *kv = dict.MatchPrefix( "itemClassname" ); kv != NULL;
					kv = dict.MatchPrefix( "itemClassname", kv ) ) {
				DM_LOG( LC_MAINMENU, LT_DEBUG )LOGSTRING( "Adding class %s to shopitem %s\r", kv->GetValue().c_str(), common->Translate( displayName ) );
				theItem->AddClassname( kv->GetValue() );
			}
			_itemDefs.Append( theItem );
		}
	}
}
Ejemplo n.º 3
0
void XProcessTablePrivate::drawExpandBox(QPainter* painter,const QRectF& expandboxRect,XProcessItem* item)
{
    QLinearGradient boxGradient(expandboxRect.topLeft(),expandboxRect.bottomLeft());
    boxGradient.setColorAt(0.0,XPT::Color::ExpandBoxStart);
    boxGradient.setColorAt(1.0,XPT::Color::ExpandBoxStop);

    painter->setPen(XPT::Color::ExpandBoxPen);
    painter->setBrush(boxGradient);

    painter->drawRect(expandboxRect);

    RectItem theItem(expandboxRect,item);
    _rectItems.push_back(theItem);
}
Ejemplo n.º 4
0
bool	CACFArray::SetFloat64(UInt32 inIndex, Float64 inItem)
{
	bool theAnswer = false;
	
	if((mCFArray != NULL) && mMutable && (inIndex <= GetNumberItems()))
	{
		CACFNumber theItem(inItem);
		if(theItem.IsValid())
		{
			theAnswer = SetCFType(inIndex, theItem.GetCFNumber());
		}
	}
	
	return theAnswer;
}
Ejemplo n.º 5
0
bool	CACFArray::InsertFloat32(UInt32 inIndex, Float32 inItem)
{
	bool theAnswer = false;
	
	if((mCFArray != NULL) && mMutable)
	{
		CACFNumber theItem(inItem);
		if(theItem.IsValid())
		{
			theAnswer = InsertCFType(inIndex, theItem.GetCFNumber());
		}
	}
	
	return theAnswer;
}
Ejemplo n.º 6
0
bool	CACFArray::InsertBool(UInt32 inIndex, bool inItem)
{
	bool theAnswer = false;
	
	if((mCFArray != NULL) && mMutable)
	{
		CACFBoolean theItem(inItem);
		if(theItem.IsValid())
		{
			theAnswer = InsertCFType(inIndex, theItem.GetCFBoolean());
		}
	}
	
	return theAnswer;
}
Ejemplo n.º 7
0
bool	CACFArray::AppendFloat64(Float64 inItem)
{
	bool theAnswer = false;
	
	if((mCFArray != NULL) && mMutable)
	{
		CACFNumber theItem(inItem);
		if(theItem.IsValid())
		{
			theAnswer = AppendCFType(theItem.GetCFNumber());
		}
	}
	
	return theAnswer;
}
Ejemplo n.º 8
0
bool	CACFArray::AppendBool(bool inItem)
{
	bool theAnswer = false;
	
	if((mCFArray != NULL) && mMutable)
	{
		CACFBoolean theItem(inItem);
		if(theItem.IsValid())
		{
			theAnswer = AppendCFType(theItem.GetCFBoolean());
		}
	}
	
	return theAnswer;
}
Ejemplo n.º 9
0
void	HP_Object::AddProperty(HP_Property* inProperty)
{
	//  get the number of addresses implemented by this property object
	UInt32 theNumberAddresses = inProperty->GetNumberAddressesImplemented();
	
	//  iterate across the addresses
	for(UInt32 theIndex = 0; theIndex < theNumberAddresses; ++theIndex)
	{
		//  get the address
		CAPropertyAddress theAddress;
		inProperty->GetImplementedAddressByIndex(theIndex, theAddress);
		
		//  look to see if it has already been spoken for
		PropertyMap::iterator thePropertyMapIterator = FindPropertyByAddress(theAddress);
		ThrowIf(thePropertyMapIterator != mPropertyMap.end(), CAException(kAudioHardwareIllegalOperationError), "HP_Object::AddProperty: redefined address");
		
		//  it isn't, so add it
		PropertyMapItem theItem(theAddress, inProperty);
		mPropertyMap.push_back(theItem);
	}
}
Ejemplo n.º 10
0
void COwnedAndLostList::ConstructLists()
{
	CString pathString;
	pathString.LoadString(IDS_NETHELP_REGISTRY); // Software\Netscape\Netscape Navigator

	// Read in the owned list
	// Look for owned subkey
	// If subkey exists, iterate over its subkeys and build the owned list
	// If subkey does not exist, the owned list should contain a certain
	// list of built-in types.  These are the types that Netscape defends initially.
	HKEY ownedKey, lostKey;
	CString ownerPath = pathString + "Owned";
	LONG result = ::RegOpenKey(HKEY_CURRENT_USER, ownerPath, &ownedKey);
	
	// Prepopulate our list with some types we want to defend.

	int dwIndex;
	char nameBuffer[_MAX_PATH];
	unsigned long nameBufferSize, valueBufferSize;
	unsigned char valueBuffer[_MAX_PATH];
	unsigned long typeCodeBuffer = 0;

	if (result != ERROR_SUCCESS)
	{
		m_OwnedList.Add(new COwnedLostItem("text/html"));
		m_OwnedList.Add(new COwnedLostItem("image/jpeg"));
		m_OwnedList.Add(new COwnedLostItem("image/pjpeg"));
		m_OwnedList.Add(new COwnedLostItem("image/gif"));
		m_OwnedList.Add(new COwnedLostItem("application/x-javascript"));
		m_OwnedList.Add(new COwnedLostItem("image/x-xbitmap"));
		
		// Be prepared to defend Internet Shortcuts if they are ever installed
		// later! 
		m_OwnedList.Add(new COwnedLostItem("application/x-http-protocol"));
		m_OwnedList.Add(new COwnedLostItem("application/x-https-protocol"));
		m_OwnedList.Add(new COwnedLostItem("application/x-news-protocol"));
		m_OwnedList.Add(new COwnedLostItem("application/x-snews-protocol"));
		m_OwnedList.Add(new COwnedLostItem("application/x-ftp-protocol"));
		m_OwnedList.Add(new COwnedLostItem("application/x-gopher-protocol"));
	}
	else
	{
		// Read in the owned list
		dwIndex = 0;
		valueBufferSize = sizeof(valueBuffer);
		nameBufferSize = sizeof(nameBuffer);
		while (RegEnumValue(ownedKey, dwIndex, nameBuffer, 
				&nameBufferSize, NULL, &typeCodeBuffer, valueBuffer,
				&valueBufferSize) != ERROR_NO_MORE_ITEMS)
		{
			m_OwnedList.Add(new COwnedLostItem(nameBuffer, valueBuffer));
			dwIndex++;
			valueBufferSize = sizeof(valueBuffer);
			nameBufferSize = sizeof(nameBuffer);
		}

	}

	// Read in the lost list
	// Look for lost subkey
	// If subkey exists, iterate over its subkeys and build the lost list
	// If subkey does not exist, the lost list is initially empty.  Do nothing.
	CString lostPath = pathString + "Lost";
	result = ::RegOpenKey(HKEY_CURRENT_USER, lostPath, &lostKey);
	
	if (result == ERROR_SUCCESS)
	{
		// Read in the lost list
		dwIndex = 0;
		valueBufferSize = sizeof(valueBuffer);
		nameBufferSize = sizeof(nameBuffer);
		while (RegEnumValue(lostKey, dwIndex, nameBuffer, 
				&nameBufferSize, NULL, &typeCodeBuffer, valueBuffer,
				&valueBufferSize) != ERROR_NO_MORE_ITEMS)
		{
			m_LostList.Add(new COwnedLostItem(nameBuffer, valueBuffer));
			dwIndex++;
			valueBufferSize = sizeof(valueBuffer);
			nameBufferSize = sizeof(nameBuffer);
		}
	}

	// Iterate over the owned list. Look up each entry in the helper app list.  If
	// it is not handled by the current Netscape, then move it to the lost list.
	int count = m_OwnedList.GetSize();
	for (int i = 0; i < count; i++)
	{
		COwnedLostItem* theItem = (COwnedLostItem*)(m_OwnedList[i]);
		
		if (theItem->m_nHandleMethod != OL_CURRENT_NETSCAPE)
		{
			// Move to the lost list
			void* thePtr = m_OwnedList[i];
			m_OwnedList.RemoveAt(i);
			m_LostList.Add(thePtr);
			i--;
			count--;
		}
	}

	// Iterate over the lost list.  If any entry is now handled by the current Netscape, move it to
	// the owner list
	count = m_LostList.GetSize();
	for (i = 0; i < count; i++)
	{
		COwnedLostItem* theItem = (COwnedLostItem*)(m_LostList[i]);
		
		if (theItem->m_nHandleMethod == OL_CURRENT_NETSCAPE)
		{
			// Move to the owned list
			m_LostList.RemoveAt(i);
			m_OwnedList.Add(theItem);
			i--;
			count--;
		}
	}

	// Iterate over all the helper apps and find any additional entries that aren't in the
	// owned list or lost list (and that should be).
	
	CPtrList* allHelpers = &(CHelperApp::m_cplHelpers);
	for (POSITION pos = allHelpers->GetHeadPosition(); pos != NULL;)
	{
		CHelperApp* app = (CHelperApp*)allHelpers->GetNext(pos);
		CString helperMime(app->cd_item->ci.type);

		COwnedLostItem theItem(helperMime);
		if (theItem.m_nHandleMethod == OL_CURRENT_NETSCAPE &&
			!IsInOwnedList(helperMime))
		{
			// This should be in the owned list, since we apparently control it.
			COwnedLostItem* realItem = new COwnedLostItem(helperMime);
			m_OwnedList.Add(realItem);
		}
		else if (theItem.m_nHandleMethod == OL_OLD_NETSCAPE &&
			!IsInLostList(helperMime))
		{
			// This item is currently used by the old Netscape.  Let's
			// offer to update to the current version of NS.
			COwnedLostItem* realItem = new COwnedLostItem(helperMime);
			m_LostList.Add(realItem);
		}
	}

	// Netscape will automatically wrest control of HTML files from a previous version
	// so we don't REALLY want HTML in our lost list if it is controlled by an older version
	// of netscape.  It should be moved to our OWNED list instead, and the handle method
	// should be updated.
	if (IsInLostList("text/html"))
	{
		COwnedLostItem* theItem = RemoveFromLostList("text/html");
		if (theItem)
		{
			if (theItem->m_nHandleMethod == OL_OLD_NETSCAPE)
			{
				theItem->m_nHandleMethod = OL_CURRENT_NETSCAPE;
				m_OwnedList.Add(theItem);  // Move it to the owned list
			}
			else m_LostList.Add(theItem); // Put it back
		}
	}

	if (IsInLostList("application/x-unknown-content-type-NetscapeMarkup"))
	{
		COwnedLostItem* theItem = RemoveFromLostList("application/x-unknown-content-type-NetscapeMarkup");
		if (theItem)
		{
			if (theItem->m_nHandleMethod == OL_OLD_NETSCAPE)
			{
				theItem->m_nHandleMethod = OL_CURRENT_NETSCAPE;
				m_OwnedList.Add(theItem);  // Move it to the owned list
			}
			else m_LostList.Add(theItem); // Put it back
		}
	}
}
Ejemplo n.º 11
0
CString CPlayerGameStats::GetItemStat (const CString &sStat, const CItemCriteria &Crit) const

//	GetItemStat
//
//	Returns the given stat

	{
	int j;

	struct SEntry
		{
		CItemType *pType;
		SItemTypeStats *pStats;
		};

	//	Generate a list of all item stats that match criteria

	CMapIterator i;
	TArray<SEntry> List;
	m_ItemStats.Reset(i);
	while (m_ItemStats.HasMore(i))
		{
		SItemTypeStats *pStats;
		DWORD dwUNID = m_ItemStats.GetNext(i, &pStats);
		CItemType *pType = g_pUniverse->FindItemType(dwUNID);
		if (pType == NULL)
			continue;

		CItem theItem(pType, 1);
		if (theItem.MatchesCriteria(Crit))
			{
			SEntry *pEntry = List.Insert();
			pEntry->pType = pType;
			pEntry->pStats = pStats;
			}
		}

	//	Handle each case separately

	if (strEquals(sStat, ITEMS_BOUGHT_COUNT_STAT))
		{
		int iTotalCount = 0;
		for (j = 0; j < List.GetCount(); j++)
			iTotalCount += List[j].pStats->iCountBought;
		return ::strFromInt(iTotalCount);
		}
	else if (strEquals(sStat, ITEMS_BOUGHT_VALUE_STAT))
		{
		CurrencyValue iTotal = 0;
		for (j = 0; j < List.GetCount(); j++)
			iTotal += List[j].pStats->iValueBought;
		return ::strFromInt((int)iTotal);
		}
	else if (strEquals(sStat, ITEMS_SOLD_COUNT_STAT))
		{
		int iTotalCount = 0;
		for (j = 0; j < List.GetCount(); j++)
			iTotalCount += List[j].pStats->iCountSold;
		return ::strFromInt(iTotalCount);
		}
	else if (strEquals(sStat, ITEMS_SOLD_VALUE_STAT))
		{
		CurrencyValue iTotal = 0;
		for (j = 0; j < List.GetCount(); j++)
			iTotal += List[j].pStats->iValueSold;
		return ::strFromInt((int)iTotal);
		}
	else
		return NULL_STR;
	}