}
}
+static void simulation_stop(void)
+{
+ world.simulating = 0;
+ world.num_fishes = 0;
+ world.sim_frame = 0;
+
+ for( int i = 0; i < arrlen( world.io ); i ++ )
+ world.io[i].recv_count = 0;
+
+ sfx_system_fadeout( &audio_system_balls_rolling, 44100 );
+
+ vg_info( "Stopping simulation!\n" );
+}
+
static int console_changelevel( int argc, char const *argv[] )
{
if( argc >= 1 )
// Save current level
if( console_save_map( 0, NULL ) )
if( console_load_map( argc, argv ) )
+ {
+ simulation_stop();
return 1;
+ }
}
else
{
if( vg_get_button_down( "prev" ) ) { if( curlevel > 0 ) changelvl --; }
else if( vg_get_button_down( "next" ) ) { if( curlevel < vg_list_size( level_pack )-1 ) changelvl ++; }
- if( changelvl != curlevel )
- {
- console_changelevel( 1, level_pack + changelvl );
- curlevel = changelvl;
-
- // TEMP!!! code dupe
- world.simulating = 0;
- world.num_fishes = 0;
- world.sim_frame = 0;
-
- for( int i = 0; i < arrlen( world.io ); i ++ )
- world.io[i].recv_count = 0;
-
- vg_info( "Stopping simulation!\n" );
- }
-
// Fit within screen
float r1 = (float)vg_window_y / (float)vg_window_x,
{
if( world.simulating )
{
- world.simulating = 0;
- world.num_fishes = 0;
- world.sim_frame = 0;
-
- for( int i = 0; i < arrlen( world.io ); i ++ )
- world.io[i].recv_count = 0;
-
- vg_info( "Stopping simulation!\n" );
-
- sfx_system_fadeout( &audio_system_balls_rolling, 44100 );
+ simulation_stop();
}
else
{
{
if( sfx_begin_edit( sys ) )
{
- sys->fadeout_current = length_samples;
- sys->fadeout = length_samples;
+ if( sys->end )
+ {
+ sys->fadeout_current = length_samples;
+ sys->fadeout = length_samples;
+
+ if( sys->thread_clone )
+ sys->cur = sys->thread_clone->cur;
- if( sys->thread_clone )
- sys->cur = sys->thread_clone->cur;
-
- sfx_save( sys );
+ sfx_save( sys );
+ }
+ else
+ {
+ // Sound was not initialized
+ MUTEX_UNLOCK( sfx_mux_t01 );
+ }
}
}