示例#1
0
文件: vrp23.c 项目: AlexMioMio/gcc
void
blah (int code1, int code2)
{
  int i;
  int n_sets;

  n_sets = (int) (code1 == 32);
  if (code2 == 64) goto L2; else goto L3;

L2:
  aa ();

L3:
  if (n_sets > 1) goto L4; else goto L10;

L4:
  aos ();
  i = 0;
  goto L24;

L10:
  if (n_sets > 0) goto L25; else goto L8;

L25:
  i = 0;

L24:
  aob ();
  i = i + 1;
  if (i < n_sets) goto L24; else goto L8;

L8:
  return;
}
/**
 *  This method returns true if the linker has links to the linker identified
 *	by "guid"/"chunkId".
 *
 *	@param guid		GUID of the linker to search in this linker's properties.
 *	@param chunkId	Chunk if the linker to search in this linker's properties.
 *  @return			true if this linker has links to "guid"
 */
bool EditorChunkItemLinkable::hasLinksTo(const UniqueID& guid, const std::string& chunkId)
{
	// look for more links to "guid"
	int propCounter = propHelper()->propCount();
	for (int i=0; i < propCounter; i++)
	{
		DataDescription* pDD = propHelper()->pType()->property( i );
		if (!pDD->editable())
			continue;

		// Is this property a user data object link
		if (propHelper()->isUserDataObjectLink( i ))
		{
			PyObjectPtr ob( propHelper()->propGetPy( i ), PyObjectPtr::STEAL_REFERENCE );

			std::string propId = PyString_AsString( PyTuple_GetItem( ob.getObject(), 0 ) );
			std::string propChunkId = PyString_AsString( PyTuple_GetItem( ob.getObject(), 1 ) );
			if ( propId == guid.toString() && propChunkId == chunkId )
				return true;
		}
		// Is this property an array of user data object links
		else if (propHelper()->isUserDataObjectLinkArray( i ))
		{
			PyObjectPtr ob(	propHelper()->propGetPy( i ), PyObjectPtr::STEAL_REFERENCE );

			SequenceDataType* dataType =
				static_cast<SequenceDataType*>( pDD->dataType() );
			ArrayPropertiesHelper propArray;
			propArray.init(this->chunkItem(),&(dataType->getElemType()), ob.getObject());

			// Iterate through the array of links
			for(int j = 0; j < propArray.propCount(); j++)
			{
				PyObjectPtr aob( propArray.propGetPy( j ), PyObjectPtr::STEAL_REFERENCE );
				std::string propId = PyString_AsString( PyTuple_GetItem( aob.getObject(), 0 ) );
				std::string propChunkId = PyString_AsString( PyTuple_GetItem( aob.getObject(), 1 ) );
				if ( propId == guid.toString() && propChunkId == chunkId )
					return true;
			}
		}
	}
	
	return false;
}
/**
 *	Method indicating whether this item's chunk is writable.
 *
 *	@return	True if writable, false otherwise.
 */
bool EditorChunkItemLinkable::linkedChunksWriteable()
{
	ChunkDirMapping* dirMap = WorldManager::instance().chunkDirMapping();
	int16 gridX, gridZ;

	// process forward links
	int propCounter = propHelper()->propCount();
	for (int i=0; i < propCounter; i++)
	{
		DataDescription* pDD = propHelper()->pType()->property( i );
		if (!pDD->editable())
			continue;

		// Is this property a user data object link
		if (propHelper()->isUserDataObjectLink( i ))
		{
			PyObjectPtr ob( propHelper()->propGetPy( i ), PyObjectPtr::STEAL_REFERENCE );

			std::string id = PyString_AsString( PyTuple_GetItem( ob.getObject(), 0 ) );
			std::string chunkId = PyString_AsString( PyTuple_GetItem( ob.getObject(), 1 ) );
			if ( id == "" || chunkId == "" )
				continue;

			// Force load the linker since we need to examine its parent chunk
			EditorChunkItemLinkable* linkableUDO =
				WorldManager::instance().linkerManager().forceLoad( id, chunkId );
			
			// If the chunk is not an outside chunk, see if it's writeable
			if (linkableUDO && linkableUDO->chunkItem()->chunk())
			{
				if (!EditorChunkCache::instance( *linkableUDO->chunkItem()->chunk() ).edIsWriteable())
				{
					return false;
				}
			}
			else
			{
				//ERROR_MSG(
				//		"EditorChunkItemLinkable::linkedChunksWriteable : "
				//		"Need access to parent chunk!\n" );
				if (!dirMap->gridFromChunkName( chunkId, gridX, gridZ ) ||
					!EditorChunk::outsideChunkWriteable( gridX, gridZ, false ) )
				{
					return false;
				}
			}
		}
		// Is this property an array of user data object links
		else if (propHelper()->isUserDataObjectLinkArray( i ))
		{
			PyObjectPtr ob(	propHelper()->propGetPy( i ), PyObjectPtr::STEAL_REFERENCE );

			SequenceDataType* dataType =
				static_cast<SequenceDataType*>( pDD->dataType() );
			ArrayPropertiesHelper propArray;
			propArray.init(this->chunkItem(),&(dataType->getElemType()), ob.getObject());

			// Iterate through the array of links
			for(int j = 0; j < propArray.propCount(); j++)
			{
				PyObjectPtr aob( propArray.propGetPy( j ), PyObjectPtr::STEAL_REFERENCE );
				std::string id = PyString_AsString( PyTuple_GetItem( aob.getObject(), 0 ) );
				std::string chunkId = PyString_AsString( PyTuple_GetItem( aob.getObject(), 1 ) );
				if ( id == "" || chunkId == "" )
					continue;

				// Force load the linker since we need to examine its parent chunk
				EditorChunkItemLinkable* linkableUDO =
					WorldManager::instance().linkerManager().forceLoad( id, chunkId );
				
				// If the chunk is not an outside chunk, see if it's writeable
				if (linkableUDO && linkableUDO->chunkItem()->chunk())
				{
					if (!EditorChunkCache::instance( *linkableUDO->chunkItem()->chunk() ).edIsWriteable())
					{
						return false;
					}
				}
				else
				{
					//ERROR_MSG(
					//		"EditorChunkItemLinkable::linkedChunksWriteable : "
					//		"Need access to parent chunk!\n" );

					if (!dirMap->gridFromChunkName( chunkId, gridX, gridZ ) ||
						!EditorChunk::outsideChunkWriteable( gridX, gridZ, false ) )
					{
						return false;
					}
				}
			}
		}
	}

	// process back links
	for ( LinksConstIter it = getBackLinksBegin();
		it != getBackLinksEnd(); ++it )
	{
		// Force load the linker since we need to examine its parent chunk
		EditorChunkItemLinkable* linkableUDO =
			WorldManager::instance().linkerManager().forceLoad( (*it).UID_, (*it).CID_ );
		
		// If the chunk is not an outside chunk, see if it's writeable
		if (linkableUDO && linkableUDO->chunkItem()->chunk())
		{
			if (!EditorChunkCache::instance( *linkableUDO->chunkItem()->chunk() ).edIsWriteable())
			{
				return false;
			}
		}
		else
		{
			//ERROR_MSG(
			//		"EditorChunkItemLinkable::linkedChunksWriteable : "
			//		"Need access to parent chunk!\n" );

			if (!dirMap->gridFromChunkName( (*it).CID_, gridX, gridZ ) ||
				!EditorChunk::outsideChunkWriteable( gridX, gridZ, false ) )
			{
				return false;
			}
		}
	}

	return true;
}