Пример #1
0
void
SButton::MakeFocus(bool focusState)
{
	if(!IsEnabled()) return;

	BWindow *window = Window();

	if(focused != focusState)
	{
		focused = focusState;
		DrawDefault(Bounds(), waitting, window->IsActive());
		window->UpdateIfNeeded();
	}

	BView::MakeFocus(focusState);

	if(focused)
	{
		if(!(Flags() & B_PULSE_NEEDED))
		{
			edge_is_black = false;
			old_time = system_time();
			SetFlags(Flags() | B_PULSE_NEEDED);
		}
	}
	else
	{
		if(Flags() & B_PULSE_NEEDED)
		{
			edge_is_black = true;
			old_time = 0;
			SetFlags(Flags() & ~B_PULSE_NEEDED);
		}
	}

	DrawDefault(Bounds(), waitting, window->IsActive());
	window->UpdateIfNeeded();

	if(is_auto_default)
	{
		if(focused)
		{
			if(window->DefaultButton() != this)
			{
				MakeDefault(true);
				window->SetDefaultButton(this);
			}
		}
		else
		{
			if(window->DefaultButton() == this)
			{
				MakeDefault(false);
				window->SetDefaultButton(NULL);
			}
		}
	}
}
Пример #2
0
/*
================
idDeclParticle::Parse
================
*/
bool idDeclParticle::Parse( const char *text, const int textLength ) {
	idLexer src;
	idToken	token;

	src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
	src.SetFlags( DECL_LEXER_FLAGS );
	src.SkipUntilString( "{" );

	depthHack = 0.0f;

	while (1) {
		if ( !src.ReadToken( &token ) ) {
			break;
		}

		if ( !token.Icmp( "}" ) ) {
			break;
		}

		if ( !token.Icmp( "{" ) ) {
			idParticleStage *stage = ParseParticleStage( src );
			if ( !stage ) {
				src.Warning( "Particle stage parse failed" );
				MakeDefault();
				return false;
			}
			stages.Append( stage );
			continue;
		}

		if ( !token.Icmp( "depthHack" ) ) {
			depthHack = src.ParseFloat();
			continue;
		}

		src.Warning( "bad token %s", token.c_str() );
		MakeDefault();
		return false;
	}

	//
	// calculate the bounds
	//
	bounds.Clear();
	for( int i = 0; i < stages.Num(); i++ ) {
		GetStageBounds( stages[i] );
		bounds.AddBounds( stages[i]->bounds );
	}

	if ( bounds.GetVolume() <= 0.1f ) {
		bounds = idBounds( vec3_origin ).Expand( 8.0f );
	}

	return true;
}
Пример #3
0
NS_IMETHODIMP
nsMailGNOMEIntegration::SetDefaultClient(bool aForAllUsers, PRUint16 aApps)
{
  nsresult rv = NS_OK;
  if (aApps & nsIShellService::MAIL)
    rv |= MakeDefault(sMailProtocols, NS_ARRAY_LENGTH(sMailProtocols));
  if (aApps & nsIShellService::NEWS)
    rv |= MakeDefault(sNewsProtocols, NS_ARRAY_LENGTH(sNewsProtocols));
  if (aApps & nsIShellService::RSS)
    rv |= MakeDefault(sFeedProtocols, NS_ARRAY_LENGTH(sFeedProtocols));
  
  return rv;	
}
Пример #4
0
/*
================
idDeclSkin::Parse
================
*/
bool idDeclSkin::Parse( const char *text, const int textLength ) {
	idLexer src;
	idToken	token, token2;

	src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
	src.SetFlags( DECL_LEXER_FLAGS );
	src.SkipUntilString( "{" );

	associatedModels.Clear();

	while (1) {
		if ( !src.ReadToken( &token ) || !token.Icmp( "}" ) ) {
			return false;
		} else if ( !src.ReadToken( &token2 ) ) {
			src.Warning( "Unexpected end of file" );
			MakeDefault();
			return false;
		} else if ( !token.Icmp( "model" ) ) {
			// The list of models associated with this skin is only to guide the
			// user selection in the editor. The skin will be applied for any model
			// the entity has, regardless on whether it is in this list, or not.
			associatedModels.Append( token2 );
		} else {
			skinMapping_t	map;

			if ( !token.Icmp( "*" ) ) {
				map.from = NULL; // wildcard
			} else {
				map.from = declManager->FindMaterial( token );
			}
			map.to = declManager->FindMaterial( token2 );
			mappings.Append( map );
		}
	}
}
Пример #5
0
/*
===================
idSoundSample::Reload
===================
*/
void idSoundSample::Reload( bool force )
{
	if( !force )
	{
		ID_TIME_T newTimestamp;
		
		// check the timestamp
		newTimestamp = GetNewTimeStamp();
		
		if( newTimestamp == FILE_NOT_FOUND_TIMESTAMP )
		{
			if( !defaultSound )
			{
				common->DWarning( "Couldn't load sound '%s' using default", name.c_str() );
				MakeDefault();
			}
			return;
		}
		
		if( newTimestamp == timestamp )
		{
			return;	// don't need to reload it
		}
	}
	common->Printf( "reloading %s\n", name.c_str() );
	PurgeSoundSample();
	Load();
}
Пример #6
0
/*
================
idDeclSkin::Parse
================
*/
bool idDeclSkin::Parse( const char *text, const int textLength ) {
	idLexer src;
	idToken	token, token2;
	src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
	src.SetFlags( DECL_LEXER_FLAGS );
	src.SkipUntilString( "{" );
	associatedModels.Clear();
	while( true ) {
		if( !src.ReadToken( &token ) ) {
			break;
		}
		if( !token.Icmp( "}" ) ) {
			break;
		}
		if( !src.ReadToken( &token2 ) ) {
			src.Warning( "Unexpected end of file" );
			MakeDefault();
			return false;
		}
		if( !token.Icmp( "model" ) ) {
			associatedModels.Append( token2 );
			continue;
		}
		skinMapping_t	map;
		if( !token.Icmp( "*" ) ) {
			// wildcard
			map.from = NULL;
		} else {
			map.from = declManager->FindMaterial( token );
		}
		map.to = declManager->FindMaterial( token2 );
		mappings.Append( map );
	}
	return false;
}
Пример #7
0
bool SingleHiScoreTable::Load()
{
  File f(true, File::STD); // yes has version info, no to glue file.

  std::string root = File::GetRoot();
  File::SetRoot(GetSaveDir(APPLICATION_NAME), "/");
  if (!f.OpenRead("hiscores.cfg"))
  {
    // Make default hi score table and return.
    MakeDefault();   
    File::SetRoot(root, "/");
    return true;
  } 
  File::SetRoot(root, "/");

  int c = 0; 
  for (int i = 0; i < TABLE_SIZE; i++)
  {
    int score = 0;
    std::string name;
    if (!f.GetInteger(&score))
    {
      MakeDefault();   
      return true;
    }
    if (!f.GetDataLine(&name))
    {
      MakeDefault();   
      return true;
    }
    c ^= score;
    m_hiScores.insert(std::make_pair(score, name));
  }
  int check = 0;
  if (!f.GetInteger(&check))
  {
    MakeDefault();   
    return true;
  }
  if (check != c)
  {
    MakeDefault();   
    return true;
  }

  return true;
}
Пример #8
0
/*
===============
idSoundShader::Parse

  this is called by the declManager
===============
*/
bool idSoundShader::Parse( const char *text, const int textLength, bool allowBinaryVersion ) {
	idLexer	src;

	src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
	src.SetFlags( DECL_LEXER_FLAGS );
	src.SkipUntilString( "{" );

	if ( !ParseShader( src ) ) {
		MakeDefault();
		return false;
	}
	return true;
}
Пример #9
0
sk_sp<SkTypeface> SkTypeface::MakeFromName(const char name[], Style style) {
    if (gCreateTypefaceDelegate) {
        sk_sp<SkTypeface> result = (*gCreateTypefaceDelegate)(name, style);
        if (result) {
            return result;
        }
    }
    if (nullptr == name) {
        return MakeDefault(style);
    }
    SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
    return sk_sp<SkTypeface>(fm->legacyCreateTypeface(name, SkFontStyle::FromOldStyle(style)));
}
Пример #10
0
bool edSETTINGS::Load(const std::string& filename)
{
  ZIPSTREAM zipstream;
  ZIPSTRING zipstring;
  Json::Reader reader;
  Json::Value root;
  
  if (!zipstream.Open(filename))
  {
    std::cout << "Failed to load settings from '" << filename << "'." << std::endl;
    MakeDefault();
    return false;
  }
  if (!zipstring.Read(zipstream))
  {
    std::cout << "Failed to load settings from '" << filename << "' : stream error." << std::endl;
    MakeDefault();
    return false;
  }
  if (!reader.parse(zipstring.Str(), root))
  {
    std::cout << "Failed to load settings from '" << filename << "' : " << reader.getFormatedErrorMessages();
    MakeDefault();
    return false;
  }
  
  SetWindowSize(
    wxSize(
      root.get("window-width", 800).asInt(),
      root.get("window-height", 600).asInt()
    )
  );

  std::cout << "Settings successfully loaded from '" << filename << "'." << std::endl;
  return true;
}
Пример #11
0
/*
===============
idSoundShader::Parse

  this is called by the declManager
===============
*/
bool idSoundShader::Parse( const char *text, const int textLength ) {
	idLexer	src;

	src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
	src.SetFlags( DECL_LEXER_FLAGS );
	src.SkipUntilString( "{" );

	// deeper functions can set this, which will cause MakeDefault() to be called at the end
	errorDuringParse = false;

	if ( !ParseShader( src ) || errorDuringParse ) {
		MakeDefault();
		return false;
	}
	return true;
}
Пример #12
0
sk_sp<SkTypeface> SkTypeface::MakeFromName(const char name[],
                                           SkFontStyle fontStyle) {
    if (gCreateTypefaceDelegate) {
        sk_sp<SkTypeface> result = (*gCreateTypefaceDelegate)(name, fontStyle);
        if (result) {
            return result;
        }
    }
    if (nullptr == name && (fontStyle.slant() == SkFontStyle::kItalic_Slant ||
                            fontStyle.slant() == SkFontStyle::kUpright_Slant) &&
                           (fontStyle.weight() == SkFontStyle::kBold_Weight ||
                            fontStyle.weight() == SkFontStyle::kNormal_Weight)) {
        return MakeDefault(static_cast<SkTypeface::Style>(
            (fontStyle.slant() == SkFontStyle::kItalic_Slant ? SkTypeface::kItalic :
                                                               SkTypeface::kNormal) |
            (fontStyle.weight() == SkFontStyle::kBold_Weight ? SkTypeface::kBold :
                                                               SkTypeface::kNormal)));
    }
    SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
    return sk_sp<SkTypeface>(fm->legacyCreateTypeface(name, fontStyle));
}
Пример #13
0
/*
================
idDeclEntityDef::Parse
================
*/
bool idDeclEntityDef::Parse( const char *text, const int textLength )
{
	idLexer src;
	idToken	token, token2;
	
	src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
	src.SetFlags( DECL_LEXER_FLAGS );
	src.SkipUntilString( "{" );
	
	while( 1 )
	{
		if( !src.ReadToken( &token ) )
		{
			break;
		}
		
		if( !token.Icmp( "}" ) )
		{
			break;
		}
		
		if( token.type != TT_STRING )
		{
			src.Warning( "Expected quoted string, but found '%s'", token.c_str() );
			MakeDefault();
			return false;
		}
		
		if( !src.ReadToken( &token2 ) )
		{
			src.Warning( "Unexpected end of file" );
			MakeDefault();
			return false;
		}
		
		if( dict.FindKey( token ) )
		{
			src.DWarning( "'%s' already defined", token.c_str() );
		}
		dict.Set( token, token2 );
	}
	
	// we always automatically set a "classname" key to our name
	dict.Set( "classname", GetName() );
	
	// "inherit" keys will cause all values from another entityDef to be copied into this one
	// if they don't conflict.  We can't have circular recursions, because each entityDef will
	// never be parsed mroe than once
	
	// find all of the dicts first, because copying inherited values will modify the dict
	idList<const idDeclEntityDef *> defList;
	
	while( 1 )
	{
		const idKeyValue *kv;
		
		kv = dict.MatchPrefix( "inherit", NULL );
		
		if( !kv )
		{
			break;
		}
		const idDeclEntityDef *copy = static_cast<const idDeclEntityDef *>( declManager->FindType( DECL_ENTITYDEF, kv->GetValue(), false ) );
		
		if( !copy )
		{
			src.Warning( "Unknown entityDef '%s' inherited by '%s'", kv->GetValue().c_str(), GetName() );
		}
		else
		{
			defList.Append( copy );
		}
		
		// delete this key/value pair
		dict.Delete( kv->GetKey() );
	}
	
	// now copy over the inherited key / value pairs
	for( int i = 0; i < defList.Num(); i++ )
	{
		dict.SetDefaults( &defList[i]->dict );
	}
	
	// precache all referenced media
	// do this as long as we arent in modview
	game->CacheDictionaryMedia( &dict );
	
	return true;
}
Пример #14
0
/*
===================
idSoundSample::Load

Loads based on name, possibly doing a MakeDefault if necessary
===================
*/
void idSoundSample::Load( void ) {
	defaultSound = false;
	purged = false;
	hardwareBuffer = false;
	timestamp = GetNewTimeStamp();
	if( timestamp == FILE_NOT_FOUND_TIMESTAMP ) {
		common->DWarning( "Couldn't load sound '%s' using default", name.c_str() );
		MakeDefault();
		return;
	}
	// load it
	idWaveFile	fh;
	waveformatex_t info;
	if( fh.Open( name, &info ) == -1 ) {
		common->DWarning( "Couldn't load sound '%s' using default", name.c_str() );
		MakeDefault();
		return;
	}
	if( info.nChannels != 1 && info.nChannels != 2 ) {
		common->Warning( "idSoundSample: %s has %i channels, using default", name.c_str(), info.nChannels );
		fh.Close();
		MakeDefault();
		return;
	}
	if( info.wBitsPerSample != 16 ) {
		common->Warning( "idSoundSample: %s is %dbits, expected 16bits using default", name.c_str(), info.wBitsPerSample );
		fh.Close();
		MakeDefault();
		return;
	}
	if( info.nSamplesPerSec != 44100 && info.nSamplesPerSec != 22050 && info.nSamplesPerSec != 11025 ) {
		common->Warning( "idSoundCache: %s is %dHz, expected 11025, 22050 or 44100 Hz. Using default", name.c_str(), info.nSamplesPerSec );
		fh.Close();
		MakeDefault();
		return;
	}
	objectInfo = info;
	objectSize = fh.GetOutputSize();
	objectMemSize = fh.GetMemorySize();
	nonCacheData = ( byte * )soundCacheAllocator.Alloc( objectMemSize );
	fh.Read( nonCacheData, objectMemSize, NULL );
	// optionally convert it to 22kHz to save memory
	CheckForDownSample();
	// create hardware audio buffers
	if( idSoundSystemLocal::useOpenAL ) {
		// PCM loads directly
		if( objectInfo.wFormatTag == WAVE_FORMAT_TAG_PCM ) {
			alGetError();
			alGenBuffers( 1, &openalBuffer );
			if( alGetError() != AL_NO_ERROR ) {
				common->Error( "idSoundCache: error generating OpenAL hardware buffer" );
			}
			if( alIsBuffer( openalBuffer ) ) {
				alGetError();
				alBufferData( openalBuffer, objectInfo.nChannels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, nonCacheData, objectMemSize, objectInfo.nSamplesPerSec );
				if( alGetError() != AL_NO_ERROR ) {
					common->Error( "idSoundCache: error loading data into OpenAL hardware buffer" );
				} else {
					hardwareBuffer = true;
				}
			}
		}
		// OGG decompressed at load time (when smaller than s_decompressionLimit seconds, 6 seconds by default)
		if( objectInfo.wFormatTag == WAVE_FORMAT_TAG_OGG ) {
#if defined(MACOS_X)
			if( ( objectSize < ( ( int ) objectInfo.nSamplesPerSec * idSoundSystemLocal::s_decompressionLimit.GetInteger() ) ) ) {
#else
			if( ( alIsExtensionPresent( ID_ALCHAR "EAX-RAM" ) == AL_TRUE ) && ( objectSize < ( ( int ) objectInfo.nSamplesPerSec * idSoundSystemLocal::s_decompressionLimit.GetInteger() ) ) ) {
#endif
				alGetError();
				alGenBuffers( 1, &openalBuffer );
				if( alGetError() != AL_NO_ERROR ) {
					common->Error( "idSoundCache: error generating OpenAL hardware buffer" );
				}
				if( alIsBuffer( openalBuffer ) ) {
					idSampleDecoder *decoder = idSampleDecoder::Alloc();
					float *destData = ( float * )soundCacheAllocator.Alloc( ( LengthIn44kHzSamples() + 1 ) * sizeof( float ) );
					// Decoder *always* outputs 44 kHz data
					decoder->Decode( this, 0, LengthIn44kHzSamples(), destData );
					// Downsample back to original frequency (save memory)
					if( objectInfo.nSamplesPerSec == 11025 ) {
						for( int i = 0; i < objectSize; i++ ) {
							if( destData[i * 4] < -32768.0f ) {
								( ( short * )destData )[i] = -32768;
							} else if( destData[i * 4] > 32767.0f ) {
								( ( short * )destData )[i] = 32767;
							} else {
								( ( short * )destData )[i] = idMath::FtoiFast( destData[i * 4] );
							}
						}
					} else if( objectInfo.nSamplesPerSec == 22050 ) {
						for( int i = 0; i < objectSize; i++ ) {
							if( destData[i * 2] < -32768.0f ) {
								( ( short * )destData )[i] = -32768;
							} else if( destData[i * 2] > 32767.0f ) {
								( ( short * )destData )[i] = 32767;
							} else {
								( ( short * )destData )[i] = idMath::FtoiFast( destData[i * 2] );
							}
						}
					} else {
						for( int i = 0; i < objectSize; i++ ) {
							if( destData[i] < -32768.0f ) {
								( ( short * )destData )[i] = -32768;
							} else if( destData[i] > 32767.0f ) {
								( ( short * )destData )[i] = 32767;
							} else {
								( ( short * )destData )[i] = idMath::FtoiFast( destData[i] );
							}
						}
					}
					alGetError();
					alBufferData( openalBuffer, objectInfo.nChannels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, destData, objectSize * sizeof( short ), objectInfo.nSamplesPerSec );
					if( alGetError() != AL_NO_ERROR ) {
						common->Error( "idSoundCache: error loading data into OpenAL hardware buffer" );
					} else {
						hardwareBuffer = true;
					}
					soundCacheAllocator.Free( ( byte * )destData );
					idSampleDecoder::Free( decoder );
				}
			}
		}
	}
	fh.Close();
}

/*
===================
idSoundSample::PurgeSoundSample
===================
*/
void idSoundSample::PurgeSoundSample() {
	purged = true;
	if( hardwareBuffer && idSoundSystemLocal::useOpenAL ) {
		alGetError();
		alDeleteBuffers( 1, &openalBuffer );
		if( alGetError() != AL_NO_ERROR ) {
			common->Error( "idSoundCache: error unloading data from OpenAL hardware buffer" );
		} else {
			openalBuffer = 0;
			hardwareBuffer = false;
		}
	}
	if( amplitudeData ) {
		soundCacheAllocator.Free( amplitudeData );
		amplitudeData = NULL;
	}
	if( nonCacheData ) {
		soundCacheAllocator.Free( nonCacheData );
		nonCacheData = NULL;
	}
}
Пример #15
0
/*
===================
idSoundSample::Load

Loads based on name, possibly doing a MakeDefault if necessary
===================
*/
void idSoundSample::Load( void ) {
	defaultSound = false;
	purged = false;
	hardwareBuffer = false;

	timestamp = GetNewTimeStamp();

	if ( timestamp == FILE_NOT_FOUND_TIMESTAMP ) {
		common->Warning( "Couldn't load sound '%s' using default", name.c_str() );
		MakeDefault();
		return;
	}

	// load it
	idWaveFile	fh;
	waveformatex_t info;

	if ( fh.Open( name, &info ) == -1 ) {
		common->Warning( "Couldn't load sound '%s' using default", name.c_str() );
		MakeDefault();
		return;
	}

	if ( info.nChannels != 1 && info.nChannels != 2 ) {
		common->Warning( "idSoundSample: %s has %i channels, using default", name.c_str(), info.nChannels );
		fh.Close();
		MakeDefault();
		return;
	}

	if ( info.wBitsPerSample != 16 ) {
		common->Warning( "idSoundSample: %s is %dbits, expected 16bits using default", name.c_str(), info.wBitsPerSample );
		fh.Close();
		MakeDefault();
		return;
	}

	if ( info.nSamplesPerSec != 44100 && info.nSamplesPerSec != 22050 && info.nSamplesPerSec != 11025 ) {
		common->Warning( "idSoundCache: %s is %dHz, expected 11025, 22050 or 44100 Hz. Using default", name.c_str(), info.nSamplesPerSec );
		fh.Close();
		MakeDefault();
		return;
	}

	objectInfo = info;
	objectSize = fh.GetOutputSize();
	objectMemSize = fh.GetMemorySize();

	nonCacheData = (byte *)soundCacheAllocator.Alloc( objectMemSize );
	fh.Read( nonCacheData, objectMemSize, NULL );

	// optionally convert it to 22kHz to save memory
	CheckForDownSample();

	// create hardware audio buffers
	// PCM loads directly
	if ( objectInfo.wFormatTag == WAVE_FORMAT_TAG_PCM ) {
		alGetError();
		alGenBuffers( 1, &openalBuffer );
		if ( alGetError() != AL_NO_ERROR )
			common->Error( "idSoundCache: error generating OpenAL hardware buffer" );
		if ( alIsBuffer( openalBuffer ) ) {
			alGetError();
			alBufferData( openalBuffer, objectInfo.nChannels==1?AL_FORMAT_MONO16:AL_FORMAT_STEREO16, nonCacheData, objectMemSize, objectInfo.nSamplesPerSec );
			if ( alGetError() != AL_NO_ERROR ) {
				common->Error( "idSoundCache: error loading data into OpenAL hardware buffer" );
			} else {
				// Compute amplitude block size
				int blockSize = 512 * objectInfo.nSamplesPerSec / 44100 ;

				// Allocate amplitude data array
				amplitudeData = (byte *)soundCacheAllocator.Alloc( ( objectSize / blockSize + 1 ) * 2 * sizeof( short) );

				// Creating array of min/max amplitude pairs per blockSize samples
				int i;
				for ( i = 0; i < objectSize; i+=blockSize ) {
					short min = 32767;
					short max = -32768;

					int j;
					for ( j = 0; j < Min( objectSize - i, blockSize ); j++ ) {
						min = ((short *)nonCacheData)[ i + j ] < min ? ((short *)nonCacheData)[ i + j ] : min;
						max = ((short *)nonCacheData)[ i + j ] > max ? ((short *)nonCacheData)[ i + j ] : max;
					}

					((short *)amplitudeData)[ ( i / blockSize ) * 2     ] = min;
					((short *)amplitudeData)[ ( i / blockSize ) * 2 + 1 ] = max;
				}

				hardwareBuffer = true;
			}
		}

		// OGG decompressed at load time (when smaller than s_decompressionLimit seconds, 6 seconds by default)
		if ( objectInfo.wFormatTag == WAVE_FORMAT_TAG_OGG ) {
			if ( ( objectSize < ( ( int ) objectInfo.nSamplesPerSec * idSoundSystemLocal::s_decompressionLimit.GetInteger() ) ) ) {
				alGetError();
				alGenBuffers( 1, &openalBuffer );
				if ( alGetError() != AL_NO_ERROR )
					common->Error( "idSoundCache: error generating OpenAL hardware buffer" );
				if ( alIsBuffer( openalBuffer ) ) {
					idSampleDecoder *decoder = idSampleDecoder::Alloc();
					float *destData = (float *)soundCacheAllocator.Alloc( ( LengthIn44kHzSamples() + 1 ) * sizeof( float ) );

					// Decoder *always* outputs 44 kHz data
					decoder->Decode( this, 0, LengthIn44kHzSamples(), destData );

					// Downsample back to original frequency (save memory)
					if ( objectInfo.nSamplesPerSec == 11025 ) {
						for ( int i = 0; i < objectSize; i++ ) {
							if ( destData[i*4] < -32768.0f )
								((short *)destData)[i] = -32768;
							else if ( destData[i*4] > 32767.0f )
								((short *)destData)[i] = 32767;
							else
								((short *)destData)[i] = idMath::FtoiFast( destData[i*4] );
						}
					} else if ( objectInfo.nSamplesPerSec == 22050 ) {
						for ( int i = 0; i < objectSize; i++ ) {
							if ( destData[i*2] < -32768.0f )
								((short *)destData)[i] = -32768;
							else if ( destData[i*2] > 32767.0f )
								((short *)destData)[i] = 32767;
							else
								((short *)destData)[i] = idMath::FtoiFast( destData[i*2] );
						}
					} else {
						for ( int i = 0; i < objectSize; i++ ) {
							if ( destData[i] < -32768.0f )
								((short *)destData)[i] = -32768;
							else if ( destData[i] > 32767.0f )
								((short *)destData)[i] = 32767;
							else
								((short *)destData)[i] = idMath::FtoiFast( destData[i] );
						}
					}

					alGetError();
					alBufferData( openalBuffer, objectInfo.nChannels==1?AL_FORMAT_MONO16:AL_FORMAT_STEREO16, destData, objectSize * sizeof( short ), objectInfo.nSamplesPerSec );
					if ( alGetError() != AL_NO_ERROR )
						common->Error( "idSoundCache: error loading data into OpenAL hardware buffer" );
					else {
						// Compute amplitude block size
						int blockSize = 512 * objectInfo.nSamplesPerSec / 44100 ;

						// Allocate amplitude data array
						amplitudeData = (byte *)soundCacheAllocator.Alloc( ( objectSize / blockSize + 1 ) * 2 * sizeof( short ) );

						// Creating array of min/max amplitude pairs per blockSize samples
						int i;
						for ( i = 0; i < objectSize; i+=blockSize ) {
							short min = 32767;
							short max = -32768;

							int j;
							for ( j = 0; j < Min( objectSize - i, blockSize ); j++ ) {
								min = ((short *)destData)[ i + j ] < min ? ((short *)destData)[ i + j ] : min;
								max = ((short *)destData)[ i + j ] > max ? ((short *)destData)[ i + j ] : max;
							}

							((short *)amplitudeData)[ ( i / blockSize ) * 2     ] = min;
							((short *)amplitudeData)[ ( i / blockSize ) * 2 + 1 ] = max;
						}

						hardwareBuffer = true;
					}

					soundCacheAllocator.Free( (byte *)destData );
					idSampleDecoder::Free( decoder );
				}
			}
		}

		// Free memory if sample was loaded into hardware
		if ( hardwareBuffer ) {
			soundCacheAllocator.Free( nonCacheData );
			nonCacheData = NULL;
		}
	}

	fh.Close();
}
Пример #16
0
edSETTINGS::edSETTINGS()
{
  MakeDefault();
}
Пример #17
0
/*
========================
idSoundSample_XAudio2::LoadWav
========================
*/
bool idSoundSample_XAudio2::LoadWav( const idStr & filename ) {

	// load the wave
	idWaveFile wave;
	if ( !wave.Open( filename ) ) {
		return false;
	}

	idStrStatic< MAX_OSPATH > sampleName = filename;
	sampleName.SetFileExtension( "amp" );
	LoadAmplitude( sampleName );

	const char * formatError = wave.ReadWaveFormat( format );
	if ( formatError != NULL ) {
		idLib::Warning( "LoadWav( %s ) : %s", filename.c_str(), formatError );
		MakeDefault();
		return false;
	}
	timestamp = wave.Timestamp();

	totalBufferSize = wave.SeekToChunk( 'data' );

	if ( format.basic.formatTag == idWaveFile::FORMAT_PCM || format.basic.formatTag == idWaveFile::FORMAT_EXTENSIBLE ) {

		if ( format.basic.bitsPerSample != 16 ) {
			idLib::Warning( "LoadWav( %s ) : %s", filename.c_str(), "Not a 16 bit PCM wav file" );
			MakeDefault();
			return false;
		}

		playBegin = 0;
		playLength = ( totalBufferSize ) / format.basic.blockSize;

		buffers.SetNum( 1 );
		buffers[0].bufferSize = totalBufferSize;
		buffers[0].numSamples = playLength;
		buffers[0].buffer = AllocBuffer( totalBufferSize, GetName() );
		

		wave.Read( buffers[0].buffer, totalBufferSize );

		if ( format.basic.bitsPerSample == 16 ) {
			idSwap::LittleArray( (short *)buffers[0].buffer, totalBufferSize / sizeof( short ) );
		}

		buffers[0].buffer = GPU_CONVERT_CPU_TO_CPU_CACHED_READONLY_ADDRESS( buffers[0].buffer );

	} else if ( format.basic.formatTag == idWaveFile::FORMAT_ADPCM ) {

		playBegin = 0;
		playLength = ( ( totalBufferSize / format.basic.blockSize ) * format.extra.adpcm.samplesPerBlock );

		buffers.SetNum( 1 );
		buffers[0].bufferSize = totalBufferSize;
		buffers[0].numSamples = playLength;
		buffers[0].buffer  = AllocBuffer( totalBufferSize, GetName() );
		
		wave.Read( buffers[0].buffer, totalBufferSize );

		buffers[0].buffer = GPU_CONVERT_CPU_TO_CPU_CACHED_READONLY_ADDRESS( buffers[0].buffer );

	} else if ( format.basic.formatTag == idWaveFile::FORMAT_XMA2 ) {

		if ( format.extra.xma2.blockCount == 0 ) {
			idLib::Warning( "LoadWav( %s ) : %s", filename.c_str(), "No data blocks in file" );
			MakeDefault();
			return false;
		}

		int bytesPerBlock = format.extra.xma2.bytesPerBlock;
		assert( format.extra.xma2.blockCount == ALIGN( totalBufferSize, bytesPerBlock ) / bytesPerBlock );
		assert( format.extra.xma2.blockCount * bytesPerBlock >= totalBufferSize );
		assert( format.extra.xma2.blockCount * bytesPerBlock < totalBufferSize + bytesPerBlock );

		buffers.SetNum( format.extra.xma2.blockCount );
		for ( int i = 0; i < buffers.Num(); i++ ) {
			if ( i == buffers.Num() - 1 ) {
				buffers[i].bufferSize = totalBufferSize - ( i * bytesPerBlock );
			} else {
				buffers[i].bufferSize = bytesPerBlock;
			}

			buffers[i].buffer = AllocBuffer( buffers[i].bufferSize, GetName() );
			wave.Read( buffers[i].buffer, buffers[i].bufferSize );
			buffers[i].buffer = GPU_CONVERT_CPU_TO_CPU_CACHED_READONLY_ADDRESS( buffers[i].buffer );
		}

		int seekTableSize = wave.SeekToChunk( 'seek' );
		if ( seekTableSize != 4 * buffers.Num() ) {
			idLib::Warning( "LoadWav( %s ) : %s", filename.c_str(), "Wrong number of entries in seek table" );
			MakeDefault();
			return false;
		}

		for ( int i = 0; i < buffers.Num(); i++ ) {
			wave.Read( &buffers[i].numSamples, sizeof( buffers[i].numSamples ) );
			idSwap::Big( buffers[i].numSamples );
		}

		playBegin = format.extra.xma2.loopBegin;
		playLength = format.extra.xma2.loopLength;

		if ( buffers[buffers.Num()-1].numSamples < playBegin + playLength ) {
			// This shouldn't happen, but it's not fatal if it does
			playLength = buffers[buffers.Num()-1].numSamples - playBegin;
		} else {
			// Discard samples beyond playLength
			for ( int i = 0; i < buffers.Num(); i++ ) {
				if ( buffers[i].numSamples > playBegin + playLength ) {
					buffers[i].numSamples = playBegin + playLength;
					// Ideally, the following loop should always have 0 iterations because playBegin + playLength ends in the last block already
					// But there is no guarantee for that, so to be safe, discard all buffers beyond this one
					for ( int j = i + 1; j < buffers.Num(); j++ ) {
						FreeBuffer( buffers[j].buffer );
					}
					buffers.SetNum( i + 1 );
					break;
				}
			}
		}

	} else {
		idLib::Warning( "LoadWav( %s ) : Unsupported wave format %d", filename.c_str(), format.basic.formatTag );
		MakeDefault();
		return false;
	}

	wave.Close();

	if ( format.basic.formatTag == idWaveFile::FORMAT_EXTENSIBLE ) {
		// HACK: XAudio2 doesn't really support FORMAT_EXTENSIBLE so we convert it to a basic format after extracting the channel mask
		format.basic.formatTag = format.extra.extensible.subFormat.data1;
	}

	// sanity check...
	assert( buffers[buffers.Num()-1].numSamples == playBegin + playLength );

	return true;
}
Пример #18
0
/*
========================
idSoundSample_XAudio2::Load
========================
*/
void idSoundSample_XAudio2::LoadResource() {
	FreeData();

	if ( idStr::Icmpn( GetName(), "_default", 8 ) == 0 ) {
		MakeDefault();
		return;
	}

	if ( s_noSound.GetBool() ) {
		MakeDefault();
		return;
	}

	loaded = false;

	for ( int i = 0; i < 2; i++ ) {
		idStrStatic< MAX_OSPATH > sampleName = GetName();
		if ( ( i == 0 ) && !sampleName.Replace( "/vo/", va( "/vo/%s/", sys_lang.GetString() ) ) ) {
			i++;
		}
		idStrStatic< MAX_OSPATH > generatedName = "generated/";
		generatedName.Append( sampleName );

		{
			if ( s_useCompression.GetBool() ) {
				sampleName.Append( ".msadpcm" );
			} else {
				sampleName.Append( ".wav" );
			}
			generatedName.Append( ".idwav" );
		}
		loaded = LoadGeneratedSample( generatedName ) || LoadWav( sampleName );

		if ( !loaded && s_useCompression.GetBool() ) {
			sampleName.SetFileExtension( "wav" );
			loaded = LoadWav( sampleName );
		}

		if ( loaded ) {
			if ( cvarSystem->GetCVarBool( "fs_buildresources" ) ) {
				fileSystem->AddSamplePreload( GetName() );
				WriteAllSamples( GetName() );

				if ( sampleName.Find( "/vo/" ) >= 0 ) {
					for ( int i = 0; i < Sys_NumLangs(); i++ ) {
						const char * lang = Sys_Lang( i );
						if ( idStr::Icmp( lang, ID_LANG_ENGLISH ) == 0 ) {
							continue;
						}
						idStrStatic< MAX_OSPATH > locName = GetName();
						locName.Replace( "/vo/", va( "/vo/%s/", Sys_Lang( i ) ) );
						WriteAllSamples( locName );
					}
				}
			}
			return;
		}
	}

	if ( !loaded ) {
		// make it default if everything else fails
		MakeDefault();
	}
	return;
}
Пример #19
0
/*
=================
idDeclTable2d::Parse
=================
*/
bool idDeclTable2d::Parse( const char* text, const int textLength, bool allowBinaryVersion )
{
	idLexer src;
	idToken token;
	
	src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
	src.SetFlags( DECL_LEXER_FLAGS );
	src.SkipUntilString( "{" );

	values.Clear();

	while ( 1 )
	{
		if ( !src.ReadToken( &token ) )
		{
			break;
		}

		if ( token == "}" )
		{
			break;
		}

		if ( token.Icmp( "[" ) == 0 )
		{
			tableEntry entry;

			bool errorFlag;
			entry.mInput = src.ParseFloat( &errorFlag );
			if ( errorFlag )
			{
				// we got something non-numeric
				MakeDefault();
				return false;
			}

			src.ReadToken( &token );
			if ( token != "," )
			{
				// we got something non-numeric
				MakeDefault();
				return false;
			}

			entry.mOutput = src.ParseFloat( &errorFlag );
			if ( errorFlag )
			{
				// we got something non-numeric
				MakeDefault();
				return false;
			}

			src.ReadToken( &token );
			if ( token != "]" )
			{
				// we got something non-numeric
				MakeDefault();
				return false;
			}

			values.Append( entry );
		}
		else
		{
			src.Warning( "unknown token '%s'", token.c_str() );
			MakeDefault();
			return false;
		}
	}

	return true;
}
Пример #20
0
/*
================
idDeclParticle::Parse
================
*/
bool idDeclParticle::Parse( const char* text, const int textLength, bool allowBinaryVersion )
{

	if( cvarSystem->GetCVarBool( "fs_buildresources" ) )
	{
		fileSystem->AddParticlePreload( GetName() );
	}
	
	idLexer src;
	idToken	token;
	
	unsigned int sourceChecksum = 0;
	idStrStatic< MAX_OSPATH > generatedFileName;
	if( allowBinaryVersion )
	{
		// Try to load the generated version of it
		// If successful,
		// - Create an MD5 of the hash of the source
		// - Load the MD5 of the generated, if they differ, create a new generated
		generatedFileName = "generated/particles/";
		generatedFileName.AppendPath( GetName() );
		generatedFileName.SetFileExtension( ".bprt" );
		
		idFileLocal file( fileSystem->OpenFileReadMemory( generatedFileName ) );
		sourceChecksum = MD5_BlockChecksum( text, textLength );
		
		if( binaryLoadParticles.GetBool() && LoadBinary( file, sourceChecksum ) )
		{
			return true;
		}
	}
	
	src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
	src.SetFlags( DECL_LEXER_FLAGS );
	src.SkipUntilString( "{" );
	
	depthHack = 0.0f;
	
	while( 1 )
	{
		if( !src.ReadToken( &token ) )
		{
			break;
		}
		
		if( !token.Icmp( "}" ) )
		{
			break;
		}
		
		if( !token.Icmp( "{" ) )
		{
			if( stages.Num() >= MAX_PARTICLE_STAGES )
			{
				src.Error( "Too many particle stages" );
				MakeDefault();
				return false;
			}
			idParticleStage* stage = ParseParticleStage( src );
			if( !stage )
			{
				src.Warning( "Particle stage parse failed" );
				MakeDefault();
				return false;
			}
			stages.Append( stage );
			continue;
		}
		
		if( !token.Icmp( "depthHack" ) )
		{
			depthHack = src.ParseFloat();
			continue;
		}
		
		src.Warning( "bad token %s", token.c_str() );
		MakeDefault();
		return false;
	}
	
	// don't calculate bounds or write binary files for defaulted ( non-existent ) particles in resource builds
	if( fileSystem->UsingResourceFiles() )
	{
		bounds = idBounds( vec3_origin ).Expand( 8.0f );
		return true;
	}
	//
	// calculate the bounds
	//
	bounds.Clear();
	for( int i = 0; i < stages.Num(); i++ )
	{
		GetStageBounds( stages[i] );
		bounds.AddBounds( stages[i]->bounds );
	}
	
	if( bounds.GetVolume() <= 0.1f )
	{
		bounds = idBounds( vec3_origin ).Expand( 8.0f );
	}
	
	if( allowBinaryVersion && binaryLoadParticles.GetBool() )
	{
		idLib::Printf( "Writing %s\n", generatedFileName.c_str() );
		idFileLocal outputFile( fileSystem->OpenFileWrite( generatedFileName, "fs_basepath" ) );
		WriteBinary( outputFile, sourceChecksum );
	}
	
	return true;
}
Пример #21
0
/*
=================
idDeclTable::Parse
=================
*/
bool idDeclTable::Parse( const char *text, const int textLength, bool allowBinaryVersion ) {
	idLexer src;
	idToken token;
	float v;

	src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
	src.SetFlags( DECL_LEXER_FLAGS );
	src.SkipUntilString( "{" );

	snap = false;
	clamp = false;
	values.Clear();

	while ( 1 ) {
		if ( !src.ReadToken( &token ) ) {
			break;
		}

		if ( token == "}" ) {
			break;
		}

		if ( token.Icmp( "snap" ) == 0 ) {
			snap = true;
		} else if ( token.Icmp( "clamp" ) == 0 ) {
			clamp = true;
		} else if ( token.Icmp( "{" ) == 0 ) {

			while ( 1 ) {
				bool errorFlag;

				v = src.ParseFloat( &errorFlag );
				if ( errorFlag ) {
					// we got something non-numeric
					MakeDefault();
					return false;
				}

				values.Append( v );

				src.ReadToken( &token );
				if ( token == "}" ) {
					break;
				}
				if ( token == "," ) {
					continue;
				}
				src.Warning( "expected comma or brace" );
				MakeDefault();
				return false;
			}

		} else {
			src.Warning( "unknown token '%s'", token.c_str() );
			MakeDefault();
			return false;
		}
	}

	// copy the 0 element to the end, so lerping doesn't
	// need to worry about the wrap case
	float val = values[0];		// template bug requires this to not be in the Append()?
	values.Append( val );

	return true;
}
Пример #22
0
bool CObjectFactory::Create(eObjects _eObjectID, IBaseObject** _pOut)
{
	if( !m_vOpen[_eObjectID].size() )
		return false;

	unsigned int nIndex = m_vOpen[_eObjectID].back();
	m_vOpen[_eObjectID].pop_back();

	switch(_eObjectID)
	{
	case OBJ_PLAYER:
		{
			MakeDefault(m_cPlayers[nIndex]);
			*_pOut = &m_cPlayers[nIndex];
			m_pOM->AddObject(&m_cPlayers[nIndex], OM_PLAYERS);
			m_pVM->AddObject(&m_cPlayers[nIndex], RG_MODELS);
		}
		break;
	
	case OBJ_BULLET_PLAYER:
		{
			MakeDefault(m_cPlayerBullets[nIndex]);
			*_pOut = &m_cPlayerBullets[nIndex];
			m_pOM->AddObject(&m_cPlayerBullets[nIndex], OM_PLAYER_BULLETS);
			m_pVM->AddObject(&m_cPlayerBullets[nIndex], RG_BULLETS);
		}
		break;

	case OBJ_BULLET_ENEMY:
		{
			MakeDefault(m_cEnemyBullets[nIndex]);
			*_pOut = &m_cEnemyBullets[nIndex];
			m_pOM->AddObject(&m_cEnemyBullets[nIndex], OM_ENEMY_BULLETS);
			m_pVM->AddObject(&m_cEnemyBullets[nIndex], RG_BULLETS);
		}
		break;

	case OBJ_BULLET_EXP:
		{
			MakeDefault(m_cExplodingBullets[nIndex]);
			*_pOut = &m_cExplodingBullets[nIndex];
			m_pOM->AddObject(&m_cExplodingBullets[nIndex], OM_PLAYER_BULLETS);
			m_pOM->AddObject(&m_cExplodingBullets[nIndex], OM_ENEMY_BULLETS);
			m_pVM->AddObject(&m_cExplodingBullets[nIndex], RG_BULLETS);
		}
		break;

	case OBJ_BULLET_TESLA:
		{
			MakeDefault(m_cTeslaBullets[nIndex]);
			*_pOut = &m_cTeslaBullets[nIndex];
			m_pOM->AddObject(&m_cTeslaBullets[nIndex], OM_PLAYER_BULLETS);
			m_pVM->AddObject(&m_cTeslaBullets[nIndex], RG_BULLETS);
		}
		break;

	case OBJ_BULLET_BEAM:
		{
			MakeDefault(m_cBeamBullets[nIndex]);
			*_pOut = &m_cBeamBullets[nIndex];
			m_pOM->AddObject(&m_cBeamBullets[nIndex], OM_PLAYER_BULLETS);
			m_pVM->AddObject(&m_cBeamBullets[nIndex], RG_BULLETS);
		}
		break;

	case OBJ_BULLET_ARC:
		{
			MakeDefault(m_cArcBullets[nIndex]);
			*_pOut = &m_cArcBullets[nIndex];
			m_pOM->AddObject(&m_cArcBullets[nIndex], OM_ENEMY_BULLETS);
			m_pVM->AddObject(&m_cArcBullets[nIndex], RG_BULLETS);
		}
		break;

	case OBJ_PICKUP:
		{
			MakeDefault(m_cPickups[nIndex]);
			*_pOut = &m_cPickups[nIndex];
			m_pOM->AddObject(&m_cPickups[nIndex], OM_ENVIRONMENT);
			m_pVM->AddObject(&m_cPickups[nIndex], RG_ENVIRONMENT);
		}
		break;
	
	case OBJ_TRASH:
		{
			MakeDefault(m_cTrashBots[nIndex]);
			*_pOut = &m_cTrashBots[nIndex];
			m_pOM->AddObject(&m_cTrashBots[nIndex], OM_ENEMIES);
			m_pVM->AddObject(&m_cTrashBots[nIndex], RG_MODELS);
		}
		break;

	case OBJ_PATROL:
		{
			MakeDefault(m_cPatrolBots[nIndex]);
			*_pOut = &m_cPatrolBots[nIndex];
			m_pOM->AddObject(&m_cPatrolBots[nIndex], OM_ENEMIES);
			m_pVM->AddObject(&m_cPatrolBots[nIndex], RG_MODELS); 
		}
		break;

	case OBJ_SMASH:
		{
			MakeDefault(m_cSmashBots[nIndex]);
			*_pOut = &m_cSmashBots[nIndex];
			m_pOM->AddObject(&m_cSmashBots[nIndex], OM_ENEMIES);
			m_pVM->AddObject(&m_cSmashBots[nIndex], RG_MODELS);
		}
		break;

	case OBJ_BURN:
		{
			MakeDefault(m_cBurnBots[nIndex]);
			*_pOut = &m_cBurnBots[nIndex];
			m_pOM->AddObject(&m_cBurnBots[nIndex], OM_ENEMIES);
			m_pVM->AddObject(&m_cBurnBots[nIndex], RG_MODELS);
		}
		break;

	case OBJ_SPIDER:
		{
			MakeDefault(m_cSpiderBots[nIndex]);
			*_pOut = &m_cSpiderBots[nIndex];
			m_pOM->AddObject(&m_cSpiderBots[nIndex], OM_ENEMIES);
			m_pVM->AddObject(&m_cSpiderBots[nIndex], RG_MODELS);
		}
		break;

	case OBJ_STEAM:
		{
			MakeDefault(m_cSteamrollerBots[nIndex]);
			*_pOut = &m_cSteamrollerBots[nIndex];
			m_pOM->AddObject(&m_cSteamrollerBots[nIndex], OM_ENEMIES);
			m_pVM->AddObject(&m_cSteamrollerBots[nIndex], RG_MODELS);
		}
		break;

	case OBJ_SPINBOT:
		{
			MakeDefault(m_cSpinBot[nIndex]);
			*_pOut = &m_cSpinBot[nIndex];
			m_pOM->AddObject(&m_cSpinBot[nIndex], OM_ENEMIES);
			m_pVM->AddObject(&m_cSpinBot[nIndex], RG_MODELS);
		}
		break;

	case OBJ_AICORE:
		{
			MakeDefault(m_cAICores[nIndex]);
			*_pOut = &m_cAICores[nIndex];
			m_pOM->AddObject(&m_cAICores[nIndex], OM_ENEMIES);
			m_pVM->AddObject(&m_cAICores[nIndex], RG_MODELS);
		}
		break;

	case OBJ_AIFIST:
		{
			MakeDefault(m_cAIFists[nIndex]);
			*_pOut = &m_cAIFists[nIndex];
			m_pOM->AddObject(&m_cAIFists[nIndex], OM_ENEMIES);
			m_pVM->AddObject(&m_cAIFists[nIndex], RG_MODELS);
		}
		break;

	case OBJ_CONVEYOR:
		{
			*_pOut = &m_cConveyors[nIndex];
			m_pOM->AddObject(&m_cConveyors[nIndex], OM_ENVIRONMENT);
		}
		break;

	case OBJ_VAT:
		{
			MakeDefault(m_cVats[nIndex]);
			*_pOut = &m_cVats[nIndex];
			m_pOM->AddObject(&m_cVats[nIndex], OM_ENVIRONMENT);
			m_pVM->AddObject(&m_cVats[nIndex], RG_ENVIRONMENT);
		}
		break;

	case OBJ_CRATE:
		{
			MakeDefault(m_cCrates[nIndex]);
			*_pOut = &m_cCrates[nIndex];
			m_pOM->AddObject(&m_cCrates[nIndex], OM_ENVIRONMENT);
			m_pVM->AddObject(&m_cCrates[nIndex], RG_ENVIRONMENT);
		}
		break;

	case OBJ_BARREL:
		{
			MakeDefault(m_cBarrels[nIndex]);
			*_pOut = &m_cBarrels[nIndex];
			m_pOM->AddObject(&m_cBarrels[nIndex], OM_ENVIRONMENT);
			m_pVM->AddObject(&m_cBarrels[nIndex], RG_ENVIRONMENT);
		}
		break;

	case OBJ_POOL:
		{
			MakeDefault(m_cPools[nIndex]);
			*_pOut = &m_cPools[nIndex];
			m_pOM->AddObject(&m_cPools[nIndex], OM_ENVIRONMENT);
			m_pVM->AddObject(&m_cPools[nIndex], RG_ENVIRONMENT);
		}
		break;
	case OBJ_TURRET:
		{
			MakeDefault(m_cTurrets[nIndex]);
			*_pOut = &m_cTurrets[nIndex];
			m_pOM->AddObject(&m_cTurrets[nIndex],OM_ENVIRONMENT);
			m_pVM->AddObject(&m_cTurrets[nIndex],RG_ENVIRONMENT);
		}
		break;
	case OBJ_INVERSION:
		{
			MakeDefault(m_cInversion[nIndex]);
			*_pOut = &m_cInversion[nIndex];
			m_pOM->AddObject(&m_cInversion[nIndex], OM_ENVIRONMENT);
			m_pVM->AddObject(&m_cInversion[nIndex], RG_ENVIRONMENT);
		}
		break;
	case OBJ_TUNNEL:
		{
			MakeDefault(m_cTunnel[nIndex]);
			*_pOut = &m_cTunnel[nIndex];
			m_pOM->AddObject(&m_cTunnel[nIndex], OM_ENVIRONMENT);
			m_pVM->AddObject(&m_cTunnel[nIndex], RG_ENVIRONMENT);
		}
		break;

	case OBJ_BOSSINV:
		{
			MakeDefault(m_cBossInv[nIndex]);
			*_pOut = &m_cBossInv[nIndex];
			m_pOM->AddObject(&m_cBossInv[nIndex], OM_ENVIRONMENT);
			m_pVM->AddObject(&m_cBossInv[nIndex], RG_ENVIRONMENT);
		}
		break;

	case OBJ_BOSSTURRET:
		{
			MakeDefault(m_cBossTurrets[nIndex]);
			*_pOut = &m_cBossTurrets[nIndex];
			m_pOM->AddObject(&m_cBossTurrets[nIndex], OM_ENVIRONMENT);
			m_pVM->AddObject(&m_cBossTurrets[nIndex], RG_ENVIRONMENT);
		}
		break;

	case OBJ_PIT:
		{
			MakeDefault(m_cDeathPits[nIndex]);
			*_pOut = &m_cDeathPits[nIndex];
			m_pOM->AddObject(&m_cDeathPits[nIndex], OM_ENVIRONMENT);
			m_pVM->AddObject(&m_cDeathPits[nIndex], RG_ENVIRONMENT);
		}
		break;

	case OBJ_FLOOR:
		{
			MakeDefault(m_cFloor[nIndex]);
			*_pOut = &m_cFloor[nIndex];
			m_pOM->AddObject(&m_cFloor[nIndex], OM_ENEMIES);
			m_pVM->AddObject(&m_cFloor[nIndex], RG_ENVIRONMENT);
		}
		break;
	}

	return true;
}