only rebuild map chunks where user clicks
authorhgn <hgodden00@gmail.com>
Sat, 23 Oct 2021 20:03:09 +0000 (21:03 +0100)
committerhgn <hgodden00@gmail.com>
Sat, 23 Oct 2021 20:03:09 +0000 (21:03 +0100)
fishladder.c
sound/mod_01.ogg
sound/mod_02.ogg
sound/mod_03.ogg
sound/mod_04.ogg
sound/mod_05.ogg
sound/mod_06.ogg

index 54e1a537926a36f78a3c4adf5a8e719233b81196..eb86953ebe0d5ce3d90fb749d7ae99894d06477b 100644 (file)
@@ -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 )
        {
index 7c4b24e206e3a689d39d6d96197a4a4f09b3fde8..b8066057a045b17e2e257ec930e6a3e1c709dca5 100644 (file)
Binary files a/sound/mod_01.ogg and b/sound/mod_01.ogg differ
index a340f18e21671070be0712c06796176ece7f6621..f573bc009af783ab17866d14d78706d46b337a9a 100644 (file)
Binary files a/sound/mod_02.ogg and b/sound/mod_02.ogg differ
index 73145647aa4466737b8bcfb77ce9432ab61cd5bd..a8589ee962eb4c4277cd7c761c8a46354f42b2f0 100644 (file)
Binary files a/sound/mod_03.ogg and b/sound/mod_03.ogg differ
index 01ff4ba28f7c836cfae05c7093b69a586b6025e8..111795315d5c4c944379671c16fd7b6435db5171 100644 (file)
Binary files a/sound/mod_04.ogg and b/sound/mod_04.ogg differ
index f48c52da7956594a63a5548a486b36d5930d999c..f700127df5efb72c2add22b62e00b9a633bd520f 100644 (file)
Binary files a/sound/mod_05.ogg and b/sound/mod_05.ogg differ
index f8b67a4156bb515cc101230f22294055694ae54f..8342edee61977ea9f2b299cae21b12e8240e8bd6 100644 (file)
Binary files a/sound/mod_06.ogg and b/sound/mod_06.ogg differ