From: hgn Date: Sat, 23 Oct 2021 20:03:09 +0000 (+0100) Subject: only rebuild map chunks where user clicks X-Git-Url: https://harrygodden.com/git/?p=fishladder.git;a=commitdiff_plain;h=c27b61b1954588e9795ff046d76d8c888d05de15 only rebuild map chunks where user clicks --- diff --git a/fishladder.c b/fishladder.c index 54e1a53..eb86953 100644 --- a/fishladder.c +++ b/fishladder.c @@ -354,6 +354,7 @@ static void map_free(void) world.io = NULL; } +static void map_reclassify( v2i start, v2i end ); static int map_load( const char *str ) { map_free(); @@ -470,6 +471,7 @@ static int map_load( const char *str ) c ++; } + map_reclassify( NULL, NULL ); vg_success( "Map loaded! (%u:%u)\n", world.w, world.h ); return 1; } @@ -671,13 +673,20 @@ static int cell_interactive( v2i co ) return 1; } -// Entire world: 2 -> worldx/y-2 - -static void fl_world_update( v2i start, v2i end ) +static void map_reclassify( v2i start, v2i end ) { - for( int y = start[1]; y < end[1]; y ++ ) + v2i full_start = { 2,2 }; + v2i full_end = { world.w-2, world.h-2 }; + + if( !start || !end ) + { + start = full_start; + end = full_end; + } + + for( int y = vg_max( start[1], full_start[1] ); y < vg_min( end[1], full_end[1] ); y ++ ) { - for( int x = start[0]; x < end[0]; x ++ ) + for( int x = vg_max( start[0], full_start[0] ); x < vg_min( end[0], full_end[0] ); x ++ ) { v2i dirs[] = {{1,0},{0,1},{-1,0},{0,-1}}; @@ -691,9 +700,8 @@ static void fl_world_update( v2i start, v2i end ) if( neighbour->state & (FLAG_CANAL|FLAG_INPUT|FLAG_OUTPUT) ) config |= 0x1 << i; } - - - } else config = 0xF; + } + else config = 0xF; pcell((v2i){x,y})->config = config; } @@ -760,6 +768,8 @@ void vg_update(void) sfx_set_playrnd( &audio_tile_mod, &audio_system_sfx, 3, 6 ); else sfx_set_playrnd( &audio_tile_mod, &audio_system_sfx, 0, 3 ); + + map_reclassify( (v2i){ tile_x -2, tile_y -2 }, (v2i){ tile_x +2, tile_y +2 } ); } } else @@ -799,9 +809,6 @@ void vg_update(void) } } - // There was world reconfiguarion here previously... - fl_world_update( (v2i){2,2}, (v2i){world.w-2,world.h-2} ); - // Fish ticks if( world.simulating ) { diff --git a/sound/mod_01.ogg b/sound/mod_01.ogg index 7c4b24e..b806605 100644 Binary files a/sound/mod_01.ogg and b/sound/mod_01.ogg differ diff --git a/sound/mod_02.ogg b/sound/mod_02.ogg index a340f18..f573bc0 100644 Binary files a/sound/mod_02.ogg and b/sound/mod_02.ogg differ diff --git a/sound/mod_03.ogg b/sound/mod_03.ogg index 7314564..a8589ee 100644 Binary files a/sound/mod_03.ogg and b/sound/mod_03.ogg differ diff --git a/sound/mod_04.ogg b/sound/mod_04.ogg index 01ff4ba..1117953 100644 Binary files a/sound/mod_04.ogg and b/sound/mod_04.ogg differ diff --git a/sound/mod_05.ogg b/sound/mod_05.ogg index f48c52d..f700127 100644 Binary files a/sound/mod_05.ogg and b/sound/mod_05.ogg differ diff --git a/sound/mod_06.ogg b/sound/mod_06.ogg index f8b67a4..8342ede 100644 Binary files a/sound/mod_06.ogg and b/sound/mod_06.ogg differ