Browse Source

Fixed tricky overloaded sfx* functions.

Daniel Buckmaster 10 years ago
parent
commit
f9cd778b3b

+ 1 - 1
Engine/source/gui/controls/guiTreeViewCtrl.cpp

@@ -5137,7 +5137,7 @@ DefineConsoleMethod(GuiTreeViewCtrl, getSelectedItemList,const char*, (), ,"retu
 		//the start of the buffer where we want to write
 		//the start of the buffer where we want to write
 		char* buffPart = buff+len;
 		char* buffPart = buff+len;
 		//the size of the remaining buffer (-1 cause dStrlen doesn't count the \0)
 		//the size of the remaining buffer (-1 cause dStrlen doesn't count the \0)
-		S32 size	=	1024-len-1;
+		S32 size	=	bufSize-len-1;
 		//write it:
 		//write it:
 		if(size < 1)
 		if(size < 1)
 		{
 		{

+ 6 - 7
Engine/source/gui/worldEditor/guiDecalEditorCtrl.cpp

@@ -817,15 +817,14 @@ DefineConsoleMethod( GuiDecalEditorCtrl, getDecalCount, S32, (), , "getDecalCoun
 
 
 DefineConsoleMethod( GuiDecalEditorCtrl, getDecalTransform, const char*, ( U32 id ), , "getDecalTransform()" )
 DefineConsoleMethod( GuiDecalEditorCtrl, getDecalTransform, const char*, ( U32 id ), , "getDecalTransform()" )
 {
 {
-	DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[id];
+   DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[id];
 
 
-	if( decalInstance == NULL )
-		return "";
+   if( decalInstance == NULL )
+      return "";
 
 
-	static const U32 bufSize = 256;
-	char* returnBuffer = Con::getReturnBuffer(bufSize);
-	returnBuffer[0] = 0;
-	
+   static const U32 bufSize = 256;
+   char* returnBuffer = Con::getReturnBuffer(bufSize);
+   returnBuffer[0] = 0;
 
 
    if ( decalInstance )
    if ( decalInstance )
    {
    {

+ 24 - 20
Engine/source/sfx/sfxSystem.cpp

@@ -1443,7 +1443,7 @@ static ConsoleDocFragment _sfxCreateSource4(
    NULL,
    NULL,
    "SFXSound sfxCreateSource( SFXDescription description, string filename, float x, float y, float z );" );
    "SFXSound sfxCreateSource( SFXDescription description, string filename, float x, float y, float z );" );
 
 
-DefineConsoleFunction( sfxCreateSource, S32, ( const char * SFXType, const char * filename, const char * x, const char * y, const char * z ), ("", "", "", ""),
+DefineConsoleFunction( sfxCreateSource, S32, ( const char * sfxType, const char * arg0, const char * arg1, const char * arg2, const char * arg3 ), ("", "", "", ""),
                      "( SFXTrack track | ( SFXDescription description, string filename ) [, float x, float y, float z ] ) "
                      "( SFXTrack track | ( SFXDescription description, string filename ) [, float x, float y, float z ] ) "
                      "Creates a new paused sound source using a profile or a description "
                      "Creates a new paused sound source using a profile or a description "
                      "and filename.  The return value is the source which must be "
                      "and filename.  The return value is the source which must be "
@@ -1451,13 +1451,13 @@ DefineConsoleFunction( sfxCreateSource, S32, ( const char * SFXType, const char
                      "@hide" )
                      "@hide" )
 {
 {
    SFXDescription* description = NULL;
    SFXDescription* description = NULL;
-   SFXTrack* track = dynamic_cast< SFXTrack* >( Sim::findObject( SFXType ) );
+   SFXTrack* track = dynamic_cast< SFXTrack* >( Sim::findObject( sfxType ) );
    if ( !track )
    if ( !track )
    {
    {
-      description = dynamic_cast< SFXDescription* >( Sim::findObject( SFXType ) );
+      description = dynamic_cast< SFXDescription* >( Sim::findObject( sfxType ) );
       if ( !description )
       if ( !description )
       {
       {
-         Con::printf( "Unable to locate sound track/description '%s'", SFXType );
+         Con::printf( "Unable to locate sound track/description '%s'", sfxType );
          return 0;
          return 0;
       }
       }
    }
    }
@@ -1466,20 +1466,22 @@ DefineConsoleFunction( sfxCreateSource, S32, ( const char * SFXType, const char
 
 
    if ( track )
    if ( track )
    {
    {
-      if ( dStrIsEmpty(x) )
+      // In this overloaded use of the function, arg0..arg2 are x, y, and z.
+      if ( dStrIsEmpty(arg0) )
       {
       {
          source = SFX->createSource( track );
          source = SFX->createSource( track );
       }
       }
       else
       else
       {
       {
          MatrixF transform;
          MatrixF transform;
-         transform.set( EulerF(0,0,0), Point3F( dAtof(x), dAtof(y), dAtof(z)) );
+         transform.set( EulerF(0,0,0), Point3F( dAtof(arg0), dAtof(arg1), dAtof(arg2)) );
          source = SFX->createSource( track, &transform );
          source = SFX->createSource( track, &transform );
       }
       }
    }
    }
    else if ( description )
    else if ( description )
    {
    {
-      SFXProfile* tempProfile = new SFXProfile( description, StringTable->insert( filename ), true );
+      // In this use, arg0 is the filename, and arg1..arg3 are x, y, and z.
+      SFXProfile* tempProfile = new SFXProfile( description, StringTable->insert( arg0), true );
       if( !tempProfile->registerObject() )
       if( !tempProfile->registerObject() )
       {
       {
          Con::errorf( "sfxCreateSource - unable to create profile" );
          Con::errorf( "sfxCreateSource - unable to create profile" );
@@ -1487,14 +1489,14 @@ DefineConsoleFunction( sfxCreateSource, S32, ( const char * SFXType, const char
       }
       }
       else
       else
       {
       {
-         if ( dStrIsEmpty(x) )
+         if ( dStrIsEmpty(arg1) )
          {
          {
             source = SFX->createSource( tempProfile );
             source = SFX->createSource( tempProfile );
          }
          }
          else
          else
          {
          {
             MatrixF transform;
             MatrixF transform;
-            transform.set(EulerF(0,0,0), Point3F( dAtof(x),dAtof(y),dAtof(z) ));
+            transform.set(EulerF(0,0,0), Point3F( dAtof(arg1), dAtof(arg2), dAtof(arg3) ));
             source = SFX->createSource( tempProfile, &transform );
             source = SFX->createSource( tempProfile, &transform );
          }
          }
 
 
@@ -1656,19 +1658,19 @@ static ConsoleDocFragment _sPlayOnce4(
    "SFXSource sfxPlayOnce( SFXDescription description, string filename, float x, float y, float z, float fadeInTime=-1 );"
    "SFXSource sfxPlayOnce( SFXDescription description, string filename, float x, float y, float z, float fadeInTime=-1 );"
 );
 );
 
 
-DefineConsoleFunction( sfxPlayOnce, S32, ( const char * SFXType, const char * filename, const char * x, const char * y, const char * z, F32 fadeInTime ), ("", "", "", -1.0f),
+DefineConsoleFunction( sfxPlayOnce, S32, ( const char * sfxType, const char * arg0, const char * arg1, const char * arg2, const char * arg3, const char* arg4 ), ("", "", "", "", "-1.0f"),
    "SFXSource sfxPlayOnce( ( SFXTrack track | SFXDescription description, string filename ) [, float x, float y, float z, float fadeInTime=-1 ] ) "
    "SFXSource sfxPlayOnce( ( SFXTrack track | SFXDescription description, string filename ) [, float x, float y, float z, float fadeInTime=-1 ] ) "
    "Create a new play-once source for the given profile or description+filename and start playback of the source.\n"
    "Create a new play-once source for the given profile or description+filename and start playback of the source.\n"
    "@hide" )
    "@hide" )
 {
 {
    SFXDescription* description = NULL;
    SFXDescription* description = NULL;
-   SFXTrack* track = dynamic_cast< SFXTrack* >( Sim::findObject( SFXType ) );
+   SFXTrack* track = dynamic_cast< SFXTrack* >( Sim::findObject( sfxType ) );
    if( !track )
    if( !track )
    {
    {
-      description = dynamic_cast< SFXDescription* >( Sim::findObject( SFXType ) );
+      description = dynamic_cast< SFXDescription* >( Sim::findObject( sfxType ) );
       if( !description )
       if( !description )
       {
       {
-         Con::errorf( "sfxPlayOnce - Unable to locate sound track/description '%s'", SFXType );
+         Con::errorf( "sfxPlayOnce - Unable to locate sound track/description '%s'", sfxType );
          return 0;
          return 0;
       }
       }
    }
    }
@@ -1676,20 +1678,22 @@ DefineConsoleFunction( sfxPlayOnce, S32, ( const char * SFXType, const char * fi
    SFXSource* source = NULL;
    SFXSource* source = NULL;
    if( track )
    if( track )
    {
    {
-      if (dStrIsEmpty(x))
+      // In this overloaded use, arg0..arg2 are x, y, z, and arg3 is the fadeInTime.
+      if (dStrIsEmpty(arg0))
       {
       {
          source = SFX->playOnce( track );
          source = SFX->playOnce( track );
       }
       }
       else
       else
       {
       {
          MatrixF transform;
          MatrixF transform;
-         transform.set( EulerF( 0, 0, 0 ), Point3F( dAtof( x ), dAtof( y ),dAtof( z ) ) );
-         source = SFX->playOnce( track, &transform, NULL, fadeInTime );
+         transform.set( EulerF( 0, 0, 0 ), Point3F( dAtof( arg0 ), dAtof( arg1 ),dAtof( arg2 ) ) );
+         source = SFX->playOnce( track, &transform, NULL, dAtof( arg3 ) );
       }
       }
    }
    }
    else if( description )
    else if( description )
    {
    {
-      SFXProfile* tempProfile = new SFXProfile( description, StringTable->insert( filename ), true );
+      // In this overload, arg0 is the filename, arg1..arg3 are x, y, z, and arg4 is fadeInTime.
+      SFXProfile* tempProfile = new SFXProfile( description, StringTable->insert( arg0 ), true );
       if( !tempProfile->registerObject() )
       if( !tempProfile->registerObject() )
       {
       {
          Con::errorf( "sfxPlayOnce - unable to create profile" );
          Con::errorf( "sfxPlayOnce - unable to create profile" );
@@ -1697,13 +1701,13 @@ DefineConsoleFunction( sfxPlayOnce, S32, ( const char * SFXType, const char * fi
       }
       }
       else
       else
       {
       {
-         if (dStrIsEmpty(x))
+         if (dStrIsEmpty(arg1))
             source = SFX->playOnce( tempProfile );
             source = SFX->playOnce( tempProfile );
          else
          else
          {
          {
             MatrixF transform;
             MatrixF transform;
-            transform.set( EulerF( 0, 0, 0 ), Point3F( dAtof( x ), dAtof( y ),dAtof( z ) ) );
-            source = SFX->playOnce( tempProfile, &transform, NULL, fadeInTime );
+            transform.set( EulerF( 0, 0, 0 ), Point3F( dAtof( arg1 ), dAtof( arg2 ),dAtof( arg3 ) ) );
+            source = SFX->playOnce( tempProfile, &transform, NULL, dAtof( arg4 ) );
          }
          }
          
          
          // Set profile to auto-delete when SFXSource releases its reference.
          // Set profile to auto-delete when SFXSource releases its reference.