some maps, update QOI, fix bug/UB with too many fishes
[fishladder.git] / fishladder.c
index 68f04febd75e54bd42da4c043bf3d956d0503caf..b6c220fbd76f6d5f95e929270d4fd7959492f640 100644 (file)
@@ -13,7 +13,8 @@ const char *level_pack_1[] = {
        "level5",
        "level6",
        "level7_combine",
-       "xor_small"
+       "xor_small",
+       "sort"
 };
 
 #pragma pack(push,1)
@@ -278,6 +279,17 @@ static void map_free(void)
        world.initialzed = 0;
 }
 
+static void io_reset(void)
+{
+       for( int i = 0; i < arrlen( world.io ); i ++ )
+       {
+               struct cell_terminal *term = &world.io[i];
+               
+               for( int j = 0; j < term->run_count; j ++ )
+                       term->runs[j].recv_count = 0;
+       }
+}
+
 static void map_reclassify( v2i start, v2i end, int update_texbuffer );
 static int map_load( const char *str, const char *name )
 {
@@ -540,6 +552,8 @@ static int map_load( const char *str, const char *name )
        
        vg_success( "Map '%s' loaded! (%u:%u)\n", name, world.w, world.h );
        
+       io_reset();
+       
        strncpy( world.map_name, name, vg_list_size( world.map_name )-1 );
        world.initialzed = 1;
        return 1;
@@ -713,17 +727,6 @@ static int console_load_map( int argc, char const *argv[] )
        }
 }
 
-static void io_reset(void)
-{
-       for( int i = 0; i < arrlen( world.io ); i ++ )
-       {
-               struct cell_terminal *term = &world.io[i];
-               
-               for( int j = 0; j < term->run_count; j ++ )
-                       term->runs[j].recv_count = 0;
-       }
-}
-
 static void simulation_stop(void)
 {
        world.simulating = 0;
@@ -1473,6 +1476,7 @@ void vg_update(void)
                                                world.sim_run ++;
                                                world.sim_frame = 0;
                                                world.sim_start = vg_time;
+                                               world.num_fishes = 0;
                                                continue;
                                        }
                                        else