Done.

Author: yekcim
Date: Sat Feb  9 00:09:58 2008
New Revision: 4031

URL: http://svn.gna.org/viewcvs/wormux?rev=4031&view=rev
Log:
precaching patch (from RDL)






RCL a écrit :
> Hi there,
> 
> this small patch allows to precache the sounds before loading a map (and
> does it properly), so you have no delays even when game starts. Pretty
> simple patch, I think I should have added it to sample cache from the very
> beginning.
> 
> Since attaches aren't allowed, I put the file here:
> http://rcl.mine.nu/outbound/wormux/precaching-proper.diff
> 
> Or, alternatively, you can copy it from this message.
> 
> Cheers,
> Dmitry 'RCL' Rekman
> 
> Index: src/sound/sample_cache.cpp
> ===================================================================
> --- src/sound/sample_cache.cpp    (revision 4016)
> +++ src/sound/sample_cache.cpp    (working copy)
> @@ -146,3 +146,8 @@
>      return it->second;
>  }
> 
> +void SampleCache::Precache( const std::string & file_name )
> +{
> +    Mix_Chunk * precache = LoadSound( file_name );
> +    FreeChunk( precache ); // this does not remove the sample from cache
> +};
> Index: src/sound/jukebox.cpp
> ===================================================================
> --- src/sound/jukebox.cpp    (revision 4016)
> +++ src/sound/jukebox.cpp    (working copy)
> @@ -381,6 +381,9 @@
> 
>      // Inserting sound sample in list
>      m_soundsamples.insert(sound_sample(profile+"/"+sample,
> sample_filename));
> +
> +    // Precache
> +    m_cache.Precache( sample_filename.c_str() );
>    }
> 
>    // The profile is loaded
> Index: src/sound/sample_cache.h
> ===================================================================
> --- src/sound/sample_cache.h    (revision 4016)
> +++ src/sound/sample_cache.h    (working copy)
> @@ -57,9 +57,11 @@
>  public:
> 
>      void          Clear           ();
> +    void          Precache        ( const std::string & file_name );
>      Mix_Chunk *   LoadSound       ( const std::string & file_name );
>      void          FreeChunk       ( Mix_Chunk * pchk );
> 
> +
>                    SampleCache     ( size_t memory_limit = 0 );
>      virtual       ~SampleCache    () { Clear(); }
>  };
> _______________________________________________
> Wormux-dev mailing list
> Wormux-dev@gna.org
> https://mail.gna.org/listinfo/wormux-dev
> 


_______________________________________________
Wormux-dev mailing list
Wormux-dev@gna.org
https://mail.gna.org/listinfo/wormux-dev

Répondre à